Skip to content

Commit 225e078

Browse files
authored
⬆️ update mqt-core (#337)
## Description This PR updates the mqt-core submodule and brings in some further advancements from #355. Specifically, it switches to using `FetchContent` for obtaining `mqt-core`. Per default, it is pointed to the vendored submodule via an overridable CMake variable. ## 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 related to it. - [x] I have added appropriate tests and documentation. - [x] I have made sure that all CI jobs on GitHub pass. - [x] The pull request introduces no new warnings and follows the project's style guidelines.
2 parents 9cb8ca1 + e5de0e1 commit 225e078

18 files changed

+212
-189
lines changed

.gitmodules

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,3 @@
22
path = extern/mqt-core
33
url = https://github.com/cda-tum/mqt-core.git
44
branch = main
5-
[submodule "extern/taskflow"]
6-
path = extern/taskflow
7-
url = https://github.com/taskflow/taskflow.git
8-
branch = master
9-
shallow = true
10-
[submodule "extern/cxxopts"]
11-
path = extern/cxxopts
12-
url = https://github.com/jarro2783/cxxopts.git
13-
branch = master
14-
shallow = true

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ repos:
7272
hooks:
7373
- id: cmake-format
7474
additional_dependencies: [pyyaml]
75+
types: [file]
76+
files: (\.cmake|CMakeLists.txt)(.in)?$
7577

7678
# Clang-format the C++ part of the code base automatically
7779
- repo: https://github.com/pre-commit/mirrors-clang-format

CMakeLists.txt

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,34 @@
11
# set required cmake version
2-
cmake_minimum_required(VERSION 3.19...3.27)
2+
cmake_minimum_required(VERSION 3.19...3.28)
33

44
project(
5-
ddsim
5+
mqt-ddsim
66
LANGUAGES CXX
7-
DESCRIPTION "MQT DDSIM - A quantum simulator based on decision diagrams")
8-
9-
# check whether `modulename` is correctly cloned in the `extern` directory.
10-
macro(CHECK_SUBMODULE_PRESENT modulename)
11-
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${modulename}/CMakeLists.txt")
12-
message(
13-
FATAL_ERROR
14-
"${modulename} submodule not cloned properly. \
15-
Please run `git submodule update --init --recursive` \
16-
from the main project directory")
17-
endif()
18-
endmacro()
19-
20-
check_submodule_present(mqt-core)
21-
check_submodule_present(taskflow)
7+
DESCRIPTION
8+
"MQT DDSIM - A quantum circuit simulator based on decision diagrams")
229

2310
option(BUILD_MQT_DDSIM_TESTS "Also build tests for the MQT DDSIM project" ON)
2411
option(BUILD_MQT_DDSIM_BINDINGS "Build the MQT DDSIM Python bindings" OFF)
12+
option(BUILD_MQT_DDSIM_CLI "Build the MQT DDSIM command line interface" ON)
13+
2514
if(BUILD_MQT_DDSIM_BINDINGS)
2615
# ensure that the BINDINGS option is set
2716
set(BINDINGS
2817
ON
29-
CACHE BOOL "Enable settings related to Python bindings" FORCE)
30-
# cmake-lint: disable=C0103
18+
CACHE INTERNAL "Enable settings related to Python bindings")
19+
# Some common settings for finding Python
3120
set(Python_FIND_VIRTUALENV
3221
FIRST
3322
CACHE STRING "Give precedence to virtualenvs when searching for Python")
34-
# cmake-lint: disable=C0103
23+
set(Python_FIND_FRAMEWORK
24+
LAST
25+
CACHE STRING "Prefer Brew/Conda to Apple framework Python")
3526
set(Python_ARTIFACTS_INTERACTIVE
3627
ON
3728
CACHE
3829
BOOL
3930
"Prevent multiple searches for Python and instead cache the results.")
31+
4032
# top-level call to find Python
4133
find_package(
4234
Python 3.8 REQUIRED
@@ -46,6 +38,9 @@ endif()
4638

4739
include(cmake/ExternalDependencies.cmake)
4840

41+
# set the include directory for the build tree
42+
set(MQT_DDSIM_INCLUDE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
43+
4944
add_subdirectory(src)
5045

5146
if(BUILD_MQT_DDSIM_TESTS)
@@ -54,7 +49,6 @@ if(BUILD_MQT_DDSIM_TESTS)
5449
add_subdirectory(test)
5550
endif()
5651

57-
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
58-
check_submodule_present(cxxopts)
52+
if(BUILD_MQT_DDSIM_CLI)
5953
add_subdirectory(apps)
6054
endif()

apps/CMakeLists.txt

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
1-
add_subdirectory("${PROJECT_SOURCE_DIR}/extern/cxxopts" "extern/cxxopts"
2-
EXCLUDE_FROM_ALL)
3-
# the following sets the SYSTEM flag for the include dirs of the cxxopts libs to
4-
# cmake-lint: disable=C0307
5-
set_target_properties(
6-
cxxopts PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
7-
$<TARGET_PROPERTY:cxxopts,INTERFACE_INCLUDE_DIRECTORIES>)
8-
91
# macro to add a executable with the given libraries
102
macro(ADD_SIM_EXECUTABLE appname)
11-
add_executable(${PROJECT_NAME}_${appname}
12-
${CMAKE_CURRENT_SOURCE_DIR}/${appname}.cpp)
13-
target_link_libraries(${PROJECT_NAME}_${appname} PRIVATE ${PROJECT_NAME}
14-
${ARGN})
3+
add_executable(mqt-ddsim-${appname} ${appname}.cpp)
4+
target_link_libraries(mqt-ddsim-${appname} PRIVATE MQT::DDSim ${ARGN})
155
endmacro()
166

17-
set(THREADS_PREFER_PTHREAD_FLAG ON)
18-
find_package(Threads)
19-
link_libraries(Threads::Threads)
20-
217
add_sim_executable(simple cxxopts::cxxopts)
228
add_sim_executable(primebases cxxopts::cxxopts)
239
if(Threads_FOUND)
2410
add_sim_executable(noise_aware cxxopts::cxxopts)
25-
target_link_libraries(${PROJECT_NAME}_noise_aware PUBLIC Threads::Threads)
11+
target_link_libraries(mqt-ddsim-noise_aware PRIVATE Threads::Threads)
2612
endif()
27-
find_package(OpenCV QUIET)
13+
2814
if(OpenCV_FOUND)
2915
add_sim_executable(frqi cxxopts::cxxopts ${OpenCV_LIBRARIES})
3016
endif()

cmake/ExternalDependencies.cmake

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,49 @@
33
include(FetchContent)
44
set(FETCH_PACKAGES "")
55

6+
if(BUILD_MQT_DDSIM_BINDINGS)
7+
if(NOT SKBUILD)
8+
# Manually detect the installed pybind11 package.
9+
execute_process(
10+
COMMAND "${Python_EXECUTABLE}" -m pybind11 --cmakedir
11+
OUTPUT_STRIP_TRAILING_WHITESPACE
12+
OUTPUT_VARIABLE pybind11_DIR)
13+
14+
# Add the detected directory to the CMake prefix path.
15+
list(APPEND CMAKE_PREFIX_PATH "${pybind11_DIR}")
16+
endif()
17+
18+
# add pybind11 library
19+
find_package(pybind11 CONFIG REQUIRED)
20+
endif()
21+
22+
set(FETCHCONTENT_SOURCE_DIR_MQT-CORE
23+
${PROJECT_SOURCE_DIR}/extern/mqt-core
24+
CACHE
25+
PATH
26+
"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."
27+
)
28+
set(MQT_CORE_VERSION
29+
2.2.2
30+
CACHE STRING "MQT Core version")
31+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
32+
FetchContent_Declare(
33+
mqt-core
34+
GIT_REPOSITORY https://github.com/cda-tum/mqt-core.git
35+
GIT_TAG v${MQT_CORE_VERSION}
36+
FIND_PACKAGE_ARGS ${MQT_CORE_VERSION})
37+
list(APPEND FETCH_PACKAGES mqt-core)
38+
else()
39+
find_package(mqt-core ${MQT_CORE_VERSION} QUIET)
40+
if(NOT mqt-core_FOUND)
41+
FetchContent_Declare(
42+
mqt-core
43+
GIT_REPOSITORY https://github.com/cda-tum/mqt-core.git
44+
GIT_TAG v${MQT_CORE_VERSION})
45+
list(APPEND FETCH_PACKAGES mqt-core)
46+
endif()
47+
endif()
48+
649
if(BUILD_MQT_DDSIM_TESTS)
750
set(gtest_force_shared_crt
851
ON
@@ -26,5 +69,75 @@ if(BUILD_MQT_DDSIM_TESTS)
2669
endif()
2770
endif()
2871

72+
set(TF_BUILD_TESTS
73+
OFF
74+
CACHE INTERNAL "")
75+
set(TF_BUILD_EXAMPLES
76+
OFF
77+
CACHE INTERNAL "")
78+
set(TF_BUILD_PROFILER
79+
OFF
80+
CACHE INTERNAL "")
81+
set(TF_VERSION
82+
3.6.0
83+
CACHE STRING "Taskflow version")
84+
set(TF_URL
85+
https://github.com/taskflow/taskflow/archive/refs/tags/v${TF_VERSION}.tar.gz
86+
)
87+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
88+
FetchContent_Declare(taskflow URL ${TF_URL} FIND_PACKAGE_ARGS)
89+
list(APPEND FETCH_PACKAGES taskflow)
90+
else()
91+
find_package(taskflow ${TF_VERSION} QUIET)
92+
if(NOT taskflow_FOUND)
93+
FetchContent_Declare(taskflow URL ${TF_URL})
94+
list(APPEND FETCH_PACKAGES taskflow)
95+
endif()
96+
endif()
97+
98+
if(BUILD_MQT_DDSIM_CLI)
99+
set(THREADS_PREFER_PTHREAD_FLAG ON)
100+
find_package(Threads)
101+
link_libraries(Threads::Threads)
102+
103+
find_package(OpenCV QUIET)
104+
105+
set(CXXOPTS_VERSION
106+
3.1.1
107+
CACHE STRING "cxxopts version")
108+
set(CXXOPTS_URL
109+
https://github.com/jarro2783/cxxopts/archive/refs/tags/v${CXXOPTS_VERSION}.tar.gz
110+
)
111+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
112+
FetchContent_Declare(cxxopts URL ${CXXOPTS_URL} FIND_PACKAGE_ARGS
113+
${CXXOPTS_VERSION})
114+
list(APPEND FETCH_PACKAGES cxxopts)
115+
else()
116+
find_package(cxxopts ${CXXOPTS_VERSION} QUIET)
117+
if(NOT cxxopts_FOUND)
118+
FetchContent_Declare(cxxopts URL ${CXXOPTS_URL})
119+
list(APPEND FETCH_PACKAGES cxxopts)
120+
endif()
121+
endif()
122+
endif()
123+
124+
if(BUILD_MQT_DDSIM_BINDINGS)
125+
# add pybind11_json library
126+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
127+
FetchContent_Declare(
128+
pybind11_json
129+
GIT_REPOSITORY https://github.com/pybind/pybind11_json
130+
FIND_PACKAGE_ARGS)
131+
list(APPEND FETCH_PACKAGES pybind11_json)
132+
else()
133+
find_package(pybind11_json QUIET)
134+
if(NOT pybind11_json_FOUND)
135+
FetchContent_Declare(
136+
pybind11_json GIT_REPOSITORY https://github.com/pybind/pybind11_json)
137+
list(APPEND FETCH_PACKAGES pybind11_json)
138+
endif()
139+
endif()
140+
endif()
141+
29142
# Make all declared dependencies available.
30143
FetchContent_MakeAvailable(${FETCH_PACKAGES})

extern/cxxopts

Lines changed: 0 additions & 1 deletion
This file was deleted.

extern/mqt-core

extern/taskflow

Lines changed: 0 additions & 1 deletion
This file was deleted.

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
if TYPE_CHECKING:
1313
from collections.abc import Sequence
1414

15-
nox.options.sessions = ["lint", "pylint", "tests"]
15+
nox.options.sessions = ["lint", "tests"]
1616

1717
PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]
1818

pyproject.toml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ classifiers = [
3434
]
3535
requires-python = ">=3.8"
3636
dependencies = [
37-
"qiskit-terra>=0.22.1"
37+
"qiskit[qasm3-import]>=0.45.0"
3838
]
3939
dynamic = ["version"]
4040

4141
[project.optional-dependencies]
4242
tnflow = [
43+
"cotengra",
4344
"sparse",
4445
"opt-einsum",
4546
"quimb",
@@ -63,7 +64,7 @@ docs = [
6364
"breathe",
6465
"sphinxext-opengraph",
6566
"sphinx-autodoc-typehints",
66-
"qiskit-terra[visualization]",
67+
"qiskit[visualization]",
6768
"graphviz",
6869
]
6970
dev = ["mqt.ddsim[tnflow, coverage, docs]"]
@@ -79,8 +80,8 @@ Discussions = "https://github.com/cda-tum/mqt-ddsim/discussions"
7980
# Protect the configuration against future changes in scikit-build-core
8081
minimum-version = "0.6.1"
8182

82-
# Set the target to build
83-
cmake.targets = ["pyddsim"]
83+
# Set the wheel install directory
84+
wheel.install-dir = "mqt/ddsim"
8485

8586
# Set required CMake and Ninja versions
8687
cmake.minimum-version = "3.19"
@@ -89,9 +90,6 @@ ninja.minimum-version = "1.10"
8990
# Setuptools-style build caching in a local directory
9091
build-dir = "build/{wheel_tag}"
9192

92-
# Build stable ABI wheels for CPython 3.12+
93-
wheel.py-api = "cp312"
94-
9593
# Explicitly set the package directory
9694
wheel.packages = ["src/mqt"]
9795

@@ -118,7 +116,7 @@ sdist.exclude = [
118116
[tool.scikit-build.cmake.define]
119117
BUILD_MQT_DDSIM_TESTS = "OFF"
120118
BUILD_MQT_DDSIM_BINDINGS = "ON"
121-
ENABLE_IPO = "ON"
119+
BUILD_MQT_DDSIM_CLI = "OFF"
122120

123121

124122
[tool.check-sdist]
@@ -147,6 +145,7 @@ filterwarnings = [
147145
"ignore:.*qiskit.utils.algorithm_globals.QiskitAlgorithmGlobals*:DeprecationWarning:qiskit",
148146
"ignore:.*Building a flow controller with keyword arguments is going to be deprecated*:PendingDeprecationWarning:qiskit",
149147
"ignore:.*qiskit.extensions module is pending deprecation*:PendingDeprecationWarning:qiskit",
148+
'ignore:.*datetime\.datetime\.utcfromtimestamp.*:DeprecationWarning:',
150149
]
151150

152151
[tool.coverage]
@@ -257,7 +256,6 @@ build = "cp3*"
257256
skip = "*-musllinux_*"
258257
archs = "auto64"
259258
test-command = "python -c \"from mqt import ddsim\""
260-
test-skip = "cp312-*" # Qiskit Terra does not support Python 3.12 yet
261259
build-frontend = "build"
262260

263261
[tool.cibuildwheel.linux]

0 commit comments

Comments
 (0)