diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 380a0d3d8f..6c256102b1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -12,7 +12,7 @@ permissions: jobs: build-sdist: name: 🐍 Packaging - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@setup-mlir # v1.17.4 # Builds wheels on all supported platforms using cibuildwheel. # The wheels are uploaded as GitHub artifacts `dev-cibw-*` or `cibw-*`, depending on whether @@ -31,9 +31,11 @@ jobs: windows-2022, windows-11-arm, ] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} + setup-mlir: true + llvm-version: 21.1.7 # Downloads the previously generated artifacts and deploys to PyPI on published releases. deploy: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7663d27c3..33930d4b44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ concurrency: jobs: change-detection: name: 🔍 Change - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-change-detection.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-change-detection.yml@setup-mlir # v1.17.4 cpp-tests-ubuntu: name: 🇨‌ Test 🐧 @@ -30,11 +30,13 @@ jobs: - runs-on: ubuntu-24.04 compiler: gcc config: Debug - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} config: ${{ matrix.config }} + setup-mlir: true + llvm-version: 21.1.7 cpp-tests-macos: name: 🇨‌ Test 🍎 @@ -50,12 +52,14 @@ jobs: - runs-on: macos-14 compiler: clang config: Debug - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} config: ${{ matrix.config }} cmake-args: -DMQT_CORE_WITH_GMP=ON + setup-mlir: true + llvm-version: 21.1.7 cpp-tests-windows: name: 🇨‌ Test 🏁 @@ -71,11 +75,13 @@ jobs: - runs-on: windows-2022 compiler: msvc config: Debug - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} config: ${{ matrix.config }} + setup-mlir: true + llvm-version: 21.1.7 # run extensive C++ tests on PRs labeled with the `extensive-cpp-ci` label cpp-tests-extensive-ubuntu: @@ -88,11 +94,13 @@ jobs: runs-on: [ubuntu-24.04, ubuntu-24.04-arm] compiler: [gcc, clang, clang-20, clang-21] config: [Release, Debug] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} config: ${{ matrix.config }} + setup-mlir: true + llvm-version: 21.1.7 # run extensive C++ tests on PRs labeled with the `extensive-cpp-ci` label cpp-tests-extensive-macos: @@ -105,12 +113,14 @@ jobs: runs-on: [macos-14, macos-15, macos-15-intel] compiler: [clang, clang-20, clang-21, gcc-14, gcc-15] config: [Release, Debug] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} config: ${{ matrix.config }} cmake-args: -DMQT_CORE_WITH_GMP=ON + setup-mlir: true + llvm-version: 21.1.7 # run extensive C++ tests on PRs labeled with the `extensive-cpp-ci` label cpp-tests-extensive-windows: @@ -123,17 +133,22 @@ jobs: runs-on: [windows-2022, windows-2025, windows-11-arm] compiler: [msvc, clang] config: [Release] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} config: ${{ matrix.config }} + setup-mlir: true + llvm-version: 21.1.7 cpp-coverage: name: 🇨‌ Coverage needs: change-detection if: fromJSON(needs.change-detection.outputs.run-cpp-tests) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-coverage.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-coverage.yml@setup-mlir # v1.17.4 + with: + setup-mlir: true + llvm-version: 21.1.7 permissions: contents: read id-token: write @@ -142,7 +157,7 @@ jobs: name: 🇨‌ Lint needs: change-detection if: fromJSON(needs.change-detection.outputs.run-cpp-linter) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-linter.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-linter.yml@setup-mlir # v1.17.4 with: cmake-args: -DBUILD_MQT_CORE_BENCHMARKS=ON -DBUILD_MQT_CORE_MLIR=ON -DBUILD_MQT_CORE_BINDINGS=ON clang-version: 21 @@ -151,6 +166,8 @@ jobs: setup-python: true install-pkgs: "pybind11==3.0.1" cpp-linter-extra-args: "-std=c++20" + setup-mlir: true + llvm-version: 21.1.7 python-tests: name: 🐍 Test @@ -167,15 +184,17 @@ jobs: macos-14, windows-2022, ] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} + setup-mlir: true + llvm-version: 21.1.7 python-coverage: name: 🐍 Coverage needs: [change-detection, python-tests] if: fromJSON(needs.change-detection.outputs.run-python-tests) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-coverage.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-coverage.yml@setup-mlir # v1.17.4 permissions: contents: read id-token: write @@ -189,23 +208,27 @@ jobs: fail-fast: false matrix: runs-on: [macos-15, windows-2025] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} + setup-mlir: true + llvm-version: 21.1.7 python-linter: name: 🐍 Lint needs: change-detection if: fromJSON(needs.change-detection.outputs.run-python-tests) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-linter.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-linter.yml@setup-mlir # v1.17.4 with: enable-ty: true + setup-mlir: true + llvm-version: 21.1.7 build-sdist: name: 🚀 CD needs: change-detection if: fromJSON(needs.change-detection.outputs.run-cd) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@setup-mlir # v1.17.4 build-wheel: name: 🚀 CD @@ -223,9 +246,11 @@ jobs: windows-2022, windows-11-arm, ] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} + setup-mlir: true + llvm-version: 21.1.7 mlir-tests: name: 🐉 Test diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 8f20e574c2..8336fb871a 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -19,16 +19,17 @@ jobs: fail-fast: false matrix: runs-on: [ubuntu-24.04, macos-14, windows-2022] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-tests.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-tests.yml@setup-mlir # v1.17.4 with: runs-on: ${{ matrix.runs-on }} - setup-z3: true + setup-mlir: true + llvm-version: 21.1.7 create-issue-on-failure: name: Create issue on failure needs: qiskit-upstream-tests if: ${{ always() }} - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-issue.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-issue.yml@setup-mlir # v1.17.4 with: tests-result: ${{ needs.qiskit-upstream-tests.result }} permissions: diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cd8e95518..9193c42de4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,7 @@ endif() set(MQT_CORE_TARGET_NAME "mqt-core") -option(BUILD_MQT_CORE_MLIR "Build the MLIR submodule of the MQT Core project" OFF) +option(BUILD_MQT_CORE_MLIR "Build the MLIR submodule of the MQT Core project" ON) if(BUILD_MQT_CORE_MLIR) include(SetupMLIR) endif() diff --git a/cmake/AddMQTCoreLibrary.cmake b/cmake/AddMQTCoreLibrary.cmake index 521d6bff45..ddb2fae6d7 100644 --- a/cmake/AddMQTCoreLibrary.cmake +++ b/cmake/AddMQTCoreLibrary.cmake @@ -47,4 +47,7 @@ function(add_mqt_core_library name) PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} EXPORT_NAME Core${ARG_ALIAS_NAME}) + + # Make version available + target_compile_definitions(${name} PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}") endfunction() diff --git a/cmake/ExternalDependencies.cmake b/cmake/ExternalDependencies.cmake index d96db70872..d01766db31 100644 --- a/cmake/ExternalDependencies.cmake +++ b/cmake/ExternalDependencies.cmake @@ -101,12 +101,21 @@ 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(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}) list(APPEND FETCH_PACKAGES spdlog) # Make all declared dependencies available. FetchContent_MakeAvailable(${FETCH_PACKAGES}) +# Ensure external shared libraries end up in a common lib layout used by our RUNPATH +if(TARGET spdlog) + set_target_properties( + spdlog PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") +endif() + # Patch for spdlog cmake files to be installed in a common cmake directory if(SPDLOG_INSTALL) include(GNUInstallDirs) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 70879df3de..24fc8fc7fa 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -15,6 +15,13 @@ if(ENABLE_COVERAGE) add_link_options(--coverage) endif() +# Conditionally set SHARED keyword for shared library builds +if(BUILD_MQT_CORE_SHARED_LIBS) + set(MQT_CORE_MLIR_LIBRARY_TYPE SHARED) +else() + set(MQT_CORE_MLIR_LIBRARY_TYPE) +endif() + # add main library code add_subdirectory(include) add_subdirectory(lib) diff --git a/mlir/lib/Conversion/MQTOptToMQTRef/CMakeLists.txt b/mlir/lib/Conversion/MQTOptToMQTRef/CMakeLists.txt index 0b8e9cc3c3..5d936cfbab 100644 --- a/mlir/lib/Conversion/MQTOptToMQTRef/CMakeLists.txt +++ b/mlir/lib/Conversion/MQTOptToMQTRef/CMakeLists.txt @@ -8,4 +8,15 @@ file(GLOB CONVERSION_SOURCES *.cpp) -add_mlir_library(MQTOptToMQTRef ${CONVERSION_SOURCES} DEPENDS MQTOptToMQTRefIncGen) +add_mlir_library( + MQTOptToMQTRef + ${CONVERSION_SOURCES} + DEPENDS + MQTOptToMQTRefIncGen + LINK_LIBS + MLIRMQTOpt + MLIRMQTRef + MLIRMemRefDialect + MLIRTransforms + MLIRFuncDialect + MLIRFuncTransforms) diff --git a/mlir/lib/Conversion/MQTRefToMQTOpt/CMakeLists.txt b/mlir/lib/Conversion/MQTRefToMQTOpt/CMakeLists.txt index d08135c396..c0e4cf86e3 100644 --- a/mlir/lib/Conversion/MQTRefToMQTOpt/CMakeLists.txt +++ b/mlir/lib/Conversion/MQTRefToMQTOpt/CMakeLists.txt @@ -8,4 +8,15 @@ file(GLOB CONVERSION_SOURCES *.cpp) -add_mlir_library(MQTRefToMQTOpt ${CONVERSION_SOURCES} DEPENDS MQTRefToMQTOptIncGen) +add_mlir_library( + MQTRefToMQTOpt + ${CONVERSION_SOURCES} + DEPENDS + MQTRefToMQTOptIncGen + LINK_LIBS + MLIRMQTOpt + MLIRMQTRef + MLIRMemRefDialect + MLIRTransforms + MLIRFuncDialect + MLIRFuncTransforms) diff --git a/mlir/lib/Conversion/MQTRefToQIR/CMakeLists.txt b/mlir/lib/Conversion/MQTRefToQIR/CMakeLists.txt index 5336be4af6..f4cb895fc9 100644 --- a/mlir/lib/Conversion/MQTRefToQIR/CMakeLists.txt +++ b/mlir/lib/Conversion/MQTRefToQIR/CMakeLists.txt @@ -8,4 +8,15 @@ file(GLOB CONVERSION_SOURCES *.cpp) -add_mlir_library(MQTRefToQIR ${CONVERSION_SOURCES} DEPENDS MQTRefToQIRIncGen) +add_mlir_library( + MQTRefToQIR + ${CONVERSION_SOURCES} + DEPENDS + MQTRefToQIRIncGen + LINK_LIBS + MLIRMQTRef + MLIRMemRefDialect + MLIRTransforms + MLIRLLVMDialect + MLIRFuncToLLVM + MLIRReconcileUnrealizedCasts) diff --git a/mlir/lib/Conversion/QIRToMQTRef/CMakeLists.txt b/mlir/lib/Conversion/QIRToMQTRef/CMakeLists.txt index 91cb08c6a6..c1e83431cf 100644 --- a/mlir/lib/Conversion/QIRToMQTRef/CMakeLists.txt +++ b/mlir/lib/Conversion/QIRToMQTRef/CMakeLists.txt @@ -8,4 +8,13 @@ file(GLOB CONVERSION_SOURCES *.cpp) -add_mlir_library(QIRToMQTRef ${CONVERSION_SOURCES} DEPENDS QIRToMQTRefIncGen) +add_mlir_library( + QIRToMQTRef + ${CONVERSION_SOURCES} + DEPENDS + QIRToMQTRefIncGen + LINK_LIBS + MLIRMQTRef + MLIRMemRefDialect + MLIRTransforms + MLIRLLVMDialect) diff --git a/mlir/lib/Dialect/MQTOpt/IR/CMakeLists.txt b/mlir/lib/Dialect/MQTOpt/IR/CMakeLists.txt index 8e962287d3..63250c798d 100644 --- a/mlir/lib/Dialect/MQTOpt/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/MQTOpt/IR/CMakeLists.txt @@ -6,8 +6,16 @@ # # Licensed under the MIT License -add_mlir_dialect_library(MLIRMQTOpt MQTOptOps.cpp DEPENDS MLIRMQTOptOpsIncGen - MLIRMQTOptInterfacesIncGen) +add_mlir_dialect_library( + MLIRMQTOpt + ${MQT_CORE_MLIR_LIBRARY_TYPE} + MQTOptOps.cpp + DEPENDS + MLIRMQTOptOpsIncGen + MLIRMQTOptInterfacesIncGen + LINK_LIBS + MLIRIR + MLIRInferTypeOpInterface) # collect header files file(GLOB_RECURSE IR_HEADERS_SOURCE "${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/MQTOpt/IR/*.h") file(GLOB_RECURSE IR_HEADERS_BUILD "${MQT_MLIR_BUILD_INCLUDE_DIR}/mlir/Dialect/MQTOpt/IR/*.inc") diff --git a/mlir/lib/Dialect/MQTRef/IR/CMakeLists.txt b/mlir/lib/Dialect/MQTRef/IR/CMakeLists.txt index 7f1b275ebc..055e8f7f3d 100644 --- a/mlir/lib/Dialect/MQTRef/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/MQTRef/IR/CMakeLists.txt @@ -6,8 +6,16 @@ # # Licensed under the MIT License -add_mlir_dialect_library(MLIRMQTRef MQTRefOps.cpp DEPENDS MLIRMQTRefOpsIncGen - MLIRMQTRefInterfacesIncGen) +add_mlir_dialect_library( + MLIRMQTRef + ${MQT_CORE_MLIR_LIBRARY_TYPE} + MQTRefOps.cpp + DEPENDS + MLIRMQTRefOpsIncGen + MLIRMQTRefInterfacesIncGen + LINK_LIBS + MLIRIR + MLIRInferTypeOpInterface) # collect header files file(GLOB_RECURSE IR_HEADERS_SOURCE "${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/MQTRef/IR/*.h") diff --git a/mlir/lib/Dialect/MQTRef/Translation/CMakeLists.txt b/mlir/lib/Dialect/MQTRef/Translation/CMakeLists.txt index c093fd04f0..1ae205a64c 100644 --- a/mlir/lib/Dialect/MQTRef/Translation/CMakeLists.txt +++ b/mlir/lib/Dialect/MQTRef/Translation/CMakeLists.txt @@ -10,6 +10,7 @@ add_compile_options(-fexceptions) add_mlir_library( MLIRMQTRefTranslation + ${MQT_CORE_MLIR_LIBRARY_TYPE} ImportQuantumComputation.cpp LINK_LIBS MLIRArithDialect diff --git a/pyproject.toml b/pyproject.toml index 3f4c255c73..f14180d1a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,10 +87,15 @@ build.targets = [ "mqt-core-ir-bindings", "mqt-core-dd-bindings", "mqt-core-qdmi-na-device", + "mqt-core-qdmi-na-device-dyn", "mqt-core-qdmi-ddsim-device", + "mqt-core-qdmi-sc-device", + "mqt-core-qdmi-sc-device-dyn", "mqt-core-fomac-bindings", "mqt-core-na-fomac", "mqt-core-na-fomac-bindings", + "quantum-opt", + "MLIRMQTRefTranslation", ] metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" diff --git a/src/na/device/CMakeLists.txt b/src/na/device/CMakeLists.txt index f6dcda1759..92d3c14496 100644 --- a/src/na/device/CMakeLists.txt +++ b/src/na/device/CMakeLists.txt @@ -13,11 +13,7 @@ set(TARGET_NAME ${MQT_CORE_TARGET_NAME}-qdmi-na-device-gen) if(NOT TARGET ${TARGET_NAME}) # Add library for device generation - # - # Note: We use a static library here to avoid issues with RPATH and finding the executable during - # the build process in Python builds - add_library(${TARGET_NAME} STATIC) - add_library(MQT::CoreQDMINaDeviceGen ALIAS ${TARGET_NAME}) + add_mqt_core_library(${TARGET_NAME} ALIAS_NAME QDMINaDeviceGen) # add sources to target target_sources(${TARGET_NAME} PRIVATE Generator.cpp) @@ -30,23 +26,16 @@ if(NOT TARGET ${TARGET_NAME}) target_link_libraries( ${TARGET_NAME} PUBLIC nlohmann_json::nlohmann_json - PRIVATE spdlog::spdlog MQT::ProjectOptions MQT::ProjectWarnings) - - # set versioning information - set_target_properties( - ${TARGET_NAME} - PROPERTIES VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - EXPORT_NAME CoreNaDeviceGen) - - # set c++ standard - target_compile_features(${TARGET_NAME} PRIVATE cxx_std_20) + PRIVATE spdlog::spdlog) # add to list of MQT core targets - set(MQT_CORE_TARGETS ${MQT_CORE_TARGETS} ${TARGET_NAME}) + list(APPEND MQT_CORE_TARGETS ${TARGET_NAME}) - # Make version available - target_compile_definitions(${TARGET_NAME} PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}") + # place the generated library in a predictable location where the executable can find it + set_target_properties( + ${TARGET_NAME} + PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") endif() # Set target name @@ -132,30 +121,17 @@ if(NOT TARGET ${TARGET_NAME}) target_link_libraries( ${TARGET_NAME} PUBLIC qdmi::qdmi - PRIVATE MQT::ProjectOptions MQT::ProjectWarnings spdlog::spdlog) + PRIVATE spdlog::spdlog) # Always compile with position independent code such that the library can be used in shared # libraries set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) - # set c++ standard - target_compile_features(${TARGET_NAME} PRIVATE cxx_std_20) - - # set versioning information - set_target_properties( - ${TARGET_NAME} - PROPERTIES VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - EXPORT_NAME CoreQDMINaDevice) - # add to list of MQT core targets - set(MQT_CORE_TARGETS - ${MQT_CORE_TARGETS} ${TARGET_NAME} - PARENT_SCOPE) + list(APPEND MQT_CORE_TARGETS ${TARGET_NAME}) # Make QDMI and MQT Core Version available - target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}" - MQT_CORE_VERSION="${MQT_CORE_VERSION}") + target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}") # Generate additional alias for the target required for generate_device_defs_executable function # in the tests @@ -201,6 +177,10 @@ if(NOT TARGET ${TARGET_NAME}) SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} EXPORT_NAME CoreQDMINaDeviceDyn) add_library(MQT::CoreQDMINaDeviceDyn ALIAS ${DYN_TARGET_NAME}) + list(APPEND MQT_CORE_TARGETS ${DYN_TARGET_NAME}) endif() endif() endif() +set(MQT_CORE_TARGETS + ${MQT_CORE_TARGETS} + PARENT_SCOPE) diff --git a/src/qdmi/dd/CMakeLists.txt b/src/qdmi/dd/CMakeLists.txt index 6b5c7065ac..5e6ac5c6c1 100644 --- a/src/qdmi/dd/CMakeLists.txt +++ b/src/qdmi/dd/CMakeLists.txt @@ -54,8 +54,7 @@ if(NOT TARGET ${TARGET_NAME}) PARENT_SCOPE) # Make QDMI and MQT Core Version available - target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}" - MQT_CORE_VERSION="${MQT_CORE_VERSION}") + target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}") # Generate additional alias for the target required for generate_device_defs_executable function # in the tests diff --git a/src/qdmi/sc/CMakeLists.txt b/src/qdmi/sc/CMakeLists.txt index f83c70bbac..a1915b0d9a 100644 --- a/src/qdmi/sc/CMakeLists.txt +++ b/src/qdmi/sc/CMakeLists.txt @@ -13,11 +13,7 @@ set(TARGET_NAME ${MQT_CORE_TARGET_NAME}-qdmi-sc-device-gen) if(NOT TARGET ${TARGET_NAME}) # Add library for device generation - # - # Note: We use a static library here to avoid issues with RPATH and finding the executable during - # the build process in Python builds - add_library(${TARGET_NAME} STATIC) - add_library(MQT::CoreQDMIScDeviceGen ALIAS ${TARGET_NAME}) + add_mqt_core_library(${TARGET_NAME} ALIAS_NAME QDMIScDeviceGen) # add sources to target target_sources(${TARGET_NAME} PRIVATE Generator.cpp) @@ -30,23 +26,13 @@ if(NOT TARGET ${TARGET_NAME}) target_link_libraries( ${TARGET_NAME} PUBLIC nlohmann_json::nlohmann_json - PRIVATE spdlog::spdlog MQT::ProjectOptions MQT::ProjectWarnings) + PRIVATE spdlog::spdlog) - # set versioning information + # place the generated library in a predictable location where the executable can find it set_target_properties( ${TARGET_NAME} - PROPERTIES VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - EXPORT_NAME CoreScDeviceGen) - - # set c++ standard - target_compile_features(${TARGET_NAME} PRIVATE cxx_std_20) - - # add to list of MQT core targets - set(MQT_CORE_TARGETS ${MQT_CORE_TARGETS} ${TARGET_NAME}) - - # Make version available - target_compile_definitions(${TARGET_NAME} PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}") + PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") endif() # Set target name @@ -132,30 +118,17 @@ if(NOT TARGET ${TARGET_NAME}) target_link_libraries( ${TARGET_NAME} PUBLIC qdmi::qdmi - PRIVATE MQT::ProjectOptions MQT::ProjectWarnings spdlog::spdlog) + PRIVATE spdlog::spdlog) # Always compile with position independent code such that the library can be used in shared # libraries set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) - # set c++ standard - target_compile_features(${TARGET_NAME} PRIVATE cxx_std_20) - - # set versioning information - set_target_properties( - ${TARGET_NAME} - PROPERTIES VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - EXPORT_NAME CoreQDMIScDevice) - # add to list of MQT core targets - set(MQT_CORE_TARGETS - ${MQT_CORE_TARGETS} ${TARGET_NAME} - PARENT_SCOPE) + list(APPEND MQT_CORE_TARGETS ${TARGET_NAME}) # Make QDMI and MQT Core Version available - target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}" - MQT_CORE_VERSION="${MQT_CORE_VERSION}") + target_compile_definitions(${TARGET_NAME} PRIVATE QDMI_VERSION="${QDMI_VERSION}") # Generate additional alias for the target required for generate_device_defs_executable function # in the tests @@ -201,6 +174,10 @@ if(NOT TARGET ${TARGET_NAME}) SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} EXPORT_NAME CoreQDMIScDeviceDyn) add_library(MQT::CoreQDMIScDeviceDyn ALIAS ${DYN_TARGET_NAME}) + list(APPEND MQT_CORE_TARGETS ${DYN_TARGET_NAME}) endif() endif() endif() +set(MQT_CORE_TARGETS + ${MQT_CORE_TARGETS} + PARENT_SCOPE) diff --git a/src/qir/runner/CMakeLists.txt b/src/qir/runner/CMakeLists.txt index 3134001ca8..bc2155e40e 100644 --- a/src/qir/runner/CMakeLists.txt +++ b/src/qir/runner/CMakeLists.txt @@ -15,8 +15,13 @@ if(NOT TARGET ${TARGET_NAME}) add_llvm_tool(${TARGET_NAME} Runner.cpp DEPENDS intrinsics_gen) export_executable_symbols(${TARGET_NAME}) endif() + + # Get the native target libraries + llvm_map_components_to_libnames(llvm_native_libs native) + # Add link libraries - target_link_libraries(${TARGET_NAME} PRIVATE MQT::CoreQIRRuntime ${llvm_libs}) + target_link_libraries(${TARGET_NAME} PRIVATE MQT::CoreQIRRuntime LLVMOrcDebugging + ${llvm_native_libs}) # Set versioning information set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${PROJECT_VERSION} EXPORT_NAME diff --git a/test/qir/runner/test_qir_runner.cpp b/test/qir/runner/test_qir_runner.cpp index 7d6ebeeaeb..55828e9b18 100644 --- a/test/qir/runner/test_qir_runner.cpp +++ b/test/qir/runner/test_qir_runner.cpp @@ -13,12 +13,6 @@ #include #include -#ifdef _WIN32 -#define SYSTEM _wsystem -#else -#define SYSTEM std::system -#endif - namespace qir { class QIRRunnerTest : public testing::TestWithParam {}; @@ -38,7 +32,7 @@ TEST_P(QIRRunnerTest, QIRFile) { const auto& file = GetParam(); std::ostringstream command; command << EXECUTABLE_PATH << " " << file; - const auto result = SYSTEM(command.str().c_str()); + const auto result = std::system(command.str().c_str()); EXPECT_EQ(result, 0); } } // namespace qir diff --git a/test/qir/runtime/CMakeLists.txt b/test/qir/runtime/CMakeLists.txt index e7726dd09e..6dd8e361ae 100644 --- a/test/qir/runtime/CMakeLists.txt +++ b/test/qir/runtime/CMakeLists.txt @@ -21,6 +21,7 @@ macro(ADD_QIR_CIRCUIT target_name circuit_path) COMMENT "Compiling ${circuit_path} to ${circuit_name}.o") add_executable(${target_name} ${circuit_name}.o) target_link_libraries(${target_name} PRIVATE MQT::CoreQIRRuntime) + set_target_properties(${target_name} PROPERTIES LINKER_LANGUAGE CXX) endif() endmacro()