-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
140 lines (122 loc) · 5.74 KB
/
CMakeLists.txt
File metadata and controls
140 lines (122 loc) · 5.74 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# ------------------------------------------------------------------------------
# CMake version requirement
# ------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.24)
# ------------------------------------------------------------------------------
# Policies - use the latest of everything
# ------------------------------------------------------------------------------
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# Disable c++20 module scanning until we have better support for it this seems to cause some
# problems when using gcc@14
if(POLICY CMP0155)
cmake_policy(SET CMP0155 OLD)
endif()
# ------------------------------------------------------------------------------
# Project declaration and version
# ------------------------------------------------------------------------------
project(IPPL VERSION 3.2 LANGUAGES CXX)
# ------------------------------------------------------------------------------
# Module path, setup before including any cmake modules
# ------------------------------------------------------------------------------
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DIR}/CMakeModules")
# ------------------------------------------------------------------------------
# Project setup
# ------------------------------------------------------------------------------
include(ProjectSetup)
# ------------------------------------------------------------------------------
# Primary IPPL options
# ------------------------------------------------------------------------------
set(IPPL_PLATFORMS "SERIAL" CACHE STRING "Platforms to build IPPL for")
option(BUILD_SHARED_LIBS "Build IPPL as a shared library" OFF)
option(IPPL_ENABLE_UNIT_TESTS "Enable unit tests using GoogleTest" OFF)
option(IPPL_ENABLE_FFT "Enable FFT support" OFF)
option(IPPL_ENABLE_SOLVERS "Enable IPPL solvers" OFF)
option(IPPL_ENABLE_ALPINE "Enable building the Alpine module" OFF)
option(IPPL_ENABLE_COSMOLOGY "Enable building the Cosmology module" OFF)
option(IPPL_ENABLE_EXAMPLES "Enable building the Example module" OFF)
option(IPPL_ENABLE_TESTS "Build integration tests in test/ directory" OFF)
option(IPPL_ENABLE_COVERAGE "Enable code coverage" OFF)
option(IPPL_ENABLE_NSYS_PROFILER "Enable Nvidia Nsys Profiler" OFF)
option(IPPL_ENABLE_SANITIZER "Enable sanitizer(s)" OFF)
option(IPPL_USE_ALTERNATIVE_VARIANT
"Use modified variant implementation (required for CUDA 12.2 + GCC 12.3.0)" OFF)
option(IPPL_USE_STANDARD_FOLDERS "Put all generated binaries in bin/lib folders" OFF)
option(IPPL_MARK_FAILING_TESTS
"Prefix names of tests that are known to fail with 'known_fail' for filtering with ctest"
OFF)
option(IPPL_ENABLE_SCRIPTS "Generate job script templates for some benchmarks/tests" OFF)
# "Build IPPL as a shared library (ON) or static library (OFF)" OFF) if(IPPL_DYL)
# set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) message(WARNING "IPPL_DYL is deprecated; use
# -DBUILD_SHARED_LIBS=ON instead.") endif()
# ------------------------------------------------------------------------------
# Setup Output directories
# ------------------------------------------------------------------------------
if(IPPL_USE_STANDARD_FOLDERS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
CACHE PATH "Single Directory for all Executables.")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
CACHE PATH "Single Directory for all Libraries")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
CACHE PATH "Single Directory for all static libraries.")
else()
unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY CACHE)
unset(CMAKE_LIBRARY_OUTPUT_DIRECTORY CACHE)
unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY CACHE)
endif()
# ------------------------------------------------------------------------------
# cmake modules
# ------------------------------------------------------------------------------
# cmake supplied modules
include(GNUInstallDirs)
include(FetchContent)
include(CMakePackageConfigHelpers)
include(ExternalProject)
include(CTest)
# custom modules
include(Messages)
include(CompilerOptions)
include(Platforms)
include(Dependencies)
include(FailingTests)
# ------------------------------------------------------------------------------
# Deprecated vars
# ------------------------------------------------------------------------------
if(DEFINED USE_ALTERNATIVE_VARIANT)
colour_message(
WARNING ${Red}
"USE_ALTERNATIVE_VARIANT is deprecated. Please set IPPL_USE_ALTERNATIVE_VARIANT instead.")
set(IPPL_USE_ALTERNATIVE_VARIANT ${USE_ALTERNATIVE_VARIANT} CACHE BOOL "" FORCE)
endif()
# ------------------------------------------------------------------------------
# Define sources for project
# ------------------------------------------------------------------------------
add_subdirectory(src)
# ------------------------------------------------------------------------------
# Include testing related material (BUILD_TESTING is defined in CTest module)
# ------------------------------------------------------------------------------
if(IPPL_ENABLE_UNIT_TESTS OR IPPL_ENABLE_TESTS)
set(BUILD_TESTING ON CACHE BOOL "" FORCE)
endif()
if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
if(IPPL_ENABLE_UNIT_TESTS)
add_subdirectory(unit_tests)
endif()
if(IPPL_ENABLE_TESTS)
add_subdirectory(test)
endif()
endif()
# ------------------------------------------------------------------------------
# Include optional source directories
# ------------------------------------------------------------------------------
if(IPPL_ENABLE_ALPINE)
add_subdirectory(alpine)
endif()
if(IPPL_ENABLE_COSMOLOGY)
add_subdirectory(cosmology)
endif()
if(IPPL_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
if(IPPL_ENABLE_SCRIPTS)
add_subdirectory(scripts)
endif()