-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
243 lines (199 loc) · 9.85 KB
/
CMakeLists.txt
File metadata and controls
243 lines (199 loc) · 9.85 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
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
240
241
242
243
# Detects whether this is a top-level project
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if(HAS_PARENT)
set(CCD_WRAPPER_TOPLEVEL_PROJECT OFF)
else()
set(CCD_WRAPPER_TOPLEVEL_PROJECT ON)
endif()
# Check required CMake version
set(REQUIRED_CMAKE_VERSION "3.14.0")
if(CCD_WRAPPER_TOPLEVEL_PROJECT)
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})
else()
# Don't use cmake_minimum_required here to avoid implicitly overriding parent policies
if(${CMAKE_VERSION} VERSION_LESS ${REQUIRED_CMAKE_VERSION})
message(FATAL_ERROR "CMake required version to build CCD Wrapper is ${REQUIRED_CMAKE_VERSION}")
endif()
endif()
# Include user-provided default options if available. We do that before the main
# `project()` so that we can define the C/C++ compilers from the option file.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CCDWrapperOptions.cmake)
message(STATUS "Using local options file: ${CMAKE_CURRENT_SOURCE_DIR}/CCDWrapperOptions.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/CCDWrapperOptions.cmake)
endif()
################################################################################
project(CCDWrapper
DESCRIPTION "A library for various continuous collision detection algorithms."
LANGUAGES CXX)
# project-options
option(CCD_WRAPPER_WITH_UNIT_TESTS "Build unit tests using Catch2" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_BENCHMARK "Build exectuable for timing methods" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
########################################################################################################################
# Methods:
# If this project is the top level then enable all by default otherwise enable no methods
option(CCD_WRAPPER_WITH_FPRF "Enable floating-point root finder method" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_MSRF "Enable minimum separation root-finding method" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_RP "Enable root parity method" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_RRP "Enable rational root parity method" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_FPRP "Enable floating-point root parity method" OFF)
mark_as_advanced(CCD_WRAPPER_WITH_FPRP) # This is a private method
option(CCD_WRAPPER_WITH_RFRP "Enable rational fixed root parity method" OFF)
mark_as_advanced(CCD_WRAPPER_WITH_RFRP) # This is a private method
option(CCD_WRAPPER_WITH_BSC "Enable Bernstein sign classification method" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_TIGHT_CCD "Enable TightCCD method" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_INTERVAL "Enable interval-based methods" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
option(CCD_WRAPPER_WITH_TIGHT_INCLUSION "Enable Tight Inclusion method" ${CCD_WRAPPER_TOPLEVEL_PROJECT})
########################################################################################################################
option(CCD_WRAPPER_IS_CI_BUILD "Is this being built on GitHub Actions" OFF)
mark_as_advanced(CCD_WRAPPER_IS_CI_BUILD) # Do not change this value
# Set default minimum C++ standard
if(CCD_WRAPPER_TOPLEVEL_PROJECT)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
### Configuration
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/ccd_wrapper/")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/recipes/")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/find/")
# Color output
include(ccd_wrapper_use_colors)
################################################################################
# CCD Wrapper Library
################################################################################
add_library(ccd_wrapper src/ccd.cpp)
add_library(ccd_wrapper::ccd_wrapper ALIAS ccd_wrapper)
target_include_directories(ccd_wrapper PUBLIC src)
################################################################################
# Optional Definitions
################################################################################
# For MSVC, do not use the min and max macros.
target_compile_definitions(ccd_wrapper PUBLIC NOMINMAX)
################################################################################
# Dependencies
################################################################################
# Extra warnings
include(ccd_wrapper_warnings)
target_link_libraries(ccd_wrapper PRIVATE ccd_wrapper::warnings)
# Eigen
include(eigen)
target_link_libraries(ccd_wrapper PUBLIC Eigen3::Eigen)
# Etienne Vouga's CTCD Library for the floating point root finding algorithm
if(CCD_WRAPPER_WITH_FPRF)
include(floating_point_root_finder)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::floating_point_root_finder)
# target_compile_definitions(ccd_wrapper PUBLIC CCD_WRAPPER_WITH_FPRF=true)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_FPRF=$<BOOL:${CCD_WRAPPER_WITH_FPRF}>)
# Exact-CCD from Brochu et al. [2012] and Tang et al. [2014]
if(CCD_WRAPPER_WITH_RP OR CCD_WRAPPER_WITH_BSC)
include(root_parity_and_bernstein_sign_classification)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::root_parity_and_bernstein_sign_classification)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_RP=$<BOOL:${CCD_WRAPPER_WITH_RP}>)
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_BSC=$<BOOL:${CCD_WRAPPER_WITH_BSC}>)
# Rational implmentation of Brochu et al. [2012]
if(CCD_WRAPPER_WITH_RRP)
include(rational_root_parity)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::rational_root_parity)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_RRP=$<BOOL:${CCD_WRAPPER_WITH_RRP}>)
# SafeCCD
# if(CCD_WRAPPER_WITH_SAFE_CCD)
# target_link_libraries(ccd_wrapper PUBLIC SafeCCD)
# endif()
target_compile_definitions(ccd_wrapper PUBLIC CCD_WRAPPER_WITH_SAFE_CCD=false)
# TightCCD implmentation of Wang et al. [2015]
if(CCD_WRAPPER_WITH_TIGHT_CCD)
include(tight_ccd)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::tight_ccd)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_TIGHT_CCD=$<BOOL:${CCD_WRAPPER_WITH_TIGHT_CCD}>)
# Minimum separation root finder of [Harmon et al. 2011]
if(CCD_WRAPPER_WITH_MSRF)
include(minimum_separation_root_finder)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::minimum_separation_root_finder)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_MSRF=$<BOOL:${CCD_WRAPPER_WITH_MSRF}>)
# Floating-point fixed root parity
if(CCD_WRAPPER_WITH_FPRP)
include(fixed_root_parity)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::floating_point_root_parity)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_FPRP=$<BOOL:${CCD_WRAPPER_WITH_FPRP}>)
# Rational fixed root parity
if(CCD_WRAPPER_WITH_RFRP)
include(fixed_root_parity)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::rational_fixed_root_parity)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_RFRP=$<BOOL:${CCD_WRAPPER_WITH_RFRP}>)
# Interval-based methods
if(CCD_WRAPPER_WITH_INTERVAL)
include(interval_based_ccd)
target_link_libraries(ccd_wrapper PUBLIC ccd_wrapper::interval_based_ccd)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_INTERVAL=$<BOOL:${CCD_WRAPPER_WITH_INTERVAL}>)
# Custom inclusion based CCD of [Wang et al. 2020]
if(CCD_WRAPPER_WITH_TIGHT_INCLUSION)
include(tight_inclusion)
target_link_libraries(ccd_wrapper PUBLIC tight_inclusion::tight_inclusion)
endif()
target_compile_definitions(ccd_wrapper PUBLIC
CCD_WRAPPER_WITH_TIGHT_INCLUSION=$<BOOL:${CCD_WRAPPER_WITH_TIGHT_INCLUSION}>)
################################################################################
# Compiler options
################################################################################
# Use C++11
target_compile_features(ccd_wrapper PUBLIC cxx_std_11)
################################################################################
# Tests
################################################################################
if(CCD_WRAPPER_WITH_UNIT_TESTS)
include(CTest)
enable_testing()
# Include Catch2 and provide function `catch_discover_tests` to register tests.
include(catch2)
FetchContent_GetProperties(catch2)
include("${catch2_SOURCE_DIR}/contrib/Catch.cmake")
add_subdirectory(tests)
endif()
################################################################################
# Benchmark
################################################################################
if(CCD_WRAPPER_WITH_BENCHMARK)
add_executable(ccd_benchmark
src/benchmark.cpp
src/utils/read_rational_csv.cpp
)
target_include_directories(ccd_benchmark PUBLIC src)
target_link_libraries(ccd_benchmark PUBLIC ccd_wrapper::ccd_wrapper)
include(filesystem)
target_link_libraries(ccd_benchmark PUBLIC ghc::filesystem)
include(fmt)
target_link_libraries(ccd_benchmark PUBLIC fmt::fmt)
include(cli11)
target_link_libraries(ccd_benchmark PUBLIC CLI11::CLI11)
# GMP for reading rational query csv files
find_package(GMP)
IF(NOT ${GMP_FOUND})
MESSAGE(FATAL_ERROR "GMP not found! Needed by CCD Benchmark for reading rational query csv files.")
ENDIF()
target_link_libraries(ccd_benchmark PUBLIC gmp::gmp)
# Download Sample Queries
include(sample_queries)
target_compile_definitions(ccd_benchmark PUBLIC
CCD_WRAPPER_SAMPLE_QUERIES_DIR="${CCD_WRAPPER_SAMPLE_QUERIES_DIR}")
target_compile_features(ccd_benchmark PUBLIC cxx_std_11)
if(CCD_WRAPPER_IS_CI_BUILD)
target_compile_definitions(ccd_benchmark PRIVATE CCD_WRAPPER_IS_CI_BUILD)
endif()
endif()