[Repository Listing] / [Slicer3] / trunk / CMakeLists.txt
 

View of /trunk/CMakeLists.txt

Parent Directory Parent Directory Revision Log Revision Log


Revision 16883  Download Blame
File MIME type: text/plain
File size: 27598 byte(s)
COMP: Remove unused QTModules directory
1 PROJECT(Slicer3)
2
3 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
4 IF(COMMAND CMAKE_POLICY)
5 CMAKE_POLICY(SET CMP0003 NEW)
6 CMAKE_POLICY(SET CMP0012 NEW)
7 ENDIF(COMMAND CMAKE_POLICY)
8 MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
9
10
11 #-----------------------------------------------------------------------------
12 #
13 set(Slicer3_INSTALL_BIN_DIR "bin")
14 set(Slicer3_INSTALL_LIB_DIR "lib/Slicer3")
15 set(Slicer3_INSTALL_INCLUDE_DIR "include/Slicer3")
16 set(Slicer3_INSTALL_SHARE_DIR "share/Slicer3")
17 set(Slicer3_INSTALL_ITKFACTORIES_DIR "${Slicer3_INSTALL_LIB_DIR}/ITKFactories")
18
19 set(Slicer3_INSTALL_PLUGINS_BIN_DIR "${Slicer3_INSTALL_LIB_DIR}/Plugins")
20 set(Slicer3_INSTALL_PLUGINS_LIB_DIR "${Slicer3_INSTALL_LIB_DIR}/Plugins")
21 set(Slicer3_INSTALL_PLUGINS_INCLUDE_DIR "${Slicer3_INSTALL_INCLUDE_DIR}/Plugins")
22 set(Slicer3_INSTALL_PLUGINS_SHARE_DIR "${Slicer3_INSTALL_SHARE_DIR}/Plugins")
23 set(Slicer3_INSTALL_PLUGINS_CACHE_DIR "${Slicer3_INSTALL_LIB_DIR}/PluginsCache")
24
25 set(Slicer3_INSTALL_MODULES_BIN_DIR "${Slicer3_INSTALL_LIB_DIR}/Modules")
26 set(Slicer3_INSTALL_MODULES_LIB_DIR "${Slicer3_INSTALL_LIB_DIR}/Modules")
27 set(Slicer3_INSTALL_MODULES_INCLUDE_DIR "${Slicer3_INSTALL_INCLUDE_DIR}/Modules")
28 set(Slicer3_INSTALL_MODULES_SHARE_DIR "${Slicer3_INSTALL_SHARE_DIR}/Modules")
29
30 set(Slicer3_HOME "${Slicer3_BINARY_DIR}")
31
32 #-----------------------------------------------------------------------------
33 # Disable the warnings that DevStudio 2005 emits wrt to sprintf, strcpu, etc.
34 #
35 # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
36 # warnings (copied from ITK's CMake files so that ITK templated code will compile
37 # correctly).
38 IF(WIN32)
39 IF(NOT BORLAND)
40 IF(NOT CYGWIN)
41 IF(NOT MINGW)
42 ADD_DEFINITIONS(
43 -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
44 -D_CRT_IS_WCTYPE_NO_DEPRECATE
45 -D_CRT_MANAGED_FP_NO_DEPRECATE
46 -D_CRT_NONSTDC_NO_DEPRECATE
47 -D_CRT_SECURE_NO_DEPRECATE
48 -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
49 -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
50 -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
51 -D_CRT_VCCLRIT_NO_DEPRECATE
52 -D_SCL_SECURE_NO_DEPRECATE
53 )
54 ENDIF(NOT MINGW)
55 ENDIF(NOT CYGWIN)
56 ENDIF(NOT BORLAND)
57 ENDIF(WIN32)
58
59 #-----------------------------------------------------------------------------
60 # if compiling 64 bit on Windows we need to use /bigobj flag.
61 if(WIN32 AND "${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
62 set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" CACHE STRING "" FORCE)
63 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" CACHE STRING "" FORCE)
64 endif()
65
66 # include a test for endianness (used to be done by default)
67
68 include(${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
69 test_big_endian(CMAKE_WORDS_BIGENDIAN)
70
71 #-----------------------------------------------------------------------------
72 # avoid linker bug in Mac OS 10.5
73 # see:
74 # http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
75 #
76 if(APPLE)
77 set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
78 set(CMAKE_EXE_LINKER_FLAGS "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
79 endif(APPLE)
80
81 #-----------------------------------------------------------------------------
82 # Slicer version number.
83 #
84 set(Slicer3_VERSION_MAJOR "3")
85 set(Slicer3_VERSION_MINOR "6")
86 if(NOT Slicer3_VERSION_PATCH)
87 set(Slicer3_VERSION_PATCH "4-beta")
88 endif(NOT Slicer3_VERSION_PATCH)
89 set(Slicer3_VERSION "${Slicer3_VERSION_MAJOR}.${Slicer3_VERSION_MINOR}")
90 set(Slicer3_VERSION_FULL "${Slicer3_VERSION}.${Slicer3_VERSION_PATCH}")
91
92 #-----------------------------------------------------------------------------
93 # Build shared lib by default
94 #
95 option(BUILD_SHARED_LIBS "Build Slicer3 with shared libraries." ON)
96
97 #-----------------------------------------------------------------------------
98 # Append the library version information to the library target properties.
99 #
100 OPTION(Slicer3_WITH_LIBRARY_VERSION "Build with library version information" OFF)
101 IF(Slicer3_WITH_LIBRARY_VERSION)
102 SET(Slicer3_LIBRARY_PROPERTIES ${Slicer3_LIBRARY_PROPERTIES}
103 VERSION ${Slicer3_VERSION_FULL}
104 SOVERSION ${Slicer3_VERSION}
105 )
106 ENDIF(Slicer3_WITH_LIBRARY_VERSION)
107
108 #-----------------------------------------------------------------------------
109 # Slicer3 macros
110 #
111 set(Slicer3_CMAKE_DIR "${Slicer3_SOURCE_DIR}/CMake" CACHE INTERNAL "")
112 add_subdirectory(CMake)
113 # Make sure VTK_CMAKE_DIR is at the beginning so that VTK's FindTCL is
114 # used before CMake's FindTCL.
115 set(CMAKE_MODULE_PATH "${VTK_CMAKE_DIR}" ${CMAKE_MODULE_PATH} "${Slicer3_CMAKE_DIR}")
116
117 include("${Slicer3_CMAKE_DIR}/Slicer3PersistenceMacros.cmake")
118
119 # See http://www.cmake.org/Wiki/CMakeMacroParseArguments
120 include("${Slicer3_CMAKE_DIR}/Slicer3ParseArgumentsMacro.cmake")
121
122 ## QT
123 INCLUDE(${Slicer3_CMAKE_DIR}/Slicer3FindQT.cmake)
124
125 #-----------------------------------------------------------------------------
126 # Top level slicer3 configurations
127 #
128 # If CMake >= 2.6.0
129 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
130 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
131 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
132
133
134 # Do NOT force into the cache, as plugins need to override locally and scoping
135 # becomes an issue.
136 #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
137 # CACHE PATH "Single output directory for building all libraries." FORCE)
138 #set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
139 # CACHE PATH "Single output directory for building all executables." FORCE)
140
141 #-----------------------------------------------------------------------------
142 # Slicer include and libraries subdirectory
143 #
144 slicer3_set_persistent_property(Slicer3_Libs_LIBRARIES "")
145 slicer3_set_persistent_property(Slicer3_Base_LIBRARIES "")
146 slicer3_set_persistent_property(Slicer3_Modules_LIBRARIES "")
147 slicer3_set_persistent_property(Slicer3_QTModules_LIBRARIES "")
148
149 slicer3_set_persistent_property(Slicer3_Libs_INCLUDE_DIRS "")
150 slicer3_set_persistent_property(Slicer3_Base_INCLUDE_DIRS "")
151 slicer3_set_persistent_property(Slicer3_Modules_INCLUDE_DIRS "")
152 slicer3_set_persistent_property(Slicer3_QTModules_INCLUDE_DIRS "")
153
154 #-----------------------------------------------------------------------------
155 # Get sytem name and architecture
156 #
157 SET(Slicer3_BUILD NA)
158 INCLUDE(${Slicer3_CMAKE_DIR}/DiscoverSystemNameAndBits.cmake)
159 MESSAGE(STATUS "Slicer3_BUILD:${Slicer3_BUILD}")
160
161 #-----------------------------------------------------------------------------
162 # Add the testing directories
163 #
164 OPTION(BUILD_TESTING "Test the project" ON)
165 SET(Slicer3_BUILD_TESTING ${BUILD_TESTING})
166 SET(LAUNCH_EXE ${Slicer3_BINARY_DIR}/Slicer3 --launch)
167 IF(Slicer3_BUILD_TESTING)
168 #IF (NOT BUILDNAME)
169 # SET(BUILDNAME "${Slicer3_BUILD}" CACHE STRING "Name of build on the dashboard")
170 #ELSE()
171 # SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
172 #ENDIF()
173 ENABLE_TESTING()
174 INCLUDE(CTest)
175 SET(CXX_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
176 MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
177
178 #-----------------------------------------------------------------------------
179 # Run test through valgrind: particularly useful for testing modules.
180 #
181 option(USE_VALGRIND "Run tests through valgrind." OFF)
182
183 ENDIF(Slicer3_BUILD_TESTING)
184
185 #-----------------------------------------------------------------------------
186 # By default, build with KWWidget
187 #
188 option(Slicer3_USE_KWWIDGETS "Build Slicer3 with KWWidgets." ON)
189
190 #-----------------------------------------------------------------------------
191 # Since modules are KWWidgets based, unset there variables
192 IF (NOT Slicer3_USE_KWWIDGETS)
193 # Since the module Logic is shared between QTModules and regular Modules,
194 # the associated BIN and LIB directory shouldn't be unset
195 #UNSET(Slicer3_INSTALL_MODULES_BIN_DIR)
196 #UNSET(Slicer3_INSTALL_MODULES_LIB_DIR)
197 UNSET(Slicer3_INSTALL_MODULES_INCLUDE_DIR)
198 UNSET(Slicer3_INSTALL_MODULES_SHARE_DIR)
199 ENDIF (NOT Slicer3_USE_KWWIDGETS)
200
201 #-----------------------------------------------------------------------------
202 # Libs
203 # - ITK
204 # - KWWidgets (pulls in VTK)
205 #
206
207 # Relax some constraints related to the build settings file. This was
208 # preventing people from using the same compiler but with a different generator,
209 # or just the same compiler installed in a non-standard location.
210
211 IF (Slicer3_USE_KWWIDGETS)
212 set(SKIP_KWWidgets_BUILD_SETTINGS_FILE 1)
213 ENDIF(Slicer3_USE_KWWIDGETS)
214 set(SKIP_VTK_BUILD_SETTINGS_FILE 1)
215 set(SKIP_ITK_BUILD_SETTINGS_FILE 1)
216 set(SKIP_Teem_BUILD_SETTINGS_FILE 1)
217
218 #-----------------------------------------------------------------------------
219 ## Python
220 option(Slicer3_USE_PYTHON "Integrate a python interpreter into Slicer." OFF)
221 if(Slicer3_USE_PYTHON)
222 find_package(PythonLibs)
223 endif(Slicer3_USE_PYTHON)
224
225 #-----------------------------------------------------------------------------
226 ## Java
227 option(Slicer3_USE_JAVA "Enable support for Java in Slicer." OFF)
228 if(Slicer3_USE_JAVA)
229 find_package( Java )
230 endif(Slicer3_USE_JAVA)
231
232 #-----------------------------------------------------------------------------
233 ## ITK
234 find_package(ITK REQUIRED)
235 if(NOT ITK_FOUND)
236 message(FATAL_ERROR "Need ITK to build")
237 endif(NOT ITK_FOUND)
238 include(${ITK_USE_FILE})
239
240 #-----------------------------------------------------------------------------
241 IF (Slicer3_USE_KWWIDGETS)
242 ## KWWidgets
243 FIND_PACKAGE(KWWidgets REQUIRED)
244 IF(NOT KWWidgets_FOUND)
245 MESSAGE(FATAL_ERROR "Need KWWidgets to build")
246 ENDIF(NOT KWWidgets_FOUND)
247 INCLUDE(${KWWidgets_USE_FILE})
248 ELSE(Slicer3_USE_KWWIDGETS)
249 FIND_PACKAGE(VTK REQUIRED)
250 IF(NOT VTK_FOUND)
251 MESSAGE(FATAL_ERROR "Need VTK to build with ")
252 ELSE(NOT VTK_FOUND)
253 IF(NOT VTK_USE_QVTK)
254 MESSAGE("Please make sure VTK is build with VTK_USE_GUISUPPORT and VTK_USE_QVTK enabled")
255 ENDIF(NOT VTK_USE_QVTK)
256 ENDIF(NOT VTK_FOUND)
257 INCLUDE(${VTK_USE_FILE})
258 ENDIF (Slicer3_USE_KWWIDGETS)
259
260 #-----------------------------------------------------------------------------
261 # Slicer3 is built with cvs head
262 #
263 option(Slicer3_USE_VTK_CVSHEAD "Slicer3 is configurated with cvs head." OFF)
264 mark_as_advanced(Slicer3_USE_VTK_CVSHEAD)
265
266 #-----------------------------------------------------------------------------
267 #
268 # Call macro defined in ${PROJECT_SOURCE_DIR}/CMake/Slicer3FindQT.cmake
269 #
270 SLICER3_SETUP_QT()
271
272 #-----------------------------------------------------------------------------
273 # Alert the user if both Slicer3_USE_QT and Slicer3_USE_KWWIDGETS are OFF
274 IF(NOT Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
275 MESSAGE(FATAL_ERROR "Both Slicer3_USE_QT and Slicer3_USE_KWWIDGETS are OFF. Please, choose one")
276 ENDIF(NOT Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
277
278 #-----------------------------------------------------------------------------
279 # If Slicer3_USE_QT is ON and Slicer3_USE_KWWIDGETS is OFF, complain if VTK_WRAP_TCL is ON
280 # Note: Later on we will expect VTK_WRAP_PYTHON to be ON
281 IF(Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
282 IF(VTK_WRAP_TCL)
283 MESSAGE(FATAL_ERROR "For now, if Slicer3_USE_QT is ON and Slicer3_USE_KWWIDGETS is OFF, we expect VTK_WRAP_TCL to be OFF")
284 ENDIF(VTK_WRAP_TCL)
285 ENDIF(Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
286
287 #-----------------------------------------------------------------------------
288 # Add Slicer3_USE_PYTHONQT option if Slicer3_USE_QT is ON
289 IF(Slicer3_USE_QT)
290 option(Slicer3_USE_PYTHONQT "Integrate a python-QT interpreter into Slicer." OFF)
291 IF(Slicer3_USE_PYTHONQT)
292 IF(NOT VTK_WRAP_PYTHON)
293 MESSAGE(FATAL_ERROR "Since both Slicer3_USE_QT and Slicer3_USE_PYTHONQT are ON, VTK_WRAP_PYTHON is expected to be ON. Disable Slicer3_USE_PYTHONQT or re-configure VTK with python wrapping.")
294 ENDIF(NOT VTK_WRAP_PYTHON)
295 # Enable qCTKWidgets python wrapping
296 # Note that qVTKWidgets and qMRMLWidgets python wrapping will be automatically enabled
297 SET(qCTKWidgets_WRAP_PYTHON ON)
298 ENDIF(Slicer3_USE_PYTHONQT)
299 ENDIF(Slicer3_USE_QT)
300
301 #-----------------------------------------------------------------------------
302 ## Teem
303 find_package(Teem REQUIRED)
304 if(NOT Teem_FOUND)
305 message(FATAL_ERROR "Need Teem to build")
306 endif(NOT Teem_FOUND)
307 include(${Teem_USE_FILE})
308
309 #-----------------------------------------------------------------------------
310 ## SlicerLibCurl
311 find_package(SLICERLIBCURL REQUIRED)
312 if(SLICERLIBCURL_FOUND)
313 include(${SLICERLIBCURL_USE_FILE})
314 endif(SLICERLIBCURL_FOUND)
315
316 #-----------------------------------------------------------------------------
317 ## BatchMake
318 option(Slicer3_USE_BatchMake "Build Slicer3 with BatchMake support." OFF)
319 if(Slicer3_USE_BatchMake)
320 find_package(BatchMake REQUIRED)
321 include(${BatchMake_USE_FILE})
322 endif(Slicer3_USE_BatchMake)
323
324 #-----------------------------------------------------------------------------
325 ## MIDAS
326 option(Slicer3_USE_MIDAS "Build Slicer3 with MIDAS support." OFF)
327
328 #-----------------------------------------------------------------------------
329 ## OpenIGTLink (Built in Slicer3-lib)
330 option(Slicer3_USE_OPENIGTLINK "Build Slicer3 with OpenIGTLink support." OFF)
331 if(Slicer3_USE_OPENIGTLINK)
332 find_package(OpenIGTLink REQUIRED)
333 include(${OpenIGTLink_USE_FILE})
334 endif(Slicer3_USE_OPENIGTLINK)
335
336 #-----------------------------------------------------------------------------
337 ## OpenCV (Built in Slicer3-lib)
338 option(Slicer3_USE_OPENCV "Build Slicer3 with OpenCV support." OFF)
339 if(Slicer3_USE_OPENCV)
340 find_package(OpenCV REQUIRED)
341
342 IF(OPENCV_BUILD_SETTINGS_FILE AND NOT SKIP_OPENCV_BUILD_SETTINGS_FILE)
343 INCLUDE(${CMAKE_ROOT}/Modules/CMakeImportBuildSettings.cmake)
344 CMAKE_IMPORT_BUILD_SETTINGS(${OPENCV_BUILD_SETTINGS_FILE})
345 ENDIF(OPENCV_BUILD_SETTINGS_FILE AND NOT SKIP_OPENCV_BUILD_SETTINGS_FILE)
346
347 # Add compiler flags needed to use OPENCV.
348 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_REQUIRED_C_FLAGS}")
349 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_REQUIRED_CXX_FLAGS}")
350 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_REQUIRED_LINK_FLAGS}")
351 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OPENCV_REQUIRED_LINK_FLAGS}")
352 SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OPENCV_REQUIRED_LINK_FLAGS}")
353
354 # Add include directories needed to use OPENCV.
355 INCLUDE_DIRECTORIES(BEFORE ${OPENCV_INCLUDE_DIRS})
356
357 # Add link directories needed to use OPENCV.
358 LINK_DIRECTORIES(${OPENCV_LIBRARY_DIRS})
359 #include(${OPENCV_USE_FILE})
360 endif(Slicer3_USE_OPENCV)
361
362 #-----------------------------------------------------------------------------
363 # Need some Tcl/Tk info
364 IF (VTK_WRAP_TCL)
365 include("${VTK_CMAKE_DIR}/vtkTclTkMacros.cmake")
366 VTK_GET_TCL_TK_VERSION(TCL_TK_MAJOR_VERSION TCL_TK_MINOR_VERSION)
367 set(TCL_TK_VERSION_DOT "${TCL_TK_MAJOR_VERSION}.${TCL_TK_MINOR_VERSION}")
368 set(TCL_TK_VERSION "${TCL_TK_MAJOR_VERSION}${TCL_TK_MINOR_VERSION}")
369 IF(Slicer3_USE_KWWIDGETS)
370 include("${KWWidgets_CMAKE_DIR}/KWWidgetsTclTkMacros.cmake")
371 incr_tcl_get_version(INCR_TCL_MAJOR_VERSION INCR_TCL_MINOR_VERSION)
372 set(INCR_TCL_VERSION_DOT "${INCR_TCL_MAJOR_VERSION}.${INCR_TCL_MINOR_VERSION}")
373 set(INCR_TCL_VERSION "${INCR_TCL_MAJOR_VERSION}${INCR_TCL_MINOR_VERSION}")
374 ENDIF(Slicer3_USE_KWWIDGETS)
375 if(VTK_TCL_INCLUDE_DIR)
376 include_directories("${VTK_TCL_INCLUDE_DIR}" "${VTK_TK_INCLUDE_DIR}")
377 endif(VTK_TCL_INCLUDE_DIR)
378 ENDIF (VTK_WRAP_TCL)
379
380 #-----------------------------------------------------------------------------
381 # Generate the default setup paths scripts.
382 # Generate some useful scripts that can be used to setup various environment
383 # variables and launch the executable properly against external packages.
384 #
385 IF (Slicer3_USE_KWWIDGETS)
386 include("${KWWidgets_CMAKE_DIR}/KWWidgetsPathsMacros.cmake")
387 set(extra_dirs
388 "${Teem_DIR}/bin"
389 "${BatchMake_DIR}/bin"
390 "${OpenIGTLink_DIR}/bin"
391 "${Slicer3_HOME}/${Slicer3_INSTALL_PLUGINS_BIN_DIR}"
392 "${Slicer3_HOME}/${Slicer3_INSTALL_PLUGINS_LIB_DIR}"
393 "${Slicer3_HOME}/${Slicer3_INSTALL_MODULES_BIN_DIR}"
394 "${Slicer3_HOME}/${Slicer3_INSTALL_MODULES_LIB_DIR}"
395 )
396 kwwidgets_generate_setup_paths_scripts(
397 "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "Slicer3SetupPaths"
398 "${extra_dirs}"
399 )
400 ENDIF (Slicer3_USE_KWWIDGETS)
401
402 #-----------------------------------------------------------------------------
403 # VTK 5.0 does not have VTK_CMAKE_DIR
404 # Alternatively you could use KWWidget's wrapping, which encapsulate
405 # the differences between various VTK versions:
406 # INCLUDE("${KWWidgets_CMAKE_DIR}/KWWidgetsWrappingMacros.cmake")
407 # KWWidgets_WRAP_TCL(${LIB_NAME} LIB_TCL_SRCS "${LIB_SRCS}" "")
408 #
409 IF (Slicer3_USE_KWWIDGETS)
410 if(NOT VTK_CMAKE_DIR)
411 set(VTK_CMAKE_DIR "${VTK_SOURCE_DIR}/CMake")
412 endif(NOT VTK_CMAKE_DIR)
413 include("${VTK_CMAKE_DIR}/vtkWrapTcl.cmake")
414 ENDIF (Slicer3_USE_KWWIDGETS)
415
416 #-----------------------------------------------------------------------------
417 # Check versions of VTK to track CVS HEAD
418 #
419 IF (Slicer3_USE_KWWIDGETS)
420 find_package(VTK REQUIRED)
421 if(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
422 include(${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
423 else(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
424 #MESSAGE("Using local version of VTKVersionMacros for compatibility.")
425 include(${Slicer3_SOURCE_DIR}/Scripts/VTKVersionMacros.cmake)
426 endif(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
427
428 vtk_get_source_revision_and_date(VTKsource_revision VTKsource_date)
429 if(VTKsource_revision LESS 1.2196)
430 message(FATAL_ERROR "Sorry, your VTK library was last updated on ${VTKsource_date}. Its source revision, according to vtkKWWidgetsVersion.h, is ${VTKsource_revision}. Please update to a newer revision.")
431 endif(VTKsource_revision LESS 1.2196)
432 ENDIF (Slicer3_USE_KWWIDGETS)
433
434 #-----------------------------------------------------------------------------
435 # These packages may exist within the Slicer3 source tree
436 #
437 set(TCLAP_DIR ${Slicer3_BINARY_DIR}/Libs/SlicerExecutionModel/tclap)
438 set(ModuleDescriptionParser_DIR ${Slicer3_BINARY_DIR}/Libs/SlicerExecutionModel/ModuleDescriptionParser)
439 set(GenerateCLP_DIR ${Slicer3_BINARY_DIR}/Libs/SlicerExecutionModel/GenerateCLP)
440 set(GenerateLM_DIR ${Slicer3_BINARY_DIR}/Libs/GenerateLM)
441 set(LoadableModule_DIR ${Slicer3_BINARY_DIR}/Libs/LoadableModule)
442 set(vtkITK_DIR ${Slicer3_BINARY_DIR}/Libs/vtkITK)
443
444 #-----------------------------------------------------------------------------
445 # Qt Loadable Modules
446 #
447 IF(Slicer3_USE_QT)
448 OPTION(Slicer3_BUILD_QTLOADABLEMODULES "Build Slicer3 QT Loadable Modules" ON)
449 IF(Slicer3_BUILD_QTLOADABLEMODULES)
450 ADD_DEFINITIONS(-DSlicer3_BUILD_QTLOADABLEMODULES)
451 set(Slicer3_INSTALL_QTLOADABLEMODULES_BIN_DIR "${Slicer3_INSTALL_LIB_DIR}/QTLoadableModules")
452 set(Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR "${Slicer3_INSTALL_LIB_DIR}/QTLoadableModules")
453 set(Slicer3_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR "${Slicer3_INSTALL_INCLUDE_DIR}/QTLoadableModules")
454 set(Slicer3_INSTALL_QTLOADABLEMODULES_SHARE_DIR "${Slicer3_INSTALL_SHARE_DIR}/QTLoadableModules")
455 ENDIF(Slicer3_BUILD_QTLOADABLEMODULES)
456 ENDIF(Slicer3_USE_QT)
457
458 # --------------------------------------------------------------------------
459 # Configure and install headers
460
461 CONFIGURE_FILE(
462 ${CMAKE_CURRENT_SOURCE_DIR}/vtkSlicerConfigure.h.in
463 ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerConfigure.h
464 )
465
466 CONFIGURE_FILE(
467 ${CMAKE_CURRENT_SOURCE_DIR}/vtkSlicerVersionConfigure.h.in
468 ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerVersionConfigure.h
469 )
470
471 CONFIGURE_FILE(
472 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/runValgrind.sh.in
473 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/runValgrind.sh
474 )
475
476 CONFIGURE_FILE(
477 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/runValgrindForOneModule.sh.in
478 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/runValgrindForOneModule.sh
479 )
480
481 CONFIGURE_FILE(
482 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/computeCodeCoverageLocally.sh.in
483 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/computeCodeCoverageLocally.sh
484 )
485
486 CONFIGURE_FILE(
487 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/computeCodeCoverageForOneTest.sh.in
488 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/computeCodeCoverageForOneTest.sh
489 )
490
491 CONFIGURE_FILE(
492 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/runExperimentalOffScreen.sh.in
493 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/runExperimentalOffScreen.sh
494 )
495
496 INCLUDE_DIRECTORIES(
497 "${CMAKE_CURRENT_SOURCE_DIR}"
498 "${CMAKE_CURRENT_BINARY_DIR}"
499 )
500
501 INSTALL(FILES
502 "${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerConfigure.h"
503 DESTINATION ${Slicer3_INSTALL_INCLUDE_DIR} COMPONENT Development
504 )
505
506 INSTALL(FILES
507 "${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerVersionConfigure.h"
508 DESTINATION ${Slicer3_INSTALL_INCLUDE_DIR} COMPONENT Development
509 )
510
511 #-----------------------------------------------------------------------------
512 # Generate Slicer3Version.txt
513
514 INCLUDE(${Slicer3_CMAKE_DIR}/Slicer3TodayMacro.cmake)
515
516 # Get build time
517 TODAY(Slicer3_BUILDDATE)
518
519 # Note that Slicer_BUILD is set above
520
521 SET(Slicer3_WC_URL NA)
522 SET(Slicer3_WC_REVISION 0)
523
524 # Get SVN info
525 FIND_PACKAGE(Subversion)
526 IF(NOT Subversion_FOUND)
527 MESSAGE(FATAL_ERROR "error: Install SVN and try to re-configure")
528 ENDIF(NOT Subversion_FOUND)
529
530 # Case where Slicer is checkout using SVN
531 IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.svn)
532 Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} Slicer3)
533 CONFIGURE_FILE(
534 ${CMAKE_CURRENT_SOURCE_DIR}/Slicer3Version.txt.in
535 ${Slicer3_HOME}/lib/Slicer3/Slicer3Version.txt
536 )
537 ENDIF()
538
539 # Case where Slicer is checkout using Git-SVN
540 IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
541 FIND_PACKAGE(Git)
542 IF(NOT Git_FOUND)
543 MESSAGE(FATAL_ERROR "error: Failed to locate Git")
544 ENDIF(NOT Git_FOUND)
545 Git_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} Slicer3)
546 CONFIGURE_FILE(
547 ${CMAKE_CURRENT_SOURCE_DIR}/Slicer3Version.txt.in
548 ${Slicer3_HOME}/lib/Slicer3/Slicer3Version.txt
549 )
550 ENDIF()
551
552
553 #-----------------------------------------------------------------------------
554 # Subdirectories
555 #
556 add_subdirectory(Libs)
557 add_subdirectory(Base)
558 add_subdirectory(Resources)
559
560 #-----------------------------------------------------------------------------
561 # At this point, let's not have the applications and modules guess which
562 # include paths or libraries they need, but use Slicer3_*_LIBRARIES and
563 # Slicer3_*_INCLUDE_DIRS instead. As far as modules are concerned, both
564 # variables are actually set automatically by the import script when building
565 # against a Slicer3 build or installed tree. When in-source, we need to
566 # set both variables now. Retrieve them from the persistent property cache
567 # since they were collected in each subdir (which makes it impossible to
568 # use normal variables, since a new scope is created in each subdir).
569 #
570 slicer3_get_persistent_property(Slicer3_Libs_LIBRARIES Slicer3_Libs_LIBRARIES)
571 slicer3_get_persistent_property(Slicer3_Base_LIBRARIES Slicer3_Base_LIBRARIES)
572
573 slicer3_get_persistent_property(Slicer3_Libs_INCLUDE_DIRS Slicer3_Libs_INCLUDE_DIRS)
574 slicer3_get_persistent_property(Slicer3_Base_INCLUDE_DIRS Slicer3_Base_INCLUDE_DIRS)
575
576 #-----------------------------------------------------------------------------
577 # Module Logic
578
579 INCLUDE("${Slicer3_CMAKE_DIR}/Slicer3ModuleLogicMacros.cmake")
580
581 IF (NOT Slicer3_USE_KWWIDGETS)
582 # Loop through Modules subdirectory and try to include Logic subdirectory if it exists
583 FILE(GLOB modules_subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Modules/*)
584 FOREACH(subdir ${modules_subdirs})
585 IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/Logic)
586 ADD_SUBDIRECTORY(${subdir}/Logic)
587 ENDIF()
588 ENDFOREACH()
589 ENDIF()
590
591
592 #-----------------------------------------------------------------------------
593 # Modules and CLI
594 #
595 option(Slicer3_BUILD_CLI "Build Slicer3 CLI Plugins" ON)
596 IF (Slicer3_USE_KWWIDGETS)
597 option(Slicer3_BUILD_MODULES "Build Slicer3 Modules" ON)
598 ENDIF (Slicer3_USE_KWWIDGETS)
599
600 include("${Slicer3_CMAKE_DIR}/Slicer3PluginsMacros.cmake")
601
602 IF (Slicer3_USE_KWWIDGETS)
603 include("${Slicer3_CMAKE_DIR}/Slicer3ModulesMacros.cmake")
604
605 if(Slicer3_BUILD_MODULES)
606 add_subdirectory(Modules)
607 else(Slicer3_BUILD_MODULES)
608 # if Slicer3_BUILD_CLI is ON, we still need at least the CommandLineModule
609 # so that we can have CLI, without all the other modules
610 if(Slicer3_BUILD_CLI)
611 add_subdirectory(Modules/CommandLineModule)
612 endif(Slicer3_BUILD_CLI)
613 endif(Slicer3_BUILD_MODULES)
614 ENDIF (Slicer3_USE_KWWIDGETS)
615
616 #-----------------------------------------------------------------------------
617 # Applications need to be built after Modules to capture the TractTracing in
618 # the correct ordering.
619 #
620 add_subdirectory(Applications)
621
622 #-----------------------------------------------------------------------------
623 # Testing
624 #
625 if(Slicer3_BUILD_TESTING)
626 add_subdirectory(Testing)
627 endif(Slicer3_BUILD_TESTING)
628
629 # Install testing data
630
631 install(DIRECTORY
632 Testing
633 DESTINATION ${Slicer3_INSTALL_SHARE_DIR} COMPONENT Development
634 PATTERN ".svn" EXCLUDE
635 PATTERN "CMakeLists.txt" EXCLUDE
636 )
637
638 #-----------------------------------------------------------------------------
639 # Launcher for slicer
640 #
641
642 # let's build the launcher for Kww, KwwAndQt and also QtOnly slicer ...
643 ADD_SUBDIRECTORY(Utilities/Launcher)
644
645 # Compute Slicer3_QT_PLUGIN_PATH used to configure launch.tcl.in
646 SET(Slicer3_QT_PLUGIN_PATH "")
647 IF(Slicer3_USE_QT)
648 SET(designer_launcher_project_name SlicerQT)
649 GET_TARGET_PROPERTY(output_directory ${designer_launcher_project_name} LIBRARY_OUTPUT_DIRECTORY)
650 SET(Slicer3_QT_PLUGIN_PATH ${output_directory})
651 ENDIF(Slicer3_USE_QT)
652
653 CONFIGURE_FILE(
654 ${Slicer3_SOURCE_DIR}/launch.tcl.in
655 "${Slicer3_BINARY_DIR}/${Slicer3_INSTALL_LIB_DIR}/launch.tcl"
656 )
657 INSTALL(
658 FILES "${Slicer3_BINARY_DIR}/${Slicer3_INSTALL_LIB_DIR}/launch.tcl"
659 DESTINATION ${Slicer3_INSTALL_LIB_DIR}
660 )
661
662 #-----------------------------------------------------------------------------
663 # Launcher for QTDesigner
664 #
665
666 IF (Slicer3_USE_QT)
667 add_subdirectory(Utilities/Designer)
668 ENDIF (Slicer3_USE_QT)
669
670 #-----------------------------------------------------------------------------
671 # Package slicer
672 #
673 add_subdirectory(Utilities/Package)
674
675 #-----------------------------------------------------------------------------
676 # Documentation
677 #
678 option(BUILD_DOCUMENTATION "Build Slicer3 Documentation" OFF)
679 if(BUILD_DOCUMENTATION)
680 add_subdirectory(Utilities/Doxygen)
681 endif(BUILD_DOCUMENTATION)
682
683 #-----------------------------------------------------------------------------
684 # Setup file for setting custom ctest vars
685 CONFIGURE_FILE(
686 ${Slicer3_SOURCE_DIR}/CTestCustom.cmake.in
687 ${Slicer3_BINARY_DIR}/CTestCustom.cmake
688 @ONLY
689 )
690
691
692 #-----------------------------------------------------------------------------
693 # Set up for building against a Slicer3 build tree and a Slicer3 installation
694 #
695 include(${Slicer3_SOURCE_DIR}/GenerateSlicer3Config.cmake)
696
697 configure_file(${Slicer3_SOURCE_DIR}/CTestConfig.cmake
698 ${Slicer3_BINARY_DIR}/${Slicer3_INSTALL_LIB_DIR}/CTestConfig.cmake COPYONLY IMMEDIATE)
699
700 configure_file(${Slicer3_SOURCE_DIR}/UseSlicer3.cmake.in
701 ${Slicer3_BINARY_DIR}/UseSlicer3.cmake COPYONLY IMMEDIATE)
702
703 configure_file(${Slicer3_SOURCE_DIR}/CMake/RemoveTemporaryFiles.cmake.in
704 ${Slicer3_BINARY_DIR}/CMake/RemoveTemporaryFiles.cmake @ONLY IMMEDIATE)
705 configure_file(${Slicer3_SOURCE_DIR}/CMake/Slicer3SampleBuildTest.cmake.in
706 ${Slicer3_BINARY_DIR}/CMake/Slicer3SampleBuildTest.cmake @ONLY)
707
708 install(FILES
709 # ${Slicer3_BINARY_DIR}/Slicer3BuildSettings.cmake
710 ${Slicer3_SOURCE_DIR}/CTestConfig.cmake
711 ${Slicer3_BINARY_DIR}/UseSlicer3.cmake
712 ${Slicer3_BINARY_DIR}/Utilities/Slicer3Config.cmake
713 ${Slicer3_BINARY_DIR}/lib/Slicer3/Slicer3Version.txt
714 DESTINATION ${Slicer3_INSTALL_LIB_DIR}
715 COMPONENT Development
716 )

  Subversion  TortoiseSVN  ViewVC