-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
678 lines (580 loc) · 25 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
cmake_minimum_required(VERSION 3.9)
project(iMSTK VERSION 7.0.0 LANGUAGES C CXX)
include(CMakeDependentOption)
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
#-----------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
set(CMAKE_DEBUG_POSTFIX "d")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#-----------------------------------------------------------------------------
# Project install directories
#-----------------------------------------------------------------------------
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Install location" FORCE)
endif()
set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
# Let's go ahead and make these directories
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/include)
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)
#-----------------------------------------------------------------------------
# Update CMake module path & CMake dir
#-----------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utilities
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/lib/cmake # Vega and VTK
)
set(${PROJECT_NAME}_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
# Add "mark_as_superbuild" CMake function to associate option with inner build
include(imstkSolveDependencies)
#-----------------------------------------------------------------------------
# C++11 Support
#-----------------------------------------------------------------------------
set(_msg "Setting C++ standard")
message(STATUS "${_msg}")
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "${_msg} - C++${CMAKE_CXX_STANDARD}")
if(NOT CMAKE_CXX_STANDARD MATCHES "^(11|14|17)$")
message(FATAL_ERROR "CMAKE_CXX_STANDARD must be set to 11, 14 or 17")
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
# Prevents a compiler error for Visual Studio 15.8
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
if(${MSVC_VERSION} GREATER_EQUAL 1915)
add_definitions(-D_DISABLE_EXTENDED_ALIGNED_STORAGE)
endif()
endif()
#-----------------------------------------------------------------------------
# Options
#-----------------------------------------------------------------------------
# Unity Switch
if (WIN32)
option(${PROJECT_NAME}_BUILD_FOR_UNITY "Build iMSTK libraries for the unity asset" OFF)
mark_as_superbuild(${PROJECT_NAME}_BUILD_FOR_UNITY:BOOL)
endif()
# SWIG
cmake_dependent_option(${PROJECT_NAME}_WRAP_CSHARP "Build iMSTK-C# wrapper code and lib" OFF "NOT ${PROJECT_NAME}_BUILD_FOR_UNITY" ON)
#option(${PROJECT_NAME}_WRAP_CSHARP "Build iMSTK-C# wrapper code and lib" OFF)
mark_as_superbuild(${PROJECT_NAME}_WRAP_CSHARP:BOOL)
# SWIG will generate managed array using pinning if this option is ON. Otherwise using P/Invoke default array marshalling.
option(${PROJECT_NAME}_SWIG_PINNED_ARRAY "Managed C# arrays using pinning" ON)
mark_as_advanced(${PROJECT_NAME}_SWIG_PINNED_ARRAY)
mark_as_superbuild(${PROJECT_NAME}_SWIG_PINNED_ARRAY:BOOL)
if (${PROJECT_NAME}_WRAP_CSHARP)
find_package(SWIG REQUIRED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
# CUDA
# option(${PROJECT_NAME}_ENABLE_CUDA_BACKEND "Enable iMSTK CUDA backend" OFF)
# mark_as_superbuild(${PROJECT_NAME}_ENABLE_CUDA_BACKEND)
# if (${PROJECT_NAME}_ENABLE_CUDA_BACKEND)
# include(CheckLanguage)
# check_language(CUDA)
# if (CMAKE_CUDA_COMPILER)
# enable_language(CUDA)
# set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
# set(CUDA_PROPAGATE_HOST_FLAGS ON)
# if(NOT DEFINED CMAKE_CUDA_STANDARD)
# set(CMAKE_CUDA_STANDARD 11)
# set(CMAKE_CUDA_STANDARD_REQUIRED ON)
# endif()
# else()
# message(STATUS "WARNING: CUDA compiler NOT FOUND; CUDA backend not enabled!")
# set(${PROJECT_NAME}_ENABLE_CUDA_BACKEND OFF)
# endif()
# endif ()
# General Options
option(${PROJECT_NAME}_BUILD_EXAMPLES "Build iMSTK examples" ON)
mark_as_superbuild(${PROJECT_NAME}_BUILD_EXAMPLES:BOOL)
option(${PROJECT_NAME}_BUILD_TESTING "Build iMSTK tests" ON)
mark_as_superbuild(${PROJECT_NAME}_BUILD_TESTING:BOOL)
option(${PROJECT_NAME}_BUILD_VISUAL_TESTING "Build iMSTK visual tests" ON)
if (${PROJECT_NAME}_BUILD_VISUAL_TESTING)
set(${PROJECT_NAME}_BUILD_TESTING ON)
endif()
mark_as_superbuild(${PROJECT_NAME}_BUILD_VISUAL_TESTING:BOOL)
set(BUILD_TESTING OFF)
if (${PROJECT_NAME}_BUILD_TESTING)
set(BUILD_TESTING ON)
endif ()
#Build Benchmark
option(${PROJECT_NAME}_BUILD_BENCHMARK "Build iMSTK benchmarks" OFF)
mark_as_superbuild(${PROJECT_NAME}_BUILD_BENCHMARK:BOOL)
if (UNIX)
option(${PROJECT_NAME}_USE_MODEL_REDUCTION "Build with model reduction, requires a VegaFEM built with Intel MKL and arpack" OFF)
mark_as_superbuild(${PROJECT_NAME}_USE_MODEL_REDUCTION:BOOL)
option(${PROJECT_NAME}_COLOR_OUTPUT "For coloring output in gcc" OFF)
mark_as_superbuild(${PROJECT_NAME}_COLOR_OUTPUT:BOOL)
option(${PROJECT_NAME}_COVERAGE "Build for calculating coverage" OFF)
mark_as_superbuild(${PROJECT_NAME}_COVERAGE:BOOL)
option(${PROJECT_NAME}_USE_VTK_OSMESA "Build with VTK OSMesa rendering" OFF)
mark_as_superbuild(${PROJECT_NAME}_USE_VTK_OSMESA:BOOL)
if (${PROJECT_NAME}_COVERAGE AND NOT ${CMAKE_BUILD_TYPE} MATCHES [Dd][Ee][Bb][Uu][Gg])
message(WARNING "Coverage requires a debug build forcing debug")
set(CMAKE_BUILD_TYPE "DEBUG")
endif()
endif()
option(${PROJECT_NAME}_USE_VRPN "Build with VRPN support" OFF)
mark_as_superbuild(${PROJECT_NAME}_USE_VRPN:BOOL)
option(${PROJECT_NAME}_USE_HAPLY "Build with Haply support" OFF)
mark_as_superbuild(${PROJECT_NAME}_USE_HAPLY:BOOL)
if (${PROJECT_NAME}_USE_HAPLY)
message(WARNING "iMSTK_USE_HAPLY set to true, this code is based of an early version of the Haply API")
endif()
cmake_dependent_option(${PROJECT_NAME}_USE_RENDERING_VTK "Build with/out VTK rendering support" ON "NOT ${PROJECT_NAME}_BUILD_FOR_UNITY" OFF)
mark_as_superbuild(${PROJECT_NAME}_USE_RENDERING_VTK:BOOL)
if (NOT ${PROJECT_NAME}_USE_RENDERING_VTK AND ${PROJECT_NAME}_USE_VTK_OSMESA)
message(FATAL_ERROR "Setting ${PROJECT_NAME}_USE_VTK_OSMESA ON is only supported when ${PROJECT_NAME}_USE_RENDERING_VTK is ON")
endif()
if (NOT ${PROJECT_NAME}_USE_RENDERING_VTK AND ${PROJECT_NAME}_BUILD_VISUAL_TESTING)
message(FATAL_ERROR "Setting ${PROJECT_NAME}_BUILD_VISUAL_TESTING ON is only supported when ${PROJECT_NAME}_USE_RENDERING_VTK is ON")
endif()
option(${PROJECT_NAME}_USE_OpenHaptics "Use OpenHaptic Support." OFF)
mark_as_superbuild(${PROJECT_NAME}_USE_OpenHaptics:BOOL)
if(NOT WIN32 AND ${PROJECT_NAME}_USE_OpenHaptics)
message(FATAL_ERROR "Setting ${PROJECT_NAME}_USE_OpenHaptics to ON is only supported on Windows")
endif()
# If at least one haptic API is provided
if (${PROJECT_NAME}_USE_HAPLY OR ${PROJECT_NAME}_USE_OpenHaptics OR ${PROJECT_NAME}_USE_VRPN)
set(${PROJECT_NAME}_USE_HAPTICS ON)
endif()
mark_as_superbuild(${PROJECT_NAME}_USE_HAPTICS:BOOL)
cmake_dependent_option(${PROJECT_NAME}_USE_BUILTIN_LOGGING "Uses iMSTK local logger when g3log and its error behavior is not wanted" OFF "NOT ${PROJECT_NAME}_BUILD_FOR_UNITY" ON)
mark_as_superbuild(${PROJECT_NAME}_USE_BUILTIN_LOGGING:BOOL)
#-----------------------------------------------------------------------------
# CTest/Dashboards
#-----------------------------------------------------------------------------
if (${PROJECT_NAME}_BUILD_TESTING)
include(CTest)
set_property(CACHE BUILD_TESTING PROPERTY TYPE INTERNAL)
endif ()
#-----------------------------------------------------------------------------
# SUPERBUILD
#-----------------------------------------------------------------------------
option(${PROJECT_NAME}_SUPERBUILD "Build ${PROJECT_NAME} and the projects it depends on." ON)
if(${PROJECT_NAME}_SUPERBUILD)
#-----------------------------------------------------------------------------
# Define External dependencies
#-----------------------------------------------------------------------------
macro(imstk_define_dependency extProj)
list(APPEND ${PROJECT_NAME}_DEPENDENCIES ${extProj})
option(USE_SYSTEM_${extProj} "Exclude ${extProj} from superbuild and use an existing build." OFF)
mark_as_advanced(USE_SYSTEM_${extProj})
endmacro()
option(${PROJECT_NAME}_USE_Uncrustify "Use Uncrustify as a code style beautifier." ON)
if(${PROJECT_NAME}_USE_Uncrustify)
find_package (Python COMPONENTS Interpreter)
if(Python_Interpreter_FOUND)
imstk_define_dependency(Uncrustify)
else()
message(WARN "Uncrustify requires a python interpreter, please install python and rerun configure")
endif()
endif()
imstk_define_dependency(Assimp)
imstk_define_dependency(Eigen3)
imstk_define_dependency(g3log)
if (${PROJECT_NAME}_USE_RENDERING_VTK)
imstk_define_dependency(OpenVR)
endif()
imstk_define_dependency(TBB)
imstk_define_dependency(VegaFEM)
imstk_define_dependency(VTK)
if(${PROJECT_NAME}_USE_OpenHaptics)
imstk_define_dependency(OpenHaptics)
endif()
if (${PROJECT_NAME}_USE_VRPN)
if(WIN32)
imstk_define_dependency(Libusb) #for VRPN
endif()
imstk_define_dependency(VRPN)
endif()
if (${PROJECT_NAME}_USE_HAPLY)
imstk_define_dependency(Haply)
endif()
if(${PROJECT_NAME}_BUILD_TESTING)
imstk_define_dependency(GTest)
#-----------------------------------------------------------------------------
# Allow CTest to cover Innerbuild
#-----------------------------------------------------------------------------
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/CMake/Utilities/imstkCTestAddInnerbuild.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/imstkCTestAddInnerbuild.cmake"
@ONLY
)
set_directory_properties(PROPERTIES TEST_INCLUDE_FILE
"${CMAKE_CURRENT_BINARY_DIR}/imstkCTestAddInnerbuild.cmake"
)
endif()
if (${PROJECT_NAME}_BUILD_TESTING OR
${PROJECT_NAME}_BUILD_EXAMPLES)
imstk_define_dependency(iMSTKData)
endif()
# Build with Google Benchmark for benchmarking
if (${PROJECT_NAME}_BUILD_BENCHMARK)
imstk_define_dependency(benchmark)
endif()
#-----------------------------------------------------------------------------
# Solve project dependencies
#-----------------------------------------------------------------------------
# Call CMakeLists.txt in CMake/External which will solve the dependencies
# and add the External projects, including this one: this top-level
# CMakeLists.txt will be called back with SUPERBUILD=OFF, to execute
# the rest of the code below (INNERBUILD), which explains the `return`
add_subdirectory(CMake/External)
return()
endif()
#-----------------------------------------------------------------------------
# INNERBUILD
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Find external dependencies
#-----------------------------------------------------------------------------
include(imstkFind)
# Set where to look for packages (If not using system)
set(PACKAGE_PREFIX_DIR ${CMAKE_INSTALL_PREFIX})
# Assimp
find_package( Assimp REQUIRED )
# Eigen
find_package( Eigen3 3.1.2 REQUIRED )
# g3log
find_package( g3log REQUIRED )
if (${PROJECT_NAME}_USE_VRPN)
# Libusb
find_package( Libusb REQUIRED)
endif()
if (${PROJECT_NAME}_USE_RENDERING_VTK)
# OpenVR
find_package( OpenVR REQUIRED )
endif()
# TBB
find_package(TBB REQUIRED)
# VegaFEM
find_package( VegaFEM REQUIRED CONFIG )
# VRPN
if (${PROJECT_NAME}_USE_VRPN)
find_package( VRPN REQUIRED )
add_definitions( -DiMSTK_USE_VRPN )
else()
remove_definitions( -DiMSTK_USE_VRPN )
endif()
if (${PROJECT_NAME}_USE_HAPLY)
find_package( Haply REQUIRED )
add_definitions( -DiMSTK_USE_HAPLY )
else()
remove_definitions( -DiMSTK_USE_HAPLY )
endif()
# OpenHaptics
if(${PROJECT_NAME}_USE_OpenHaptics)
find_package( OpenHapticsSDK REQUIRED )
add_definitions( -DiMSTK_USE_OPENHAPTICS )
else()
remove_definitions( -DiMSTK_USE_OPENHAPTICS )
endif()
# VTK
find_package(VTK REQUIRED CONFIG)
# modules are linked via `VTK::CommonCore`
# vtk_module_autoinit is needed
if (${PROJECT_NAME}_USE_RENDERING_VTK)
find_package(vtkRenderingOpenVR QUIET)
find_package(vtkRenderingExternal QUIET)
endif()
if (${PROJECT_NAME}_USE_HAPTICS)
add_definitions( -DiMSTK_USE_HAPTICS )
endif()
list(APPEND iMSTK_VTK_DEPENDENCIES
ChartsCore
CommonCore
CommonDataModel
FiltersCore
FiltersExtraction
FiltersGeneral
FiltersModeling
FiltersSources
IOExport
IOImport
IOPLY
IOParallel
IOParallelXML
ImagingCore
ImagingGeneral
ImagingStencil
InteractionStyle)
if (${PROJECT_NAME}_USE_RENDERING_VTK)
list(APPEND iMSTK_VTK_DEPENDENCIES
RenderingAnnotation
RenderingContext2D
RenderingContextOpenGL2
RenderingCore
RenderingExternal
RenderingLabel
RenderingOpenGL2
RenderingOpenVR
RenderingVolume
RenderingVolumeOpenGL2
ViewsContext2D)
endif()
find_package(VTK COMPONENTS ${iMSTK_VTK_DEPENDENCIES} REQUIRED)
if(${PROJECT_NAME}_USE_VTK_OSMESA)
add_definitions(-DiMSTK_USE_VTK_OSMESA)
endif()
#--------------------------------------------------------------------------
# External Utility Packages
#--------------------------------------------------------------------------
include(imstkAddExecutable)
# Uncrustify
find_program(Uncrustify_EXECUTABLE uncrustify)
# include(SetupUncrustifyConfig)
if(Uncrustify_EXECUTABLE)
include(imstkAddUncrustifyCustomTarget)
else(Uncrustify_EXECUTABLE)
message(WARNING "uncrustify not found! Cannot run code-style test.")
endif(Uncrustify_EXECUTABLE)
#--------------------------------------------------------------------------
# Logger switch
#--------------------------------------------------------------------------
if (${PROJECT_NAME}_USE_BUILTIN_LOGGING)
add_definitions( -DiMSTK_SYNCHRONOUS_LOGGING)
endif()
#-----------------------------------------------------------------------------
# Data
#----------------------------------------------------------------------
if (${PROJECT_NAME}_BUILD_TESTING OR ${PROJECT_NAME}_BUILD_EXAMPLES)
if (UNIX)
# Don't use relative directory on Linux
add_definitions( -DiMSTK_DATA_ROOT=\"${CMAKE_INSTALL_PREFIX}/data/\")
else()
# Use relative directory to bin for movement of the install directory
add_definitions( -DiMSTK_DATA_ROOT=\"../data/\")
endif()
# Note if the target name or data name changes this has to be changed as well
add_custom_target(CopyDataFiles ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_BINARY_DIR}/../External/iMSTKData/src/Data
${CMAKE_INSTALL_PREFIX}/data
)
endif()
#-----------------------------------------------------------------------------
# Testing
#----------------------------------------------------------------------
if(${PROJECT_NAME}_BUILD_TESTING)
find_package( GTest CONFIG REQUIRED )
endif()
#------------------------------------------------------------------
# Benchmarking
#------------------------------------------------------------------
if (${PROJECT_NAME}_BUILD_BENCHMARK)
find_package( benchmark REQUIRED )
endif()
#-----------------------------------------------------------------------------
# Code Coverage
#----------------------------------------------------------------------
if(${PROJECT_NAME}_COVERAGE)
# Note HS Had to add ALL in setup_target_for_coverage to force the code coverage pass
set(CODE_COVERAGE_VERBOSE ON)
include(CodeCoverage)
append_coverage_compiler_flags()
setup_target_for_coverage_lcov(
NAME Coverage
EXECUTABLE ctest -E "(CodeFormatTest)"
EXCLUDE "${CMAKE_BINARY_DIR}/../install/include/*" "/usr/*" "*/Testing/*" "*/Examples/*" "*/Wrappers/*"
)
endif()
# Folder name to put our headers/cmake config files under
set(${PROJECT_NAME}_INSTALL_FOLDER ${PROJECT_NAME}-${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR})
#--------------------------------------------------------------------------
# Add Source code subdirectories
#--------------------------------------------------------------------------
add_subdirectory(Source/Common)
add_subdirectory(Source/ComponentModel)
add_subdirectory(Source/Materials)
add_subdirectory(Source/Geometry)
add_subdirectory(Source/MeshIO)
add_subdirectory(Source/GeometryMappers)
add_subdirectory(Source/DataStructures)
add_subdirectory(Source/Constraint)
add_subdirectory(Source/Devices)
add_subdirectory(Source/RenderingCore)
if (${PROJECT_NAME}_USE_RENDERING_VTK)
add_subdirectory(Source/RenderingVTK)
endif()
add_subdirectory(Source/Solvers)
add_subdirectory(Source/DynamicalModels)
add_subdirectory(Source/SceneEntities)
add_subdirectory(Source/Animation)
add_subdirectory(Source/Controllers)
add_subdirectory(Source/CollisionDetection)
add_subdirectory(Source/CollisionHandling)
add_subdirectory(Source/Needle)
add_subdirectory(Source/Scene)
add_subdirectory(Source/SimulationManager)
add_subdirectory(Source/ViewerCore)
if (${PROJECT_NAME}_USE_RENDERING_VTK)
add_subdirectory(Source/ViewerVTK)
endif()
if( ${PROJECT_NAME}_BUILD_TESTING )
add_subdirectory(Source/Testing)
if (${PROJECT_NAME}_USE_RENDERING_VTK AND ${PROJECT_NAME}_BUILD_VISUAL_TESTING)
add_subdirectory(Source/VisualTesting)
endif()
endif()
add_subdirectory(Source/Filtering)
add_subdirectory(Source/FilteringCore)
if (${PROJECT_NAME}_WRAP_CSHARP)
add_subdirectory(Source/Wrappers)
endif()
#--------------------------------------------------------------------------
# Add Examples subdirectories
#--------------------------------------------------------------------------
if(${PROJECT_NAME}_BUILD_EXAMPLES)
add_subdirectory(Examples)
endif()
#--------------------------------------------------------------------------
# VandV ..
#--------------------------------------------------------------------------
if (${PROJECT_NAME}_USE_RENDERING_VTK AND ${PROJECT_NAME}_BUILD_VISUAL_TESTING)
add_subdirectory(Testing)
endif()
#--------------------------------------------------------------------------
# Add setup script for *nix systems
#--------------------------------------------------------------------------
if(NOT WIN32)
# Create setup shell script to create an environment for running examples
set(LIBRARY_PATH_VAR "LD_LIBRARY_PATH")
if( APPLE )
set(LIBRARY_PATH_VAR "DYLD_FALLBACK_LIBRARY_PATH")
endif()
configure_file(
${CMAKE_SOURCE_DIR}/CMake/setup_iMSTK.sh.in
${CMAKE_INSTALL_PREFIX}/setup_iMSTK.sh
@ONLY)
endif()
#--------------------------------------------------------------------------
# Install Find Modules
#--------------------------------------------------------------------------
set(${PROJECT_NAME}_INSTALL_CONFIG_DIR "lib/cmake/${${PROJECT_NAME}_INSTALL_FOLDER}")
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_CONFIG_DIR}/modules)
file(GLOB modules ${CMAKE_SOURCE_DIR}/CMake/Find*.cmake)
foreach(module ${modules})
install(FILES ${module} DESTINATION "${${PROJECT_NAME}_INSTALL_CONFIG_DIR}/modules")
endforeach()
install(FILES ${CMAKE_SOURCE_DIR}/CMake/Utilities/imstkFind.cmake DESTINATION "${${PROJECT_NAME}_INSTALL_CONFIG_DIR}/modules")
#--------------------------------------------------------------------------
# Innerbuild dummy test
#--------------------------------------------------------------------------
add_test(
NAME imstkDummyTest
COMMAND ${CMAKE_COMMAND} -E echo "Success"
)
#--------------------------------------------------------------------------
# Export Targets
#--------------------------------------------------------------------------
# This variable controls the prefix used to generate the following files:
# ${PROJECT_NAME}ConfigVersion.cmake
# ${PROJECT_NAME}Config.cmake
# ${PROJECT_NAME}Targets.cmake
# and it also used to initialize ${PROJECT_NAME}_INSTALL_CONFIG_DIR value.
set(export_config_name ${PROJECT_NAME})
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAMESPACE)
set(PROJECT_NAMESPACE "${PROJECT_NAMESPACE}::")
#------------------------------------------------------------------------------
# Configure ${PROJECT_NAME}ConfigVersion.cmake common to build and install tree
include(CMakePackageConfigHelpers)
set(config_version_file ${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake)
write_basic_package_version_file(
${config_version_file}
VERSION "${${PROJECT_NAME}_VERSION}"
COMPATIBILITY AnyNewerVersion
)
#------------------------------------------------------------------------------
# Export '${PROJECT_NAME}Targets.cmake' for a build tree
export(
EXPORT ${PROJECT_NAME}Targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAMESPACE}
)
# Configure '${PROJECT_NAME}Config.cmake' for a build tree
set(CONFIG_CODE "####### Expanded from \@CONFIG_CODE\@ #######\n")
set(CONFIG_CODE "${CONFIG_CODE}set(Assimp_ROOT_DIR \"${Assimp_ROOT_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(Assimp_LIB_DIR \"${Assimp_LIB_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(Eigen3_DIR \"${Eigen3_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(g3log_ROOT_DIR \"${g3log_ROOT_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(g3log_LIB_DIR \"${g3log_LIB_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(GTest_DIR \"${GTest_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(benchmark_DIR \"${benchmark_DIR}\")\n")
if(WIN32 AND ${PROJECT_NAME}_USE_VRPN)
set(CONFIG_CODE "${CONFIG_CODE}set(Libusb_ROOT_DIR \"${Libusb_ROOT_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(Libusb_LIB_DIR \"${Libusb_LIB_DIR}\")\n")
endif()
if (${PROJECT_NAME}_USE_RENDERING_VTK)
set(CONFIG_CODE "${CONFIG_CODE}# Add variables to CACHE to workaround issue related to use of\n")
set(CONFIG_CODE "${CONFIG_CODE}# mark_as_advanced command in FindOpenVR and described in CMP0102\n")
set(CONFIG_CODE "${CONFIG_CODE}# See https://cmake.org/cmake/help/latest/policy/CMP0102.html\n")
set(CONFIG_CODE "${CONFIG_CODE}set(OpenVR_INCLUDE_DIR \"${OpenVR_INCLUDE_DIR}\" CACHE PATH \"\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(OpenVR_LIBRARY \"${OpenVR_LIBRARY}\" CACHE FILEPATH \"\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(OpenVR_ROOT_DIR \"${OpenVR_ROOT_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(OpenVR_LIB_DIR \"${OpenVR_LIB_DIR}\")\n")
endif()
set(CONFIG_CODE "${CONFIG_CODE}set(TBB_DIR \"${TBB_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(VegaFEM_DIR \"${VegaFEM_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(VTK_DIR \"${VTK_DIR}\")\n")
if (${PROJECT_NAME}_USE_RENDERING_VTK)
set(CONFIG_CODE "${CONFIG_CODE}set(vtkRenderingOpenVR_DIR \"${vtkRenderingOpenVR_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(vtkRenderingExternal_DIR \"${vtkRenderingExternal_DIR}\")\n")
endif()
set(CONFIG_CODE "${CONFIG_CODE}##################################################")
set(build_config ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake)
configure_package_config_file(
CMake/${PROJECT_NAME}Config.cmake.in
${build_config}
INSTALL_DESTINATION "${PROJECT_BINARY_DIR}"
)
#------------------------------------------------------------------------------
# Export '${PROJECT_NAME}Targets.cmake' for an install tree
install(
EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAMESPACE}
DESTINATION ${${PROJECT_NAME}_INSTALL_CONFIG_DIR}
)
# Configure '${PROJECT_NAME}Config.cmake' for an install tree
set(CONFIG_CODE "####### Expanded from \@CONFIG_CODE\@ #######\n")
# Note: iMSTK specific variables likes <proj>_ROOT_DIR and <proj>_LIB_DIR
# are not set because the location of the corresponding project is automatically
# inferred by Find<proj> CMake module provided by iSMTK.
set(CONFIG_CODE "${CONFIG_CODE}set(Eigen3_DIR \"${Eigen3_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(GTest_DIR \"${GTest_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(TBB_DIR \"${TBB_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(VegaFEM_DIR \"${VegaFEM_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(VTK_DIR \"${VTK_DIR}\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(benchmark_DIR \"${benchmark_DIR}\")\n")
if (${PROJECT_NAME}_USE_RENDERING_VTK)
set(CONFIG_CODE "${CONFIG_CODE}# Add variables to CACHE to workaround issue related to use of\n")
set(CONFIG_CODE "${CONFIG_CODE}# mark_as_advanced command in FindOpenVR and described in CMP0102\n")
set(CONFIG_CODE "${CONFIG_CODE}# See https://cmake.org/cmake/help/latest/policy/CMP0102.html\n")
set(CONFIG_CODE "${CONFIG_CODE}set(OpenVR_INCLUDE_DIR \"${OpenVR_INCLUDE_DIR}\" CACHE PATH \"\")\n")
set(CONFIG_CODE "${CONFIG_CODE}set(OpenVR_LIBRARY \"${OpenVR_LIBRARY}\" CACHE FILEPATH \"\")\n")
set(CONFIG_CODE "${CONFIG_CODE}##################################################")
endif()
set(install_config ${PROJECT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake)
configure_package_config_file(
CMake/${PROJECT_NAME}Config.cmake.in
${install_config}
INSTALL_DESTINATION ${${PROJECT_NAME}_INSTALL_CONFIG_DIR}
)
# Install config files
install(
FILES ${config_version_file} ${install_config}
DESTINATION "${${PROJECT_NAME}_INSTALL_CONFIG_DIR}"
)