Skip to content

Commit 3a78710

Browse files
authored
♻️ Refactor CMake Configuration (#211)
## Description This PR builds on cda-tum/dd_package#125 as well as munich-quantum-toolkit/core#246 and refactors the overall CMake configuration. The newly enabled compiler warnings showed some alerts, which have subsequently been fixed. ## 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 f503740 + 6b23684 commit 3a78710

29 files changed

+163
-325
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@ updates:
66
interval: "weekly"
77
day: "friday"
88
time: "06:00"
9-
assignees:
10-
- "burgholzer"
9+
timezone: "Europe/Vienna"
1110

1211
- package-ecosystem: "github-actions"
1312
directory: "/"
1413
schedule:
1514
interval: "weekly"
1615
day: "friday"
1716
time: "06:00"
18-
assignees:
19-
- "burgholzer"
17+
timezone: "Europe/Vienna"
2018

2119
- package-ecosystem: "pip"
2220
directory: "/"
2321
schedule:
2422
interval: "weekly"
2523
day: "friday"
2624
time: "06:00"
27-
assignees:
28-
- "burgholzer"
25+
timezone: "Europe/Vienna"

.github/workflows/ci.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defaults:
1717

1818
env:
1919
CMAKE_BUILD_PARALLEL_LEVEL: 3
20+
CTEST_PARALLEL_LEVEL: 3
2021
Z3_VERSION: 4.11.2
2122

2223
jobs:
@@ -27,13 +28,9 @@ jobs:
2728
fail-fast: false
2829
matrix:
2930
config:
30-
- { os: ubuntu-latest, test-dir: build/test, toolchain: "" }
31-
- { os: macos-latest, test-dir: build/test, toolchain: "" }
32-
- {
33-
os: windows-latest,
34-
test-dir: build\test\Release,
35-
toolchain: "-T ClangCl",
36-
}
31+
- { os: ubuntu-latest, toolchain: "" }
32+
- { os: macos-latest, toolchain: "" }
33+
- { os: windows-latest, toolchain: "-T ClangCl" }
3734
steps:
3835
- uses: actions/checkout@v3
3936
with:
@@ -51,15 +48,13 @@ jobs:
5148
- name: Build
5249
run: cmake --build build --config Release
5350
- name: Test
54-
working-directory: ${{ matrix.config.test-dir }}
55-
run: ctest -C Release --output-on-failure
51+
run: ctest -C Release --output-on-failure --test-dir build --repeat until-pass:3 --timeout 300
5652
- if: runner.os == 'Linux'
5753
name: Coverage
5854
run: |
59-
cmake -S . -B buildCov -DCMAKE_BUILD_TYPE=Debug -DBUILD_QMAP_TESTS=ON -DCOVERAGE=ON
55+
cmake -S . -B buildCov -DCMAKE_BUILD_TYPE=Debug -DBUILD_QMAP_TESTS=ON -DENABLE_COVERAGE=ON
6056
cmake --build buildCov --config Debug
61-
cd buildCov/test
62-
ctest -C Debug --output-on-failure
57+
ctest -C Debug --output-on-failure --test-dir buildCov --repeat until-pass:3 --timeout 300
6358
- if: runner.os == 'Linux'
6459
name: Upload coverage to Codecov
6560
uses: codecov/codecov-action@v3.1.1

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: "CodeQL"
22

33
on:
44
push:
5-
branches: [main]
65
pull_request:
76
schedule:
87
- cron: "15 21 * * 6"
8+
workflow_dispatch:
99

1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/cpp-linter.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ jobs:
3232
CC=clang-14 CXX=clang++-14 \
3333
cmake -S . -B build \
3434
-DBINDINGS=ON \
35-
-DBUILD_QMAP_TESTS=ON \
36-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
35+
-DBUILD_QMAP_TESTS=ON
3736
- name: Run cpp-linter
3837
id: linter
3938
env:

.gitmodules

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
path = extern/qfr
33
url = https://github.com/cda-tum/qfr.git
44
branch = main
5-
shallow = true
65
[submodule "extern/LogicBlocks"]
76
path = extern/LogicBlocks
87
url = https://github.com/cda-tum/LogicBlocks.git
98
branch = main
10-
shallow = true

CMakeLists.txt

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,15 @@
1-
cmake_minimum_required(VERSION 3.19...3.24)
1+
# set required cmake version
2+
cmake_minimum_required(VERSION 3.19)
3+
4+
# This avoids googletest complaining that this (IPO) policy is not set
5+
cmake_policy(SET CMP0069 NEW)
6+
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
27

38
project(
49
qmap
510
LANGUAGES CXX
611
DESCRIPTION "MQT QMAP - A library for mapping of quantum circuits to quantum architectures")
712

8-
# enable organization of targets into folders
9-
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
10-
11-
# configuration options
12-
option(DEPLOY "Configure for deployment")
13-
option(BINDINGS "Configure for building Python bindings")
14-
option(COVERAGE "Configure for coverage report generation")
15-
option(GENERATE_POSITION_INDEPENDENT_CODE "Generate position independent code")
16-
option(BUILD_QMAP_TESTS "Also build tests for QMAP project")
17-
18-
if(DEFINED ENV{DEPLOY})
19-
set(DEPLOY
20-
$ENV{DEPLOY}
21-
CACHE BOOL "Use deployment configuration from environment" FORCE)
22-
message(STATUS "Setting deployment configuration to '${DEPLOY}' from environment")
23-
endif()
24-
25-
# set deployment specific options
26-
if(DEPLOY)
27-
# set the macOS deployment target appropriately
28-
set(CMAKE_OSX_DEPLOYMENT_TARGET
29-
"10.15"
30-
CACHE STRING "" FORCE)
31-
endif()
32-
33-
# build type settings
34-
set(DEFAULT_BUILD_TYPE "Release")
35-
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
36-
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
37-
set(CMAKE_BUILD_TYPE
38-
"${default_build_type}"
39-
CACHE STRING "Choose the type of build." FORCE)
40-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel"
41-
"RelWithDebInfo")
42-
endif()
43-
4413
# check whether the submodule ``modulename`` is correctly cloned in the ``/extern`` directory.
4514
macro(CHECK_SUBMODULE_PRESENT modulename)
4615
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${modulename}/CMakeLists.txt")
@@ -65,20 +34,19 @@ if(NOT Z3_FOUND)
6534
message(WARNING "Did not find Z3. Exact library and other depending target will not be available")
6635
endif()
6736

