Skip to content

Commit 16fd3ac

Browse files
committed
πŸ‘¨β€πŸ’»πŸ“¦ Build spdlog as a shared library on project installs (#1411)
## Description Picked from #1403. Builds `spdlog` as a shared library on library installs. This reduces the wheel size from 14.3 MiB to 11.0 MiB on x86 linux. ## Checklist: <!--- This checklist serves as a reminder of a couple of things that ensure your pull request will be merged swiftly. --> - [x] The pull request only contains commits that are focused and relevant to this change. - [x] I have added appropriate tests that cover the new/changed functionality. - [x] I have updated the documentation to reflect these changes. - [x] I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals. - [x] I have added migration instructions to the upgrade guide (if needed). - [x] The changes follow the project's style guidelines and introduce no new warnings. - [x] The changes are fully tested and pass the CI checks. - [x] I have reviewed my own code changes. Signed-off-by: burgholzer <burgholzer@me.com> Signed-off-by: Lukas Burgholzer <burgholzer@me.com> (cherry picked from commit b9f6cf8)
1 parent e4d30ad commit 16fd3ac

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
2424

2525
### Changed
2626

27+
- πŸ‘¨β€πŸ’»πŸ“¦ Build `spdlog` as a shared library on project installs ([#1411]) ([**@burgholzer**])
2728
- β™»οΈπŸ Remove Windows-specific restrictions for dynamic QDMI device library handling ([#1406]) ([**@burgholzer**])
2829
- ♻️ Migrate Python bindings from `pybind11` to `nanobind` ([#1383]) ([**@denialhaag**], [**@burgholzer**])
2930
- πŸ“¦οΈ Provide Stable ABI wheels for Python 3.12+ ([#1383]) ([**@burgholzer**], [**@denialhaag**])
@@ -286,6 +287,7 @@ _πŸ“š Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
286287

287288
<!-- PR links -->
288289

290+
[#1411]: https://github.com/munich-quantum-toolkit/core/pull/1411
289291
[#1406]: https://github.com/munich-quantum-toolkit/core/pull/1406
290292
[#1402]: https://github.com/munich-quantum-toolkit/core/pull/1402
291293
[#1385]: https://github.com/munich-quantum-toolkit/core/pull/1385

β€Žcmake/ExternalDependencies.cmakeβ€Ž

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
include(FetchContent)
1212
include(CMakeDependentOption)
13+
include(GNUInstallDirs)
1314
set(FETCH_PACKAGES "")
1415

1516
if(BUILD_MQT_CORE_BINDINGS)
@@ -94,15 +95,25 @@ set(SPDLOG_SYSTEM_INCLUDES
9495
ON
9596
CACHE INTERNAL "Treat the library headers like system headers")
9697
cmake_dependent_option(SPDLOG_INSTALL "Install spdlog library" ON "MQT_CORE_INSTALL" OFF)
98+
cmake_dependent_option(SPDLOG_BUILD_SHARED "Build spdlog as shared library" ON
99+
"BUILD_MQT_CORE_SHARED_LIBS" OFF)
97100
FetchContent_Declare(spdlog URL ${SPDLOG_URL} FIND_PACKAGE_ARGS ${SPDLOG_VERSION})
98101
list(APPEND FETCH_PACKAGES spdlog)
99102

100103
# Make all declared dependencies available.
101104
FetchContent_MakeAvailable(${FETCH_PACKAGES})
102105

106+
# Ensure external shared libraries end up in a common lib layout used by our RUNPATH
107+
if(TARGET spdlog)
108+
set_target_properties(
109+
spdlog
110+
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
111+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
112+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
113+
endif()
114+
103115
# Patch for spdlog cmake files to be installed in a common cmake directory
104116
if(SPDLOG_INSTALL)
105-
include(GNUInstallDirs)
106117
install(
107118
CODE "
108119
file(GLOB SPDLOG_CMAKE_FILES

β€Žsrc/qdmi/na/CMakeLists.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(NOT TARGET ${TARGET_NAME})
2626
target_sources(${TARGET_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS ${MQT_CORE_INCLUDE_BUILD_DIR}
2727
FILES ${MQT_CORE_INCLUDE_BUILD_DIR}/qdmi/na/Generator.hpp)
2828

29-
# Link nlohmann_json, spdlog
29+
# Link nlohmann_json and spdlog
3030
target_link_libraries(
3131
${TARGET_NAME}
3232
PUBLIC nlohmann_json::nlohmann_json

β€Žsrc/qdmi/sc/CMakeLists.txtβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(NOT TARGET ${TARGET_NAME})
2626
target_sources(${TARGET_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS ${MQT_CORE_INCLUDE_BUILD_DIR}
2727
FILES ${MQT_CORE_INCLUDE_BUILD_DIR}/qdmi/sc/Generator.hpp)
2828

29-
# Link nlohmann_json, spdlog
29+
# Link nlohmann_json and spdlog
3030
target_link_libraries(
3131
${TARGET_NAME}
3232
PUBLIC nlohmann_json::nlohmann_json

0 commit comments

Comments
Β (0)