-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
233 lines (191 loc) · 8.69 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
cmake_minimum_required(VERSION 3.13)
project(Lustrine VERSION 0.1.0)
cmake_policy(SET CMP0079 NEW)
if (${CMAKE_VERSION} VERSION_GREATER "3.19.0")
cmake_policy(SET CMP0111 NEW) # error on missing imported targets
endif()
include(CTest)
include(GenerateExportHeader)
enable_testing()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)
#the following macros break the code (at least the rendering :))
#add_compile_definitions(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES)
#add_compile_definitions(GLM_FORCE_SIMD_AVX2)
if (UNIX)
add_compile_definitions(PLATFORM_UNIX)
endif()
if (WIN32)
add_compile_definitions(PLATFORM_WINDOWS)
endif()
if (WIN32)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
message(FATAL "cannot use MSCV")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /arch:AVX2 /fp:fast /FA") #-mfma -ffp-contract=fast") #
endif()
endif()
#/clang:-march=skylake /clang:-mavx2
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("using predefined flags")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ") #-fsanitize=undefined
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clang:-O3 /clang:-ffast-math /clang:-mfma ") # /clang: /clang: /clang: -mfma -ffp-contract=fast") #
endif()
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message("Lustrine: using gcc")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mavx2 -ffast-math -mfma -march=skylake") #-ffast-math
endif()
#target_compile_options(Lustrine PRIVATE -fsanitize=address)
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address)")
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /clang:-ffast-math -mavx2 ") #-mfma -ffp-contract=fast") #
endif()
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
#option(ENV{LEVEKGL_USE_INTERNAL_GLM} "Include paths to external GLM library" ON)
#option(ENV{LEVEKGL_USE_INTERNAL_GLM} OFF)
#option(ENV{LEVEKGL_EXTERNAL_GLM} "${Lustrine_SOURCE_DIR}/thirdparty/glm-0.9.9.8/glm/glm.hpp")
set(LEVEKGL_BUILD_SAMPLES OFF CACHE BOOL "Do not build LevekGL samples" FORCE)
set(LEVEKGL_USE_INTERNAL_GLM OFF CACHE BOOL "Request LevekGL to use another path for GLM" FORCE)
set(ENV{LEVEKGL_EXTERNAL_GLM_PATH} "${Lustrine_SOURCE_DIR}/thirdparty/glm-0.9.9.8") #CACHE STRING "Request LevekGL to use another path for GLM" FORCE)
#set(ENV{LEVEKGL_USE_INTERNAL_GLM_REQUESTED})
#set(ENV{LEVEKGL_EXTERNAL_GLM} "${Lustrine_SOURCE_DIR}/thirdparty/glm-0.9.9.8")
add_subdirectory(thirdparty)
link_directories(${Lustrine_SOURCE_DIR}/src)
set(LUSTRINE_SOURCES
"src/Lustrine.cpp"
"src/JsonWriter.cpp"
"src/Kernels.cpp"
"src/neighbors/Neighbors.cpp"
"src/VoxelLoader.cpp"
"src/BulletPhysics.cpp"
"src/profiling/Profiling.cpp"
"src/Simulate.cpp"
"src/neighbors/Sorting.cpp"
"src/neighbors/Utils.cpp"
)
set(LUSTRINEWRAPPER_SOURCES
"src/Lustrine.cpp"
"src/JsonWriter.cpp"
"src/Kernels.cpp"
"src/neighbors/Neighbors.cpp"
"src/LustrineWrapper.cpp"
"src/BulletPhysics.cpp"
"src/VoxelLoader.cpp"
"src/profiling/Profiling.cpp"
"src/Simulate.cpp"
"src/neighbors/Sorting.cpp"
"src/neighbors/Utils.cpp"
)
add_library(Lustrine SHARED ${LUSTRINE_SOURCES})
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set_property(TARGET Lustrine PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
else()
set_property(TARGET Lustrine PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
generate_export_header(Lustrine
BASE_NAME Lustrine
EXPORT_MACRO_NAME LUSTRINE_EXPORT
EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/Lustrine_Export.h
STATIC_DEFINE LUSTRINE_BUILT_AS_STATIC
)
target_include_directories(Lustrine PUBLIC ${CMAKE_BINARY_DIR}/exports)
add_library(LustrineWrapper SHARED ${LUSTRINEWRAPPER_SOURCES})
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set_property(TARGET LustrineWrapper PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
else()
set_property(TARGET LustrineWrapper PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
#add_library(LustrineWrapper STATIC ${LUSTRINEWRAPPER_SOURCES})
generate_export_header(LustrineWrapper
BASE_NAME LustrineWrapper
EXPORT_MACRO_NAME LUSTRINE_WRAPPER_EXPORT
EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/LustrineWrapper_Export.h
STATIC_DEFINE LUSTRINE_WRAPPER_BUILT_AS_STATIC
)
set_target_properties(
LustrineWrapper PROPERTIES
PUBLIC_HEADER src/LustrineWrapper.hpp
)
target_include_directories(LustrineWrapper PUBLIC ${CMAKE_BINARY_DIR}/exports)
target_link_libraries(Lustrine LevekGL)
if (WIN32)
set(BULLET_INCLUDE_DIR "${Lustrine_SOURCE_DIR}/thirdparty/Bullet3/bullet3/src")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BULLET_LIB_DIR "${Lustrine_SOURCE_DIR}/thirdparty/Bullet3/windows/MDd")
set(Bullet3LinearMathLibPath "${BULLET_LIB_DIR}/LinearMath_Debug.lib")
set(Bullet3CommonLibPath "${BULLET_LIB_DIR}/Bullet3Common_Debug.lib")
set(BulletDynamicsLibPath "${BULLET_LIB_DIR}/BulletDynamics_Debug.lib")
set(BulletInverseDynamicsLibPath "${BULLET_LIB_DIR}/BulletInverseDynamics_Debug.lib")
set(BulletCollisionLibPath "${BULLET_LIB_DIR}/BulletCollision_Debug.lib")
set(BulletSoftBodyLibPath "${BULLET_LIB_DIR}/BulletSoftBody_Debug.lib")
else()
set(BULLET_LIB_DIR "${Lustrine_SOURCE_DIR}/thirdparty/Bullet3/windows/MD")
set(Bullet3LinearMathLibPath "${BULLET_LIB_DIR}/LinearMath.lib")
set(Bullet3CommonLibPath "${BULLET_LIB_DIR}/Bullet3Common.lib")
set(BulletDynamicsLibPath "${BULLET_LIB_DIR}/BulletDynamics.lib")
set(BulletInverseDynamicsLibPath "${BULLET_LIB_DIR}/BulletInverseDynamics.lib")
set(BulletCollisionLibPath "${BULLET_LIB_DIR}/BulletCollision.lib")
set(BulletSoftBodyLibPath "${BULLET_LIB_DIR}/BulletSoftBody.lib")
endif()
add_library(Bullet3LinearMath STATIC IMPORTED)
set_property(TARGET Bullet3LinearMath PROPERTY IMPORTED_LOCATION ${Bullet3LinearMathLibPath})
list (APPEND BULLET_LIBRARIES Bullet3LinearMath)
add_library(Bullet3Common STATIC IMPORTED)
set_property(TARGET Bullet3Common PROPERTY IMPORTED_LOCATION ${Bullet3CommonLibPath})
list (APPEND BULLET_LIBRARIES Bullet3Common)
add_library(Bullet3InverseDynamics STATIC IMPORTED)
set_property(TARGET Bullet3InverseDynamics PROPERTY IMPORTED_LOCATION ${BulletInverseDynamicsLibPath})
list (APPEND BULLET_LIBRARIES Bullet3InverseDynamics)
add_library(BulletCollision STATIC IMPORTED)
set_property(TARGET BulletCollision PROPERTY IMPORTED_LOCATION ${BulletCollisionLibPath})
list (APPEND BULLET_LIBRARIES BulletCollision)
add_library(BulletDynamics STATIC IMPORTED)
set_property(TARGET BulletDynamics PROPERTY IMPORTED_LOCATION ${BulletDynamicsLibPath})
list (APPEND BULLET_LIBRARIES BulletDynamics)
add_library(BulletSoftBody STATIC IMPORTED)
set_property(TARGET BulletSoftBody PROPERTY IMPORTED_LOCATION ${BulletSoftBodyLibPath})
list (APPEND BULLET_LIBRARIES BulletSoftBody)
message("linear math ${Bullet3LinearMathLibPath}")
message("common ${Bullet3CommonLibPath}")
message("Bullet3InverseDynamics ${BulletInverseDynamicsLibPath}")
message("BulletCollision ${BulletCollisionLibPath}")
message("BulletDynamics ${BulletDynamicsLibPath}")
message("Bullet3SoftBody ${BulletSoftBodyLibPath}")
else()
find_package(Bullet REQUIRED)
endif()
message("bullet libraries: ${BULLET_LIBRARIES}")
message("bullet include dir: ${BULLET_INCLUDE_DIR}")
target_link_libraries(Lustrine ${BULLET_LIBRARIES})
target_link_libraries(LustrineWrapper ${BULLET_LIBRARIES})
target_include_directories(Lustrine PUBLIC ${BULLET_INCLUDE_DIR})
target_include_directories(LustrineWrapper PUBLIC ${BULLET_INCLUDE_DIR})
set(LUSTRINE_TARGET_INCLUDE_DIRS
PUBLIC "src"
PRIVATE "${Lustrine_SOURCE_DIR}/thirdparty/glm-0.9.9.8"#"thirdparty/glm-0.9.9.8"
PUBLIC "thirdparty/LevekGL"
)
set(LUSTRINEWRAPPER_TARGET_INCLUDE_DIRS
PUBLIC "src"
PRIVATE "${Lustrine_SOURCE_DIR}/thirdparty/glm-0.9.9.8"#"thirdparty/glm-0.9.9.8"
)
target_include_directories(Lustrine ${LUSTRINE_TARGET_INCLUDE_DIRS})
target_include_directories(LustrineWrapper ${LUSTRINEWRAPPER_TARGET_INCLUDE_DIRS})
add_compile_definitions(LUSTRINE_EXPERIMENTS_DIRECTORY="${Lustrine_SOURCE_DIR}/experiments")
add_subdirectory(experiments)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)