Skip to content

Commit

Permalink
🚸 Installation Improvements (#539)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
burgholzer authored Jan 27, 2024
2 parents 6d9a08e + 889ac89 commit 3d0d0be
Show file tree
Hide file tree
Showing 109 changed files with 254 additions and 781 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/reusable-code-ql-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ on:
description: "The version of Z3 to set up"
default: "4.11.2"
type: string
build-time-dependencies:
description: "The build-time dependencies to install"
default: "scikit-build-core[pyproject] setuptools_scm pybind11"
type: string

jobs:
analyze:
Expand Down Expand Up @@ -43,22 +39,10 @@ jobs:
override_cache_key: codeql-python
- name: Set up mold as linker
uses: rui314/setup-mold@v1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
pip install ${{ inputs.build-time-dependencies }}
pip install --no-build-isolation -ve .
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: python
setup-python-dependencies: false
config: |
queries:
- uses: security-and-quality
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/reusable-code-ql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ on:
description: "The version of Z3 to set up"
default: "4.11.2"
type: string
build-time-dependencies:
description: "The build-time dependencies to install"
default: "scikit-build-core[pyproject] setuptools_scm pybind11"
type: string
enable-cpp:
description: "Whether to enable C++ analysis"
default: true
Expand All @@ -45,4 +41,3 @@ jobs:
with:
setup-z3: ${{ inputs.setup-z3 }}
z3-version: ${{ inputs.z3-version }}
build-time-dependencies: ${{ inputs.build-time-dependencies }}
1 change: 1 addition & 0 deletions .github/workflows/reusable-cpp-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- if: ${{ inputs.setup-z3 }}
name: Setup Z3
uses: cda-tum/setup-z3@v1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reusable-cpp-tests-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- if: ${{ inputs.setup-z3 }}
name: Setup Z3
uses: cda-tum/setup-z3@v1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reusable-cpp-tests-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- if: ${{ inputs.setup-z3 }}
name: Setup Z3
uses: cda-tum/setup-z3@v1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reusable-cpp-tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: ilammy/msvc-dev-cmd@v1
- if: ${{ inputs.setup-z3 }}
name: Setup Z3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/reusable-python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
uses: ./.github/workflows/reusable-python-tests.yml
with:
runs-on: ubuntu-latest
Expand All @@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
uses: ./.github/workflows/reusable-python-tests.yml
with:
runs-on: macos-latest
Expand All @@ -55,7 +55,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
uses: ./.github/workflows/reusable-python-tests.yml
with:
runs-on: windows-latest
Expand All @@ -68,7 +68,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
uses: ./.github/workflows/reusable-python-coverage.yml
with:
python-version: ${{ matrix.python-version }}
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ repos:
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]
types: [file]
files: (\.cmake|CMakeLists.txt)(.in)?$

# Format configuration files with prettier
- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
37 changes: 19 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,17 @@ include(cmake/StandardProjectSettings.cmake)
include(cmake/PreventInSourceBuilds.cmake)
include(cmake/PackageAddTest.cmake)
include(cmake/Cache.cmake)
include(cmake/Python.cmake)

option(BUILD_MQT_CORE_BINDINGS "Build the MQT Core Python bindings" OFF)
if(BUILD_MQT_CORE_BINDINGS)
# ensure that the BINDINGS option is set
set(BINDINGS
ON
CACHE INTERNAL "Enable settings related to Python bindings")

# top-level call to find Python
find_package(
Python 3.8 REQUIRED
COMPONENTS Interpreter Development.Module
OPTIONAL_COMPONENTS Development.SABIModule)
find_python()
endif()

# try to determine the version from either git or the Python package
include(cmake/GetVersion.cmake)
get_version()

project(
mqt-core
LANGUAGES CXX
VERSION ${MQT_CORE_VERSION}
DESCRIPTION "MQT Core - The Backbone of the Munich Quantum Toolkit")

# check if this is the master project or used via add_subdirectory
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(MQT_CORE_MASTER_PROJECT ON)
Expand All @@ -48,10 +34,20 @@ option(MQT_CORE_INSTALL "Generate installation instructions for MQT Core"
${MQT_CORE_MASTER_PROJECT})
option(BUILD_MQT_CORE_TESTS "Also build tests for the MQT Core project" ${MQT_CORE_MASTER_PROJECT})

# try to determine the project version
include(cmake/GetVersion.cmake)
get_mqt_core_version()

project(
mqt-core
LANGUAGES CXX
VERSION ${MQT_CORE_VERSION}
DESCRIPTION "MQT Core - The Backbone of the Munich Quantum Toolkit")

include(cmake/ExternalDependencies.cmake)

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

# add main library code
add_subdirectory(src)
Expand All @@ -68,7 +64,12 @@ if(BUILD_MQT_CORE_BENCHMARKS)
add_subdirectory(eval)
endif()

if(NOT MQT_CORE_MASTER_PROJECT)
if(MQT_CORE_MASTER_PROJECT)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
else()
set(mqt-core_FOUND
TRUE
CACHE INTERNAL "True if mqt-core is found on the system")
Expand Down
5 changes: 3 additions & 2 deletions cmake/CompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ function(enable_project_options target_name)
endif()

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

# enable some more options for better debugging
target_compile_options(
Expand Down
Loading

0 comments on commit 3d0d0be

Please sign in to comment.