-
Notifications
You must be signed in to change notification settings - Fork 103
/
CMakeLists.txt
277 lines (248 loc) · 11.6 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
PROJECT(PlusLib)
CMAKE_MINIMUM_REQUIRED(VERSION 3.3.0)
# Cache C++ standard to allow setting externally
SET(_minimum_cxx_standard "11")
SET(CMAKE_CXX_STANDARD "${_minimum_cxx_standard}" CACHE STRING "C++ standard")
IF("${CMAKE_CXX_STANDARD}" LESS "${_minimum_cxx_standard}")
MESSAGE(FATAL_ERROR "CMAKE_CXX_STANDARD must be equal or larger than ${_minimum_cxx_standard}")
ENDIF()
SET(CMAKE_CXX_STANDARD_REQUIRED ON CACHE STRING "C++ standard required")
INCLUDE(CMake/PlusLibMacros.cmake)
# ------------------------------------------------------------------------
# Set project version number
SET(PLUSLIB_VERSION_MAJOR "2")
SET(PLUSLIB_VERSION_MINOR "9")
SET(PLUSLIB_VERSION_PATCH "0")
SET(PLUSLIB_VERSION ${PLUSLIB_VERSION_MAJOR}.${PLUSLIB_VERSION_MINOR}.${PLUSLIB_VERSION_PATCH})
# Set project install folders, these paths should be relative to ${CMAKE_INTALL_PREFIX}, absolute paths will break things
SET(PLUSLIB_INSTALL_FOLDERNAME "PlusLib-${PLUSLIB_VERSION_MAJOR}.${PLUSLIB_VERSION_MINOR}")
SET(PLUSLIB_BINARY_INSTALL "bin")
SET(PLUSLIB_INCLUDE_INSTALL "include/${PLUSLIB_INSTALL_FOLDERNAME}")
SET(PLUSLIB_LIBRARY_INSTALL "lib")
SET(PLUSLIB_ARCHIVE_INSTALL "lib")
SET(PLUSLIB_DATA_INSTALL "data")
SET(PLUSLIB_CMAKE_INSTALL "lib/cmake/${PLUSLIB_INSTALL_FOLDERNAME}")
SET(PLUSLIB_SHARE_INSTALL "share/${PLUSLIB_INSTALL_FOLDERNAME}")
# Use solution folders.
IF(MSVC OR ${CMAKE_GENERATOR} MATCHES "Xcode")
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET_PROPERTY(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets")
SET_PROPERTY(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "AutoGen (Qt) Targets")
ENDIF()
MESSAGE(STATUS "Configuring PLUS toolkit version ${PLUSLIB_VERSION}.")
IF(MSVC OR ${CMAKE_GENERATOR} MATCHES "Xcode")
IF( ${CMAKE_VS_PLATFORM_NAME} MATCHES "x64")
SET(PLUSLIB_PLATFORM "Win64" CACHE STRING "Name of the platform this instance of PlusLib is built on")
ELSE()
SET(PLUSLIB_PLATFORM "Win32" CACHE STRING "Name of the platform this instance of PlusLib is built on")
ENDIF()
ELSE()
IF(APPLE)
SET(PLUSLIB_PLATFORM "OSX" CACHE STRING "Name of the platform this instance of PlusLib is built on")
ELSE()
SET(PLUSLIB_PLATFORM "Linux" CACHE STRING "Name of the platform this instance of PlusLib is built on")
ENDIF()
ENDIF()
MESSAGE(STATUS "Detected platform: ${PLUSLIB_PLATFORM}.")
# --------------------------------------------------------------------------
# System Settings
IF(WIN32)
# This method adds the necessary compiler flag
SET(RUNTIME_MINIMUM_WINDOWS_VERSION "0x0602")
ADD_DEFINITIONS(-D_MSC_PLATFORM_TOOLSET_$(PlatformToolset))
ENDIF()
# --------------------------------------------------------------------------
# Testing
#
OPTION(BUILD_TESTING "Build test programs" ON)
INCLUDE(CTest)
# Clean up the IDE folder name for CTest dashboard targets
IF(BUILD_TESTING)
FOREACH(mode Experimental Nightly Continuous NightlyMemoryCheck)
IF(TARGET ${mode})
SET_PROPERTY(TARGET ${mode} PROPERTY FOLDER "CTest Targets")
ENDIF()
ENDFOREACH()
ENDIF()
# --------------------------------------------------------------------------
# Repository
#
IF(PLUS_OFFLINE_BUILD)
SET(PLUSLIB_REVISION "NA")
SET(PLUSLIB_SHORT_REVISION "NA")
SET(PLUSLIB_COMMIT_DATE_NO_DASHES "NA")
SET(PLUSLIB_COMMIT_DATE "NA")
ELSE()
# Need git for the automatic update of the repository
FIND_PACKAGE(Git)
IF(Git_FOUND)
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
OUTPUT_VARIABLE PLUSLIB_REVISION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
STRING(REGEX REPLACE "\n$" "" PLUSLIB_REVISION "${PLUSLIB_REVISION}")
STRING(REGEX REPLACE "\r$" "" PLUSLIB_REVISION "${PLUSLIB_REVISION}")
MESSAGE(STATUS "Current git hash is ${PLUSLIB_REVISION}")
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
OUTPUT_VARIABLE PLUSLIB_SHORT_REVISION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
STRING(REGEX REPLACE "\n$" "" PLUSLIB_SHORT_REVISION "${PLUSLIB_SHORT_REVISION}")
STRING(REGEX REPLACE "\r$" "" PLUSLIB_SHORT_REVISION "${PLUSLIB_SHORT_REVISION}")
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} show ${PLUSLIB_REVISION} --date=iso8601
OUTPUT_VARIABLE _git_show_output
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
STRING(REGEX MATCH "([0-9])+-([0-9]+)-([0-9]+)" PLUSLIB_COMMIT_DATE ${_git_show_output})
STRING(REPLACE "-" "" PLUSLIB_COMMIT_DATE_NO_DASHES ${PLUSLIB_COMMIT_DATE})
ELSE()
MESSAGE(WARNING "Git tool not found. Cannot retrieve revision information from repository")
SET(PLUSLIB_REVISION "NA")
SET(PLUSLIB_SHORT_REVISION "NA")
ENDIF()
ENDIF()
# --------------------------------------------------------------------------
# Developer setup
#
IF(Git_FOUND)
GET_FILENAME_COMPONENT(_git_directory ${GIT_EXECUTABLE} DIRECTORY)
ENDIF()
SET(_x86env "ProgramFiles(x86)")
FIND_PROGRAM(BASH_EXECUTABLE bash
HINTS
${_git_directory}
$ENV{ProgramFiles}/Git/bin
$ENV{${_x86env}}/Git/bin
)
MARK_AS_ADVANCED(BASH_EXECUTABLE)
IF(BASH_EXECUTABLE)
EXECUTE_PROCESS(COMMAND "${BASH_EXECUTABLE}" -c "cd ${CMAKE_SOURCE_DIR} && ${CMAKE_SOURCE_DIR}/Utilities/SetupForDevelopment.sh copyOnly"
OUTPUT_VARIABLE _bashOutput
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}}
)
ENDIF()
# --------------------------------------------------------------------------
# Set up paths for data and SDKs
#
SET(PLUSLIB_TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Tools)
SET(ATC_TRAKSTAR_BASE_DIR ${PLUSLIB_TOOLS_DIR}/Ascension/trakSTAR_940041_RevE)
SET(ATC_TRAKSTAR_INCLUDE_DIR ${ATC_TRAKSTAR_BASE_DIR}/inc CACHE PATH "Path to the Ascension trakSTAR 3D Guidance include folder (where the ATC3DG.h file is located)" FORCE )
SET(ATC_TRAKSTAR_LIB_DIR ${ATC_TRAKSTAR_BASE_DIR}/lib CACHE PATH "Path to the Ascension trakSTAR 3D Guidance lib folder" FORCE )
SET(ATC_TRAKSTAR_BINARY_DIR ${ATC_TRAKSTAR_BASE_DIR}/bin CACHE PATH "Path to the Ascension trakSTAR 3D Guidance dll folder" FORCE )
SET(ATC_MEDSAFE_BASE_DIR ${PLUSLIB_TOOLS_DIR}/Ascension/medSAFE_940033_Rev_F)
SET(ATC_MEDSAFE_INCLUDE_DIR ${ATC_MEDSAFE_BASE_DIR}/inc CACHE PATH "Path to the Ascension medSAFE 3D Guidance include folder (where the ATC3DGm.h file is located)" FORCE )
SET(ATC_MEDSAFE_LIB_DIR ${ATC_MEDSAFE_BASE_DIR}/lib CACHE PATH "Path to the Ascension medSAFE 3D Guidance lib folder" FORCE )
SET(ATC_MEDSAFE_BINARY_DIR ${ATC_MEDSAFE_BASE_DIR}/bin CACHE PATH "Path to the Ascension medSAFE 3D Guidance dll folder" FORCE )
MARK_AS_ADVANCED(ATC_TRAKSTAR_BASE_DIR
ATC_TRAKSTAR_INCLUDE_DIR
ATC_TRAKSTAR_LIB_DIR
ATC_TRAKSTAR_BINARY_DIR
ATC_MEDSAFE_BASE_DIR
ATC_MEDSAFE_INCLUDE_DIR
ATC_MEDSAFE_LIB_DIR
ATC_MEDSAFE_BINARY_DIR
)
IF(PLUS_USE_Ascension3DG)
ADD_SUBDIRECTORY(${ATC_TRAKSTAR_BASE_DIR})
ENDIF()
IF(PLUS_USE_Ascension3DGm)
ADD_SUBDIRECTORY(${ATC_MEDSAFE_BASE_DIR})
ENDIF()
SET(PHIDGET_SPATIAL_BASE_DIR ${PLUSLIB_TOOLS_DIR}/Phidget/Phidget22)
SET(PHIDGET_SPATIAL_INCLUDE_DIR ${PHIDGET_SPATIAL_BASE_DIR} CACHE PATH "Path to the Phidget Spatial include folder" FORCE )
IF(MSVC AND "${CMAKE_VS_PLATFORM_NAME}" MATCHES "x64")
SET(PHIDGET_SPATIAL_LIB_DIR ${PHIDGET_SPATIAL_BASE_DIR}/x64 CACHE PATH "Path to the Phidget Spatial 64-bit lib folder" FORCE )
SET(PHIDGET_SPATIAL_BINARY_DIR ${PHIDGET_SPATIAL_BASE_DIR}/x64 CACHE PATH "Path to the Phidget Spatial 64-bit dll folder" FORCE )
ELSE()
SET(PHIDGET_SPATIAL_LIB_DIR ${PHIDGET_SPATIAL_BASE_DIR}/x86 CACHE PATH "Path to the Phidget Spatial 32-bit lib folder" FORCE )
SET(PHIDGET_SPATIAL_BINARY_DIR ${PHIDGET_SPATIAL_BASE_DIR}/x86 CACHE PATH "Path to the Phidget Spatial 32-bit dll folder" FORCE )
ENDIF()
MARK_AS_ADVANCED(PHIDGET_SPATIAL_BASE_DIR
PHIDGET_SPATIAL_INCLUDE_DIR
PHIDGET_SPATIAL_LIB_DIR
PHIDGET_SPATIAL_BINARY_DIR
)
IF(PLUS_USE_PHIDGET_SPATIAL_TRACKER)
ADD_SUBDIRECTORY(${PLUSLIB_TOOLS_DIR}/Phidget/Phidget22)
ENDIF()
SET(EPIPHAN_SDK_BASE_DIR ${PLUSLIB_TOOLS_DIR}/Epiphan)
SET(EPIPHAN_INCLUDE_DIR ${EPIPHAN_SDK_BASE_DIR} CACHE PATH "Path to the Epiphan SDK include directory." FORCE )
IF(MSVC AND "${CMAKE_VS_PLATFORM_NAME}" MATCHES "x64")
SET(EPIPHAN_BINARY_DIR ${EPIPHAN_SDK_BASE_DIR}/x64 CACHE PATH "Directory containing Epiphan shared library file." FORCE)
SET(EPIPHAN_LIB_DIR ${EPIPHAN_SDK_BASE_DIR}/x64 CACHE PATH "Directory containing Epiphan static library file." FORCE)
ELSE()
SET(EPIPHAN_BINARY_DIR ${EPIPHAN_SDK_BASE_DIR}/Win32 CACHE PATH "Directory containing Epiphan shared library file." FORCE)
SET(EPIPHAN_LIB_DIR ${EPIPHAN_SDK_BASE_DIR}/Win32 CACHE PATH "Directory containing Epiphan static library file." FORCE)
ENDIF()
MARK_AS_ADVANCED(EPIPHAN_SDK_BASE_DIR
EPIPHAN_INCLUDE_DIR
EPIPHAN_BINARY_DIR
EPIPHAN_LIB_DIR
)
IF(PLUS_USE_EPIPHAN)
ADD_SUBDIRECTORY(${PLUSLIB_TOOLS_DIR}/Epiphan)
ENDIF()
SET(USDIGITAL_SEI_BASE_DIR ${PLUSLIB_TOOLS_DIR}/UsDigital/SEI_5.22)
SET(USDIGITAL_SEI_INCLUDE_DIR ${USDIGITAL_SEI_BASE_DIR}/inc CACHE PATH "Path to the US Digital SEI include directory (needed for the CIVCO stepper)." FORCE )
SET(USDIGITAL_SEI_BINARY_DIR ${USDIGITAL_SEI_BASE_DIR}/bin CACHE PATH "Path to the US Digital SEI binary directory (needed for the CIVCO stepper)." FORCE )
SET(USDIGITAL_SEI_LIB_DIR ${USDIGITAL_SEI_BASE_DIR}/lib CACHE PATH "Path to the US Digital SEI library directory (needed for the CIVCO stepper)." FORCE )
MARK_AS_ADVANCED(USDIGITAL_SEI_BASE_DIR
USDIGITAL_SEI_INCLUDE_DIR
USDIGITAL_SEI_BINARY_DIR
USDIGITAL_SEI_LIB_DIR
)
IF(PLUS_USE_BRACHY_TRACKER)
ADD_SUBDIRECTORY(${PLUSLIB_TOOLS_DIR}/UsDigital/SEI_5.22)
ENDIF()
IF(WIN32)
SET(NVIDIA_DVP_BASE_DIR ${PLUSLIB_TOOLS_DIR}/NVidia/dvp170)
SET(NVIDIA_DVP_INCLUDE_DIR ${NVIDIA_DVP_BASE_DIR}/include CACHE PATH "Path to the NVidia DVP include directory." FORCE )
IF(MSVC AND ${CMAKE_VS_PLATFORM_NAME} MATCHES "x64")
SET(NVIDIA_DVP_BINARY_DIR ${NVIDIA_DVP_BASE_DIR}/bin/x64 CACHE PATH "Directory containing NVidia DVP shared library file." FORCE)
SET(NVIDIA_DVP_LIB_DIR ${NVIDIA_DVP_BASE_DIR}/lib/x64 CACHE PATH "Directory containing NVidia DVP static library file." FORCE)
ELSE()
SET(NVIDIA_DVP_BINARY_DIR ${NVIDIA_DVP_BASE_DIR}/bin/win32 CACHE PATH "Directory containing NVidia DVP shared library file." FORCE)
SET(NVIDIA_DVP_LIB_DIR ${NVIDIA_DVP_BASE_DIR}/lib/win32 CACHE PATH "Directory containing NVidia DVP static library file." FORCE)
ENDIF()
MARK_AS_ADVANCED(NVIDIA_DVP_BASE_DIR
NVIDIA_DVP_INCLUDE_DIR
NVIDIA_DVP_BINARY_DIR
NVIDIA_DVP_LIB_DIR
)
IF(PLUS_USE_NVIDIA_DVP)
ADD_SUBDIRECTORY(${PLUSLIB_TOOLS_DIR}/NVidia/dvp170)
ENDIF()
ENDIF()
INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("#include <future>
int main(){ return 0; }"
HAVE_FUTURE
)
# --------------------------------------------------------------------------
# Subdirs
#
ADD_SUBDIRECTORY(src)
#-----------------------------------------------------------------------------
# Generate convenience files for automatic build, test, and packaging
#
IF(WIN32)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/BuildAndTest.bat.in
${CMAKE_CURRENT_BINARY_DIR}/BuildAndTest.bat
)
# Documentation generator
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/CreateApiReference.bat.in
${CMAKE_CURRENT_BINARY_DIR}/CreateApiReference.bat
)
ELSE()
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/BuildAndTest.sh.in
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/BuildAndTest.sh
@ONLY
)
FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/BuildAndTest.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ
)
ENDIF()