forked from TUM-I5/MolSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
183 lines (146 loc) · 6.72 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
cmake_minimum_required(VERSION 3.24.1)
# define project name, version
project(PSEMolDyn_GroupD VERSION 0.0.1 LANGUAGES CXX)
# let ccmake and cmake-gui offer the default build type options
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Profile")
cmake_policy(SET CMP0135 NEW)
# set Release as the default build type if it is not yet set.
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif (NOT CMAKE_BUILD_TYPE)
##### LIBRARY #####
# collect all cpp files
file(GLOB_RECURSE MY_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib/*.cpp"
# we use cxx extension to exclude generated files from clang-tidy
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib/*.cxx"
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib/*.h"
# we use hxx extension to exclude generated files from clang-tidy
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib/*.hxx"
)
add_library(simulator
STATIC
${MY_SRC}
)
target_include_directories(simulator
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/libs/libxsd
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib"
)
target_link_libraries(simulator
PUBLIC
# asan
spdlog::spdlog
XercesC::XercesC
range-v3::range-v3
)
target_compile_features(simulator
PRIVATE
cxx_std_20
)
target_compile_options(simulator
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wall -march=native>
# disable some spam warnings for icpc...
$<$<CXX_COMPILER_ID:Intel>:-w3 -march=native -Xhost -wd383,981,1418,1572,2259>
$<$<CXX_COMPILER_ID:Clang>:-Wall -g -march=native >
)
get_target_property(SIMULATOR_INCLUDES simulator INCLUDE_DIRECTORIES)
#### EXECUTABLE #####
# create make target
add_executable(MolSim src/bin/MolSim.cpp)
# set cxx standard. You may raise this if you want.
target_compile_features(MolSim
PRIVATE
cxx_std_20
)
target_include_directories(MolSim
PUBLIC
${SIMULATOR_INCLUDES}
)
target_link_libraries(MolSim
PRIVATE
simulator
)
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
if (result)
set_property(TARGET MolSim PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
set_property(TARGET simulator PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()
target_compile_options(MolSim
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wall -march=native>
# disable some spam warnings for icpc...
$<$<CXX_COMPILER_ID:Intel>:-w3 -march=native -Xhost -xCORE-AVX512 -wd383,981,1418,1572,2259>
$<$<CXX_COMPILER_ID:Clang>:-Wall -march=native #[[ -fsanitize=address,leak]] >
)
# Configure Debug and Release specific options
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(simulator
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -O0 -g -fno-omit-frame-pointer -fdebug-info-for-profiling #[[-fsanitize=address]] >
)
target_compile_options(MolSim
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -O0 -g -fno-omit-frame-pointer -fdebug-info-for-profiling #[[-fsanitize=address]] >
)
target_compile_definitions(MolSim PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
target_compile_definitions(simulator PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
target_compile_definitions(MolSim PUBLIC DEBUG=true)
target_compile_definitions(simulator PUBLIC DEBUG=true)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(simulator
PRIVATE
$<$<CXX_COMPILER_ID:Intel>: -O3 -ipo -fast -mprefer-vector-width=512 -fvectorize -fprof-use=../profiles/default.profdata>
$<$<CXX_COMPILER_ID:Clang>: -O3 -mprefer-vector-width=512 #[[-fsanitize=address]] -fprofile-instr-use=../profiles/default.profdata -fvectorize -Rpass=vectorize >
$<$<CXX_COMPILER_ID:GNU>: -O3 -ftree-vectorize -mprefer-vector-width=512>
)
target_compile_options(MolSim
PRIVATE
$<$<CXX_COMPILER_ID:Intel>: -O3 -ipo -fast -mprefer-vector-width=512 -fvectorize -fprof-use=../profiles/default.profdata>
$<$<CXX_COMPILER_ID:Clang>: -O3 -mprefer-vector-width=512 #[[-fsanitize=address]] -fprofile-instr-use=../profiles/default.profdata -fvectorize -Rpass=vectorize >
$<$<CXX_COMPILER_ID:GNU>: -O3 -ftree-vectorize -mprefer-vector-width=512>
)
target_compile_definitions(MolSim PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
target_compile_definitions(simulator PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
target_link_options(simulator
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -Wl -fprofile-use=../profiles/default.profdata>
)
target_link_options(MolSim
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -Wl -fprofile-use=../profiles/default.profdata >
)
elseif (CMAKE_BUILD_TYPE STREQUAL "Profile")
target_compile_options(simulator
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -O3 -Rpass=loop-vectorize -mprefer-vector-width=512 -fcs-profile-generate=../profiles -fvectorize -Rpass-missed=loop-vectorize -fno-omit-frame-pointer -fdebug-info-for-profiling>
$<$<CXX_COMPILER_ID:Intel>: -O3 -ipo -fast Rpass=loop-vectorize -mprefer-vector-width=512 -fprof-gen=../profiles -fvectorize -Rpass-missed=loop-vectorize -fno-omit-frame-pointer -fdebug-info-for-profiling>
$<$<CXX_COMPILER_ID:GNU>: -O3 -ftree-vectorize -mprefer-vector-width=512>
)
target_compile_options(MolSim
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -O3 -Rpass=loop-vectorize -mprefer-vector-width=512 -fcs-profile-generate=../profiles -fvectorize -Rpass-missed=loop-vectorize -fno-omit-frame-pointer -fdebug-info-for-profiling>
$<$<CXX_COMPILER_ID:Intel>: -O3 -ipo -fast -Rpass=loop-vectorize -mprefer-vector-width=512 -fprof-gene=../profiles -fvectorize -Rpass-missed=loop-vectorize -fno-omit-frame-pointer -fdebug-info-for-profiling>
$<$<CXX_COMPILER_ID:GNU>: -O3 -ftree-vectorize -mprefer-vector-width=512>
)
target_compile_definitions(MolSim PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
target_compile_definitions(simulator PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
target_link_options(simulator
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -Wl -fcs-profile-generate=../profiles >
$<$<CXX_COMPILER_ID:Intel>: -Wl -fprof-gen=../profiles >
)
target_link_options(MolSim
PRIVATE
$<$<CXX_COMPILER_ID:Clang>: -Wl -fcs-profile-generate=../profiles >
$<$<CXX_COMPILER_ID:Intel>: -Wl -fprof-gen=../profiles >
)
endif ()
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
include(doxygen)
include(spdlog)
include(g_test)