forked from openigtlink/OpenIGTLink
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
308 lines (240 loc) · 11.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
PROJECT( OpenIGTLink )
cmake_minimum_required(VERSION 2.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
#-----------------------------------------------------------------------------
# OpenIGTlink version number.
SET(OpenIGTLink_VERSION_MAJOR "3")
SET(OpenIGTLink_VERSION_MINOR "1")
SET(OpenIGTLink_VERSION_PATCH "0")
option(OpenIGTLink_PROTOCOL_VERSION_2 "Build Library for Protocol Version 2" ON)
option(OpenIGTLink_PROTOCOL_VERSION_3 "Build Library for Protocol Version 3" ON)
SET(OpenIGTLink_HEADER_VERSION "1")
IF(OpenIGTLink_PROTOCOL_VERSION_3)
SET(OpenIGTLink_PROTOCOL_VERSION "3")
SET(OpenIGTLink_HEADER_VERSION "2")
ELSEIF(OpenIGTLink_PROTOCOL_VERSION_2)
SET(OpenIGTLink_PROTOCOL_VERSION "2")
ELSE()
SET(OpenIGTLink_PROTOCOL_VERSION "1")
ENDIF()
#-----------------------------------------------------------------------------
# Configure VideoStreaming
#Configure VideoStream
OPTION(BUILD_VIDEOSTREAM "Build the Video Stream." OFF)
IF(BUILD_VIDEOSTREAM)
OPTION(LINK_H264 "Link the OpenH264 tree." OFF)
SET(OpenIGTLink_LINK_H264 "0")
IF(LINK_H264)
SET(OpenIGTLink_LINK_H264 "1")
ENDIF()
OPTION(LINK_VP9 "Link the VP9 tree." OFF)
SET(OpenIGTLink_LINK_VP9 "0")
IF(LINK_VP9)
SET(OpenIGTLink_LINK_VP9 "1")
ENDIF()
OPTION(LINK_X265 "Link the X265 tree." OFF)
SET(OpenIGTLink_LINK_X265 "0")
IF(LINK_X265)
SET(OpenIGTLink_LINK_X265 "1")
ENDIF()
OPTION(LINK_OPENHEVC "Link the OpenHevc tree." OFF)
SET(OpenIGTLink_LINK_OPENHEVC "0")
IF(LINK_OPENHEVC)
SET(OpenIGTLink_LINK_OPENHEVC "1")
ENDIF()
ENDIF()
#-----------------------------------------------------------------------------
#Configure WebSocket
OPTION(BUILD_WEBSOCKET "Build the Websocket." OFF)
SET(OpenIGTLink_BUILD_WEBSOCKET "0")
IF(BUILD_WEBSOCKET)
SET(OpenIGTLink_BUILD_WEBSOCKET "1")
ENDIF()
#-----------------------------------------------------------------------------
# OpenIGTLink build configuration options.
OPTION(BUILD_SHARED_LIBS "Build OpenIGTLink with shared libraries." OFF)
SET(OpenIGTLink_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
if(NOT OpenIGTLink_BUILD_SHARED_LIBS)
OPTION(BUILD_GENERATE_PIC "Generate position independent code (for static)." ON)
SET(OpenIGTLink_BUILD_GENERATE_PIC ${BUILD_GENERATE_PIC})
endif(NOT OpenIGTLink_BUILD_SHARED_LIBS)
OPTION(BUILD_EXAMPLES "Build OpenIGTLink example programs." OFF)
SET(OpenIGTLink_BUILD_EXAMPLES ${BUILD_EXAMPLES})
#-----------------------------------------------------------------------------
# Output directories.
IF(NOT LIBRARY_OUTPUT_PATH)
SET (LIBRARY_OUTPUT_PATH ${OpenIGTLink_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
ENDIF(NOT LIBRARY_OUTPUT_PATH)
IF(NOT EXECUTABLE_OUTPUT_PATH)
SET (EXECUTABLE_OUTPUT_PATH ${OpenIGTLink_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
SET(OpenIGTLink_LIBRARY_PATH "${LIBRARY_OUTPUT_PATH}")
SET(OpenIGTLink_EXECUTABLE_PATH "${EXECUTABLE_OUTPUT_PATH}")
SET(OpenIGTLink_CMAKE_DIR "${OpenIGTLink_SOURCE_DIR}/CMake")
SET(CMAKE_MODULE_PATH "${OpenIGTLink_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
#-----------------------------------------------------------------------------
# Installation vars.
# OpenIGTLink_INSTALL_BIN_DIR - binary dir (executables)
# OpenIGTLink_INSTALL_LIB_DIR - library dir (libs)
# OpenIGTLink_INSTALL_DATA_DIR - share dir (say, examples, data, etc)
# OpenIGTLink_INSTALL_INCLUDE_DIR - include dir (headers)
# OpenIGTLink_INSTALL_PACKAGE_DIR - package/export configuration files
# OpenIGTLink_INSTALL_NO_DEVELOPMENT - do not install development files
# OpenIGTLink_INSTALL_NO_RUNTIME - do not install runtime files
# OpenIGTLink_INSTALL_NO_DOCUMENTATION - do not install documentation files
IF(NOT OpenIGTLink_INSTALL_BIN_DIR)
SET(OpenIGTLink_INSTALL_BIN_DIR "bin")
ENDIF(NOT OpenIGTLink_INSTALL_BIN_DIR)
IF(NOT OpenIGTLink_INSTALL_LIB_DIR)
SET(OpenIGTLink_INSTALL_LIB_DIR "lib/igtl")
ENDIF(NOT OpenIGTLink_INSTALL_LIB_DIR)
IF(NOT OpenIGTLink_INSTALL_DATA_DIR)
SET(OpenIGTLink_INSTALL_DATA_DIR "share/igtl")
ENDIF(NOT OpenIGTLink_INSTALL_DATA_DIR)
IF(NOT OpenIGTLink_INSTALL_INCLUDE_DIR)
SET(OpenIGTLink_INSTALL_INCLUDE_DIR "include/igtl")
ENDIF(NOT OpenIGTLink_INSTALL_INCLUDE_DIR)
IF(NOT OpenIGTLink_INSTALL_PACKAGE_DIR)
SET(OpenIGTLink_INSTALL_PACKAGE_DIR "${OpenIGTLink_INSTALL_LIB_DIR}/cmake/igtl-${OpenIGTLink_VERSION_MAJOR}.${OpenIGTLink_VERSION_MINOR}"
CACHE INTERNAL "")
ENDIF(NOT OpenIGTLink_INSTALL_PACKAGE_DIR)
IF(NOT OpenIGTLink_INSTALL_NO_DOCUMENTATION)
SET(OpenIGTLink_INSTALL_NO_DOCUMENTATION 0)
ENDIF(NOT OpenIGTLink_INSTALL_NO_DOCUMENTATION)
SET(OpenIGTLink_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "OpenIGTLink dir to be used by subprojects")
#-----------------------------------------------------------------------------
# Include directories
SET(OpenIGTLink_INCLUDE_DIRS_BUILD_TREE ${OpenIGTLink_INCLUDE_DIRS_BUILD_TREE}
${OpenIGTLink_BINARY_DIR}
${OpenIGTLink_SOURCE_DIR}/Source
${OpenIGTLink_SOURCE_DIR}/Source/igtlutil
)
INCLUDE_DIRECTORIES(
${OpenIGTLink_INCLUDE_DIRS_BUILD_TREE}
)
#-----------------------------------------------------------------------------
# OpenIGTLink requires special compiler flags on some platforms.
INCLUDE (FindThreads)
IF(CMAKE_COMPILER_IS_GNUCXX)
# '-fno-tree-vectorize' option is added to avoid segmentation fault that occurs in
# igtl_image_convert_byte_order() (Source/igtlutil/igtl_image.c) built with 'Release'
# option on 64-bit Linux.
INCLUDE (CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-fno-tree-vectorize" OpenIGTLink_GNUCXX_TREE_VECTORIZE_SUPPORT)
IF (OpenIGTLink_GNUCXX_TREE_VECTORIZE_SUPPORT)
SET(OpenIGTLink_REQUIRED_C_FLAGS "${OpenIGTLink_REQUIRED_C_FLAGS} -w -fno-tree-vectorize")
SET(OpenIGTLink_REQUIRED_CXX_FLAGS "${OpenIGTLink_REQUIRED_CXX_FLAGS} -ftemplate-depth-50 -fno-tree-vectorize")
ENDIF (OpenIGTLink_GNUCXX_TREE_VECTORIZE_SUPPORT)
# If the library is built as a static library, pass -fPIC option to the compiler
IF(OpenIGTLink_BUILD_GENERATE_PIC)
SET(OpenIGTLink_REQUIRED_C_FLAGS "${OpenIGTLink_REQUIRED_C_FLAGS} -fPIC")
SET(OpenIGTLink_REQUIRED_CXX_FLAGS "${OpenIGTLink_REQUIRED_CXX_FLAGS} -fPIC")
ENDIF(OpenIGTLink_BUILD_GENERATE_PIC)
# pthread
IF(CMAKE_HAVE_THREADS_LIBRARY)
SET(OpenIGTLink_REQUIRED_LINK_FLAGS "${OpenIGTLink_REQUIRED_LINK_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
ENDIF(CMAKE_HAVE_THREADS_LIBRARY)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
# for the gnu compiler a -D_PTHREADS is needed on sun
# for the native compiler a -mt flag is needed on the sun
IF(CMAKE_USE_PTHREADS)
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(OpenIGTLink_REQUIRED_CXX_FLAGS "${OpenIGTLink_REQUIRED_CXX_FLAGS} -D_PTHREADS")
ELSE(CMAKE_COMPILER_IS_GNUCXX)
SET(OpenIGTLink_REQUIRED_CXX_FLAGS "${OpenIGTLink_REQUIRED_CXX_FLAGS} -mt")
SET(OpenIGTLink_REQUIRED_C_FLAGS "${OpenIGTLink_REQUIRED_C_FLAGS} -mt")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
ENDIF(CMAKE_USE_PTHREADS)
#-----------------------------------------------------------------------------
# Platform configuration tests.
# Socket tests etc.
INCLUDE(${OpenIGTLink_CMAKE_DIR}/OpenIGTLinkCMakeTests.cmake)
SET(OpenIGTLink_LIBRARY_TARGETS_FILE "${CMAKE_BINARY_DIR}/OpenIGTLinkTargets.cmake")
#-----------------------------------------------------------------------------
# Generate Configuration Header files.
include (${OpenIGTLink_SOURCE_DIR}/OpenIGTLinkConfigPlatform.cmake)
CONFIGURE_FILE(${OpenIGTLink_SOURCE_DIR}/igtlConfigure.h.in
${OpenIGTLink_BINARY_DIR}/igtlConfigure.h)
CONFIGURE_FILE(${OpenIGTLink_SOURCE_DIR}/igtl_typeconfig.h.in
${OpenIGTLink_BINARY_DIR}/igtl_typeconfig.h)
CONFIGURE_FILE(${OpenIGTLink_SOURCE_DIR}/igtlTypeConfig.h.in
${OpenIGTLink_BINARY_DIR}/igtlTypeConfig.h)
#-----------------------------------------------------------------------------
# Help other projects use OpenIGTLink.
# Copy the UseOpenIGTLink.cmake file to the binary tree for backward compatability.
CONFIGURE_FILE(${OpenIGTLink_SOURCE_DIR}/UseOpenIGTLink.cmake.in
${OpenIGTLink_BINARY_DIR}/UseOpenIGTLink.cmake COPYONLY IMMEDIATE)
# Create the OpenIGTLinkConfig.cmake file containing the OpenIGTLink configuration.
INCLUDE (${OpenIGTLink_SOURCE_DIR}/GenerateOpenIGTLinkConfig.cmake)
# Save the compiler settings so another project can import them.
INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake)
CMAKE_EXPORT_BUILD_SETTINGS(${OpenIGTLink_BINARY_DIR}/OpenIGTLinkBuildSettings.cmake)
# Save library dependencies.
#EXPORT_LIBRARY_DEPENDENCIES(${OpenIGTLink_BINARY_DIR}/OpenIGTLinkLibraryDepends.cmake)
INSTALL(FILES
${OpenIGTLink_BINARY_DIR}/OpenIGTLinkBuildSettings.cmake
${OpenIGTLink_BINARY_DIR}/UseOpenIGTLink.cmake
${OpenIGTLink_BINARY_DIR}/Utilities/OpenIGTLinkConfig.cmake
DESTINATION ${OpenIGTLink_INSTALL_PACKAGE_DIR}
COMPONENT Development
)
INSTALL(FILES
${OpenIGTLink_BINARY_DIR}/igtlConfigure.h
DESTINATION ${OpenIGTLink_INSTALL_INCLUDE_DIR}
COMPONENT Development
)
INSTALL(FILES
${OpenIGTLink_BINARY_DIR}/igtl_typeconfig.h
DESTINATION ${OpenIGTLink_INSTALL_INCLUDE_DIR}
COMPONENT Development
)
INSTALL(FILES
${OpenIGTLink_BINARY_DIR}/igtlTypeConfig.h
DESTINATION ${OpenIGTLink_INSTALL_INCLUDE_DIR}
COMPONENT Development
)
#-----------------------------------------------------------------------------
# Add compiler flags OpenIGTLink needs to work on this platform. This must be
# done AFTER the call to CMAKE_EXPORT_BUILD_SETTINGS.
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenIGTLink_REQUIRED_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenIGTLink_REQUIRED_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenIGTLink_REQUIRED_LINK_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenIGTLink_REQUIRED_LINK_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OpenIGTLink_REQUIRED_LINK_FLAGS}")
#-----------------------------------------------------------------------------
# Configure Subdirectories
ADD_SUBDIRECTORY(Source)
ADD_SUBDIRECTORY(Tools)
IF(OpenIGTLink_BUILD_EXAMPLES)
ADD_SUBDIRECTORY(Examples)
ENDIF(OpenIGTLink_BUILD_EXAMPLES)
#-----------------------------------------------------------------------------
# Export targets
export(TARGETS OpenIGTLink
FILE "${OpenIGTLink_LIBRARY_TARGETS_FILE}"
)
# Export targets for install
INSTALL(EXPORT OpenIGTLink
DESTINATION "${OpenIGTLink_INSTALL_PACKAGE_DIR}"
FILE "OpenIGTLinkTargets.cmake"
)
#-----------------------------------------------------------------------------
# Tests
OPTION(BUILD_TESTING "Build the testing tree." ON)
SET(OpenIGTLink_BUILD_TESTING ${BUILD_TESTING})
IF(OpenIGTLink_BUILD_TESTING)
ENABLE_TESTING()
ADD_SUBDIRECTORY(Testing)
INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)
ENDIF()
#-----------------------------------------------------------------------------
# Doxygen
OPTION(BUILD_DOCUMENTATION "Build OpenIGTLink Documentation" OFF)
IF(BUILD_DOCUMENTATION)
ADD_SUBDIRECTORY( Documents/Doxygen )
ENDIF(BUILD_DOCUMENTATION)