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

View of /oldtrunk/CMakeLists.txt

Parent Directory Parent Directory Revision Log Revision Log


Revision 15040  Download Blame
File MIME type: text/plain
File size: 31522 byte(s)
ENH: implementing changes described in the email linked below.
http://massmail.spl.harvard.edu/public-archives/slicer-devel/2010/005338.html
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 # Convenient macro allowing to download a file
34 #
35 MACRO(downloadFile url dest)
36 IF(NOT EXISTS ${dest})
37 FILE(DOWNLOAD ${url} ${dest} STATUS status)
38 LIST(GET status 0 error_code)
39 LIST(GET status 1 error_msg)
40 IF(error_code)
41 MESSAGE(FATAL_ERROR "error: Failed to download ${url} - ${error_msg}")
42 ENDIF()
43 ELSE()
44 # Make sure the file is not empty
45 FILE(READ ${dest} dest_content LIMIT 4)
46 STRING(LENGTH "${dest_content}" dest_length)
47 IF(NOT "${dest_length}" EQUAL 4)
48 FILE(REMOVE ${dest})
49 downloadFile(${url} ${dest})
50 ENDIF()
51 ENDIF()
52 ENDMACRO()
53
54 #-----------------------------------------------------------------------------
55 # Disable the warnings that DevStudio 2005 emits wrt to sprintf, strcpu, etc.
56 #
57 # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
58 # warnings (copied from ITK's CMake files so that ITK templated code will compile
59 # correctly).
60 IF(WIN32)
61 IF(NOT BORLAND)
62 IF(NOT CYGWIN)
63 IF(NOT MINGW)
64 ADD_DEFINITIONS(
65 -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
66 -D_CRT_IS_WCTYPE_NO_DEPRECATE
67 -D_CRT_MANAGED_FP_NO_DEPRECATE
68 -D_CRT_NONSTDC_NO_DEPRECATE
69 -D_CRT_SECURE_NO_DEPRECATE
70 -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
71 -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
72 -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
73 -D_CRT_VCCLRIT_NO_DEPRECATE
74 -D_SCL_SECURE_NO_DEPRECATE
75 )
76 ENDIF(NOT MINGW)
77 ENDIF(NOT CYGWIN)
78 ENDIF(NOT BORLAND)
79 ENDIF(WIN32)
80
81 # Disable warning C4996: [...] This function or variable may be unsafe. [...]
82 # To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details
83 if(MSVC90)
84 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
85 endif(MSVC90)
86
87 # include a test for endianness (used to be done by default)
88
89 include(${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
90 test_big_endian(CMAKE_WORDS_BIGENDIAN)
91
92 #-----------------------------------------------------------------------------
93 # avoid linker bug in Mac OS 10.5
94 # see:
95 # http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
96 #
97 if(APPLE)
98 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")
99 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")
100 endif(APPLE)
101
102 #-----------------------------------------------------------------------------
103 # Slicer version number.
104 #
105 set(Slicer3_VERSION_MAJOR "4")
106 set(Slicer3_VERSION_MINOR "0")
107 if(NOT Slicer3_VERSION_PATCH)
108 set(Slicer3_VERSION_PATCH "alpha")
109 endif(NOT Slicer3_VERSION_PATCH)
110 set(Slicer3_VERSION "${Slicer3_VERSION_MAJOR}.${Slicer3_VERSION_MINOR}")
111 set(Slicer3_VERSION_FULL "${Slicer3_VERSION}.${Slicer3_VERSION_PATCH}")
112
113 #-----------------------------------------------------------------------------
114 # Build shared lib by default
115 #
116 option(BUILD_SHARED_LIBS "Build Slicer3 with shared libraries." ON)
117
118 #-----------------------------------------------------------------------------
119 # Append the library version information to the library target properties.
120 #
121 OPTION(Slicer3_WITH_LIBRARY_VERSION "Build with library version information" OFF)
122 IF(Slicer3_WITH_LIBRARY_VERSION)
123 SET(Slicer3_LIBRARY_PROPERTIES ${Slicer3_LIBRARY_PROPERTIES}
124 VERSION ${Slicer3_VERSION_FULL}
125 SOVERSION ${Slicer3_VERSION}
126 )
127 ENDIF(Slicer3_WITH_LIBRARY_VERSION)
128
129 #-----------------------------------------------------------------------------
130 # Slicer3 macros
131 #
132 set(Slicer3_CMAKE_DIR "${Slicer3_SOURCE_DIR}/CMake" CACHE INTERNAL "")
133 add_subdirectory(CMake)
134 # Make sure VTK_CMAKE_DIR is at the beginning so that VTK's FindTCL is
135 # used before CMake's FindTCL.
136 set(CMAKE_MODULE_PATH
137 "${VTK_CMAKE_DIR}"
138 "${Slicer3_CMAKE_DIR}"
139 ${Slicer3_BINARY_DIR}/CMake
140 ${CMAKE_MODULE_PATH}
141 )
142
143 include("${Slicer3_CMAKE_DIR}/Slicer3PersistenceMacros.cmake")
144
145 # See http://www.cmake.org/Wiki/CMakeMacroParseArguments
146 include("${Slicer3_CMAKE_DIR}/Slicer3ParseArgumentsMacro.cmake")
147
148 ## QT
149 INCLUDE(${Slicer3_CMAKE_DIR}/Slicer3FindQT.cmake)
150
151 #-----------------------------------------------------------------------------
152 # Top level slicer3 configurations
153 #
154 # If CMake >= 2.6.0
155 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
156 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
157 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
158
159
160 # Do NOT force into the cache, as plugins need to override locally and scoping
161 # becomes an issue.
162 #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
163 # CACHE PATH "Single output directory for building all libraries." FORCE)
164 #set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
165 # CACHE PATH "Single output directory for building all executables." FORCE)
166
167 #-----------------------------------------------------------------------------
168 # Slicer include and libraries subdirectory
169 #
170 slicer3_set_persistent_property(Slicer3_Libs_LIBRARIES "")
171 slicer3_set_persistent_property(Slicer3_Base_LIBRARIES "")
172 slicer3_set_persistent_property(Slicer3_Modules_LIBRARIES "")
173 slicer3_set_persistent_property(Slicer3_QTModules_LIBRARIES "")
174
175 slicer3_set_persistent_property(Slicer3_Libs_INCLUDE_DIRS "")
176 slicer3_set_persistent_property(Slicer3_Base_INCLUDE_DIRS "")
177 slicer3_set_persistent_property(Slicer3_Modules_INCLUDE_DIRS "")
178 slicer3_set_persistent_property(Slicer3_QTModules_INCLUDE_DIRS "")
179
180 #-----------------------------------------------------------------------------
181 # Get sytem name and architecture
182 #
183 SET(Slicer3_BUILD NA)
184 INCLUDE(${Slicer3_CMAKE_DIR}/DiscoverSystemNameAndBits.cmake)
185 MESSAGE(STATUS "Slicer3_BUILD:${Slicer3_BUILD}")
186
187 #-----------------------------------------------------------------------------
188 # Add the testing directories
189 #
190 OPTION(BUILD_TESTING "Test the project" ON)
191 SET(Slicer3_BUILD_TESTING ${BUILD_TESTING})
192 SET(LAUNCH_EXE ${Slicer3_BINARY_DIR}/Slicer3 --launch)
193 IF(Slicer3_BUILD_TESTING)
194 #IF (NOT BUILDNAME)
195 # SET(BUILDNAME "${Slicer3_BUILD}" CACHE STRING "Name of build on the dashboard")
196 #ELSE()
197 # SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
198 #ENDIF()
199 ENABLE_TESTING()
200 INCLUDE(CTest)
201 SET(CXX_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
202 MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
203
204 #-----------------------------------------------------------------------------
205 # Run test through valgrind: particularly useful for testing modules.
206 #
207 option(USE_VALGRIND "Run tests through valgrind." OFF)
208
209 ENDIF(Slicer3_BUILD_TESTING)
210
211 #-----------------------------------------------------------------------------
212 # By default, build with KWWidget
213 #
214 option(Slicer3_USE_KWWIDGETS "Build Slicer3 with KWWidgets." ON)
215
216 #-----------------------------------------------------------------------------
217 # Since modules are KWWidgets based, unset there variables
218 IF (NOT Slicer3_USE_KWWIDGETS)
219 # Since the module Logic is shared between QTModules and regular Modules,
220 # the associated BIN, LIB and INCLUDE directory shouldn't be unset
221 #UNSET(Slicer3_INSTALL_MODULES_BIN_DIR)
222 #UNSET(Slicer3_INSTALL_MODULES_LIB_DIR)
223 #UNSET(Slicer3_INSTALL_MODULES_INCLUDE_DIR)
224 UNSET(Slicer3_INSTALL_MODULES_SHARE_DIR)
225 ENDIF (NOT Slicer3_USE_KWWIDGETS)
226
227 #-----------------------------------------------------------------------------
228 # Libs
229 # - ITK
230 # - KWWidgets (pulls in VTK)
231 #
232
233 # Relax some constraints related to the build settings file. This was
234 # preventing people from using the same compiler but with a different generator,
235 # or just the same compiler installed in a non-standard location.
236
237 IF (Slicer3_USE_KWWIDGETS)
238 set(SKIP_KWWidgets_BUILD_SETTINGS_FILE 1)
239 ENDIF(Slicer3_USE_KWWIDGETS)
240 set(SKIP_VTK_BUILD_SETTINGS_FILE 1)
241 set(SKIP_ITK_BUILD_SETTINGS_FILE 1)
242 set(SKIP_Teem_BUILD_SETTINGS_FILE 1)
243
244 #-----------------------------------------------------------------------------
245 ## Python
246 option(Slicer3_USE_PYTHON "Integrate a python interpreter into Slicer." OFF)
247 if(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
248 find_package(PythonLibs)
249 find_package(PythonInterp)
250 endif(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
251
252 #-----------------------------------------------------------------------------
253 ## ITK
254 find_package(ITK REQUIRED)
255 if(NOT ITK_FOUND)
256 message(FATAL_ERROR "Need ITK to build")
257 endif(NOT ITK_FOUND)
258 include(${ITK_USE_FILE})
259
260 #-----------------------------------------------------------------------------
261 # FindCTK
262 #
263 SET(git_repo http://github.com/commontk/CTK/raw/master/)
264
265 if (Slicer3_USE_QT)
266 SET(file Utilities/CMake/FindCTK.cmake)
267 downloadFile(${git_repo}/${file} ${Slicer3_BINARY_DIR}/CMake/FindCTK.cmake)
268
269 FIND_PACKAGE(CTK REQUIRED)
270 IF(CTK_FOUND)
271 INCLUDE(${CTK_USE_FILE})
272 # Update CMake module path
273 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CTK_CMAKE_UTILITIES_DIR})
274 IF(Slicer3_USE_PYTHONQT)
275 SET(PYTHONQT_INSTALL_DIR ${CTK_PYTHONQT_INSTALL_DIR})
276 LINK_DIRECTORIES(${PYTHONQT_INSTALL_DIR}/lib)
277 INCLUDE(${CTK_CMAKE_DIR}/ctkMacroWrapPythonQt.cmake)
278 ENDIF()
279 ENDIF()
280 ENDIF()
281
282 #-----------------------------------------------------------------------------
283 IF (Slicer3_USE_KWWIDGETS)
284 ## KWWidgets
285 FIND_PACKAGE(KWWidgets REQUIRED)
286 IF(NOT KWWidgets_FOUND)
287 MESSAGE(FATAL_ERROR "Need KWWidgets to build")
288 ENDIF(NOT KWWidgets_FOUND)
289 INCLUDE(${KWWidgets_USE_FILE})
290
291 ELSE(Slicer3_USE_KWWIDGETS)
292
293 # VTK
294 FIND_PACKAGE(VTK REQUIRED)
295 IF(NOT VTK_FOUND)
296 MESSAGE(FATAL_ERROR "Need VTK to build")
297 ELSE(NOT VTK_FOUND)
298 IF(NOT VTK_USE_QVTK)
299 MESSAGE("Please make sure VTK is build with VTK_USE_GUISUPPORT and VTK_USE_QVTK enabled")
300 ENDIF(NOT VTK_USE_QVTK)
301 ENDIF(NOT VTK_FOUND)
302 INCLUDE(${VTK_USE_FILE})
303
304 ENDIF (Slicer3_USE_KWWIDGETS)
305
306 #-----------------------------------------------------------------------------
307 # Slicer3 is built with cvs head
308 #
309 option(Slicer3_USE_VTK_CVSHEAD "Slicer3 is configurated with cvs head." OFF)
310 mark_as_advanced(Slicer3_USE_VTK_CVSHEAD)
311
312 #-----------------------------------------------------------------------------
313 #
314 # Call macro defined in ${PROJECT_SOURCE_DIR}/CMake/Slicer3FindQT.cmake
315 #
316 SLICER3_SETUP_QT()
317
318 #-----------------------------------------------------------------------------
319 # Alert the user if both Slicer3_USE_QT and Slicer3_USE_KWWIDGETS are OFF
320 IF(NOT Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
321 MESSAGE(FATAL_ERROR "Both Slicer3_USE_QT and Slicer3_USE_KWWIDGETS are OFF. Please, choose one")
322 ENDIF(NOT Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
323
324 #-----------------------------------------------------------------------------
325 # If Slicer3_USE_QT is ON and Slicer3_USE_KWWIDGETS is OFF, complain if VTK_WRAP_TCL is ON
326 # Note: Later on we will expect VTK_WRAP_PYTHON to be ON
327 IF(Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
328 IF(VTK_WRAP_TCL)
329 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")
330 ENDIF(VTK_WRAP_TCL)
331 ENDIF(Slicer3_USE_QT AND NOT Slicer3_USE_KWWIDGETS)
332
333 #-----------------------------------------------------------------------------
334 # Add Slicer3_USE_PYTHONQT option if Slicer3_USE_QT is ON
335 IF(Slicer3_USE_QT)
336 option(Slicer3_USE_PYTHONQT "Integrate a python-QT interpreter into Slicer." OFF)
337 IF(Slicer3_USE_PYTHONQT)
338 IF(NOT VTK_WRAP_PYTHON)
339 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.")
340 ENDIF(NOT VTK_WRAP_PYTHON)
341 # Include convenient script allowing to copy and compile python scripts
342 INCLUDE(${Slicer3_CMAKE_DIR}/Slicer3CompilePythonScripts.cmake)
343 # Enable qMRMLWidgets python wrapping
344 SET(qMRMLWidgets_WRAP_PYTHON OFF)
345 ENDIF(Slicer3_USE_PYTHONQT)
346 ENDIF(Slicer3_USE_QT)
347
348 #-----------------------------------------------------------------------------
349 ## Teem
350 find_package(Teem REQUIRED)
351 if(NOT Teem_FOUND)
352 message(FATAL_ERROR "Need Teem to build")
353 endif(NOT Teem_FOUND)
354 include(${Teem_USE_FILE})
355
356 #-----------------------------------------------------------------------------
357 ## SlicerLibCurl
358 find_package(SLICERLIBCURL REQUIRED)
359 if(SLICERLIBCURL_FOUND)
360 include(${SLICERLIBCURL_USE_FILE})
361 endif(SLICERLIBCURL_FOUND)
362
363 #-----------------------------------------------------------------------------
364 ## BatchMake
365 option(Slicer3_USE_BatchMake "Build Slicer3 with BatchMake support." OFF)
366 if(Slicer3_USE_BatchMake)
367 find_package(BatchMake REQUIRED)
368 include(${BatchMake_USE_FILE})
369 endif(Slicer3_USE_BatchMake)
370
371 #-----------------------------------------------------------------------------
372 ## MIDAS
373 option(Slicer3_USE_MIDAS "Build Slicer3 with MIDAS support." OFF)
374
375 #-----------------------------------------------------------------------------
376 ## OpenIGTLink (Built in Slicer3-lib)
377 option(Slicer3_USE_OPENIGTLINK "Build Slicer3 with OpenIGTLink support." OFF)
378 if(Slicer3_USE_OPENIGTLINK)
379 find_package(OpenIGTLink REQUIRED)
380 include(${OpenIGTLink_USE_FILE})
381 endif(Slicer3_USE_OPENIGTLINK)
382
383 #-----------------------------------------------------------------------------
384 ## OpenCV (Built in Slicer3-lib)
385 option(Slicer3_USE_OPENCV "Build Slicer3 with OpenCV support." OFF)
386 if(Slicer3_USE_OPENCV)
387 find_package(OpenCV REQUIRED)
388
389 IF(OPENCV_BUILD_SETTINGS_FILE AND NOT SKIP_OPENCV_BUILD_SETTINGS_FILE)
390 INCLUDE(${CMAKE_ROOT}/Modules/CMakeImportBuildSettings.cmake)
391 CMAKE_IMPORT_BUILD_SETTINGS(${OPENCV_BUILD_SETTINGS_FILE})
392 ENDIF(OPENCV_BUILD_SETTINGS_FILE AND NOT SKIP_OPENCV_BUILD_SETTINGS_FILE)
393
394 # Add compiler flags needed to use OPENCV.
395 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_REQUIRED_C_FLAGS}")
396 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_REQUIRED_CXX_FLAGS}")
397 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_REQUIRED_LINK_FLAGS}")
398 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OPENCV_REQUIRED_LINK_FLAGS}")
399 SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OPENCV_REQUIRED_LINK_FLAGS}")
400
401 # Add include directories needed to use OPENCV.
402 INCLUDE_DIRECTORIES(BEFORE ${OPENCV_INCLUDE_DIRS})
403
404 # Add link directories needed to use OPENCV.
405 LINK_DIRECTORIES(${OPENCV_LIBRARY_DIRS})
406 #include(${OPENCV_USE_FILE})
407 endif(Slicer3_USE_OPENCV)
408
409
410 #-----------------------------------------------------------------------------
411 # Need some Tcl/Tk info
412 IF (VTK_WRAP_TCL)
413 include("${VTK_CMAKE_DIR}/vtkTclTkMacros.cmake")
414 VTK_GET_TCL_TK_VERSION(TCL_TK_MAJOR_VERSION TCL_TK_MINOR_VERSION)
415 set(TCL_TK_VERSION_DOT "${TCL_TK_MAJOR_VERSION}.${TCL_TK_MINOR_VERSION}")
416 set(TCL_TK_VERSION "${TCL_TK_MAJOR_VERSION}${TCL_TK_MINOR_VERSION}")
417 IF(Slicer3_USE_KWWIDGETS)
418 include("${KWWidgets_CMAKE_DIR}/KWWidgetsTclTkMacros.cmake")
419 incr_tcl_get_version(INCR_TCL_MAJOR_VERSION INCR_TCL_MINOR_VERSION)
420 set(INCR_TCL_VERSION_DOT "${INCR_TCL_MAJOR_VERSION}.${INCR_TCL_MINOR_VERSION}")
421 set(INCR_TCL_VERSION "${INCR_TCL_MAJOR_VERSION}${INCR_TCL_MINOR_VERSION}")
422 ENDIF(Slicer3_USE_KWWIDGETS)
423 ELSE(VTK_WRAP_TCL)
424 # TODO: these should be passed in by SuperBuild
425 # For now, use 3.2 as a fallback - we haven't changed versions in years and probably
426 # never will, so this is always likely to work.
427 # This is needed so the launcher can set the paths to the correct subdirectories
428 # for incrTcl and incrTk
429 set(TCL_TK_VERSION_DOT "8.4")
430 set(TCL_TK_VERSION "84")
431 set(INCR_TCL_VERSION_DOT "3.2")
432 set(INCR_TCL_VERSION "32")
433 ENDIF (VTK_WRAP_TCL)
434
435 #-----------------------------------------------------------------------------
436 # Generate the default setup paths scripts.
437 # Generate some useful scripts that can be used to setup various environment
438 # variables and launch the executable properly against external packages.
439 #
440 IF (Slicer3_USE_KWWIDGETS)
441 include("${KWWidgets_CMAKE_DIR}/KWWidgetsPathsMacros.cmake")
442 set(extra_dirs
443 "${Teem_DIR}/bin"
444 "${BatchMake_DIR}/bin"
445 "${OpenIGTLink_DIR}/bin"
446 "${Slicer3_HOME}/${Slicer3_INSTALL_PLUGINS_BIN_DIR}"
447 "${Slicer3_HOME}/${Slicer3_INSTALL_PLUGINS_LIB_DIR}"
448 "${Slicer3_HOME}/${Slicer3_INSTALL_MODULES_BIN_DIR}"
449 "${Slicer3_HOME}/${Slicer3_INSTALL_MODULES_LIB_DIR}"
450 )
451 kwwidgets_generate_setup_paths_scripts(
452 "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "Slicer3SetupPaths"
453 "${extra_dirs}"
454 )
455 ENDIF (Slicer3_USE_KWWIDGETS)
456
457 #-----------------------------------------------------------------------------
458 # VTK 5.0 does not have VTK_CMAKE_DIR
459 # Alternatively you could use KWWidget's wrapping, which encapsulate
460 # the differences between various VTK versions:
461 # INCLUDE("${KWWidgets_CMAKE_DIR}/KWWidgetsWrappingMacros.cmake")
462 # KWWidgets_WRAP_TCL(${LIB_NAME} LIB_TCL_SRCS "${LIB_SRCS}" "")
463 #
464 IF (Slicer3_USE_KWWIDGETS)
465 if(NOT VTK_CMAKE_DIR)
466 set(VTK_CMAKE_DIR "${VTK_SOURCE_DIR}/CMake")
467 endif(NOT VTK_CMAKE_DIR)
468 include("${VTK_CMAKE_DIR}/vtkWrapTcl.cmake")
469 ENDIF (Slicer3_USE_KWWIDGETS)
470
471 #-----------------------------------------------------------------------------
472 # Check versions of VTK to track CVS HEAD
473 #
474 IF (Slicer3_USE_KWWIDGETS)
475 find_package(VTK REQUIRED)
476 if(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
477 include(${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
478 else(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
479 #MESSAGE("Using local version of VTKVersionMacros for compatibility.")
480 include(${Slicer3_SOURCE_DIR}/Scripts/VTKVersionMacros.cmake)
481 endif(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
482
483 vtk_get_source_revision_and_date(VTKsource_revision VTKsource_date)
484 if(VTKsource_revision LESS 1.2196)
485 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.")
486 endif(VTKsource_revision LESS 1.2196)
487 ENDIF (Slicer3_USE_KWWIDGETS)
488
489 #-----------------------------------------------------------------------------
490 # These packages may exist within the Slicer3 source tree
491 #
492 set(TCLAP_DIR ${Slicer3_BINARY_DIR}/Libs/SlicerExecutionModel/tclap)
493 set(ModuleDescriptionParser_DIR ${Slicer3_BINARY_DIR}/Libs/SlicerExecutionModel/ModuleDescriptionParser)
494 set(GenerateCLP_DIR ${Slicer3_BINARY_DIR}/Libs/SlicerExecutionModel/GenerateCLP)
495 set(GenerateLM_DIR ${Slicer3_BINARY_DIR}/Libs/GenerateLM)
496 set(LoadableModule_DIR ${Slicer3_BINARY_DIR}/Libs/LoadableModule)
497 set(vtkITK_DIR ${Slicer3_BINARY_DIR}/Libs/vtkITK)
498
499 #-----------------------------------------------------------------------------
500 # Qt Loadable Modules
501 #
502 IF(Slicer3_USE_QT)
503 OPTION(Slicer3_BUILD_QTLOADABLEMODULES "Build Slicer3 QT Loadable Modules" ON)
504 IF(Slicer3_BUILD_QTLOADABLEMODULES)
505 ADD_DEFINITIONS(-DSlicer3_BUILD_QTLOADABLEMODULES)
506 set(Slicer3_INSTALL_QTLOADABLEMODULES_BIN_DIR "${Slicer3_INSTALL_LIB_DIR}/QTLoadableModules")
507 set(Slicer3_INSTALL_QTLOADABLEMODULES_LIB_DIR "${Slicer3_INSTALL_LIB_DIR}/QTLoadableModules")
508 set(Slicer3_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR "${Slicer3_INSTALL_INCLUDE_DIR}/QTLoadableModules")
509 set(Slicer3_INSTALL_QTLOADABLEMODULES_SHARE_DIR "${Slicer3_INSTALL_SHARE_DIR}/QTLoadableModules")
510 ENDIF(Slicer3_BUILD_QTLOADABLEMODULES)
511 ENDIF(Slicer3_USE_QT)
512
513 # --------------------------------------------------------------------------
514 # Configure and install headers
515
516 CONFIGURE_FILE(
517 ${CMAKE_CURRENT_SOURCE_DIR}/vtkSlicerConfigure.h.in
518 ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerConfigure.h
519 )
520
521 CONFIGURE_FILE(
522 ${CMAKE_CURRENT_SOURCE_DIR}/vtkSlicerVersionConfigure.h.in
523 ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerVersionConfigure.h
524 )
525
526 CONFIGURE_FILE(
527 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/runValgrind.sh.in
528 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/runValgrind.sh
529 )
530
531 CONFIGURE_FILE(
532 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/runValgrindForOneModule.sh.in
533 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/runValgrindForOneModule.sh
534 )
535
536 CONFIGURE_FILE(
537 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/runValgrindForOneModuleWithSlicer4AndQT.sh.in
538 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/runValgrindForOneModuleWithSlicer4AndQT.sh
539 )
540
541 CONFIGURE_FILE(
542 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/computeCodeCoverageLocally.sh.in
543 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/computeCodeCoverageLocally.sh
544 )
545
546 CONFIGURE_FILE(
547 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/computeCodeCoverageForOneTest.sh.in
548 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/computeCodeCoverageForOneTest.sh
549 )
550
551 CONFIGURE_FILE(
552 ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/runExperimentalOffScreen.sh.in
553 ${CMAKE_CURRENT_BINARY_DIR}/Scripts/runExperimentalOffScreen.sh
554 )
555
556 INCLUDE_DIRECTORIES(
557 "${CMAKE_CURRENT_SOURCE_DIR}"
558 "${CMAKE_CURRENT_BINARY_DIR}"
559 )
560
561 INSTALL(FILES
562 "${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerConfigure.h"
563 DESTINATION ${Slicer3_INSTALL_INCLUDE_DIR} COMPONENT Development
564 )
565
566 INSTALL(FILES
567 "${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerVersionConfigure.h"
568 DESTINATION ${Slicer3_INSTALL_INCLUDE_DIR} COMPONENT Development
569 )
570
571 #-----------------------------------------------------------------------------
572 # Generate Slicer3Version.txt
573
574 INCLUDE(${Slicer3_CMAKE_DIR}/Slicer3TodayMacro.cmake)
575
576 # Get build time
577 TODAY(Slicer3_BUILDDATE)
578
579 # Note that Slicer_BUILD is set above
580
581 SET(Slicer3_WC_URL NA)
582 SET(Slicer3_WC_REVISION 0)
583
584 # Get SVN info
585 FIND_PACKAGE(Subversion)
586 IF(NOT Subversion_FOUND)
587 MESSAGE(FATAL_ERROR "error: Install SVN and try to re-configure")
588 ENDIF(NOT Subversion_FOUND)
589
590 # Case where Slicer is checkout using SVN
591 IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.svn)
592 Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} Slicer3)
593 CONFIGURE_FILE(
594 ${CMAKE_CURRENT_SOURCE_DIR}/Slicer3Version.txt.in
595 ${Slicer3_HOME}/lib/Slicer3/Slicer3Version.txt
596 )
597 ENDIF()
598
599 # Case where Slicer is checkout using Git-SVN
600 IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
601 FIND_PACKAGE(Git)
602 IF(NOT Git_FOUND)
603 MESSAGE(FATAL_ERROR "error: Failed to locate Git")
604 ENDIF(NOT Git_FOUND)
605 Git_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} Slicer3)
606 CONFIGURE_FILE(
607 ${CMAKE_CURRENT_SOURCE_DIR}/Slicer3Version.txt.in
608 ${Slicer3_HOME}/lib/Slicer3/Slicer3Version.txt
609 )
610 ENDIF()
611
612
613 #-----------------------------------------------------------------------------
614 # Subdirectories
615 #
616 add_subdirectory(Libs)
617 add_subdirectory(Base)
618 add_subdirectory(Resources)
619
620 #-----------------------------------------------------------------------------
621 # At this point, let's not have the applications and modules guess which
622 # include paths or libraries they need, but use Slicer3_*_LIBRARIES and
623 # Slicer3_*_INCLUDE_DIRS instead. As far as modules are concerned, both
624 # variables are actually set automatically by the import script when building
625 # against a Slicer3 build or installed tree. When in-source, we need to
626 # set both variables now. Retrieve them from the persistent property cache
627 # since they were collected in each subdir (which makes it impossible to
628 # use normal variables, since a new scope is created in each subdir).
629 #
630 slicer3_get_persistent_property(Slicer3_Libs_LIBRARIES Slicer3_Libs_LIBRARIES)
631 slicer3_get_persistent_property(Slicer3_Base_LIBRARIES Slicer3_Base_LIBRARIES)
632
633 slicer3_get_persistent_property(Slicer3_Libs_INCLUDE_DIRS Slicer3_Libs_INCLUDE_DIRS)
634 slicer3_get_persistent_property(Slicer3_Base_INCLUDE_DIRS Slicer3_Base_INCLUDE_DIRS)
635
636 #-----------------------------------------------------------------------------
637 # Module Logic
638
639 INCLUDE("${Slicer3_CMAKE_DIR}/Slicer3ModuleLogicMacros.cmake")
640
641 IF (NOT Slicer3_USE_KWWIDGETS)
642 # KWWidgets and Qt modules share the same logics typically located in the
643 # kwwdigets modules. When KWWidgets is not build, the logic are missing for Qt
644 # we need to manually add them:
645 # Loop through Modules subdirectory and try to include Logic subdirectory if it exists
646 FILE(GLOB modules_subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Modules/*)
647 FOREACH(subdir ${modules_subdirs})
648 IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/Logic)
649 ADD_SUBDIRECTORY(${subdir}/Logic)
650 ENDIF()
651 FILE(GLOB subsubdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${subdir}/*)
652 FOREACH(subsubdir ${subsubdirs})
653 IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subsubdir}/Logic)
654 ADD_SUBDIRECTORY(${subsubdir}/Logic)
655 ENDIF()
656 ENDFOREACH()
657 ENDFOREACH()
658 ENDIF()
659
660
661 #-----------------------------------------------------------------------------
662 # Modules and CLI
663 #
664 option(Slicer3_BUILD_CLI "Build Slicer3 CLI Plugins" ON)
665 IF (Slicer3_USE_KWWIDGETS)
666 option(Slicer3_BUILD_MODULES "Build Slicer3 Modules" ON)
667 ENDIF (Slicer3_USE_KWWIDGETS)
668
669 include("${Slicer3_CMAKE_DIR}/Slicer3PluginsMacros.cmake")
670
671 IF (Slicer3_USE_KWWIDGETS)
672 include("${Slicer3_CMAKE_DIR}/Slicer3ModulesMacros.cmake")
673
674 if(Slicer3_BUILD_MODULES)
675 add_subdirectory(Modules)
676 else(Slicer3_BUILD_MODULES)
677 # if Slicer3_BUILD_CLI is ON, we still need at least the CommandLineModule
678 # so that we can have CLI, without all the other modules
679 if(Slicer3_BUILD_CLI)
680 add_subdirectory(Modules/CommandLineModule)
681 endif(Slicer3_BUILD_CLI)
682 endif(Slicer3_BUILD_MODULES)
683 ENDIF (Slicer3_USE_KWWIDGETS)
684
685 #-----------------------------------------------------------------------------
686 # Module EMSegment libraries
687 # The EMSegment{Registration,Graph,Algorithm,MRML} libraries are built from the top-level
688 # CMakeLists.txt. Doing so allow to build these libraries also if Slicer3_USE_KWWIDGETS is OFF
689
690 if(Slicer3_BUILD_MODULES OR Slicer3_BUILD_QTLOADABLEMODULES)
691 include("${Slicer3_CMAKE_DIR}/Slicer3ModulesMacros.cmake")
692 ADD_SUBDIRECTORY(Modules/EMSegment/Algorithm)
693 ADD_SUBDIRECTORY(Modules/EMSegment/MRML)
694 ADD_SUBDIRECTORY(Modules/EMSegment/Registration)
695 ADD_SUBDIRECTORY(Modules/EMSegment/Graph)
696 endif()
697
698 # Since EMSegment module expects Volume module and its associated library to be
699 # built beforehand,let's enfore that by building EMSegment here.
700 # Note that EMSegment has been commented in Modules/CMakeLists.txt
701 IF (Slicer3_USE_KWWIDGETS)
702 if(Slicer3_BUILD_MODULES)
703 ADD_SUBDIRECTORY(Modules/EMSegment)
704 endif()
705 ENDIF()
706
707 #-----------------------------------------------------------------------------
708 # Qt Loadable Modules
709 #
710 IF(Slicer3_USE_QT AND Slicer3_BUILD_QTLOADABLEMODULES)
711 add_subdirectory(QTModules)
712 ENDIF(Slicer3_USE_QT AND Slicer3_BUILD_QTLOADABLEMODULES)
713
714 #-----------------------------------------------------------------------------
715 # Applications need to be built after Modules to capture the TractTracing in
716 # the correct ordering.
717 #
718 add_subdirectory(Applications)
719
720 #-----------------------------------------------------------------------------
721 # Testing
722 #
723 if(Slicer3_BUILD_TESTING)
724 add_subdirectory(Testing)
725 endif(Slicer3_BUILD_TESTING)
726
727 # Install testing data
728
729 install(DIRECTORY
730 Testing
731 DESTINATION ${Slicer3_INSTALL_SHARE_DIR} COMPONENT Development
732 PATTERN ".svn" EXCLUDE
733 PATTERN "CMakeLists.txt" EXCLUDE
734 )
735
736 #-----------------------------------------------------------------------------
737 # Launcher for slicer
738 #
739
740 # let's build the launcher for Kww, KwwAndQt and also QtOnly slicer ...
741 ADD_SUBDIRECTORY(Utilities/Launcher)
742
743 # Compute Slicer3_QT_PLUGIN_PATH used to configure launch.tcl.in
744 SET(Slicer3_QT_PLUGIN_PATH "")
745 IF(Slicer3_USE_QT)
746 SET(designer_launcher_project_name SlicerQT)
747 GET_TARGET_PROPERTY(output_directory ${designer_launcher_project_name} LIBRARY_OUTPUT_DIRECTORY)
748 SET(Slicer3_QT_PLUGIN_PATH ${output_directory})
749
750 # on Mac we need to include the path of each Qt Framework in DYLD_LIBRARY_PATH in the launcher.
751 IF(APPLE)
752 SET (QTLIBLIST QTCORE QTGUI QTNETWORK QTXML QTTEST QTSQL QTOPENGL QTWEBKIT PHONON QTXMLPATTERNS)
753
754 FOREACH(qtlib ${QTLIBLIST})
755 IF (QT_${qtlib}_LIBRARY_RELEASE AND APPLE)
756 GET_FILENAME_COMPONENT(QT_FRAMEWORK_NAME_tmp ${QT_${qtlib}_LIBRARY_RELEASE} NAME)
757 SET(Slicer3_QT_FRAMEWORK_DIRS "lib/Qt/${QT_FRAMEWORK_NAME_tmp}/Versions/4:${Slicer3_QT_FRAMEWORK_DIRS}")
758 ENDIF()
759 ENDFOREACH(qtlib)
760 ENDIF(APPLE)
761
762 ENDIF(Slicer3_USE_QT)
763
764 CONFIGURE_FILE(
765 ${Slicer3_SOURCE_DIR}/launch.tcl.in
766 "${Slicer3_BINARY_DIR}/${Slicer3_INSTALL_LIB_DIR}/launch.tcl"
767 )
768 INSTALL(
769 FILES "${Slicer3_BINARY_DIR}/${Slicer3_INSTALL_LIB_DIR}/launch.tcl"
770 DESTINATION ${Slicer3_INSTALL_LIB_DIR}
771 )
772
773 #-----------------------------------------------------------------------------
774 # Launcher for QTDesigner
775 #
776
777 IF (Slicer3_USE_QT)
778 add_subdirectory(Utilities/Designer)
779 ENDIF (Slicer3_USE_QT)
780
781 #-----------------------------------------------------------------------------
782 # Package slicer
783 #
784 add_subdirectory(Utilities/Package)
785
786 #-----------------------------------------------------------------------------
787 # Documentation
788 #
789 option(BUILD_DOCUMENTATION "Build Slicer3 Documentation" OFF)
790 if(BUILD_DOCUMENTATION)
791 add_subdirectory(Utilities/Doxygen)
792 endif(BUILD_DOCUMENTATION)
793
794 #-----------------------------------------------------------------------------
795 # Setup file for setting custom ctest vars
796 CONFIGURE_FILE(
797 ${Slicer3_SOURCE_DIR}/CTestCustom.cmake.in
798 ${Slicer3_BINARY_DIR}/CTestCustom.cmake
799 @ONLY
800 )
801
802
803 #-----------------------------------------------------------------------------
804 # Set up for building against a Slicer3 build tree and a Slicer3 installation
805 #
806 include(${Slicer3_SOURCE_DIR}/GenerateSlicer3Config.cmake)
807
808 configure_file(${Slicer3_SOURCE_DIR}/CTestConfig.cmake
809 ${Slicer3_BINARY_DIR}/${Slicer3_INSTALL_LIB_DIR}/CTestConfig.cmake COPYONLY IMMEDIATE)
810
811 configure_file(${Slicer3_SOURCE_DIR}/UseSlicer3.cmake.in
812 ${Slicer3_BINARY_DIR}/UseSlicer3.cmake COPYONLY IMMEDIATE)
813
814 configure_file(${Slicer3_SOURCE_DIR}/CMake/RemoveTemporaryFiles.cmake.in
815 ${Slicer3_BINARY_DIR}/CMake/RemoveTemporaryFiles.cmake @ONLY IMMEDIATE)
816 configure_file(${Slicer3_SOURCE_DIR}/CMake/Slicer3SampleBuildTest.cmake.in
817 ${Slicer3_BINARY_DIR}/CMake/Slicer3SampleBuildTest.cmake @ONLY)
818
819 install(FILES
820 # ${Slicer3_BINARY_DIR}/Slicer3BuildSettings.cmake
821 ${Slicer3_SOURCE_DIR}/CTestConfig.cmake
822 ${Slicer3_BINARY_DIR}/UseSlicer3.cmake
823 ${Slicer3_BINARY_DIR}/Utilities/Slicer3Config.cmake
824 ${Slicer3_BINARY_DIR}/lib/Slicer3/Slicer3Version.txt
825 DESTINATION ${Slicer3_INSTALL_LIB_DIR}
826 COMPONENT Development
827 )

  Subversion  TortoiseSVN  ViewVC