-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
101 lines (81 loc) · 2.87 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# ##############################################################################
# This code is part of Fast Pauli.
#
# (C) Copyright Qognitive Inc 2024.
#
# This code is licensed under the BSD 2-Clause License. You may obtain a copy of
# this license in the LICENSE.txt file in the root directory of this source
# tree.
#
# Any modifications or derivative works of this code must retain this copyright
# notice, and modified files need to carry a notice indicating that they have
# been altered from the originals.
# ##############################################################################
#
# Boilerplate CMakeLists.txt for C++ projects
#
cmake_minimum_required(VERSION 3.27)
set(CMAKE_EXPORT_COMPILE_COMMANDS
TRUE
CACHE BOOL "Export compile commands to build directory" FORCE)
include(cmake/CPM.cmake)
# Set C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Need to enforce -fPIC across whole project to build shared libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# TODO adding a package lock to help with SBOM
# cpmusepackagelock(package-lock.cmake)
#
# Project specific configuration
#
# Dependencies
cpmaddpackage("gh:doctest/[email protected]")
cpmaddpackage("gh:fmtlib/fmt#10.2.1")
cpmaddpackage("gh:kokkos/mdspan#b885a2c60ad42f9e1aaa0d317a38105b950cbed0")
cpmaddpackage("gh:wjakob/nanobind#v2.0.0")
#
# User Options
#
# TODO NOT WORKING YET
# option(ENABLE_COVERAGE "Enable coverage reporting" OFF) if(ENABLE_COVERAGE)
# message(STATUS "[FAST_PAULI] Enabling coverage reporting") message(STATUS
# "[FAST_PAULI]") set(FAST_PAULI_EXTRA_CXX_COMPILE_FLAGS "-coverage")
# set(FAST_PAULI_EXTRA_CXX_LD_FLAGS "-lgcov;--coverage") endif()
#
# Fast Pauli
#
project(fast_pauli LANGUAGES CXX)
# Build type
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE
Release
CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# Set up OpenMP
find_package(OpenMP REQUIRED)
# Setup Python
find_package(Python 3.10 # This is a minimum version
COMPONENTS Interpreter Development.Module REQUIRED)
# Our primary target
add_library(fast_pauli INTERFACE)
target_include_directories(
fast_pauli INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/fast_pauli/cpp/include/)
target_link_libraries(fast_pauli INTERFACE fmt::fmt mdspan OpenMP::OpenMP_CXX)
target_compile_options(fast_pauli INTERFACE -Wall -Wextra -Werror)
# Testing
include(CTest)
enable_testing()
add_subdirectory(fast_pauli/cpp/tests)
# Examples
add_subdirectory(fast_pauli/cpp/examples)
# Python bindings
add_subdirectory(fast_pauli/cpp/src)
option(ENABLE_DOCS "Enable documentation generation" OFF)
if(ENABLE_DOCS)
add_subdirectory(docs)
endif()