diff --git a/.gitmodules b/.gitmodules index 3c73b983..1c485ae9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,13 +2,3 @@ path = extern/mqt-core url = https://github.com/cda-tum/mqt-core.git branch = main -[submodule "extern/taskflow"] - path = extern/taskflow - url = https://github.com/taskflow/taskflow.git - branch = master - shallow = true -[submodule "extern/cxxopts"] - path = extern/cxxopts - url = https://github.com/jarro2783/cxxopts.git - branch = master - shallow = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 301654cd..ad4bc4ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,6 +72,8 @@ repos: hooks: - id: cmake-format additional_dependencies: [pyyaml] + types: [file] + files: (\.cmake|CMakeLists.txt)(.in)?$ # Clang-format the C++ part of the code base automatically - repo: https://github.com/pre-commit/mirrors-clang-format diff --git a/CMakeLists.txt b/CMakeLists.txt index 85edbe30..1d3a500e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,42 +1,34 @@ # set required cmake version -cmake_minimum_required(VERSION 3.19...3.27) +cmake_minimum_required(VERSION 3.19...3.28) project( - ddsim + mqt-ddsim LANGUAGES CXX - DESCRIPTION "MQT DDSIM - A quantum simulator based on decision diagrams") - -# check whether `modulename` is correctly cloned in the `extern` directory. -macro(CHECK_SUBMODULE_PRESENT modulename) - if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${modulename}/CMakeLists.txt") - message( - FATAL_ERROR - "${modulename} submodule not cloned properly. \ - Please run `git submodule update --init --recursive` \ - from the main project directory") - endif() -endmacro() - -check_submodule_present(mqt-core) -check_submodule_present(taskflow) + DESCRIPTION + "MQT DDSIM - A quantum circuit simulator based on decision diagrams") option(BUILD_MQT_DDSIM_TESTS "Also build tests for the MQT DDSIM project" ON) option(BUILD_MQT_DDSIM_BINDINGS "Build the MQT DDSIM Python bindings" OFF) +option(BUILD_MQT_DDSIM_CLI "Build the MQT DDSIM command line interface" ON) + if(BUILD_MQT_DDSIM_BINDINGS) # ensure that the BINDINGS option is set set(BINDINGS ON - CACHE BOOL "Enable settings related to Python bindings" FORCE) - # cmake-lint: disable=C0103 + CACHE INTERNAL "Enable settings related to Python bindings") + # Some common settings for finding Python set(Python_FIND_VIRTUALENV FIRST CACHE STRING "Give precedence to virtualenvs when searching for Python") - # cmake-lint: disable=C0103 + set(Python_FIND_FRAMEWORK + LAST + CACHE STRING "Prefer Brew/Conda to Apple framework Python") set(Python_ARTIFACTS_INTERACTIVE ON CACHE BOOL "Prevent multiple searches for Python and instead cache the results.") + # top-level call to find Python find_package( Python 3.8 REQUIRED @@ -46,6 +38,9 @@ endif() include(cmake/ExternalDependencies.cmake) +# set the include directory for the build tree +set(MQT_DDSIM_INCLUDE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") + add_subdirectory(src) if(BUILD_MQT_DDSIM_TESTS) @@ -54,7 +49,6 @@ if(BUILD_MQT_DDSIM_TESTS) add_subdirectory(test) endif() -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - check_submodule_present(cxxopts) +if(BUILD_MQT_DDSIM_CLI) add_subdirectory(apps) endif() diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index ec062f1d..2c36f640 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,30 +1,16 @@ -add_subdirectory("${PROJECT_SOURCE_DIR}/extern/cxxopts" "extern/cxxopts" - EXCLUDE_FROM_ALL) -# the following sets the SYSTEM flag for the include dirs of the cxxopts libs to -# cmake-lint: disable=C0307 -set_target_properties( - cxxopts PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES - $) - # macro to add a executable with the given libraries macro(ADD_SIM_EXECUTABLE appname) - add_executable(${PROJECT_NAME}_${appname} - ${CMAKE_CURRENT_SOURCE_DIR}/${appname}.cpp) - target_link_libraries(${PROJECT_NAME}_${appname} PRIVATE ${PROJECT_NAME} - ${ARGN}) + add_executable(mqt-ddsim-${appname} ${appname}.cpp) + target_link_libraries(mqt-ddsim-${appname} PRIVATE MQT::DDSim ${ARGN}) endmacro() -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads) -link_libraries(Threads::Threads) - add_sim_executable(simple cxxopts::cxxopts) add_sim_executable(primebases cxxopts::cxxopts) if(Threads_FOUND) add_sim_executable(noise_aware cxxopts::cxxopts) - target_link_libraries(${PROJECT_NAME}_noise_aware PUBLIC Threads::Threads) + target_link_libraries(mqt-ddsim-noise_aware PRIVATE Threads::Threads) endif() -find_package(OpenCV QUIET) + if(OpenCV_FOUND) add_sim_executable(frqi cxxopts::cxxopts ${OpenCV_LIBRARIES}) endif() diff --git a/cmake/ExternalDependencies.cmake b/cmake/ExternalDependencies.cmake index 9c21c178..443301b2 100644 --- a/cmake/ExternalDependencies.cmake +++ b/cmake/ExternalDependencies.cmake @@ -3,6 +3,49 @@ include(FetchContent) set(FETCH_PACKAGES "") +if(BUILD_MQT_DDSIM_BINDINGS) + if(NOT SKBUILD) + # Manually detect the installed pybind11 package. + execute_process( + COMMAND "${Python_EXECUTABLE}" -m pybind11 --cmakedir + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE pybind11_DIR) + + # Add the detected directory to the CMake prefix path. + list(APPEND CMAKE_PREFIX_PATH "${pybind11_DIR}") + endif() + + # add pybind11 library + find_package(pybind11 CONFIG REQUIRED) +endif() + +set(FETCHCONTENT_SOURCE_DIR_MQT-CORE + ${PROJECT_SOURCE_DIR}/extern/mqt-core + CACHE + PATH + "Path to the source directory of the mqt-core library. This variable is used by FetchContent to download the library if it is not already available." +) +set(MQT_CORE_VERSION + 2.2.2 + CACHE STRING "MQT Core version") +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + FetchContent_Declare( + mqt-core + GIT_REPOSITORY https://github.com/cda-tum/mqt-core.git + GIT_TAG v${MQT_CORE_VERSION} + FIND_PACKAGE_ARGS ${MQT_CORE_VERSION}) + list(APPEND FETCH_PACKAGES mqt-core) +else() + find_package(mqt-core ${MQT_CORE_VERSION} QUIET) + if(NOT mqt-core_FOUND) + FetchContent_Declare( + mqt-core + GIT_REPOSITORY https://github.com/cda-tum/mqt-core.git + GIT_TAG v${MQT_CORE_VERSION}) + list(APPEND FETCH_PACKAGES mqt-core) + endif() +endif() + if(BUILD_MQT_DDSIM_TESTS) set(gtest_force_shared_crt ON @@ -26,5 +69,75 @@ if(BUILD_MQT_DDSIM_TESTS) endif() endif() +set(TF_BUILD_TESTS + OFF + CACHE INTERNAL "") +set(TF_BUILD_EXAMPLES + OFF + CACHE INTERNAL "") +set(TF_BUILD_PROFILER + OFF + CACHE INTERNAL "") +set(TF_VERSION + 3.6.0 + CACHE STRING "Taskflow version") +set(TF_URL + https://github.com/taskflow/taskflow/archive/refs/tags/v${TF_VERSION}.tar.gz +) +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + FetchContent_Declare(taskflow URL ${TF_URL} FIND_PACKAGE_ARGS) + list(APPEND FETCH_PACKAGES taskflow) +else() + find_package(taskflow ${TF_VERSION} QUIET) + if(NOT taskflow_FOUND) + FetchContent_Declare(taskflow URL ${TF_URL}) + list(APPEND FETCH_PACKAGES taskflow) + endif() +endif() + +if(BUILD_MQT_DDSIM_CLI) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + link_libraries(Threads::Threads) + + find_package(OpenCV QUIET) + + set(CXXOPTS_VERSION + 3.1.1 + CACHE STRING "cxxopts version") + set(CXXOPTS_URL + https://github.com/jarro2783/cxxopts/archive/refs/tags/v${CXXOPTS_VERSION}.tar.gz + ) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + FetchContent_Declare(cxxopts URL ${CXXOPTS_URL} FIND_PACKAGE_ARGS + ${CXXOPTS_VERSION}) + list(APPEND FETCH_PACKAGES cxxopts) + else() + find_package(cxxopts ${CXXOPTS_VERSION} QUIET) + if(NOT cxxopts_FOUND) + FetchContent_Declare(cxxopts URL ${CXXOPTS_URL}) + list(APPEND FETCH_PACKAGES cxxopts) + endif() + endif() +endif() + +if(BUILD_MQT_DDSIM_BINDINGS) + # add pybind11_json library + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + FetchContent_Declare( + pybind11_json + GIT_REPOSITORY https://github.com/pybind/pybind11_json + FIND_PACKAGE_ARGS) + list(APPEND FETCH_PACKAGES pybind11_json) + else() + find_package(pybind11_json QUIET) + if(NOT pybind11_json_FOUND) + FetchContent_Declare( + pybind11_json GIT_REPOSITORY https://github.com/pybind/pybind11_json) + list(APPEND FETCH_PACKAGES pybind11_json) + endif() + endif() +endif() + # Make all declared dependencies available. FetchContent_MakeAvailable(${FETCH_PACKAGES}) diff --git a/extern/cxxopts b/extern/cxxopts deleted file mode 160000 index 554396be..00000000 --- a/extern/cxxopts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 554396be3b19bff45384a3c6307a1eb9a3497940 diff --git a/extern/mqt-core b/extern/mqt-core index 6d9a08ed..3d5e14b2 160000 --- a/extern/mqt-core +++ b/extern/mqt-core @@ -1 +1 @@ -Subproject commit 6d9a08ed81019bd120065ca511721a500bc52aca +Subproject commit 3d5e14b20809108b90de6df03fa25def3d2851c9 diff --git a/extern/taskflow b/extern/taskflow deleted file mode 160000 index b91df2c3..00000000 --- a/extern/taskflow +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b91df2c365c20fa4cb43951192f6939fbe876abf diff --git a/noxfile.py b/noxfile.py index 7793ff82..f6ef02ce 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: from collections.abc import Sequence -nox.options.sessions = ["lint", "pylint", "tests"] +nox.options.sessions = ["lint", "tests"] PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"] diff --git a/pyproject.toml b/pyproject.toml index d5f19a5a..67bbf1cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,12 +34,13 @@ classifiers = [ ] requires-python = ">=3.8" dependencies = [ - "qiskit-terra>=0.22.1" + "qiskit[qasm3-import]>=0.45.0" ] dynamic = ["version"] [project.optional-dependencies] tnflow = [ + "cotengra", "sparse", "opt-einsum", "quimb", @@ -63,7 +64,7 @@ docs = [ "breathe", "sphinxext-opengraph", "sphinx-autodoc-typehints", - "qiskit-terra[visualization]", + "qiskit[visualization]", "graphviz", ] dev = ["mqt.ddsim[tnflow, coverage, docs]"] @@ -79,8 +80,8 @@ Discussions = "https://github.com/cda-tum/mqt-ddsim/discussions" # Protect the configuration against future changes in scikit-build-core minimum-version = "0.6.1" -# Set the target to build -cmake.targets = ["pyddsim"] +# Set the wheel install directory +wheel.install-dir = "mqt/ddsim" # Set required CMake and Ninja versions cmake.minimum-version = "3.19" @@ -89,9 +90,6 @@ ninja.minimum-version = "1.10" # Setuptools-style build caching in a local directory build-dir = "build/{wheel_tag}" -# Build stable ABI wheels for CPython 3.12+ -wheel.py-api = "cp312" - # Explicitly set the package directory wheel.packages = ["src/mqt"] @@ -118,7 +116,7 @@ sdist.exclude = [ [tool.scikit-build.cmake.define] BUILD_MQT_DDSIM_TESTS = "OFF" BUILD_MQT_DDSIM_BINDINGS = "ON" -ENABLE_IPO = "ON" +BUILD_MQT_DDSIM_CLI = "OFF" [tool.check-sdist] @@ -147,6 +145,7 @@ filterwarnings = [ "ignore:.*qiskit.utils.algorithm_globals.QiskitAlgorithmGlobals*:DeprecationWarning:qiskit", "ignore:.*Building a flow controller with keyword arguments is going to be deprecated*:PendingDeprecationWarning:qiskit", "ignore:.*qiskit.extensions module is pending deprecation*:PendingDeprecationWarning:qiskit", + 'ignore:.*datetime\.datetime\.utcfromtimestamp.*:DeprecationWarning:', ] [tool.coverage] @@ -257,7 +256,6 @@ build = "cp3*" skip = "*-musllinux_*" archs = "auto64" test-command = "python -c \"from mqt import ddsim\"" -test-skip = "cp312-*" # Qiskit Terra does not support Python 3.12 yet build-frontend = "build" [tool.cibuildwheel.linux] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c1a5762f..55b0ae41 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,60 +1,45 @@ -# add MQT::Core target -set(BUILD_MQT_CORE_TESTS - OFF - CACHE BOOL "Build MQT Core tests") -add_subdirectory("${PROJECT_SOURCE_DIR}/extern/mqt-core" "extern/mqt-core" - EXCLUDE_FROM_ALL) +set(MQT_DDSIM_TARGET_NAME mqt-ddsim) add_library( - ${PROJECT_NAME} - ${PROJECT_SOURCE_DIR}/include/Simulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/Simulator.cpp - ${PROJECT_SOURCE_DIR}/include/CircuitSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/CircuitSimulator.cpp - ${PROJECT_SOURCE_DIR}/include/GroverSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/GroverSimulator.cpp - ${PROJECT_SOURCE_DIR}/include/ShorSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/ShorSimulator.cpp - ${PROJECT_SOURCE_DIR}/include/ShorFastSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/ShorFastSimulator.cpp - ${PROJECT_SOURCE_DIR}/include/StochasticNoiseSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/StochasticNoiseSimulator.cpp - ${PROJECT_SOURCE_DIR}/include/DeterministicNoiseSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/DeterministicNoiseSimulator.cpp - ${PROJECT_SOURCE_DIR}/include/HybridSchrodingerFeynmanSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/HybridSchrodingerFeynmanSimulator.cpp - ${PROJECT_SOURCE_DIR}/include/UnitarySimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/UnitarySimulator.cpp - ${PROJECT_SOURCE_DIR}/include/PathSimulator.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/PathSimulator.cpp) + ${MQT_DDSIM_TARGET_NAME} + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/Simulator.hpp + Simulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/CircuitSimulator.hpp + CircuitSimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/GroverSimulator.hpp + GroverSimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/ShorSimulator.hpp + ShorSimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/ShorFastSimulator.hpp + ShorFastSimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/StochasticNoiseSimulator.hpp + StochasticNoiseSimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/DeterministicNoiseSimulator.hpp + DeterministicNoiseSimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/HybridSchrodingerFeynmanSimulator.hpp + HybridSchrodingerFeynmanSimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/UnitarySimulator.hpp + UnitarySimulator.cpp + ${MQT_DDSIM_INCLUDE_BUILD_DIR}/PathSimulator.hpp + PathSimulator.cpp) # set include directories -target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include - ${PROJECT_BINARY_DIR}/include) +target_include_directories( + ${MQT_DDSIM_TARGET_NAME} + PUBLIC $) -# link to the MQT::Core libraries -target_link_libraries(${PROJECT_NAME} PUBLIC MQT::CoreDD) +# link to the MQT::Core and Taskflow libraries +target_link_libraries(${MQT_DDSIM_TARGET_NAME} PUBLIC MQT::CoreDD Taskflow) +target_link_libraries(${MQT_DDSIM_TARGET_NAME} PRIVATE MQT::ProjectWarnings + MQT::ProjectOptions) -set(TF_BUILD_TESTS - OFF - CACHE BOOL "") -set(TF_BUILD_EXAMPLES - OFF - CACHE BOOL "") -set(TF_BUILD_PROFILER - OFF - CACHE BOOL "") -add_subdirectory("${PROJECT_SOURCE_DIR}/extern/taskflow" "extern/taskflow" - EXCLUDE_FROM_ALL) -target_link_libraries(${PROJECT_NAME} PUBLIC Taskflow) # the following sets the SYSTEM flag for the include dirs of the taskflow libs -# cmake-lint: disable=C0307 set_target_properties( Taskflow PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $) # add MQT alias -add_library(MQT::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) +add_library(MQT::DDSim ALIAS ${MQT_DDSIM_TARGET_NAME}) if(BUILD_MQT_DDSIM_BINDINGS) add_subdirectory(python) diff --git a/src/mqt/ddsim/hybridqasmsimulator.py b/src/mqt/ddsim/hybridqasmsimulator.py index 0e0483b7..fc4e6ed7 100644 --- a/src/mqt/ddsim/hybridqasmsimulator.py +++ b/src/mqt/ddsim/hybridqasmsimulator.py @@ -95,16 +95,12 @@ def _run_experiment(self, qc: QuantumCircuit, **options: Any) -> ExperimentResul nthreads=nthreads, ) - metadata = qc.metadata - if metadata is None: - metadata = {} - return ExperimentResult( shots=shots, success=True, status="DONE", seed=seed, data=data, - metadata=metadata, + metadata=qc.metadata, header=DDSIMHeader(qc), ) diff --git a/src/mqt/ddsim/pathqasmsimulator.py b/src/mqt/ddsim/pathqasmsimulator.py index 870e0071..2aefb061 100644 --- a/src/mqt/ddsim/pathqasmsimulator.py +++ b/src/mqt/ddsim/pathqasmsimulator.py @@ -207,10 +207,6 @@ def _run_experiment(self, qc: QuantumCircuit, **options: Any) -> ExperimentResul time_sim=end_time - setup_time, ) - metadata = qc.metadata - if metadata is None: - metadata = {} - return ExperimentResult( shots=shots, success=True, @@ -218,6 +214,6 @@ def _run_experiment(self, qc: QuantumCircuit, **options: Any) -> ExperimentResul config=pathsim_configuration, seed=seed, data=data, - metadata=metadata, + metadata=qc.metadata, header=DDSIMHeader(qc), ) diff --git a/src/mqt/ddsim/qasmsimulator.py b/src/mqt/ddsim/qasmsimulator.py index 0c9bb1d3..8d373bb9 100644 --- a/src/mqt/ddsim/qasmsimulator.py +++ b/src/mqt/ddsim/qasmsimulator.py @@ -177,17 +177,13 @@ def _run_experiment(self, qc: QuantumCircuit, **options: dict[str, Any]) -> Expe time_taken=end_time - start_time, ) - metadata = qc.metadata - if metadata is None: - metadata = {} - return ExperimentResult( shots=shots, success=True, status="DONE", seed=seed, data=data, - metadata=metadata, + metadata=qc.metadata, header=DDSIMHeader(qc), ) diff --git a/src/mqt/ddsim/unitarysimulator.py b/src/mqt/ddsim/unitarysimulator.py index deed3686..3c12a2fa 100644 --- a/src/mqt/ddsim/unitarysimulator.py +++ b/src/mqt/ddsim/unitarysimulator.py @@ -81,17 +81,13 @@ def _run_experiment(cls, qc: QuantumCircuit, **options: Any) -> ExperimentResult time_taken=end_time - start_time, ) - metadata = qc.metadata - if metadata is None: - metadata = {} - return ExperimentResult( shots=1, success=True, status="DONE", seed=seed, data=data, - metadata=metadata, + metadata=qc.metadata, header=DDSIMHeader(qc), ) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index c7e0fe13..d76e9dd7 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -1,43 +1,17 @@ -if(NOT SKBUILD) - message( - NOTICE - "\ - This CMake file is meant to be executed using 'scikit-build'. Running - it directly will almost certainly not produce the desired result. If - you are a user trying to install this package, please use the command - below, which will install all necessary build dependencies, compile - the package in an isolated environment, and then install it. - ===================================================================== - $ pip install . - ===================================================================== - If you are a software developer, and this is your own package, then - it is usually much more efficient to install the build dependencies - in your environment once and use the following command that avoids - a costly creation of a new virtual environment at every compilation: - ===================================================================== - $ pip install 'scikit-build-core[pyproject]' setuptools_scm pybind11 - $ pip install --no-build-isolation -ve . - ===================================================================== - You may optionally add -Ceditable.rebuild=true to auto-rebuild when - the package is imported. Otherwise, you need to re-run the above - after editing C++ files.") -endif() - -if(NOT SKBUILD) - # Manually detect the installed pybind11 package and import it into CMake. - execute_process( - COMMAND "${Python_EXECUTABLE}" -m pybind11 --cmakedir - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE pybind11_DIR) - list(APPEND CMAKE_PREFIX_PATH "${pybind11_DIR}") -endif() - -# Import pybind11 through CMake's find_package mechanism -find_package(pybind11 CONFIG REQUIRED) - -# We are now ready to compile the actual extension module -pybind11_add_module(py${PROJECT_NAME} bindings.cpp) -target_link_libraries(py${PROJECT_NAME} PRIVATE ${PROJECT_NAME} MQT::CorePython) +pybind11_add_module( + pyddsim + # Prefer thin LTO if available + THIN_LTO + # Optimize the bindings for size + OPT_SIZE + # Source code goes here + bindings.cpp) +target_link_libraries( + pyddsim PRIVATE MQT::DDSim MQT::ProjectOptions MQT::ProjectWarnings + MQT::CorePython pybind11_json) # Install directive for scikit-build-core -install(TARGETS py${PROJECT_NAME} LIBRARY DESTINATION mqt/ddsim) +install( + TARGETS pyddsim + DESTINATION . + COMPONENT mqt-ddsim_PythonModule) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f2ddc7f7..7acc5077 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,30 +1,29 @@ package_add_test( - ${PROJECT_NAME}_test - ${PROJECT_NAME} - ${CMAKE_CURRENT_SOURCE_DIR}/test_circuit_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_shor_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_fast_shor_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_grover_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_hybridsim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_stoch_noise_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_det_noise_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_unitary_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_path_sim.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_output_ddvis.cpp) + mqt-ddsim-test + MQT::DDSim + test_circuit_sim.cpp + test_shor_sim.cpp + test_fast_shor_sim.cpp + test_grover_sim.cpp + test_hybridsim.cpp + test_stoch_noise_sim.cpp + test_det_noise_sim.cpp + test_unitary_sim.cpp + test_path_sim.cpp + test_output_ddvis.cpp) add_custom_command( - TARGET ${PROJECT_NAME}_test + TARGET mqt-ddsim-test POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink - $/${PROJECT_NAME}_test - ${CMAKE_BINARY_DIR}/${PROJECT_NAME}_test + $/mqt-ddsim-test + ${CMAKE_BINARY_DIR}/mqt-ddsim-test COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/circuits - $/circuits + $/circuits COMMAND ${CMAKE_COMMAND} -E create_symlink - $/circuits - ${CMAKE_BINARY_DIR}/circuits - COMMENT "Copying circuits and creating symlinks for ${PROJECT_NAME}_test" + $/circuits ${CMAKE_BINARY_DIR}/circuits + COMMENT "Copying circuits and creating symlinks for mqt-ddsim-test" VERBATIM) diff --git a/test/python/constraints.txt b/test/python/constraints.txt index 7c858a73..aac0312c 100644 --- a/test/python/constraints.txt +++ b/test/python/constraints.txt @@ -2,4 +2,4 @@ scikit-build-core==0.6.1 setuptools-scm==7.0.0 pybind11==2.11.0 pytest==7.0.0 -qiskit-terra==0.22.1 +qiskit==0.45.0