Skip to content

Commit 3d0d0be

Browse files
authored
🚸 Installation Improvements (#539)
## Description This PR improves a couple of bits and pieces throughout the library and should increase the overall usability and DX. Most notable breaking changes: - The `MQT::CorePython` target is removed. After this PR is merged, top-level packages are expected to use the `mqt.core` Python package for translating from Qiskit to MQT. Furthermore, the top-level packages are responsible for bringing in the `pybind11_json` dependency if they require it, as it is no longer shipped with `mqt-core`. - The `MQT::ProjectOptions` and `MQT::ProjectWarnings` targets are now linked privately into the libraries in order to not pollute other CMake targets. This means that top-level projects now also need to explicitly link against these targets if they want to benefit from the common settings. - Includes are now placed in a dedicated `include/mqt-core` subdirectory to create a cleaner installation structure. ## 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. - [ ] I have made sure that all CI jobs on GitHub pass. - [ ] The pull request introduces no new warnings and follows the project's style guidelines.
2 parents 6d9a08e + 889ac89 commit 3d0d0be

File tree

109 files changed

+254
-781
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+254
-781
lines changed

.github/workflows/reusable-code-ql-python.yml

-16
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ on:
1010
description: "The version of Z3 to set up"
1111
default: "4.11.2"
1212
type: string
13-
build-time-dependencies:
14-
description: "The build-time dependencies to install"
15-
default: "scikit-build-core[pyproject] setuptools_scm pybind11"
16-
type: string
1713

1814
jobs:
1915
analyze:
@@ -43,22 +39,10 @@ jobs:
4339
override_cache_key: codeql-python
4440
- name: Set up mold as linker
4541
uses: rui314/setup-mold@v1
46-
- name: Set up Python
47-
uses: actions/setup-python@v5
48-
with:
49-
python-version: "3.11"
50-
cache: "pip"
51-
- name: Install dependencies
52-
run: |
53-
python -m pip install --upgrade pip wheel setuptools
54-
pip install ${{ inputs.build-time-dependencies }}
55-
pip install --no-build-isolation -ve .
56-
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
5742
- name: Initialize CodeQL
5843
uses: github/codeql-action/init@v3
5944
with:
6045
languages: python
61-
setup-python-dependencies: false
6246
config: |
6347
queries:
6448
- uses: security-and-quality

.github/workflows/reusable-code-ql.yml

-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ on:
1515
description: "The version of Z3 to set up"
1616
default: "4.11.2"
1717
type: string
18-
build-time-dependencies:
19-
description: "The build-time dependencies to install"
20-
default: "scikit-build-core[pyproject] setuptools_scm pybind11"
21-
type: string
2218
enable-cpp:
2319
description: "Whether to enable C++ analysis"
2420
default: true
@@ -45,4 +41,3 @@ jobs:
4541
with:
4642
setup-z3: ${{ inputs.setup-z3 }}
4743
z3-version: ${{ inputs.z3-version }}
48-
build-time-dependencies: ${{ inputs.build-time-dependencies }}

.github/workflows/reusable-cpp-coverage.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
with:
3333
submodules: recursive
34+
fetch-depth: 0
3435
- if: ${{ inputs.setup-z3 }}
3536
name: Setup Z3
3637
uses: cda-tum/setup-z3@v1

.github/workflows/reusable-cpp-tests-macos.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
with:
3333
submodules: recursive
34+
fetch-depth: 0
3435
- if: ${{ inputs.setup-z3 }}
3536
name: Setup Z3
3637
uses: cda-tum/setup-z3@v1

.github/workflows/reusable-cpp-tests-ubuntu.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
with:
3333
submodules: recursive
34+
fetch-depth: 0
3435
- if: ${{ inputs.setup-z3 }}
3536
name: Setup Z3
3637
uses: cda-tum/setup-z3@v1

.github/workflows/reusable-cpp-tests-windows.yml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- uses: actions/checkout@v4
3636
with:
3737
submodules: recursive
38+
fetch-depth: 0
3839
- uses: ilammy/msvc-dev-cmd@v1
3940
- if: ${{ inputs.setup-z3 }}
4041
name: Setup Z3

.github/workflows/reusable-python-ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
strategy:
3030
fail-fast: false
3131
matrix:
32-
python-version: ["3.8", "3.9", "3.10", "3.11"]
32+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
3333
uses: ./.github/workflows/reusable-python-tests.yml
3434
with:
3535
runs-on: ubuntu-latest
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
fail-fast: false
4444
matrix:
45-
python-version: ["3.8", "3.11"]
45+
python-version: ["3.8", "3.12"]
4646
uses: ./.github/workflows/reusable-python-tests.yml
4747
with:
4848
runs-on: macos-latest
@@ -55,7 +55,7 @@ jobs:
5555
strategy:
5656
fail-fast: false
5757
matrix:
58-
python-version: ["3.8", "3.11"]
58+
python-version: ["3.8", "3.12"]
5959
uses: ./.github/workflows/reusable-python-tests.yml
6060
with:
6161
runs-on: windows-latest
@@ -68,7 +68,7 @@ jobs:
6868
strategy:
6969
fail-fast: false
7070
matrix:
71-
python-version: ["3.8", "3.11"]
71+
python-version: ["3.8", "3.12"]
7272
uses: ./.github/workflows/reusable-python-coverage.yml
7373
with:
7474
python-version: ${{ matrix.python-version }}

.pre-commit-config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ repos:
9292
hooks:
9393
- id: cmake-format
9494
additional_dependencies: [pyyaml]
95+
types: [file]
96+
files: (\.cmake|CMakeLists.txt)(.in)?$
9597

9698
# Format configuration files with prettier
9799
- repo: https://github.com/pre-commit/mirrors-prettier

CMakeLists.txt

+19-18
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,17 @@ include(cmake/StandardProjectSettings.cmake)
1212
include(cmake/PreventInSourceBuilds.cmake)
1313
include(cmake/PackageAddTest.cmake)
1414
include(cmake/Cache.cmake)
15+
include(cmake/Python.cmake)
1516

1617
option(BUILD_MQT_CORE_BINDINGS "Build the MQT Core Python bindings" OFF)
1718
if(BUILD_MQT_CORE_BINDINGS)
1819
# ensure that the BINDINGS option is set
1920
set(BINDINGS
2021
ON
2122
CACHE INTERNAL "Enable settings related to Python bindings")
22-
23-
# top-level call to find Python
24-
find_package(
25-
Python 3.8 REQUIRED
26-
COMPONENTS Interpreter Development.Module
27-
OPTIONAL_COMPONENTS Development.SABIModule)
23+
find_python()
2824
endif()
2925

30-
# try to determine the version from either git or the Python package
31-
include(cmake/GetVersion.cmake)
32-
get_version()
33-
34-
project(
35-
mqt-core
36-
LANGUAGES CXX
37-
VERSION ${MQT_CORE_VERSION}
38-
DESCRIPTION "MQT Core - The Backbone of the Munich Quantum Toolkit")
39-
4026
# check if this is the master project or used via add_subdirectory
4127
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
4228
set(MQT_CORE_MASTER_PROJECT ON)
@@ -48,10 +34,20 @@ option(MQT_CORE_INSTALL "Generate installation instructions for MQT Core"
4834
${MQT_CORE_MASTER_PROJECT})
4935
option(BUILD_MQT_CORE_TESTS "Also build tests for the MQT Core project" ${MQT_CORE_MASTER_PROJECT})
5036

37+
# try to determine the project version
38+
include(cmake/GetVersion.cmake)
39+
get_mqt_core_version()
40+
41+
project(
42+
mqt-core
43+
LANGUAGES CXX
44+
VERSION ${MQT_CORE_VERSION}
45+
DESCRIPTION "MQT Core - The Backbone of the Munich Quantum Toolkit")
46+
5147
include(cmake/ExternalDependencies.cmake)
5248

5349
# set the include directory for the build tree
54-
set(MQT_CORE_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include")
50+
set(MQT_CORE_INCLUDE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/mqt-core")
5551

5652
# add main library code
5753
add_subdirectory(src)
@@ -68,7 +64,12 @@ if(BUILD_MQT_CORE_BENCHMARKS)
6864
add_subdirectory(eval)
6965
endif()
7066

71-
if(NOT MQT_CORE_MASTER_PROJECT)
67+
if(MQT_CORE_MASTER_PROJECT)
68+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
69+
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
70+
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P
71+
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
72+
else()
7273
set(mqt-core_FOUND
7374
TRUE
7475
CACHE INTERNAL "True if mqt-core is found on the system")

cmake/CompilerOptions.cmake

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ function(enable_project_options target_name)
4141
endif()
4242

4343
# enable some more optimizations in release mode
44-
target_compile_options(${target_name} INTERFACE $<$<CONFIG:RELEASE>:-fno-math-errno
45-
-ffinite-math-only -fno-trapping-math>)
44+
target_compile_options(
45+
${target_name} INTERFACE $<$<CONFIG:RELEASE>:-fno-math-errno -ffinite-math-only
46+
-fno-trapping-math -fno-stack-protector>)
4647

4748
# enable some more options for better debugging
4849
target_compile_options(

0 commit comments

Comments
 (0)