-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
342 lines (301 loc) · 13.9 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
######################################################################################################################################################
######################################################################################################################################################
cmake_minimum_required(VERSION 3.20.0 FATAL_ERROR)
######################################################################################################################################################
# Proejct meta data
project(FuncViz
VERSION 0.0.0.60
DESCRIPTION "Generalized bitree/quadtree/octree library"
HOMEPAGE_URL "https://github.com/richmit/FuncViz/"
LANGUAGES CXX)
set(FUNCVIZ_VERSION_DATE 2024-08-20)
mark_as_advanced(FUNCVIZ_VERSION_DATE)
string(TIMESTAMP FUNCVIZ_CONFIG_DATE "%Y-%m-%d")
mark_as_advanced(FUNCVIZ_CONFIG_DATE)
######################################################################################################################################################
# Include ctest -- we might not use it if boost is not found...
include(CTest)
######################################################################################################################################################
# Here are the options we use to modify the build -- these options are passed to cmake like so: cmake -DO_BTEST=YES or -DO_BTEST=NO
OPTION(O_DOXYGEN "Include support for doxygen" ON )
OPTION(O_BTEST "Include support for boost.test" ON )
OPTION(O_MRASTER "Include support for MRaster" ON )
OPTION(O_MRPTREE "Include support for MRPTree" ON )
######################################################################################################################################################
# Find tools & libraries used to build targets
if(O_DOXYGEN)
set(FUNCVIZ_OPT_DOXYGEN "1")
find_package(Doxygen)
if(Doxygen_FOUND)
set(FUNCVIZ_FOUND_DOXYGEN "1")
else()
set(FUNCVIZ_FOUND_DOXYGEN "0")
endif()
else()
set(FUNCVIZ_OPT_DOXYGEN "0")
endif()
if(O_BTEST)
set(FUNCVIZ_OPT_BTEST "1")
find_package(Boost COMPONENTS unit_test_framework)
if(Boost_FOUND)
set(FUNCVIZ_FOUND_BTEST "1")
else()
set(FUNCVIZ_FOUND_BTEST "0")
endif()
else()
set(FUNCVIZ_OPT_BTEST "0")
endif()
if(O_MRASTER)
set(FUNCVIZ_OPT_MRASTER "1")
find_package(MRaster HINTS "./mraster/build/install/share/cmake/MRaster/" "./mraster/build/" "../mraster/build/install/share/cmake/MRaster/" "../mraster/build/")
message(STATUS "MRaster_FOUND: ${MRaster_FOUND}")
if(MRaster_FOUND)
set(MRaster_FOUND "YES")
set(FUNCVIZ_FOUND_MRASTER "1")
set(MRASTER_FOUND_WHAT "PACKAGE")
message(STATUS "MRaster package found (${MRaster_DIR})")
else()
find_file (MRASTER_PATH "CMakeLists.txt" PATHS "mraster" "../mraster")
if(NOT MRASTER_PATH STREQUAL "MRASTER_PATH-NOTFOUND")
cmake_path(GET MRASTER_PATH PARENT_PATH MRASTER_PATH)
if(EXISTS "${MRASTER_PATH}/build/MRasterLib.cmake")
set(MRaster_FOUND "YES")
set(FUNCVIZ_FOUND_MRASTER "1")
set(MRASTER_FOUND_WHAT "EXPORT")
include("${MRASTER_PATH}/build/MRasterLib.cmake")
message(STATUS "MRaster build package found (${MRaster_DIR})")
elseif(EXISTS "${MRASTER_PATH}/lib/ramCanvasTpl.hpp")
set(MRaster_FOUND "YES")
set(FUNCVIZ_FOUND_MRASTER "1")
set(MRASTER_FOUND_WHAT "SOURCE")
message(STATUS "MRaster source headers found (${MRASTER_PATH})")
else()
set(FUNCVIZ_FOUND_MRASTER "0")
endif()
else()
set(FUNCVIZ_OPT_MRASTER "0")
endif()
endif()
message(STATUS "MRaster_FOUND: ${MRaster_FOUND}")
message(STATUS "FUNCVIZ_FOUND_MRASTER: ${FUNCVIZ_FOUND_MRASTER}")
message(STATUS "MRASTER_FOUND_WHAT: ${MRASTER_FOUND_WHAT}")
else()
set(FUNCVIZ_OPT_MRASTER "0")
endif()
mark_as_advanced(MRASTER_FOUND_WHAT)
mark_as_advanced(FUNCVIZ_FOUND_MRASTER FUNCVIZ_FOUND_BTEST FUNCVIZ_FOUND_DOXYGEN)
mark_as_advanced(FUNCVIZ_OPT_MRASTER FUNCVIZ_OPT_BOOST FUNCVIZ_OPT_DOXYGEN)
if(O_MRPTREE)
set(FUNCVIZ_OPT_MRPTREE "1")
find_package(MRPTree HINTS "./MRPTree/build/install/share/cmake/MRPTree/" "./MRPTree/build/" "../MRPTree/build/install/share/cmake/MRPTree/" "../MRPTree/build/")
message(STATUS "MRPTree_FOUND: ${MRPTree_FOUND}")
if(MRPTree_FOUND)
set(MRPTree_FOUND "YES")
set(FUNCVIZ_FOUND_MRPTREE "1")
set(MRPTREE_FOUND_WHAT "PACKAGE")
message(STATUS "MRPTree package found (${MRPTree_DIR})")
else()
find_file (MRPTREE_PATH "CMakeLists.txt" PATHS "MRPTree" "../MRPTree")
if(NOT MRPTREE_PATH STREQUAL "MRPTREE_PATH-NOTFOUND")
cmake_path(GET MRPTREE_PATH PARENT_PATH MRPTREE_PATH)
if(EXISTS "${MRPTREE_PATH}/build/MRPTreeLib.cmake")
set(MRPTree_FOUND "YES")
set(FUNCVIZ_FOUND_MRPTREE "1")
set(MRPTREE_FOUND_WHAT "EXPORT")
include("${MRPTREE_PATH}/build/MRPTreeLib.cmake")
message(STATUS "MRPTree build package found (${MRPTree_DIR})")
elseif(EXISTS "${MRPTREE_PATH}/lib/MR_rect_tree.hpp")
set(MRPTree_FOUND "YES")
set(FUNCVIZ_FOUND_MRPTREE "1")
set(MRPTREE_FOUND_WHAT "SOURCE")
message(STATUS "MRPTree source headers found (${MRPTREE_PATH})")
else()
set(FUNCVIZ_FOUND_MRPTREE "0")
endif()
else()
set(FUNCVIZ_OPT_MRPTREE "0")
endif()
endif()
message(STATUS "MRPTree_FOUND: ${MRPTree_FOUND}")
message(STATUS "FUNCVIZ_FOUND_MRPTREE: ${FUNCVIZ_FOUND_MRPTREE}")
message(STATUS "MRPTREE_FOUND_WHAT: ${MRPTREE_FOUND_WHAT}")
else()
set(FUNCVIZ_OPT_MRPTREE "0")
endif()
mark_as_advanced(MRPTREE_FOUND_WHAT)
mark_as_advanced(FUNCVIZ_FOUND_MRPTREE FUNCVIZ_FOUND_BTEST FUNCVIZ_FOUND_DOXYGEN)
mark_as_advanced(FUNCVIZ_OPT_MRPTREE FUNCVIZ_OPT_BOOST FUNCVIZ_OPT_DOXYGEN)
######################################################################################################################################################
# Create Targets for examples, functional tests, & unit tests
# Master list of targets
set(TARGETS "hello_world"
"surface_with_normals"
"surface_plot_edge" "surface_branch_glue" "surface_plot_corner" "surface_plot_step" "surface_plot_annular_edge"
"parametric_surface_with_defects" "performance_with_large_surface"
"parametric_curve_3d"
"implicit_surface" "implicit_curve_2d"
"vector_field_3d"
"curve_plot"
### Extra examples
"ear_surface" "ear_surface_glue"
"trefoil"
### MR_cell_cplx examples (don't use MR_rect_tree or MR_rt_to_cc)
"holy_wave_surf"
### Examples using MRaster
"hello_MRaster"
"complex_magnitude_surface"
"complex_color_image"
### Unit Tests
"check_cell_hexahedron" "check_cell_pyramid" "check_cell_quad" "check_cell_triangle" "check_cell_segment"
"geomi_pnt_line_distance" "geomi_seg_isect_type"
"geomr_pnt_pln_distance" "geomr_pnt_tri_distance" "geomr_pnt_line_distance"
### Functional Tests
"flat_test_tree_01"
"nan_solver"
"segment_folder" "triangle_folder"
"rect_fix_dup" "rect_fix_nan"
### Config
"funcviz_config"
)
# Targets listed here require MRaster to build --- *grep -El '(MR_rect_tree|MR_math|MR_cell_cplx|MR_rt_to_cc)\.hpp' */*.cpp | xargs basename -as .cpp | xargs -n 1000 echo
set(REQ_MRPTREE complex_magnitude_surface curve_plot ear_surface ear_surface_glue hello_MRaster hello_world holy_wave_surf implicit_curve_2d implicit_surface parametric_curve_3d parametric_surface_with_defects performance_with_large_surface surface_branch_glue surface_plot_annular_edge surface_plot_corner surface_plot_edge surface_plot_step surface_with_normals trefoil vector_field_3d flat_test_tree_01 nan_solver rect_fix_dup rect_fix_nan segment_folder triangle_folder check_cell_hexahedron check_cell_pyramid check_cell_quad check_cell_segment check_cell_triangle geomi_pnt_line_distance geomi_seg_isect_type geomr_pnt_line_distance geomr_pnt_pln_distance geomr_pnt_tri_distance)
# Targets listed here require MRaster to build --- *grep -El '(ramCanvas|MRcolor)\.hpp' */*.cpp | xargs basename -as .cpp | xargs -n 1000 echo
set(REQ_MRASTER complex_magnitude_surface complex_color_image hello_MRaster)
# Add a target for each one we can build
foreach(CURTGT IN LISTS TARGETS)
list (FIND REQ_MRASTER ${CURTGT} TMPR)
if(${TMPR} GREATER -1)
set(CURTGT_REQ_MRASTER "YES")
else()
set(CURTGT_REQ_MRASTER "NO")
endif()
list (FIND REQ_MRPTREE ${CURTGT} TMPR)
if(${TMPR} GREATER -1)
set(CURTGT_REQ_MRPTREE "YES")
else()
set(CURTGT_REQ_MRPTREE "NO")
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/${CURTGT}.cpp")
if(CURTGT_REQ_MRASTER AND NOT MRaster_FOUND)
message(NOTICE "Target ${CURTGT} will not be built (no MRaster support)")
continue()
endif()
if(CURTGT_REQ_MRPTREE AND NOT MRPTree_FOUND)
message(NOTICE "Target ${CURTGT} will not be built (no MRPTree support)")
continue()
endif()
add_executable(${CURTGT} EXCLUDE_FROM_ALL "examples/${CURTGT}.cpp")
list(APPEND TARGETS_EXAMPLES ${CURTGT})
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ftests/${CURTGT}.cpp")
add_executable(${CURTGT} EXCLUDE_FROM_ALL "ftests/${CURTGT}.cpp")
list(APPEND TARGETS_FTEST ${CURTGT})
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/utests/${CURTGT}.cpp")
if(NOT Boost_FOUND)
message(NOTICE "Target ${CURTGT} will not be built (no boost support)")
continue()
endif()
add_executable(${CURTGT} EXCLUDE_FROM_ALL "utests/${CURTGT}.cpp")
list(APPEND TARGETS_UTEST ${CURTGT})
else()
message("Warning: Unable to find source for target ${CURTGT}!")
continue()
endif()
target_compile_features(${CURTGT} PUBLIC cxx_std_23)
# FuncViz specific header libs
target_include_directories(${CURTGT} PRIVATE lib)
target_include_directories(${CURTGT} PRIVATE ${CMAKE_BINARY_DIR})
# Compiler specific stuff
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${CURTGT} PUBLIC -Wall -Wconversion -Wno-unknown-pragmas -Wextra -Wno-deprecated-copy)
target_compile_options(${CURTGT} PUBLIC -O4)
elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
target_compile_options(${CURTGT} PUBLIC -Wall -Wconversion -Wno-unknown-pragmas -Wextra -Wno-sign-conversion)
target_compile_options(${CURTGT} PUBLIC -O3)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
target_compile_options(${CURTGT} PUBLIC -Wall)
target_compile_options(${CURTGT} PUBLIC -O3)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
#message("Warning: MSVC support is currently experimental")
endif()
# Unit Test Specific Stuff
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/utests/${CURTGT}.cpp")
target_link_libraries(${CURTGT} PRIVATE ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
add_test(NAME "${CURTGT}" COMMAND "${CURTGT}")
endif()
# targets that require MRaster
if(CURTGT_REQ_MRASTER)
if(MRASTER_FOUND_WHAT STREQUAL "SOURCE")
target_include_directories(${CURTGT} PRIVATE "${MRASTER_PATH}/lib")
else()
target_link_libraries(${CURTGT} PRIVATE MRaster)
endif()
endif()
if(CURTGT_REQ_MRPTREE)
if(MRPTREE_FOUND_WHAT STREQUAL "SOURCE")
target_include_directories(${CURTGT} PRIVATE "${MRPTREE_PATH}/lib")
else()
target_link_libraries(${CURTGT} PRIVATE MRPTree)
endif()
endif()
endforeach(CURTGT)
######################################################################################################################################################
add_custom_target(ftests
DEPENDS ${TARGETS_FTEST}
COMMENT "Building Functional Tests"
)
add_custom_target(run-ftests
DEPENDS ${TARGETS_FTEST}
COMMENT "Running Functional Tests"
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/ftests/run_tests.sh"
)
if(Boost_FOUND)
add_custom_target(utests
DEPENDS ${TARGETS_UTEST}
COMMENT "Building Unit Tests"
)
add_custom_target(run-utests
DEPENDS ${TARGETS_UTEST}
COMMENT "Running Unit Tests"
COMMAND "cmake --build . -t test"
)
endif()
add_custom_target(examples
DEPENDS ${TARGETS_EXAMPLES}
COMMENT "Building Examples"
)
add_custom_target(clean-data
COMMAND rm -f *.vtu *.vtp *.vtk *.ply
COMMENT "Cleaning VTK & PLY files"
)
if(EXISTS "c:/Users/richmit/Documents/WWW/site/SS/FuncViz/doc-lib/")
add_custom_target(install-doc-lib
DEPENDS doc-lib
COMMAND rsync -rlt --log-format=%f --stats --delete --delete-excluded --modify-window=2 doc-lib/ /c/Users/richmit/Documents/WWW/site/SS/FuncViz/doc-lib
COMMENT "Put doc-lib data in web site directory"
)
endif()
if(EXISTS "c:/Users/richmit/Documents/WWW/site/SS/FuncViz/doc-examples/")
add_custom_target(install-doc-examples
DEPENDS doc-examples/
COMMAND rsync -rlt --log-format=%f --stats --delete --delete-excluded --modify-window=2 doc-examples/ /c/Users/richmit/Documents/WWW/site/SS/FuncViz/doc-examples
COMMENT "Put doc-examples data in web site directory"
)
endif()
######################################################################################################################################################
# Generate an include file with various methdata about the build.
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/funcviz_config.hpp.cmake ${CMAKE_BINARY_DIR}/funcviz_config.hpp)
######################################################################################################################################################
# Add targets for documentation
if(Doxygen_FOUND)
foreach(DOXINPUT IN ITEMS "lib" "examples")
message(STATUS "Generateing doxygen target for ${DOXINPUT}")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_BINARY_DIR}/doc-${DOXINPUT}/Doxyfile)
add_custom_target(doc-${DOXINPUT}
COMMAND ${DOXYGEN_EXECUTABLE} > dox.out
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc-${DOXINPUT}
COMMENT "Generating ${DOXINPUT} documentation with Doxygen"
VERBATIM)
endforeach(DOXINPUT)
else()
message("Warning: Doxygen not found. No documentation targets!")
endif()