-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
117 lines (99 loc) · 3.92 KB
/
Copy pathCMakeLists.txt
File metadata and controls
117 lines (99 loc) · 3.92 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required(VERSION 3.28...4.0)
project(monoprop LANGUAGES CXX)
# warn if the user invokes CMake directly
if(NOT SKBUILD)
message(
WARNING
"\
This CMake file is meant to be executed using 'scikit-build-core'.
Running it directly will almost certainly not produce the desired
result. If you are a user trying to install this package, use the
command below, which will install all necessary build dependencies,
compile the package in an isolated environment, and then install it.
=====================================================================
$ pip install .
=====================================================================
If you are a software developer, and this is your own package, then
it is usually much more efficient to install the build dependencies
in your environment once and use the following command that avoids
a costly creation of a new virtual environment at every compilation:
=====================================================================
$ pip install nanobind scikit-build-core
$ pip install --no-build-isolation -ve .
=====================================================================
You may optionally add -Ceditable.rebuild=true to auto-rebuild when
the package is imported. Otherwise, you need to rerun the above
after editing C++ files."
)
endif()
if(APPLE)
set(THREADS_FOUND TRUE CACHE BOOL "")
set(CMAKE_THREAD_LIBS_INIT "-lpthread" CACHE STRING "")
set(CMAKE_HAVE_THREADS_LIBRARY TRUE CACHE BOOL "")
set(CMAKE_USE_PTHREADS_INIT TRUE CACHE BOOL "")
set(THREADS_PREFER_PTHREAD_FLAG ON CACHE BOOL "")
endif()
# if CMAKE_BUILD_TYPE undefined, we set it to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
set(
monoprop_MAX_NUM_MODES
"1024"
CACHE STRING
"Maximum number of simulable Fermionic modes with Python bindings"
)
option(monoprop_ENABLE_MPI "Enable MPI parallelization" OFF)
option(monoprop_ENABLE_CXX_UNIT_TESTS "Enable C++ unit test suite" ON)
set(Python_FIND_VIRTUALENV FIRST)
find_package(
Python
3.11
REQUIRED
COMPONENTS
Interpreter
Development.Module
${SKBUILD_SABI_COMPONENT}
)
find_package(Threads REQUIRED)
if(monoprop_ENABLE_MPI)
find_package(MPI REQUIRED COMPONENTS CXX)
endif()
include(${PROJECT_SOURCE_DIR}/cmake/compiler_flags/Sanitizers.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/compiler_flags/CXXFlags.cmake)
# report on compiler flags in use
message(STATUS "Configuring a ${CMAKE_BUILD_TYPE} build")
string(TOUPPER ${CMAKE_BUILD_TYPE} _cmake_build_type_upper)
message(STATUS "Compiler flags for ${CMAKE_CXX_COMPILER_ID}")
message(STATUS " From environment : ${CMAKE_CXX_FLAGS}")
set(
_cmake_build_type_specific_flags
"${CMAKE_CXX_FLAGS_${_cmake_build_type_upper}}"
)
message(
STATUS
" Build-type-specific : ${_cmake_build_type_specific_flags}"
)
message(STATUS " Vectorization flag : ${ARCH_FLAG}")
message(
STATUS
" Project defaults : ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION} ${monoprop_CXX_FLAGS}"
)
message(STATUS " User-appended : ${EXTRA_CXXFLAGS}")
message(STATUS " Sanitizer profile : ${monoprop_SANITIZER}")
message(STATUS " MPI parallelization : ${monoprop_ENABLE_MPI}")
message(STATUS " Max simulable modes : ${monoprop_MAX_NUM_MODES}")
message(STATUS " C++ unit tests : ${monoprop_ENABLE_CXX_UNIT_TESTS}")
include(GNUInstallDirs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
add_library(monoprop-objs OBJECT "")
add_library(monoprop SHARED $<TARGET_OBJECTS:monoprop-objs>)
# must run before add_subdirectory(cpp): CTest's enabled-ness does not propagate
# back up to a parent directory that has already been added as a subdirectory.
if(monoprop_ENABLE_CXX_UNIT_TESTS)
enable_testing()
include(CTest)
endif()
add_subdirectory(cpp)
add_subdirectory(src/monoprop/bindings)