68-
set(THREADS_PREFER_PTHREAD_FLAG ON)
69-
find_package(Threads REQUIRED)
70-
7137
# add main library code
7238
add_subdirectory(src)
7339

7440
# add test code
41+
option(BUILD_QMAP_TESTS "Also build tests for QMAP project")
7542
if(BUILD_QMAP_TESTS)
7643
enable_testing()
7744
include(GoogleTest)
7845
add_subdirectory(test)
7946
endif()
8047

8148
# add Python binding code
49+
option(BINDINGS "Configure for building Python bindings")
8250
if(BINDINGS)
8351
add_subdirectory(mqt/qmap)
8452
endif()

extern/qfr

Submodule qfr updated from c11670d to 94257ff

include/Architecture.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Architecture {
4848
void set(const KeyType& key, const ValueType& value) {
4949
props[key] = value;
5050
}
51-
[[nodiscard]] bool available(const KeyType& key) const {
51+
[[nodiscard, gnu::pure]] bool available(const KeyType& key) const {
5252
return props.find(key) != props.end();
5353
}
5454
void clear() { props.clear(); }
@@ -217,8 +217,8 @@ class Architecture {
217217
loadProperties(propsFilename);
218218
}
219219

220-
Architecture(std::uint16_t nQ, const CouplingMap& couplingMap);
221-
Architecture(std::uint16_t nQ, const CouplingMap& couplingMap,
220+
Architecture(std::uint16_t nQ, const CouplingMap& cm);
221+
Architecture(std::uint16_t nQ, const CouplingMap& cm,
222222
const Properties& props);
223223

224224
[[nodiscard]] std::uint16_t getNqubits() const { return nqubits; }

include/Mapper.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Mapper {
3838
qc::Operation* op = nullptr;
3939

4040
Gate(const std::int16_t c, const std::uint16_t t) : control(c), target(t){};
41-
Gate(const std::int16_t c, const std::uint16_t t, qc::Operation* op)
42-
: control(c), target(t), op(op){};
41+
Gate(const std::int16_t c, const std::uint16_t t, qc::Operation* operation)
42+
: control(c), target(t), op(operation){};
4343

4444
[[nodiscard]] bool singleQubit() const { return control == -1; }
4545
};
@@ -128,7 +128,7 @@ class Mapper {
128128
* @brief Get the index of the next layer after the given index containing a
129129
* gate acting on more than one qubit
130130
*/
131-
virtual std::size_t getNextLayer(std::size_t idx);
131+
[[gnu::pure]] virtual std::size_t getNextLayer(std::size_t idx);
132132

133133
/**
134134
* @brief adding additional qubits to the result circuit if architecture has

0 commit comments

Comments
 (0)