-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
executable file
·658 lines (428 loc) · 22.1 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
# Apache License 2.0
## Project Properties
SET (PROJECT_NAME "OpenSpaceToolkitPhysics")
SET (PROJECT_DESCRIPTION "Physics library.")
SET (PROJECT_PATH "OpenSpaceToolkit/Physics")
SET (PROJECT_PACKAGE_NAME "open-space-toolkit-physics")
SET (PROJECT_LICENSE "Apache License 2.0")
SET (PROJECT_VENDOR_ID "org.open-space-collective")
SET (PROJECT_VENDOR_NAME "Open Space Collective")
SET (PROJECT_VENDOR_CONTACT "[email protected]")
SET (PROJECT_VENDOR_URL "open-space-collective.org")
## Project Options
OPTION (BUILD_SHARED_LIBRARY "Build shared library." ON)
OPTION (BUILD_STATIC_LIBRARY "Build static library." OFF)
OPTION (BUILD_UNIT_TESTS "Build tests" ON)
OPTION (BUILD_PYTHON_BINDINGS "Build Python bindings." ON)
OPTION (BUILD_CODE_COVERAGE "Build code coverage" OFF)
OPTION (BUILD_DOCUMENTATION "Build documentation" OFF)
OPTION (BUILD_WITH_DEBUG_SYMBOLS "Build with debug symbols" ON)
OPTION (BUILD_SCRIPT "Build script" OFF)
OPTION (BUILD_WITH_CXX_17 "Build with C++ 17 support." OFF)
## Setup
### Compatibility Check
CMAKE_MINIMUM_REQUIRED (VERSION "2.8.12" FATAL_ERROR)
### Paths
SET (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
### Policies
CMAKE_POLICY (SET "CMP0048" NEW)
## Version
INCLUDE ("GetGitRevisionDescription" OPTIONAL)
IF (COMMAND "GET_GIT_HEAD_REVISION" AND COMMAND "GIT_DESCRIBE")
# Versioning using current git branch tag
GET_GIT_HEAD_REVISION (GIT_REFSPEC GIT_HASH)
GIT_DESCRIBE (GIT_TAGS "--tags")
STRING (REPLACE "." ";" VERSION_LIST ${GIT_TAGS})
IF (VERSION_LIST)
LIST (GET VERSION_LIST 0 PROJECT_VERSION_MAJOR)
LIST (GET VERSION_LIST 1 PROJECT_VERSION_MINOR)
LIST (GET VERSION_LIST 2 PROJECT_VERSION_PATCH_TWEAK)
STRING (REPLACE "-" ";" PROJECT_VERSION_PATCH_TWEAKS ${PROJECT_VERSION_PATCH_TWEAK})
LIST (GET PROJECT_VERSION_PATCH_TWEAKS 0 PROJECT_VERSION_PATCH)
LIST (LENGTH PROJECT_VERSION_PATCH_TWEAKS PROJECT_VERSION_PATCH_TWEAKS_LENGTH)
IF (PROJECT_VERSION_PATCH_TWEAKS_LENGTH GREATER 1)
LIST (GET PROJECT_VERSION_PATCH_TWEAKS 1 PROJECT_VERSION_TWEAK)
ENDIF ()
SET (PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
IF (DEFINED "PROJECT_VERSION_TWEAK")
SET (PROJECT_VERSION_STRING "${PROJECT_VERSION_STRING}.${PROJECT_VERSION_TWEAK}")
ENDIF ()
ENDIF ()
ENDIF ()
IF (NOT DEFINED PROJECT_VERSION_STRING)
# Versioning using current date / time
STRING (TIMESTAMP CURRENT_YEAR %Y UTC)
STRING (TIMESTAMP CURRENT_MONTH %m UTC)
STRING (TIMESTAMP CURRENT_DAY %d UTC)
STRING (TIMESTAMP CURRENT_DAY_OF_YEAR %j UTC)
SET (PROJECT_VERSION_MAJOR ${CURRENT_YEAR})
SET (PROJECT_VERSION_MINOR ${CURRENT_MONTH})
SET (PROJECT_VERSION_PATCH ${CURRENT_DAY})
SET (PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
ENDIF ()
MESSAGE (STATUS "Version: ${PROJECT_VERSION_STRING}")
## Project Configuration
PROJECT (${PROJECT_NAME} VERSION ${PROJECT_VERSION_STRING} LANGUAGES "C" "CXX")
SET (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited Configs" FORCE)
IF (BUILD_CODE_COVERAGE)
SET (CMAKE_BUILD_TYPE "Debug")
ELSEIF (NOT CMAKE_BUILD_TYPE)
SET (CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type [None|Debug|Release|RelWithDebInfo|MinSizeRel]." FORCE)
ENDIF ()
## Flags
### C++ 17/20 support
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
IF (BUILD_WITH_CXX_17 OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
SET (CMAKE_CXX_STANDARD 17)
MESSAGE (STATUS "C++17 support enabled")
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
MESSAGE (FATAL_ERROR "GCC version must be at least 7.0 to build with C++17")
ENDIF ()
ELSE ()
MESSAGE (STATUS "C++20 support enabled")
SET (CMAKE_CXX_STANDARD 20)
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0)
MESSAGE (FATAL_ERROR "GCC version must be at least 13.0 to build with C++20")
ENDIF ()
ENDIF ()
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wshadow -Wno-deprecated")
ELSE ()
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wshadow")
ENDIF ()
SET (CMAKE_CXX_STANDARD_REQUIRED ON)
SET (CMAKE_CXX_EXTENSIONS OFF)
### Debug Symbols
IF (BUILD_WITH_DEBUG_SYMBOLS)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
ENDIF ()
### Debugging Options
SET (CMAKE_VERBOSE_MAKEFILE 0) # Use 1 for debugging, 0 for release
## Paths
### Search Paths
LIST (APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}")
LIST (APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/tools")
LIST (APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/thirdparty")
### Output Paths
SET (EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/bin")
SET (LIBRARY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/lib")
SET (DOCS_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/docs")
IF (WIN32)
SET (INSTALL_ROOT ".") # C:\Programme\<project>
SET (INSTALL_DATA "bin") # C:\Programme\<project>
SET (INSTALL_BIN "bin") # C:\Programme\<project>
SET (INSTALL_LIB "lib") # C:\Programme\<project>\lib
SET (INSTALL_INCLUDE "include") # C:\Programme\<project>\include
SET (INSTALL_DOC "doc") # C:\Programme\<project>\doc
SET (INSTALL_SHORTCUTS ".") # Not available under Windows
SET (INSTALL_ICONS ".") # Not available under Windows
SET (INSTALL_INIT ".") # Not available under Windows
ELSE ()
SET (INSTALL_ROOT "share/${PROJECT_PATH}") # /usr/[local]/share/<project>
SET (INSTALL_DATA "share/${PROJECT_PATH}") # /usr/[local]/share/<project>
SET (INSTALL_BIN "bin") # /usr/[local]/bin
SET (INSTALL_LIB "lib") # /usr/[local]/lib
SET (INSTALL_TEST "test/${PROJECT_PATH}") # /usr/[local]/test/<project>
SET (INSTALL_INCLUDE "include/${PROJECT_PATH}") # /usr/[local]/include/<project>
SET (INSTALL_DOC "share/doc/${PROJECT_PATH}") # /usr/[local]/share/doc/<project>
SET (INSTALL_SHORTCUTS "share/applications") # /usr/[local]/share/applications
SET (INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts)
ENDIF ()
## Configure Files
FILE (GLOB_RECURSE CONFIGINPUTS1 "include/*.in.hpp.cmake")
FILE (GLOB_RECURSE CONFIGINPUTS2 "include/*.hpp.in.cmake")
FILE (GLOB_RECURSE CONFIGINPUTS3 "src/*.in.hpp.cmake")
FILE (GLOB_RECURSE CONFIGINPUTS4 "src/*.hpp.in.cmake")
FILE (GLOB_RECURSE CONFIGINPUTS5 "test/*.in.hpp.cmake")
FILE (GLOB_RECURSE CONFIGINPUTS6 "test/*.hpp.in.cmake")
LIST (APPEND CONFIGINPUTS "${CONFIGINPUTS1}")
LIST (APPEND CONFIGINPUTS "${CONFIGINPUTS2}")
LIST (APPEND CONFIGINPUTS "${CONFIGINPUTS3}")
LIST (APPEND CONFIGINPUTS "${CONFIGINPUTS4}")
LIST (APPEND CONFIGINPUTS "${CONFIGINPUTS5}")
LIST (APPEND CONFIGINPUTS "${CONFIGINPUTS6}")
FOREACH (CONFIGINPUT ${CONFIGINPUTS})
STRING (REPLACE ".in.hpp.cmake" ".h" CONFIGOUTPUT1 "${CONFIGINPUT}")
STRING (REPLACE ".hpp.in.cmake" ".h" CONFIGOUTPUT2 "${CONFIGOUTPUT1}")
CONFIGURE_FILE ("${CONFIGINPUT}" "${CONFIGOUTPUT2}")
ENDFOREACH ()
## Dependencies
### Boost [1.82.0]
SET (Boost_USE_STATIC_LIBS ON)
SET (Boost_USE_MULTITHREADED ON)
FIND_PACKAGE ("Boost" "1.82" REQUIRED COMPONENTS "date_time" "regex" "filesystem")
## Stacktrace definitions
# Detect system architecture
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
# Architecture-specific include for x86_64
set(BACKTRACE_INCLUDE "/usr/lib/gcc/x86_64-linux-gnu/9/include/backtrace.h")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
# Example path adjustment for aarch64, adjust the path as needed
set(BACKTRACE_INCLUDE "/usr/lib/gcc/aarch64-linux-gnu/9/include/backtrace.h")
else()
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
# Add definitions with architecture-specific path
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
ADD_DEFINITIONS(-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=<${BACKTRACE_INCLUDE}>)
IF (NOT Boost_FOUND)
MESSAGE (SEND_ERROR "[Boost] not found.")
ENDIF ()
### NRLMSISE-00 Model
FIND_PACKAGE ("NRLMSISE-00" REQUIRED)
IF (NRLMSISE-00_FOUND)
INCLUDE_DIRECTORIES (${NRLMSISE-00_INCLUDE_DIRS})
LINK_DIRECTORIES (${NRLMSISE-00_LIBRARY_DIRS})
ELSE ()
MESSAGE (SEND_ERROR "[NRLMSISE-00] not found.")
ENDIF ()
### Eigen [3]
FIND_PACKAGE ("Eigen3" REQUIRED)
IF (EIGEN3_FOUND)
INCLUDE_DIRECTORIES (${EIGEN3_INCLUDE_DIR})
ELSE ()
MESSAGE (SEND_ERROR "[Eigen 3] not found.")
ENDIF ()
### IAU SOFA
FIND_PACKAGE ("SOFA" REQUIRED)
IF (SOFA_FOUND)
INCLUDE_DIRECTORIES (${SOFA_INCLUDE_DIRS})
LINK_DIRECTORIES (${SOFA_LIBRARY_DIRS})
ELSE ()
MESSAGE (SEND_ERROR "[IAU SOFA] not found.")
ENDIF ()
### SPICE Toolkit
FIND_PACKAGE ("SPICEToolkit" REQUIRED)
IF (SPICEToolkit_FOUND)
INCLUDE_DIRECTORIES (${SPICEToolkit_INCLUDE_DIRS})
LINK_DIRECTORIES (${SPICEToolkit_LIBRARY_DIRS})
ELSE ()
MESSAGE (SEND_ERROR "[SPICE Toolkit] not found.")
ENDIF ()
### GeographicLib
FIND_PACKAGE ("GeographicLib" REQUIRED)
IF (GEOGRAPHICLIB_FOUND)
INCLUDE_DIRECTORIES (${GEOGRAPHICLIB_INCLUDE_DIRS})
LINK_DIRECTORIES (${GEOGRAPHICLIB_LIBRARY_DIRS})
ELSE ()
MESSAGE (SEND_ERROR "[GeographicLib] not found.")
ENDIF ()
### Open Space Toolkit ▸ Core [4.x.y]
FIND_PACKAGE ("OpenSpaceToolkitCore" "4" REQUIRED)
IF (NOT OpenSpaceToolkitCore_FOUND)
MESSAGE (SEND_ERROR "[Open Space Toolkit ▸ Core] not found.")
ENDIF ()
### Open Space Toolkit ▸ I/O [4.x.y]
FIND_PACKAGE ("OpenSpaceToolkitIO" "4" REQUIRED)
IF (NOT OpenSpaceToolkitIO_FOUND)
MESSAGE (SEND_ERROR "[Open Space Toolkit ▸ I/O] not found.")
ENDIF ()
### Open Space Toolkit ▸ Mathematics [4.x.y]
FIND_PACKAGE ("OpenSpaceToolkitMathematics" "4" REQUIRED)
IF (NOT OpenSpaceToolkitMathematics_FOUND)
MESSAGE (SEND_ERROR "[Open Space Toolkit ▸ Mathematics] not found.")
ENDIF ()
#####################################################################################3###########################################################################
## Versioning
IF (DEFINED PROJECT_VERSION_STRING AND EXISTS "${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/Utility/Version.cpp.in")
CONFIGURE_FILE ("${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/Utility/Version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/${PROJECT_PATH}/Utility/Version.cpp" @ONLY)
ENDIF ()
## Targets
### Shared Library
IF (BUILD_SHARED_LIBRARY)
SET (SHARED_LIBRARY_NAME "${PROJECT_PACKAGE_NAME}")
SET (SHARED_LIBRARY_TARGET "lib${SHARED_LIBRARY_NAME}.so")
FILE (GLOB_RECURSE SHARED_LIBRARY_HEADERS "${PROJECT_SOURCE_DIR}/include/${PROJECT_PATH}/*.hpp")
FILE (GLOB_RECURSE SHARED_LIBRARY_SRCS "${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/*.cpp")
IF (APPLE)
SET (CMAKE_MACOSX_RPATH ON)
ENDIF (APPLE)
ADD_LIBRARY (${SHARED_LIBRARY_TARGET} SHARED ${SHARED_LIBRARY_SRCS})
TARGET_INCLUDE_DIRECTORIES (${SHARED_LIBRARY_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include/")
TARGET_INCLUDE_DIRECTORIES (${SHARED_LIBRARY_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/src/")
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} "dl")
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} "pthread")
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} "stdc++fs")
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} "Boost::date_time" "Boost::filesystem" "Boost::regex")
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${NRLMSISE-00_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${SOFA_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${SPICEToolkit_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${GEOGRAPHICLIB_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${OpenSpaceToolkitCore_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${OpenSpaceToolkitIO_LIBRARIES})
TARGET_LINK_LIBRARIES (${SHARED_LIBRARY_TARGET} ${OpenSpaceToolkitMathematics_LIBRARIES})
SET_TARGET_PROPERTIES (${SHARED_LIBRARY_TARGET} PROPERTIES VERSION ${PROJECT_VERSION_STRING} SOVERSION ${PROJECT_VERSION_MAJOR} OUTPUT_NAME ${SHARED_LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1 INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.hpp")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.tpp")
INSTALL (TARGETS ${SHARED_LIBRARY_TARGET} DESTINATION ${INSTALL_LIB} COMPONENT "libraries")
ENDIF ()
### Static Library
IF (BUILD_STATIC_LIBRARY)
SET (STATIC_LIBRARY_NAME "${PROJECT_PACKAGE_NAME}")
SET (STATIC_LIBRARY_TARGET "lib${STATIC_LIBRARY_NAME}.a")
FILE (GLOB_RECURSE STATIC_LIBRARY_HEADERS "${PROJECT_SOURCE_DIR}/include/${PROJECT_PATH}/*.hpp")
FILE (GLOB_RECURSE STATIC_LIBRARY_SRCS "${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/*.cpp")
ADD_LIBRARY (${STATIC_LIBRARY_TARGET} STATIC ${STATIC_LIBRARY_SRCS})
TARGET_INCLUDE_DIRECTORIES (${STATIC_LIBRARY_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include/")
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} "dl")
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} "pthread")
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} "stdc++fs")
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} "Boost::date_time" "Boost::filesystem" "Boost::regex")
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${NRLMSISE-00_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${SOFA_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${SPICEToolkit_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${GEOGRAPHICLIB_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${OpenSpaceToolkitCore_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${OpenSpaceToolkitIO_LIBRARIES})
TARGET_LINK_LIBRARIES (${STATIC_LIBRARY_TARGET} ${OpenSpaceToolkitMathematics_LIBRARIES})
SET_TARGET_PROPERTIES (${STATIC_LIBRARY_TARGET} PROPERTIES VERSION ${PROJECT_VERSION_STRING} OUTPUT_NAME ${STATIC_LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1 INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.hpp")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.tpp")
INSTALL (TARGETS ${STATIC_LIBRARY_TARGET} DESTINATION ${INSTALL_LIB} COMPONENT "libraries")
ENDIF ()
IF (BUILD_SCRIPT)
SET (UTILITY_NAME "${PROJECT_PACKAGE_NAME}")
SET (UTILITY_TARGET "${UTILITY_NAME}.exe")
FILE (GLOB_RECURSE UTILITY_HEADERS "${PROJECT_SOURCE_DIR}/include/${PROJECT_PATH}/*.hpp")
FILE (GLOB_RECURSE UTILITY_SRCS "${PROJECT_SOURCE_DIR}/scripts/*.cxx")
ADD_EXECUTABLE (${UTILITY_TARGET} ${UTILITY_SRCS})
TARGET_INCLUDE_DIRECTORIES (${UTILITY_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include/")
TARGET_LINK_LIBRARIES (${UTILITY_TARGET} "pthread")
TARGET_LINK_LIBRARIES (${UTILITY_TARGET} ${Boost_STACKTRACE_BACKTRACE_LIBRARY})
TARGET_LINK_LIBRARIES (${UTILITY_TARGET} ${SHARED_LIBRARY_TARGET})
SET_TARGET_PROPERTIES (${UTILITY_TARGET} PROPERTIES VERSION ${PROJECT_VERSION_STRING} OUTPUT_NAME ${SHARED_LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1 INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.hpp")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/src/${PROJECT_PATH}/" DESTINATION ${INSTALL_INCLUDE} COMPONENT "headers" FILES_MATCHING PATTERN "*.tpp")
INSTALL (TARGETS ${SHARED_LIBRARY_TARGET} DESTINATION ${INSTALL_LIB} COMPONENT "libraries")
ENDIF ()
### Unit Tests
IF (BUILD_UNIT_TESTS)
IF (NOT BUILD_SHARED_LIBRARY)
MESSAGE (SEND_ERROR "[Unit Tests] cannot be built without [Shared Library].")
ENDIF ()
SET (UNIT_TESTS_TARGET "${PROJECT_PACKAGE_NAME}.test")
ENABLE_TESTING ()
FILE (GLOB_RECURSE TEST_SRCS "${PROJECT_SOURCE_DIR}/test/${PROJECT_PATH}/*.test.cpp")
ADD_EXECUTABLE (${UNIT_TESTS_TARGET} ${TEST_SRCS})
ADD_DEPENDENCIES (${UNIT_TESTS_TARGET} ${SHARED_LIBRARY_TARGET})
FIND_PACKAGE ("GTest" QUIET)
IF (NOT GTEST_FOUND)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/thirdparty/gtest")
ADD_DEPENDENCIES (${UNIT_TESTS_TARGET} "googletest")
LIST (APPEND GTEST_BOTH_LIBRARIES "${GTEST_LIBS_DIR}/libgtest.a")
LIST (APPEND GTEST_BOTH_LIBRARIES "${GTEST_LIBS_DIR}/libgtest_main.a")
ENDIF ()
TARGET_INCLUDE_DIRECTORIES (${UNIT_TESTS_TARGET} PUBLIC ${GTEST_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES (${UNIT_TESTS_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include")
TARGET_INCLUDE_DIRECTORIES (${UNIT_TESTS_TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/test")
# TARGET_LINK_LIBRARIES (${UNIT_TESTS_TARGET} "GTest::GTest" "GTest::Main")
TARGET_LINK_LIBRARIES (${UNIT_TESTS_TARGET} "${GTEST_BOTH_LIBRARIES}")
TARGET_LINK_LIBRARIES (${UNIT_TESTS_TARGET} "gmock")
TARGET_LINK_LIBRARIES (${UNIT_TESTS_TARGET} "${SHARED_LIBRARY_TARGET}")
GTEST_DISCOVER_TESTS (${UNIT_TESTS_TARGET})
SET_TARGET_PROPERTIES (${UNIT_TESTS_TARGET} PROPERTIES VERSION ${PROJECT_VERSION_STRING} OUTPUT_NAME ${UNIT_TESTS_TARGET} CLEAN_DIRECT_OUTPUT 1 INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
INSTALL (TARGETS ${UNIT_TESTS_TARGET} DESTINATION ${INSTALL_TEST} COMPONENT "tests")
#### Code Coverage
IF (BUILD_CODE_COVERAGE)
SET (COVERAGE_TARGET "coverage")
INCLUDE (CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS ()
SET (COVERAGE_EXCLUDES '*.test.cpp' '/usr/*' '/app/bindings/*')
SETUP_TARGET_FOR_COVERAGE (
NAME ${COVERAGE_TARGET}
EXECUTABLE ${UNIT_TESTS_TARGET}
DEPENDENCIES "coverage"
)
ENDIF ()
ENDIF ()
### Python Bindings
IF (BUILD_PYTHON_BINDINGS)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/bindings/python")
ENDIF ()
### Documentation
IF (BUILD_DOCUMENTATION)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/docs")
ENDIF ()
### Configuration
CONFIGURE_FILE (
"${CMAKE_MODULE_PATH}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
@ONLY)
CONFIGURE_FILE (
"${CMAKE_MODULE_PATH}/${PROJECT_NAME}ConfigVersion.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
@ONLY)
INSTALL (FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION "${INSTALL_LIB}/${PROJECT_NAME}" COMPONENT "libraries")
INSTALL (FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${INSTALL_LIB}/${PROJECT_NAME}" COMPONENT "libraries")
### Uninstall
CONFIGURE_FILE (
"${CMAKE_MODULE_PATH}/UninstallTarget.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET ("uninstall" COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/UninstallTarget.cmake")
### Misc
INSTALL (FILES "LICENSE" DESTINATION ${INSTALL_ROOT} COMPONENT "documentation")
IF (EXISTS "${PROJECT_SOURCE_DIR}/share")
INSTALL (DIRECTORY "${PROJECT_SOURCE_DIR}/share/" DESTINATION ${INSTALL_DATA} COMPONENT "data")
ENDIF ()
## Packaging
SET (CPACK_PACKAGE_NAME ${PROJECT_PACKAGE_NAME})
SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})
SET (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/LICENSE")
SET (CPACK_PACKAGE_SUMMARY ${PROJECT_NAME})
SET (CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR_NAME})
SET (CPACK_PACKAGE_CONTACT ${PROJECT_VENDOR_CONTACT})
SET (CPACK_PACKAGE_LICENSE ${PROJECT_LICENSE})
SET (CPACK_PACKAGE_VERSION ${PROJECT_VERSION_STRING})
SET (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
SET (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
SET (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
SET (CPACK_PACKAGE_RELEASE 1)
SET (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
SET (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
SET (CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
SET (CPACK_COMPONENTS_ALL "applications" "headers" "libraries" "documentation" "tests" "data" "python")
SET (CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Applications")
SET (CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Headers")
SET (CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
SET (CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation")
SET (CPACK_COMPONENT_TESTS_DISPLAY_NAME "Unit Tests")
SET (CPACK_COMPONENT_DATA_DISPLAY_NAME "Shared Data")
SET (CPACK_COMPONENT_PYTHON_DISPLAY_NAME "Python Bindings")
SET (CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "Applications")
SET (CPACK_COMPONENT_HEADERS_DESCRIPTION "Headers")
SET (CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Libraries")
SET (CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "Documentation")
SET (CPACK_COMPONENT_TESTS_DESCRIPTION "Unit Tests")
SET (CPACK_COMPONENT_DATA_DESCRIPTION "Shared Data")
SET (CPACK_COMPONENT_PYTHON_DESCRIPTION "Python Bindings")
SET (CPACK_COMPONENT_APPLICATIONS_DEPENDS "libraries")
SET (CPACK_COMPONENT_HEADERS_DEPENDS "libraries")
SET (CPACK_COMPONENT_LIBRARIES_DEPENDS "data")
SET (CPACK_COMPONENT_PYTHON_DEPENDS "libraries")
SET (CPACK_COMPONENT_APPLICATIONS_GROUP "runtime")
SET (CPACK_COMPONENT_HEADERS_GROUP "devel")
SET (CPACK_COMPONENT_LIBRARIES_GROUP "runtime")
SET (CPACK_COMPONENT_DOCUMENTATION_GROUP "devel")
SET (CPACK_COMPONENT_TESTS_GROUP "devel")
SET (CPACK_COMPONENT_DATA_GROUP "runtime")
SET (CPACK_COMPONENT_PYTHON_GROUP "python")
SET (CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "Runtime")
SET (CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION "Development tools")
SET (CPACK_COMPONENT_GROUP_PYTHON_DESCRIPTION "Python bindings")
SET (CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
SET (CPACK_DEB_COMPONENT_INSTALL "ON")
SET (CPACK_RPM_COMPONENT_INSTALL "ON")
SET (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
/usr
/usr/bin
/usr/include
/usr/lib
/usr/share
/usr/local
/usr/local/bin
/usr/local/include
/usr/local/lib
/usr/local/share
/usr/share/man
)
INCLUDE (CPack)