forked from superjax/matrix_comparison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
215 lines (185 loc) · 7.33 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
cmake_minimum_required(VERSION 3.21)
# CMake Packages
include(FetchContent)
include(CMakePrintHelpers)
########################################################################################################################
################################## CMake Project Configuration #########################################################
########################################################################################################################
set(CMAKE_C_STANDARD 23)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
# Note: by default ENABLE_DEVELOPER_MODE is True
# This means that all analysis (sanitizers, static analysis)
# is enabled and all warnings are treated as errors
# if you want to switch this behavior, change TRUE to FALSE
set(ENABLE_DEVELOPER_MODE TRUE CACHE BOOL "Enable 'developer mode'")
# Change this to false if you want to disable warnings_as_errors in developer mode
set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT FALSE)
# Add cmake conan integration
# https://github.com/cpp-best-practices/project_options
message(STATUS "Fetching cmake conan integration...")
FetchContent_Declare(_cmake_conan
GIT_REPOSITORY https://github.com/conan-io/cmake-conan.git
GIT_TAG origin/develop2
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(_cmake_conan)
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES ${_cmake_conan_SOURCE_DIR}/conan_provider.cmake)
# Add cmake project_options
# https://github.com/cpp-best-practices/project_options
message(STATUS "Fetching cmake project options...")
FetchContent_Declare(_project_options
GIT_REPOSITORY https://github.com/cpp-best-practices/project_options
GIT_TAG origin/main
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(_project_options)
include(${_project_options_SOURCE_DIR}/Index.cmake)
project(
matrix_comparison
VERSION 1.0.1.0
DESCRIPTION "Biological fluid mechanics Lattice Boltzmann Solver"
HOMEPAGE_URL "https://gitlab.com/timmkrueger/biofmgroupcode"
LANGUAGES CXX C)
include(GNUInstallDirs)
# This variable is set by project() in CMake 3.21+
string(
COMPARE EQUAL
"${CMAKE_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}"
PROJECT_IS_TOP_LEVEL)
if(PROJECT_IS_TOP_LEVEL)
# Consider the CTest module, which creates targets and options!
# Only needed if you want to enable submissions to a CDash server.
include(CTest)
endif()
set(GIT_SHA
"Unknown"
CACHE STRING "SHA this build was generated from")
string(
SUBSTRING "${GIT_SHA}"
0
8
GIT_SHORT_SHA)
get_property(BUILDING_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(BUILDING_MULTI_CONFIG)
if(NOT CMAKE_BUILD_TYPE)
# Make sure that all supported configuration types have their
# associated conan packages available. You can reduce this
# list to only the configuration types you use, but only if one
# is not forced-set on the command line for VS
message(TRACE "Setting up multi-config build types")
set(CMAKE_CONFIGURATION_TYPES
Debug
Release
RelWithDebInfo
MinSizeRel
CACHE STRING "Enabled build types" FORCE)
else()
message(TRACE "User chose a specific build type, so we are using that")
set(CMAKE_CONFIGURATION_TYPES
${CMAKE_BUILD_TYPE}
CACHE STRING "Enabled build types" FORCE)
endif()
endif()
include(${_project_options_SOURCE_DIR}/src/DynamicProjectOptions.cmake)
project_options(
# ENABLE_CACHE
# ENABLE_CPPCHECK
# ENABLE_CLANG_TIDY
# ENABLE_CONAN
ENABLE_INTERPROCEDURAL_OPTIMIZATION
ENABLE_NATIVE_OPTIMIZATION
ENABLE_DOXYGEN
# ENABLE_COVERAGE
# ENABLE_SANITIZER_ADDRESS
# ENABLE_SANITIZER_LEAK
# ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
# ENABLE_SANITIZER_THREAD
# ENABLE_SANITIZER_MEMORY
# ENABLE_PCH
# PCH_HEADERS <vector> <string>
# WARNINGS_AS_ERRORS
# ENABLE_INCLUDE_WHAT_YOU_USE
LINKER "lld"
# ENABLE_BUILD_WITH_TIME_TRACE
# CONAN_OPTIONS
)
# configure files based on CMake configuration options
# Get the latest commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
cmake_print_variables(GIT_HASH)
target_compile_features(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
# TODO: The INTERFACE library NAMESPACE ALIAS are missing! CK
add_library(matrix_comparison::project_options INTERFACE IMPORTED)
add_library(matrix_comparison::project_warnings INTERFACE IMPORTED)
# configure files based on CMake configuration options
add_subdirectory(configured_files)
########################################################################################################################
########################################################################################################################
# Find BLAS and lapack
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
# Find dependencies:
set(DEPENDENCIES_CONFIGURED
armadillo
blaze
Catch2
CLI11
Eigen3
GSL
fmt
pcg-cpp
spdlog
range-v3
xtensor
)
foreach (DEPENDENCY ${DEPENDENCIES_CONFIGURED})
find_package(${DEPENDENCY} CONFIG REQUIRED)
endforeach ()
# Adding the src:
add_subdirectory(src)
# Adding the tests:
option(ENABLE_TESTING "Enable the tests" ${PROJECT_IS_TOP_LEVEL})
if(ENABLE_TESTING)
enable_testing()
message(AUTHOR_WARNING "Building Tests. Be sure to check out test/constexpr_tests.cpp for constexpr testing")
add_subdirectory(test)
endif()
option(ENABLE_FUZZING "Enable the fuzz tests" OFF)
if(ENABLE_FUZZING)
message(AUTHOR_WARNING "Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html")
add_subdirectory(fuzz_test)
endif()
# If MSVC is being used, and ASAN is enabled, we need to set the debugger environment
# so that it behaves well with MSVC's debugger, and we can run the target from visual studio
if(MSVC)
get_all_installable_targets(all_targets)
message("all_targets=${all_targets}")
set_target_properties(${all_targets} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=$(VC_ExecutablePath_x64);%PATH%")
endif()
# set the startup project for the "play" button in MSVC
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT intro)
if(CMAKE_SKIP_INSTALL_RULES)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()
# Add other targets that you want installed here, be default we just package the one executable
# we know we want to ship
package_project(TARGETS matrix_test project_options project_warnings
# FIXME: this does not work! CK
# PRIVATE_DEPENDENCIES_CONFIGURED project_options project_warnings
)
# Experience shows that explicit package naming can help make it easier to sort
# out potential ABI related issues before they start, while helping you
# track a build to a specific GIT SHA
set(CPACK_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${GIT_SHORT_SHA}-${CMAKE_SYSTEM_NAME}-${CMAKE_BUILD_TYPE}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}"
)
include(CPack)