Skip to content

Commit 70b9d1f

Browse files
πŸ‘¨β€πŸ’»πŸ“¦ build QDMI generators as shared libraries on install (#1403)
## Description This PR copies over some changes from #1356 so that the latter becomes a bit leaner and more focused on relevant changes. ## Checklist: - [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> Co-authored-by: burgholzer <burgholzer@me.com>
1 parent 6763e1e commit 70b9d1f

4 files changed

Lines changed: 35 additions & 47 deletions

File tree

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
2626
### Changed
2727

2828
- ⚑ Improve uv build caching by removing unconditional `reinstall-package` and configuring dedicated `cache-keys` ([#1412]) ([**@burgholzer**])
29-
- πŸ‘¨β€πŸ’»πŸ“¦ Build `spdlog` as a shared library on project installs ([#1411]) ([**@burgholzer**])
29+
- πŸ‘¨β€πŸ’»πŸ“¦ Build `spdlog` and QDMI generators as shared libraries in Python package builds ([#1411], [#1403]) ([**@burgholzer**])
3030
- β™»οΈπŸ Remove Windows-specific restrictions for dynamic QDMI device library handling ([#1406]) ([**@burgholzer**])
3131
- ♻️ Migrate Python bindings from `pybind11` to `nanobind` ([#1383]) ([**@denialhaag**], [**@burgholzer**])
3232
- πŸ“¦οΈ Provide Stable ABI wheels for Python 3.12+ ([#1383]) ([**@burgholzer**], [**@denialhaag**])
@@ -48,6 +48,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
4848

4949
### Fixed
5050

51+
- πŸ”§ Install all available QDMI device targets in Python package builds ([#1403]) ([**@burgholzer**])
5152
- πŸ› Fix operation validation in Qiskit backend to handle device-specific gate naming conventions ([#1384]) ([**@marcelwa**])
5253
- πŸ› Fix conditional branch handling when importing MLIR from `QuantumComputation` ([#1378]) ([**@lirem101**])
5354
- πŸ› Fix custom QDMI property and parameter handling in SC and NA devices ([#1355]) ([**@burgholzer**])
@@ -292,6 +293,7 @@ _πŸ“š Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
292293
[#1412]: https://github.com/munich-quantum-toolkit/core/pull/1412
293294
[#1411]: https://github.com/munich-quantum-toolkit/core/pull/1411
294295
[#1406]: https://github.com/munich-quantum-toolkit/core/pull/1406
296+
[#1403]: https://github.com/munich-quantum-toolkit/core/pull/1403
295297
[#1402]: https://github.com/munich-quantum-toolkit/core/pull/1402
296298
[#1385]: https://github.com/munich-quantum-toolkit/core/pull/1385
297299
[#1384]: https://github.com/munich-quantum-toolkit/core/pull/1384

β€Žpyproject.tomlβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ build.targets = [
9393
"mqt-core-na",
9494
"mqt-core-ir-bindings",
9595
"mqt-core-dd-bindings",
96-
"mqt-core-qdmi-na-device",
97-
"mqt-core-qdmi-ddsim-device",
9896
"mqt-core-fomac-bindings",
9997
"mqt-core-na-bindings",
98+
"mqt-core-qdmi-ddsim-device",
99+
"mqt-core-qdmi-na-device",
100+
"mqt-core-qdmi-na-device-dyn",
101+
"mqt-core-qdmi-sc-device",
102+
"mqt-core-qdmi-sc-device-dyn",
100103
]
101104

102105
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"

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

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ set(TARGET_NAME ${MQT_CORE_TARGET_NAME}-qdmi-na-device-gen)
1313
if(NOT TARGET ${TARGET_NAME})
1414

1515
# Add library for device generation
16-
#
17-
# Note: We use a static library here to avoid issues with RPATH and finding the executable during
18-
# the build process in Python builds
19-
add_library(${TARGET_NAME} STATIC)
20-
add_library(MQT::CoreQDMINaDeviceGen ALIAS ${TARGET_NAME})
16+
add_mqt_core_library(${TARGET_NAME} ALIAS_NAME QDMINaDeviceGen)
2117

2218
# add sources to target
2319
target_sources(${TARGET_NAME} PRIVATE Generator.cpp)
@@ -30,23 +26,17 @@ if(NOT TARGET ${TARGET_NAME})
3026
target_link_libraries(
3127
${TARGET_NAME}
3228
PUBLIC nlohmann_json::nlohmann_json
33-
PRIVATE spdlog::spdlog MQT::ProjectOptions MQT::ProjectWarnings)
34-
35-
# set versioning information
36-
set_target_properties(
37-
${TARGET_NAME}
38-
PROPERTIES VERSION ${PROJECT_VERSION}
39-
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
40-
EXPORT_NAME CoreNaDeviceGen)
41-
42-
# set c++ standard
43-
target_compile_features(${TARGET_NAME} PRIVATE cxx_std_20)
29+
PRIVATE spdlog::spdlog)
4430

4531
# add to list of MQT core targets
46-
set(MQT_CORE_TARGETS ${MQT_CORE_TARGETS} ${TARGET_NAME})
32+
list(APPEND MQT_CORE_TARGETS ${TARGET_NAME})
4733

48-
# Make version available
49-
target_compile_definitions(${TARGET_NAME} PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}")
34+
# place the generated library in a predictable location where the executable can find it
35+
set_target_properties(
36+
${TARGET_NAME}
37+
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
38+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
39+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
5040
endif()
5141

5242
# Set target name
@@ -139,9 +129,7 @@ if(NOT TARGET ${TARGET_NAME})
139129
set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
140130

141131
# add to list of MQT core targets
142-
set(MQT_CORE_TARGETS
143-
${MQT_CORE_TARGETS} ${TARGET_NAME}
144-
PARENT_SCOPE)
132+
list(APPEND MQT_CORE_TARGETS ${TARGET_NAME})
145133

146134
# Make QDMI version available
147135
target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}")
@@ -189,5 +177,10 @@ if(NOT TARGET ${TARGET_NAME})
189177
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
190178
EXPORT_NAME CoreQDMINaDeviceDyn)
191179
add_library(MQT::CoreQDMINaDeviceDyn ALIAS ${DYN_TARGET_NAME})
180+
list(APPEND MQT_CORE_TARGETS ${DYN_TARGET_NAME})
192181
endif()
193182
endif()
183+
184+
set(MQT_CORE_TARGETS
185+
${MQT_CORE_TARGETS}
186+
PARENT_SCOPE)

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ set(TARGET_NAME ${MQT_CORE_TARGET_NAME}-qdmi-sc-device-gen)
1313
if(NOT TARGET ${TARGET_NAME})
1414

1515
# Add library for device generation
16-
#
17-
# Note: We use a static library here to avoid issues with RPATH and finding the executable during
18-
# the build process in Python builds
19-
add_library(${TARGET_NAME} STATIC)
20-
add_library(MQT::CoreQDMIScDeviceGen ALIAS ${TARGET_NAME})
16+
add_mqt_core_library(${TARGET_NAME} ALIAS_NAME QDMIScDeviceGen)
2117

2218
# add sources to target
2319
target_sources(${TARGET_NAME} PRIVATE Generator.cpp)
@@ -30,23 +26,14 @@ if(NOT TARGET ${TARGET_NAME})
3026
target_link_libraries(
3127
${TARGET_NAME}
3228
PUBLIC nlohmann_json::nlohmann_json
33-
PRIVATE spdlog::spdlog MQT::ProjectOptions MQT::ProjectWarnings)
29+
PRIVATE spdlog::spdlog)
3430

35-
# set versioning information
31+
# place the generated library in a predictable location where the executable can find it
3632
set_target_properties(
3733
${TARGET_NAME}
38-
PROPERTIES VERSION ${PROJECT_VERSION}
39-
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
40-
EXPORT_NAME CoreScDeviceGen)
41-
42-
# set c++ standard
43-
target_compile_features(${TARGET_NAME} PRIVATE cxx_std_20)
44-
45-
# add to list of MQT core targets
46-
set(MQT_CORE_TARGETS ${MQT_CORE_TARGETS} ${TARGET_NAME})
47-
48-
# Make version available
49-
target_compile_definitions(${TARGET_NAME} PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}")
34+
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
35+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}"
36+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
5037
endif()
5138

5239
# Set target name
@@ -139,9 +126,7 @@ if(NOT TARGET ${TARGET_NAME})
139126
set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
140127

141128
# add to list of MQT core targets
142-
set(MQT_CORE_TARGETS
143-
${MQT_CORE_TARGETS} ${TARGET_NAME}
144-
PARENT_SCOPE)
129+
list(APPEND MQT_CORE_TARGETS ${TARGET_NAME})
145130

146131
# Make QDMI version available
147132
target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}")
@@ -189,5 +174,10 @@ if(NOT TARGET ${TARGET_NAME})
189174
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
190175
EXPORT_NAME CoreQDMIScDeviceDyn)
191176
add_library(MQT::CoreQDMIScDeviceDyn ALIAS ${DYN_TARGET_NAME})
177+
list(APPEND MQT_CORE_TARGETS ${DYN_TARGET_NAME})
192178
endif()
193179
endif()
180+
181+
set(MQT_CORE_TARGETS
182+
${MQT_CORE_TARGETS}
183+
PARENT_SCOPE)

0 commit comments

Comments
Β (0)