diff --git a/CHANGELOG.md b/CHANGELOG.md index 3683ed932f..706103e11b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel ### Changed +- 📦 Switch to component-based installation for the MQT Core Python package ([#1596]) ([**@burgholzer**]) - ⬆️ Update QDMI to latest version from stable `v1.2.x` branch ([#1593]) ([**@burgholzer**]) - ⬆️ Update `clang-tidy` to version 22 ([#1564]) ([**@denialhaag**], [**@burgholzer**]) - 👷 Build on `macos-26`/`macos-26-intel` by default and `macos-15`/`macos-15-intel` for extensive tests ([#1571]) ([**@denialhaag**]) @@ -334,6 +335,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool +[#1596]: https://github.com/munich-quantum-toolkit/core/pull/1596 [#1593]: https://github.com/munich-quantum-toolkit/core/pull/1593 [#1588]: https://github.com/munich-quantum-toolkit/core/pull/1588 [#1583]: https://github.com/munich-quantum-toolkit/core/pull/1583 diff --git a/CMakeLists.txt b/CMakeLists.txt index 75e455919d..4c1a0eee53 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,8 @@ project( VERSION ${MQT_CORE_VERSION} DESCRIPTION "MQT Core - The Backbone of the Munich Quantum Toolkit") +set(MQT_CORE_TARGET_NAME "mqt-core") + if(BUILD_MQT_CORE_MLIR) include(SetupMLIR) endif() @@ -116,8 +118,6 @@ if(MQT_CORE_INSTALL) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) endif() -set(MQT_CORE_TARGET_NAME "mqt-core") - cmake_dependent_option(BUILD_MQT_CORE_QIR_RUNNER "Build the QIR runner of the MQT Core project" ON "BUILD_MQT_CORE_MLIR" OFF) diff --git a/cmake/ExternalDependencies.cmake b/cmake/ExternalDependencies.cmake index 7767bc84a7..ae4da90bfc 100644 --- a/cmake/ExternalDependencies.cmake +++ b/cmake/ExternalDependencies.cmake @@ -52,7 +52,12 @@ set(JSON_URL https://github.com/nlohmann/json/releases/download/v${JSON_VERSION} set(JSON_SystemInclude ON CACHE INTERNAL "Treat the library headers like system headers") -cmake_dependent_option(JSON_Install "Install nlohmann_json library" ON "MQT_CORE_INSTALL" OFF) +cmake_dependent_option(MQT_CORE_JSON_INSTALL "Install nlohmann_json library" ON "MQT_CORE_INSTALL" + OFF) +# Disable upstream nlohmann_json install rules and install with explicit MQT components below. +set(JSON_Install + OFF + CACHE BOOL "Disable upstream nlohmann_json install rules; handled by mqt-core" FORCE) FetchContent_Declare(nlohmann_json URL ${JSON_URL} FIND_PACKAGE_ARGS ${JSON_VERSION}) list(APPEND FETCH_PACKAGES nlohmann_json) @@ -117,7 +122,11 @@ set(SPDLOG_BUILD_PIC ON) set(SPDLOG_SYSTEM_INCLUDES ON CACHE INTERNAL "Treat the library headers like system headers") -cmake_dependent_option(SPDLOG_INSTALL "Install spdlog library" ON "MQT_CORE_INSTALL" OFF) +cmake_dependent_option(MQT_CORE_SPDLOG_INSTALL "Install spdlog library" ON "MQT_CORE_INSTALL" OFF) +# Disable upstream spdlog install rules and install with explicit MQT components below. +set(SPDLOG_INSTALL + OFF + CACHE BOOL "Disable upstream spdlog install rules; handled by mqt-core" FORCE) cmake_dependent_option(SPDLOG_BUILD_SHARED "Build spdlog as shared library" ON "BUILD_MQT_CORE_SHARED_LIBS" OFF) FetchContent_Declare(spdlog URL ${SPDLOG_URL} FIND_PACKAGE_ARGS ${SPDLOG_VERSION}) @@ -145,6 +154,62 @@ if(_eigen_target) endif() endif() +# Install nlohmann_json with explicit MQT components. +if(MQT_CORE_JSON_INSTALL AND TARGET nlohmann_json) + set(MQT_CORE_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/nlohmann_json") + set(MQT_CORE_JSON_TARGETS_EXPORT_NAME "nlohmann_jsonTargets") + set(MQT_CORE_JSON_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/nlohmann_jsonConfig.cmake") + set(MQT_CORE_JSON_VERSION_CONFIG_FILE + "${CMAKE_CURRENT_BINARY_DIR}/nlohmann_jsonConfigVersion.cmake") + + # nlohmann_json's upstream templates expect these names. + set(_mqt_core_saved_project_name "${PROJECT_NAME}") + set(_mqt_core_saved_project_version "${PROJECT_VERSION}") + set(_mqt_core_saved_project_version_major "${PROJECT_VERSION_MAJOR}") + set(PROJECT_NAME "nlohmann_json") + set(PROJECT_VERSION "${JSON_VERSION}") + string(REGEX MATCH "^[0-9]+" PROJECT_VERSION_MAJOR "${JSON_VERSION}") + set(NLOHMANN_JSON_TARGET_NAME "nlohmann_json") + set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${MQT_CORE_JSON_TARGETS_EXPORT_NAME}") + + configure_file(${nlohmann_json_SOURCE_DIR}/cmake/config.cmake.in ${MQT_CORE_JSON_CONFIG_FILE} + @ONLY) + configure_file(${nlohmann_json_SOURCE_DIR}/cmake/nlohmann_jsonConfigVersion.cmake.in + ${MQT_CORE_JSON_VERSION_CONFIG_FILE} @ONLY) + + set(PROJECT_NAME "${_mqt_core_saved_project_name}") + set(PROJECT_VERSION "${_mqt_core_saved_project_version}") + set(PROJECT_VERSION_MAJOR "${_mqt_core_saved_project_version_major}") + unset(_mqt_core_saved_project_name) + unset(_mqt_core_saved_project_version) + unset(_mqt_core_saved_project_version_major) + unset(NLOHMANN_JSON_TARGET_NAME) + unset(NLOHMANN_JSON_TARGETS_EXPORT_NAME) + + install( + DIRECTORY ${nlohmann_json_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Development) + + install( + TARGETS nlohmann_json + EXPORT ${MQT_CORE_JSON_TARGETS_EXPORT_NAME} + INCLUDES + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Development) + + install( + EXPORT ${MQT_CORE_JSON_TARGETS_EXPORT_NAME} + NAMESPACE nlohmann_json:: + DESTINATION ${MQT_CORE_JSON_CONFIG_INSTALL_DIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Development) + + install( + FILES ${MQT_CORE_JSON_CONFIG_FILE} ${MQT_CORE_JSON_VERSION_CONFIG_FILE} + DESTINATION ${MQT_CORE_JSON_CONFIG_INSTALL_DIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Development) +endif() + # Ensure external shared libraries end up in a common lib layout used by our RUNPATH if(TARGET spdlog) set_target_properties( @@ -154,17 +219,59 @@ if(TARGET spdlog) RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}") endif() -# Patch for spdlog cmake files to be installed in a common cmake directory -if(SPDLOG_INSTALL) +# Install spdlog with explicit MQT components. +if(MQT_CORE_SPDLOG_INSTALL + AND TARGET spdlog + AND TARGET spdlog_header_only) + include(CMakePackageConfigHelpers) + + set(MQT_CORE_SPDLOG_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/spdlog") + set(MQT_CORE_SPDLOG_CONFIG_TARGETS_FILE "spdlogConfigTargets.cmake") + set(MQT_CORE_SPDLOG_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfig.cmake") + set(MQT_CORE_SPDLOG_VERSION_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfigVersion.cmake") + + install( + TARGETS spdlog spdlog_header_only + EXPORT spdlog + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${MQT_CORE_TARGET_NAME}_Runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Runtime + NAMELINK_COMPONENT ${MQT_CORE_TARGET_NAME}_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${MQT_CORE_TARGET_NAME}_Development) + + install( + DIRECTORY ${spdlog_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Development + PATTERN "fmt/bundled" EXCLUDE) + + if(NOT SPDLOG_USE_STD_FORMAT + AND NOT SPDLOG_FMT_EXTERNAL + AND NOT SPDLOG_FMT_EXTERNAL_HO) + install( + DIRECTORY ${spdlog_SOURCE_DIR}/include/spdlog/fmt/bundled/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spdlog/fmt/bundled + COMPONENT ${MQT_CORE_TARGET_NAME}_Development) + endif() + + install( + EXPORT spdlog + FILE ${MQT_CORE_SPDLOG_CONFIG_TARGETS_FILE} + NAMESPACE spdlog:: + DESTINATION ${MQT_CORE_SPDLOG_CONFIG_INSTALL_DIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Development) + + set(config_targets_file ${MQT_CORE_SPDLOG_CONFIG_TARGETS_FILE}) + configure_package_config_file( + ${spdlog_SOURCE_DIR}/cmake/spdlogConfig.cmake.in ${MQT_CORE_SPDLOG_CONFIG_FILE} + INSTALL_DESTINATION ${MQT_CORE_SPDLOG_CONFIG_INSTALL_DIR}) + write_basic_package_version_file( + ${MQT_CORE_SPDLOG_VERSION_CONFIG_FILE} + VERSION ${SPDLOG_VERSION} + COMPATIBILITY SameMajorVersion) + install( - CODE " - file(GLOB SPDLOG_CMAKE_FILES - \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/spdlog/*\") - if(SPDLOG_CMAKE_FILES) - file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/cmake/spdlog\") - file(COPY \${SPDLOG_CMAKE_FILES} - DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/cmake/spdlog\") - file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/spdlog\") - endif() - ") + FILES ${MQT_CORE_SPDLOG_CONFIG_FILE} ${MQT_CORE_SPDLOG_VERSION_CONFIG_FILE} + DESTINATION ${MQT_CORE_SPDLOG_CONFIG_INSTALL_DIR} + COMPONENT ${MQT_CORE_TARGET_NAME}_Development) endif() diff --git a/mlir/lib/Compiler/CMakeLists.txt b/mlir/lib/Compiler/CMakeLists.txt index 990ac0cb7e..66afb3515a 100644 --- a/mlir/lib/Compiler/CMakeLists.txt +++ b/mlir/lib/Compiler/CMakeLists.txt @@ -20,8 +20,7 @@ add_mlir_library( MLIRQCToQCO MLIRQCOToQC MLIRQCToQIR - MQT::MLIRSupport - DISABLE_INSTALL) + MQT::MLIRSupport) mqt_mlir_target_use_project_options(MQTCompilerPipeline) diff --git a/mlir/lib/Conversion/JeffToQCO/CMakeLists.txt b/mlir/lib/Conversion/JeffToQCO/CMakeLists.txt index 43d5c4caf9..c58f4d25ed 100644 --- a/mlir/lib/Conversion/JeffToQCO/CMakeLists.txt +++ b/mlir/lib/Conversion/JeffToQCO/CMakeLists.txt @@ -17,5 +17,4 @@ add_mlir_conversion_library( MLIRJeff MLIRJeffToNative MLIRQCODialect - MLIRTransforms - DISABLE_INSTALL) + MLIRTransforms) diff --git a/mlir/lib/Conversion/QCOToJeff/CMakeLists.txt b/mlir/lib/Conversion/QCOToJeff/CMakeLists.txt index 269af18c2b..6d79f5a64e 100644 --- a/mlir/lib/Conversion/QCOToJeff/CMakeLists.txt +++ b/mlir/lib/Conversion/QCOToJeff/CMakeLists.txt @@ -18,8 +18,7 @@ add_mlir_conversion_library( MLIRJeff MLIRNativeToJeff MLIRQCODialect - MLIRTransforms - DISABLE_INSTALL) + MLIRTransforms) if(TARGET MLIRQCOToJeff) target_compile_definitions(MLIRQCOToJeff PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}") diff --git a/mlir/lib/Conversion/QCOToQC/CMakeLists.txt b/mlir/lib/Conversion/QCOToQC/CMakeLists.txt index eba206ceda..f7b35a11b3 100644 --- a/mlir/lib/Conversion/QCOToQC/CMakeLists.txt +++ b/mlir/lib/Conversion/QCOToQC/CMakeLists.txt @@ -20,7 +20,6 @@ add_mlir_conversion_library( MLIRArithDialect MLIRFuncDialect MLIRTransforms - MLIRFuncTransforms - DISABLE_INSTALL) + MLIRFuncTransforms) mqt_mlir_target_use_project_options(MLIRQCOToQC) diff --git a/mlir/lib/Conversion/QCToQCO/CMakeLists.txt b/mlir/lib/Conversion/QCToQCO/CMakeLists.txt index 0474683bfd..335d64d3e1 100644 --- a/mlir/lib/Conversion/QCToQCO/CMakeLists.txt +++ b/mlir/lib/Conversion/QCToQCO/CMakeLists.txt @@ -20,7 +20,6 @@ add_mlir_conversion_library( MLIRArithDialect MLIRFuncDialect MLIRTransforms - MLIRFuncTransforms - DISABLE_INSTALL) + MLIRFuncTransforms) mqt_mlir_target_use_project_options(MLIRQCToQCO) diff --git a/mlir/lib/Conversion/QCToQIR/CMakeLists.txt b/mlir/lib/Conversion/QCToQIR/CMakeLists.txt index f3b9bcbe98..d10fd233fe 100644 --- a/mlir/lib/Conversion/QCToQIR/CMakeLists.txt +++ b/mlir/lib/Conversion/QCToQIR/CMakeLists.txt @@ -21,7 +21,6 @@ add_mlir_conversion_library( MLIRTransforms MLIRFuncDialect MLIRFuncToLLVM - MLIRReconcileUnrealizedCasts - DISABLE_INSTALL) + MLIRReconcileUnrealizedCasts) mqt_mlir_target_use_project_options(MLIRQCToQIR) diff --git a/mlir/lib/Dialect/QC/Builder/CMakeLists.txt b/mlir/lib/Dialect/QC/Builder/CMakeLists.txt index 71ae043b39..868674da35 100644 --- a/mlir/lib/Dialect/QC/Builder/CMakeLists.txt +++ b/mlir/lib/Dialect/QC/Builder/CMakeLists.txt @@ -14,8 +14,7 @@ add_mlir_library( MLIRArithDialect MLIRFuncDialect MLIRSCFDialect - MLIRQCDialect - DISABLE_INSTALL) + MLIRQCDialect) mqt_mlir_target_use_project_options(MLIRQCProgramBuilder) diff --git a/mlir/lib/Dialect/QC/IR/CMakeLists.txt b/mlir/lib/Dialect/QC/IR/CMakeLists.txt index 66b2acb52d..b3646e4726 100644 --- a/mlir/lib/Dialect/QC/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/QC/IR/CMakeLists.txt @@ -25,8 +25,7 @@ add_mlir_dialect_library( PRIVATE MLIRIR MLIRInferTypeOpInterface - MLIRSideEffectInterfaces - DISABLE_INSTALL) + MLIRSideEffectInterfaces) mqt_mlir_target_use_project_options(MLIRQCDialect) diff --git a/mlir/lib/Dialect/QC/Translation/CMakeLists.txt b/mlir/lib/Dialect/QC/Translation/CMakeLists.txt index 563240df98..a514f33df6 100644 --- a/mlir/lib/Dialect/QC/Translation/CMakeLists.txt +++ b/mlir/lib/Dialect/QC/Translation/CMakeLists.txt @@ -15,8 +15,7 @@ add_mlir_library( MLIRSCFDialect MLIRQCDialect MLIRQCProgramBuilder - MQT::CoreIR - DISABLE_INSTALL) + MQT::CoreIR) mqt_mlir_target_use_project_options(MLIRQCTranslation) diff --git a/mlir/lib/Dialect/QCO/Builder/CMakeLists.txt b/mlir/lib/Dialect/QCO/Builder/CMakeLists.txt index e55eab1497..34ada9f0f9 100644 --- a/mlir/lib/Dialect/QCO/Builder/CMakeLists.txt +++ b/mlir/lib/Dialect/QCO/Builder/CMakeLists.txt @@ -15,8 +15,7 @@ add_mlir_library( MLIRFuncDialect MLIRSCFDialect MLIRQCODialect - MLIRQTensorDialect - DISABLE_INSTALL) + MLIRQTensorDialect) mqt_mlir_target_use_project_options(MLIRQCOProgramBuilder) diff --git a/mlir/lib/Dialect/QCO/IR/CMakeLists.txt b/mlir/lib/Dialect/QCO/IR/CMakeLists.txt index 8fafbb2080..f33ece7000 100644 --- a/mlir/lib/Dialect/QCO/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/QCO/IR/CMakeLists.txt @@ -30,8 +30,7 @@ add_mlir_dialect_library( MLIRInferTypeOpInterface MLIRSideEffectInterfaces PUBLIC - Eigen3::Eigen - DISABLE_INSTALL) + Eigen3::Eigen) mqt_mlir_target_use_project_options(MLIRQCODialect) diff --git a/mlir/lib/Dialect/QCO/Utils/CMakeLists.txt b/mlir/lib/Dialect/QCO/Utils/CMakeLists.txt index 0e32e7b21a..9b94885f1b 100644 --- a/mlir/lib/Dialect/QCO/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/QCO/Utils/CMakeLists.txt @@ -18,8 +18,7 @@ add_mlir_dialect_library( MLIRQCOInterfacesIncGen LINK_LIBS PUBLIC - MLIRQCODialect - DISABLE_INSTALL) + MLIRQCODialect) mqt_mlir_target_use_project_options(MLIRQCOUtils) diff --git a/mlir/lib/Dialect/QIR/Builder/CMakeLists.txt b/mlir/lib/Dialect/QIR/Builder/CMakeLists.txt index 3fa768bdef..1cdc4b7527 100644 --- a/mlir/lib/Dialect/QIR/Builder/CMakeLists.txt +++ b/mlir/lib/Dialect/QIR/Builder/CMakeLists.txt @@ -14,8 +14,7 @@ add_mlir_library( MLIRLLVMDialect MLIRQIRUtils MLIRIR - MLIRSupport - DISABLE_INSTALL) + MLIRSupport) mqt_mlir_target_use_project_options(MLIRQIRProgramBuilder) diff --git a/mlir/lib/Dialect/QIR/Utils/CMakeLists.txt b/mlir/lib/Dialect/QIR/Utils/CMakeLists.txt index 1e4d557ab9..d5244bcfc2 100644 --- a/mlir/lib/Dialect/QIR/Utils/CMakeLists.txt +++ b/mlir/lib/Dialect/QIR/Utils/CMakeLists.txt @@ -8,14 +8,7 @@ file(GLOB QIR_UTILS_SOURCES *.cpp) -add_mlir_library( - MLIRQIRUtils - ${QIR_UTILS_SOURCES} - LINK_LIBS - PUBLIC - MLIRLLVMDialect - MLIRIR - DISABLE_INSTALL) +add_mlir_library(MLIRQIRUtils ${QIR_UTILS_SOURCES} LINK_LIBS PUBLIC MLIRLLVMDialect MLIRIR) mqt_mlir_target_use_project_options(MLIRQIRUtils) diff --git a/mlir/lib/Dialect/QTensor/IR/CMakeLists.txt b/mlir/lib/Dialect/QTensor/IR/CMakeLists.txt index a602ba461c..f19fa71111 100644 --- a/mlir/lib/Dialect/QTensor/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/QTensor/IR/CMakeLists.txt @@ -24,8 +24,7 @@ add_mlir_dialect_library( MLIRInferTypeOpInterface MLIRSideEffectInterfaces PUBLIC - MLIRQCODialect - DISABLE_INSTALL) + MLIRQCODialect) mqt_mlir_target_use_project_options(MLIRQTensorDialect) diff --git a/mlir/lib/Support/CMakeLists.txt b/mlir/lib/Support/CMakeLists.txt index 3813366025..0e93033d4a 100644 --- a/mlir/lib/Support/CMakeLists.txt +++ b/mlir/lib/Support/CMakeLists.txt @@ -23,8 +23,7 @@ add_mlir_library( MLIRTransformUtils MLIRLLVMDialect MLIRFuncDialect - MLIRArithDialect - DISABLE_INSTALL) + MLIRArithDialect) mqt_mlir_target_use_project_options(MLIRSupportMQT) diff --git a/pyproject.toml b/pyproject.toml index 05d990af76..3cc806138c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,6 +102,13 @@ build.targets = [ "mqt-core-qdmi-sc-device-dyn", ] +install.components = [ + "mqt-core_Runtime", + "mqt-core_Development", + "mqt-core_Python", + "qdmi_Development", +] + metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" sdist.include = ["python/mqt/core/_version.py"] sdist.exclude = [