forked from alexander-at-github/rti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
239 lines (222 loc) · 8.37 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
# Set compiler
#set(ENV{CXX} "/usr/bin/clang++-6.0")
#set(ENV{CXX} "/usr/bin/clang")
# REMARK: setting ENV{CXX} only works when the project function/macro is called afterwards!
## TODO: Which setting overrides the other? ENV or CACHE?
project(
rti-superbuild
VERSION 0.1
LANGUAGES CXX C
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
##########################################################################################
### If one wants to uses an Intel SPMD Compiler, the one has to set that here
##########################################################################################
set(EMBREE_ISPC_SUPPORT OFF CACHE BOOL "Set whether or not you use Intel's SPMD Compiler")
##########################################################################################
set(M_DEPENDENCIES_DIR ${CMAKE_SOURCE_DIR}/dependencies)
set(STAGED_INSTALL_PREFIX ${M_DEPENDENCIES_DIR}/stage) # will be used in ./external/upstream/
message(STATUS "${PROJECT_NAME} external project's staged install path: ${STAGED_INSTALL_PREFIX}")
list(APPEND BOOST_COMPONENTS_REQUIRED "log" "system" "timer" "iostreams" "filesystem")
# move value of VTK_DIR to cache.
if(DEFINED ${VTK_DIR})
set(VTK_DIR ${VTK_DIR} CACHE PATH "Path to VTK installation")
endif()
include(ExternalProject)
add_subdirectory(external/upstream)
message(STATUS "Using VTK located at ${VTK_DIR}")
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "NOT CMAKE_BUILD_TYPE holds")
#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Set build type to \"Debug\" or \"Release\"" FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE == ${CMAKE_BUILD_TYPE}")
# -Wno-unused-parameter
#set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
# link time optimizations (-flto) creates errors with clang on ubuntu
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native") #"-DNDEBUG
#set(CMAKE_CXX_FLAGS_RELEASE "-O")
#set(CMAKE_CXX_FLAGS_RELEASE "-pg -O") # arguments for gprof
#set(CMAKE_CXX_FLAGS_RELEASE "-O -fprofile-arcs -ftest-coverage") # arguments for gcov
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") # CACHE STRING "cmake c++ flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "cmake c++ flags" FORCE)
message(STATUS "CMAKE_BUILD_TYPE == Debug and CMAKE_CXX_FLAGS == ${CMAKE_CXX_FLAGS}")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}") # CACHE STRING "cmake c++ flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "cmake c++ flags" FORCE)
message(STATUS "CMAKE_BUILD_TYPE == Release and CMAKE_CXX_FLAGS == ${CMAKE_CXX_FLAGS}")
endif()
message(STATUS "CMAKE_CXX_FLAGS == ${CMAKE_CXX_FLAGS}")
externalproject_add(rti
DEPENDS
#embree-external
#vtk-external
#
# optional:
#gtest-external
#abseil-external
#
# The project depends on embree-external and other external libraries. We do not add it here,
# because otherwise the build system is very slow when rebuilding the project.
# (The build configuration of these dependecies redo a lot of steps). You are adviced
# to build these targets once yourself.
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/src
# Eventhough this is a superbuild, we want the final binary in the build directory
INSTALL_DIR
${CMAKE_BINARY_DIR}
#LIST_SEPARATOR ;
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
#
-DBOOST_ROOT:PATH=${BOOST_ROOT}
-DGMSH_DIR=${GMSH_DIR}
-DEMBREE_DIR=${EMBREE_DIR}
-DVTK_DIR=${VTK_DIR}
CMAKE_CACHE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_INCLUDE_PATH:PATH=${CMAKE_INCLUDE_PATH}
-DCMAKE_LIBRARY_PATH:PATH=${CMAKE_LIBRARY_PATH}
# To pass a list into externalproject_add() would need some yoga.
# One can see an example here
# https://stackoverflow.com/questions/45414507/pass-a-list-of-prefix-paths-to-externalproject-add-in-cmake-args
#-D BOOST_COMPONENTS_REQUIRED="${BOOST_COMPONENTS_REQUIRED}"
BUILD_ALWAYS
1
#INSTALL_COMMAND
# ""
)
externalproject_get_property(rti SOURCE_DIR)
set(RTI_SRC_DIR ${SOURCE_DIR})
unset(SOURCE_DIR)
externalproject_add(rti-test
DEPENDS
#gtest-external
#boost-external
#gnuplot-iostream-external
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/test
INSTALL_DIR
${CMAKE_BINARY_DIR}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
#
-DBOOST_ROOT:PATH=${BOOST_ROOT}
#-DGMSH_DIR=${GMSH_DIR}
-DEMBREE_DIR=${EMBREE_DIR}
#-DVTK_DIR=${VTK_DIR}
#
-DRTI_SRC_DIR=${RTI_SRC_DIR}
#
-DGTEST_SRC_DIR=${GTEST_SRC_DIR}
-DGTEST_BIN_DIR=${GTEST_BIN_DIR}
-DGPLOT_IO_DIR=${GPLOT_IO_DIR}
CMAKE_CACHE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_INCLUDE_PATH:PATH=${CMAKE_INCLUDE_PATH}
-DCMAKE_LIBRARY_PATH:PATH=${CMAKE_LIBRARY_PATH}
#-D BOOST_COMPONENTS_REQUIRED="${BOOST_COMPONENTS_REQUIRED}"
BUILD_ALWAYS
1
)
externalproject_add(rti-bench
DEPENDS
#gbench-external
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/benchmark
INSTALL_DIR
${CMAKE_BINARY_DIR}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
#
-DBOOST_ROOT:PATH=${BOOST_ROOT}
#-DGMSH_DIR=${GMSH_DIR}
-DEMBREE_DIR=${EMBREE_DIR}
#-DVTK_DIR=${VTK_DIR}
#
-DRTI_SRC_DIR=${RTI_SRC_DIR}
#
-DGBENCH_SRC_DIR=${GBENCH_SRC_DIR}
-DGBENCH_BIN_DIR=${GBENCH_BIN_DIR}
-DGBENCH_INST_DIR=${GBENCH_INST_DIR}
CMAKE_CACHE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_INCLUDE_PATH:PATH=${CMAKE_INCLUDE_PATH}
-DCMAKE_LIBRARY_PATH:PATH=${CMAKE_LIBRARY_PATH}
#-D BOOST_COMPONENTS_REQUIRED="${BOOST_COMPONENTS_REQUIRED}"
BUILD_ALWAYS
1
)
externalproject_add(rti-experimental
DEPENDS
#
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/experimental
INSTALL_DIR
${CMAKE_BINARY_DIR}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
#
-DBOOST_ROOT:PATH=${BOOST_ROOT}
-DEMBREE_DIR=${EMBREE_DIR}
#-DVTK_DIR=${VTK_DIR}
#
-DRTI_SRC_DIR=${RTI_SRC_DIR}
CMAKE_CACHE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_INCLUDE_PATH:PATH=${CMAKE_INCLUDE_PATH}
-DCMAKE_LIBRARY_PATH:PATH=${CMAKE_LIBRARY_PATH}
BUILD_ALWAYS
1
)