/[Slicer4]/branches/Slicer-4-6/CMakeLists.txt
ViewVC logotype

Contents of /branches/Slicer-4-6/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25516 - (show annotations) (download)
Tue Nov 8 04:13:52 2016 UTC (11 months, 1 week ago) by jcfr
File MIME type: text/plain
File size: 48786 byte(s)
ENH: Slicer 4.6.2
1
2 cmake_minimum_required(VERSION 2.8.9)
3 if(POLICY CMP0017)
4 cmake_policy(SET CMP0017 OLD)
5 endif()
6 foreach(p
7 CMP0048 # CMake 3.0
8 CMP0054 # CMake 3.1
9 )
10 if(POLICY ${p})
11 cmake_policy(SET ${p} NEW)
12 endif()
13 endforeach()
14
15 #-----------------------------------------------------------------------------
16 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
17 include(ExternalProject)
18 include(ExternalProjectDependency)
19
20 #-----------------------------------------------------------------------------
21 if(APPLE)
22 # Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls,
23 # we ensure that the bitness, and C++ standard library will be properly detected.
24 include(SlicerBlockSetCMakeOSXVariables)
25 mark_as_superbuild(
26 VARS CMAKE_OSX_ARCHITECTURES:STRING CMAKE_OSX_SYSROOT:PATH CMAKE_OSX_DEPLOYMENT_TARGET:STRING
27 ALL_PROJECTS
28 )
29 endif()
30
31 #-----------------------------------------------------------------------------
32 if(NOT DEFINED Slicer_VERSION_MAJOR)
33 set(Slicer_VERSION_MAJOR "4")
34 endif()
35 if(NOT DEFINED Slicer_VERSION_MINOR)
36 set(Slicer_VERSION_MINOR "6")
37 endif()
38 if(NOT DEFINED Slicer_VERSION_PATCH)
39 set(Slicer_VERSION_PATCH "2")
40 endif()
41 if(POLICY CMP0048)
42 set(_project_version VERSION "${Slicer_VERSION_MAJOR}.${Slicer_VERSION_MINOR}.${Slicer_VERSION_PATCH}")
43 endif()
44 project(Slicer ${_project_version})
45
46 #-----------------------------------------------------------------------------
47 # Update CMake module path
48 #------------------------------------------------------------------------------
49 set(CMAKE_MODULE_PATH
50 ${Slicer_SOURCE_DIR}/Extensions/CMake
51 ${CMAKE_MODULE_PATH}
52 )
53
54 set(Slicer_CMAKE_DIR ${Slicer_SOURCE_DIR}/CMake)
55 set(Slicer_EXTENSIONS_CMAKE_DIR ${Slicer_SOURCE_DIR}/Extensions/CMake)
56
57 #-----------------------------------------------------------------------------
58 # http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/DevelopmentWithGit
59 #-----------------------------------------------------------------------------
60 include(SlicerCheckSourceTree)
61
62 #-----------------------------------------------------------------------------
63 # Superbuild Option - Enabled by default
64 #-----------------------------------------------------------------------------
65 option(Slicer_SUPERBUILD "Build ${PROJECT_NAME} and the projects it depends on." ON)
66 mark_as_advanced(Slicer_SUPERBUILD)
67 set(Slicer_BINARY_INNER_SUBDIR Slicer-build)
68
69 #-----------------------------------------------------------------------------
70 include(CTestUseLaunchers OPTIONAL)
71 if(${CTEST_USE_LAUNCHERS})
72 message(STATUS "CTest launchers enabled")
73 endif()
74
75 #-----------------------------------------------------------------------------
76 # Sanity checks
77 #------------------------------------------------------------------------------
78 if(WIN32)
79 set(${PROJECT_NAME}_ROOT_DIR_MAX_LENGTH 40)
80 if(NOT ${PROJECT_NAME}_SUPERBUILD)
81 string(LENGTH ${Slicer_BINARY_INNER_SUBDIR} _inner_subdir_length)
82 math(EXPR ${PROJECT_NAME}_ROOT_DIR_MAX_LENGTH "${${PROJECT_NAME}_ROOT_DIR_MAX_LENGTH} + ${_inner_subdir_length}")
83 endif()
84 include(PreventDirWithTooManyChars)
85 endif()
86 include(PreventInSourceBuilds)
87 include(PreventInBuildInstalls)
88 include(PreventDirWithSpaces)
89 mark_as_superbuild(${PROJECT_NAME}_SKIP_DIR_WITH_SPACES_CHECK:BOOL)
90
91 #-----------------------------------------------------------------------------
92 # Overwrite default options
93 #-----------------------------------------------------------------------------
94 set(_overwrite_options_file ${Slicer_CMAKE_DIR}/SlicerOverwriteDefaultOptions.cmake)
95 if(EXISTS ${_overwrite_options_file})
96 include(${_overwrite_options_file})
97 endif()
98
99 #-----------------------------------------------------------------------------
100 # Check if the linker will resolve symbols of underlinked libraries
101 #-----------------------------------------------------------------------------
102 if(UNIX AND NOT APPLE)
103 include(SlicerLinkerAsNeededFlagCheck)
104 if(Slicer_LINKER_NO_AS_NEEDED_FLAG_REQUIRED)
105 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed"
106 CACHE STRING "Flags used by the linker"
107 FORCE)
108 endif()
109 endif()
110
111 #-----------------------------------------------------------------------------
112 # Set a default build type if none was specified
113 #-----------------------------------------------------------------------------
114 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
115 message(STATUS "Setting build type to 'Debug' as none was specified.")
116 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
117 mark_as_advanced(CMAKE_BUILD_TYPE)
118 # Set the possible values of build type for cmake-gui
119 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
120 "MinSizeRel" "RelWithDebInfo")
121 endif()
122 if(NOT CMAKE_CONFIGURATION_TYPES)
123 mark_as_superbuild(VARS CMAKE_BUILD_TYPE ALL_PROJECTS)
124 endif()
125
126 #-----------------------------------------------------------------------------
127 # Set the header template which defines custom export/import macros
128 # for shared libraries
129 #-----------------------------------------------------------------------------
130 set(Slicer_EXPORT_HEADER_TEMPLATE "${Slicer_SOURCE_DIR}/CMake/qSlicerExport.h.in")
131 set(Slicer_LOGOS_RESOURCE "${Slicer_SOURCE_DIR}/Resources/qSlicer.qrc")
132
133 #-----------------------------------------------------------------------------
134 # Platform checks
135 #-----------------------------------------------------------------------------
136 include(SlicerBlockPlatformCheck)
137 mark_as_superbuild(Slicer_PLATFORM_CHECK:BOOL)
138
139 #-----------------------------------------------------------------------------
140 # Determine endian type
141 #-----------------------------------------------------------------------------
142 include(TestBigEndian)
143 test_big_endian(CMAKE_WORDS_BIGENDIAN)
144
145 #-----------------------------------------------------------------------------
146 # Prerequisites
147 #-----------------------------------------------------------------------------
148 find_package(Subversion)
149 if(NOT Subversion_FOUND)
150 message(FATAL_ERROR "error: Install SVN and try to re-configure")
151 endif()
152 mark_as_superbuild(Subversion_SVN_EXECUTABLE)
153
154 find_package(Git)
155 if(NOT GIT_FOUND)
156 message(FATAL_ERROR "error: Install Git and try to re-configure")
157 endif()
158 mark_as_superbuild(GIT_EXECUTABLE)
159
160 #-----------------------------------------------------------------------------
161 # Qt requirements
162 #-----------------------------------------------------------------------------
163 if(NOT DEFINED Slicer_REQUIRED_QT_VERSION)
164 set(Slicer_REQUIRED_QT_VERSION "4.7.4" CACHE STRING "Minimum required Qt version" FORCE)
165 endif()
166 mark_as_superbuild(Slicer_REQUIRED_QT_VERSION)
167
168 #-----------------------------------------------------------------------------
169 # Build shared lib by default
170 #------------------------------------------------------------------------------
171 # option(BUILD_SHARED_LIBS "Build Slicer with shared libraries." ON)
172 set(BUILD_SHARED_LIBS ON)
173 mark_as_superbuild(BUILD_SHARED_LIBS:BOOL)
174
175 #-----------------------------------------------------------------------------
176 # Append the library version information to the library target properties.
177 #------------------------------------------------------------------------------
178 option(Slicer_WITH_LIBRARY_VERSION "Build with library version information" OFF)
179 mark_as_advanced(Slicer_WITH_LIBRARY_VERSION)
180 mark_as_superbuild(Slicer_WITH_LIBRARY_VERSION)
181 if(Slicer_WITH_LIBRARY_VERSION)
182 set(Slicer_LIBRARY_PROPERTIES ${Slicer_LIBRARY_PROPERTIES}
183 VERSION ${Slicer_VERSION_FULL}
184 SOVERSION ${Slicer_VERSION}
185 )
186 endif()
187
188 #-----------------------------------------------------------------------------
189 # General Slicer Options
190 #-----------------------------------------------------------------------------
191 include(CMakeDependentOption)
192
193 option(BUILD_TESTING "Test the project" ON)
194 mark_as_superbuild(BUILD_TESTING)
195
196 #option(WITH_MEMCHECK "Run tests through valgrind." OFF)
197 #mark_as_superbuild(WITH_MEMCHECK)
198
199 option(WITH_COVERAGE "Enable/Disable coverage" OFF)
200 mark_as_superbuild(WITH_COVERAGE)
201
202 option(Slicer_USE_VTK_DEBUG_LEAKS "Enable VTKs Debug Leaks functionality in both VTK and Slicer." ON)
203 set(VTK_DEBUG_LEAKS ${Slicer_USE_VTK_DEBUG_LEAKS})
204 mark_as_superbuild(VTK_DEBUG_LEAKS:BOOL)
205
206 option(Slicer_BUILD_DICOM_SUPPORT "Build Slicer with DICOM support" ON)
207 mark_as_superbuild(Slicer_BUILD_DICOM_SUPPORT)
208
209 option(Slicer_BUILD_DIFFUSION_SUPPORT "Build Slicer with diffusion (DWI, DTI) support" ON)
210 mark_as_superbuild(Slicer_BUILD_DIFFUSION_SUPPORT)
211
212 option(Slicer_BUILD_I18N_SUPPORT "Build Slicer with Internationalization support" OFF)
213
214 option(Slicer_BUILD_QTLOADABLEMODULES "Build Slicer QT Loadable Modules" ON)
215 mark_as_advanced(Slicer_BUILD_QTLOADABLEMODULES)
216 mark_as_superbuild(Slicer_BUILD_QTLOADABLEMODULES)
217
218 option(Slicer_USE_PYTHONQT "Integrate a python-QT interpreter into Slicer." ON)
219 mark_as_superbuild(Slicer_USE_PYTHONQT)
220
221 CMAKE_DEPENDENT_OPTION(
222 Slicer_BUILD_QTSCRIPTEDMODULES "Build Slicer Python QT Modules" ON
223 "Slicer_USE_PYTHONQT" OFF)
224 mark_as_advanced(Slicer_BUILD_QTSCRIPTEDMODULES)
225 mark_as_superbuild(Slicer_BUILD_QTSCRIPTEDMODULES)
226
227 option(Slicer_BUILD_CLI_SUPPORT "Build Slicer with CLI support" ON)
228 mark_as_superbuild(Slicer_BUILD_CLI_SUPPORT)
229 CMAKE_DEPENDENT_OPTION(
230 Slicer_BUILD_CLI "Build Slicer CLI Plugins" ON
231 "Slicer_BUILD_CLI_SUPPORT" OFF
232 )
233
234 mark_as_superbuild(Slicer_BUILD_CLI)
235 CMAKE_DEPENDENT_OPTION(
236 Slicer_BUILD_LEGACY_CLI "Build Slicer LEGACY_CLI Plugins" ON
237 "Slicer_BUILD_CLI" OFF
238 )
239
240 option(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT "Build Slicer extension manager" ON)
241 mark_as_superbuild(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT)
242
243 CMAKE_DEPENDENT_OPTION(Slicer_UPDATE_TRANSLATION "update translation" OFF "Slicer_BUILD_I18N_SUPPORT" OFF)
244 mark_as_advanced(Slicer_UPDATE_TRANSLATION)
245 mark_as_superbuild(Slicer_UPDATE_TRANSLATION)
246
247 set(Slicer_FORCED_WC_REVISION "" CACHE STRING "Overwrite value of auto-discovered Slicer_WC_REVISION")
248 mark_as_advanced(Slicer_FORCED_WC_REVISION)
249
250 option(Slicer_USE_FOLDERS "Organize build targets into folders" ON)
251 mark_as_superbuild(Slicer_USE_FOLDERS)
252 mark_as_advanced(Slicer_USE_FOLDERS)
253
254 #-----------------------------------------------------------------------------
255 # External projects related options
256 #-----------------------------------------------------------------------------
257 CMAKE_DEPENDENT_OPTION(
258 Slicer_USE_PYTHONQT_WITH_OPENSSL "Enable PythonQt SSL support" ON
259 "Slicer_USE_PYTHONQT" OFF)
260 mark_as_superbuild(Slicer_USE_PYTHONQT_WITH_OPENSSL)
261
262 CMAKE_DEPENDENT_OPTION(
263 Slicer_USE_PYTHONQT_WITH_TCL "Enable PythonQt Tcl adapter layer" ON
264 "Slicer_USE_PYTHONQT" OFF)
265 mark_as_superbuild(Slicer_USE_PYTHONQT_WITH_TCL)
266
267 CMAKE_DEPENDENT_OPTION(
268 Slicer_USE_NUMPY "Build Slicer with NumPy" ON
269 "Slicer_USE_PYTHONQT" OFF)
270 mark_as_superbuild(Slicer_USE_NUMPY)
271
272 option(Slicer_USE_OpenIGTLink "Build Slicer with OpenIGTLink support." ON)
273 mark_as_superbuild(Slicer_USE_OpenIGTLink)
274
275 option(Slicer_USE_CTKAPPLAUNCHER "Configure ctkAppLauncher." ON)
276 mark_as_advanced(Slicer_USE_CTKAPPLAUNCHER)
277 mark_as_superbuild(Slicer_USE_CTKAPPLAUNCHER)
278
279 option(Slicer_USE_QtTesting "Integrate QtTesting framework into Slicer." ON)
280 mark_as_advanced(Slicer_USE_QtTesting)
281 mark_as_superbuild(Slicer_USE_QtTesting)
282
283 option(Slicer_USE_SimpleITK "Build Slicer with SimpleITK support" ON)
284 mark_as_superbuild(Slicer_USE_SimpleITK)
285
286 option(Slicer_BUILD_ITKPython "Build Python wrapping for ITK" OFF)
287 mark_as_superbuild(Slicer_BUILD_ITKPython)
288 CMAKE_DEPENDENT_OPTION(
289 Slicer_INSTALL_ITKPython "Install Slicer with Python wrapping for ITK" OFF
290 "Slicer_BUILD_ITKPython" OFF)
291 mark_as_superbuild(Slicer_INSTALL_ITKPython)
292
293 option(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT "Build Slicer with parameter serializer support" ON)
294 mark_as_superbuild(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT)
295
296 #
297 # SimpleITK has large internal libraries, which take an extremely long
298 # time to link on windows when they are static. Creating shared
299 # SimpleITK internal libraries can reduce linking time. Also the size
300 # of the debug libraries are monstrous. Using shared libraries for
301 # debug, reduce disc requirements, and can improve linking
302 # times. However, these shared libraries take longer to load than the
303 # monolithic target from static libraries.
304 #
305 set( Slicer_USE_SimpleITK_SHARED_DEFAULT OFF)
306 string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
307 if(MSVC OR _CMAKE_BUILD_TYPE MATCHES "DEBUG")
308 set(Slicer_USE_SimpleITK_SHARED_DEFAULT ON)
309 endif()
310 CMAKE_DEPENDENT_OPTION(Slicer_USE_SimpleITK_SHARED "Build SimpleITK with shared libraries. Reduces linking time, increases run-time load time." ${Slicer_USE_SimpleITK_SHARED_DEFAULT} "Slicer_USE_SimpleITK" OFF )
311 mark_as_superbuild(Slicer_USE_SimpleITK_SHARED)
312
313 #-----------------------------------------------------------------------------
314 # Install no development files by default, but allow the user to get
315 # them installed by setting Slicer_INSTALL_DEVELOPMENT to true.
316 #-----------------------------------------------------------------------------
317 #option(Slicer_INSTALL_DEVELOPMENT "Install Slicer extension development files." OFF)
318 #mark_as_advanced(Slicer_INSTALL_DEVELOPMENT)
319 set(Slicer_INSTALL_DEVELOPMENT OFF)
320 if(NOT Slicer_INSTALL_DEVELOPMENT)
321 set(Slicer_INSTALL_NO_DEVELOPMENT 1)
322 else()
323 set(Slicer_INSTALL_NO_DEVELOPMENT 0)
324 endif()
325
326 #-----------------------------------------------------------------------------
327 # Documentation
328 #-----------------------------------------------------------------------------
329 find_package(Doxygen QUIET)
330
331 if(DOXYGEN_DOT_FOUND)
332 mark_as_superbuild(DOXYGEN_EXECUTABLE)
333
334 set(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
335 CACHE PATH "Where documentation archives should be stored")
336 mark_as_advanced(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
337 mark_as_superbuild(DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
338
339 option(DOCUMENTATION_TARGET_IN_ALL "Include the custom target for building documentation in 'all'" OFF)
340 mark_as_advanced(DOCUMENTATION_TARGET_IN_ALL)
341 mark_as_superbuild(DOCUMENTATION_TARGET_IN_ALL)
342 endif()
343
344 #-----------------------------------------------------------------------------
345 # CTestCustom
346 #-----------------------------------------------------------------------------
347 configure_file(
348 CMake/CTestCustom.cmake.in
349 ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
350 @ONLY)
351
352 #-----------------------------------------------------------------------------
353 # Additional CXX/C Flags
354 #-----------------------------------------------------------------------------
355 set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags")
356 mark_as_advanced(ADDITIONAL_C_FLAGS)
357 set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags")
358 mark_as_advanced(ADDITIONAL_CXX_FLAGS)
359
360 #-----------------------------------------------------------------------------
361 # CMake Function(s) and Macro(s)
362 #-----------------------------------------------------------------------------
363 include(CMakeParseArguments)
364 include(Slicer3PluginsMacros)
365 include(SlicerMacroGetOperatingSystemArchitectureBitness)
366 if(Slicer_BUILD_I18N_SUPPORT)
367 include(SlicerMacroTranslation)
368 endif()
369 include(SlicerFunctionInstallLibrary)
370 include(SlicerFunctionAddPythonQtResources)
371
372 #-----------------------------------------------------------------------------
373 # Internationalization
374 #-----------------------------------------------------------------------------
375 if(Slicer_BUILD_I18N_SUPPORT)
376 set(Slicer_LANGUAGES
377 "fr"
378 )
379 set_property(GLOBAL PROPERTY Slicer_LANGUAGES ${Slicer_LANGUAGES})
380 endif()
381
382 #-----------------------------------------------------------------------------
383 # Set Slicer_{C,CXX}_REQUIRED_FLAGS variables
384 #-----------------------------------------------------------------------------
385 include(SlicerBlockCXXRequiredFlags)
386
387 #-----------------------------------------------------------------------------
388 # Main application
389 #-----------------------------------------------------------------------------
390 if(NOT DEFINED Slicer_MAIN_PROJECT)
391 set(Slicer_MAIN_PROJECT SlicerApp CACHE INTERNAL "Main project name")
392 endif()
393 mark_as_superbuild(Slicer_MAIN_PROJECT:STRING)
394 if(NOT DEFINED ${Slicer_MAIN_PROJECT}_APPLICATION_NAME)
395 set(${Slicer_MAIN_PROJECT}_APPLICATION_NAME Slicer CACHE INTERNAL "Main application name")
396 else()
397 if(NOT DEFINED SlicerApp_APPLICATION_NAME)
398 set(SlicerApp_APPLICATION_NAME Slicer)
399 endif()
400 endif()
401
402 set(Slicer_MAIN_PROJECT_APPLICATION_NAME ${${Slicer_MAIN_PROJECT}_APPLICATION_NAME})
403
404 if(WIN32)
405 option(Slicer_BUILD_WIN32_CONSOLE "Build ${PROJECT_NAME} executable as a console app on windows (allows debug output)" ON)
406 else()
407 set(Slicer_BUILD_WIN32_CONSOLE OFF)
408 endif()
409 mark_as_superbuild(Slicer_BUILD_WIN32_CONSOLE:BOOL)
410
411 #-----------------------------------------------------------------------------
412 # Organization name
413 #-----------------------------------------------------------------------------
414 if(NOT DEFINED Slicer_ORGANIZATION_DOMAIN)
415 set(Slicer_ORGANIZATION_DOMAIN "www.na-mic.org" CACHE STRING "Organization domain")
416 endif()
417 mark_as_advanced(Slicer_ORGANIZATION_DOMAIN)
418 mark_as_superbuild(Slicer_ORGANIZATION_DOMAIN)
419 message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} organization domain [${Slicer_ORGANIZATION_DOMAIN}]")
420
421 if(NOT DEFINED Slicer_ORGANIZATION_NAME)
422 set(Slicer_ORGANIZATION_NAME "NA-MIC" CACHE STRING "Organization name")
423 endif()
424 mark_as_advanced(Slicer_ORGANIZATION_NAME)
425 mark_as_superbuild(Slicer_ORGANIZATION_NAME)
426 message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} organization name [${Slicer_ORGANIZATION_NAME}]")
427
428 set(SLICER_REVISION_SPECIFIC_USER_SETTINGS_FILEBASENAME "")
429
430 #-----------------------------------------------------------------------------
431 # Home and favorite modules
432 #-----------------------------------------------------------------------------
433 if(NOT DEFINED Slicer_DEFAULT_HOME_MODULE)
434 set(Slicer_DEFAULT_HOME_MODULE "Welcome" CACHE STRING "Name of the module that Slicer activates on start-up by default")
435 endif()
436 mark_as_advanced(Slicer_DEFAULT_HOME_MODULE)
437 mark_as_superbuild(Slicer_DEFAULT_HOME_MODULE)
438 message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} default home module [${Slicer_DEFAULT_HOME_MODULE}]")
439
440 if(NOT DEFINED Slicer_DEFAULT_FAVORITE_MODULES)
441 set(Slicer_DEFAULT_FAVORITE_MODULES "SubjectHierarchy, Volumes, Models, Transforms, Markups, Editor" CACHE STRING "Name of the modules shown on the toolbar by default (comma-separated list)")
442 endif()
443 mark_as_advanced(Slicer_DEFAULT_FAVORITE_MODULES)
444 mark_as_superbuild(Slicer_DEFAULT_FAVORITE_MODULES)
445 message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} default favorite modules [${Slicer_DEFAULT_FAVORITE_MODULES}]")
446
447 #-----------------------------------------------------------------------------
448 # Disclaimer popup
449 #-----------------------------------------------------------------------------
450
451 if(NOT DEFINED Slicer_DISCLAIMER_AT_STARTUP)
452 set(Slicer_DISCLAIMER_AT_STARTUP "Thank you for using %1!<br><br>This software is not intended for clinical use." CACHE STRING "Text displayed at the first startup of Slicer in a popup window")
453 # Note: %1 is replaced by the application name and version. Add <br> for newline.
454 # If the disclaimer text is set to empty then no disclaimer popup is displayed.
455 endif()
456 mark_as_advanced(Slicer_DISCLAIMER_AT_STARTUP)
457 mark_as_superbuild(Slicer_DISCLAIMER_AT_STARTUP)
458 message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} text of disclaimer at startup [${Slicer_DISCLAIMER_AT_STARTUP}]")
459
460 #-----------------------------------------------------------------------------
461 # Slicer version number.
462 #-----------------------------------------------------------------------------
463 # Releases define a tweak level
464 set(Slicer_VERSION_TWEAK 0)
465 #set(Slicer_VERSION_RC 0)
466 include(SlicerVersion)
467
468 #-----------------------------------------------------------------------------
469 # Slicer sub-directories
470 #-----------------------------------------------------------------------------
471 set(Slicer_BIN_DIR "bin")
472 set(Slicer_LIB_DIR "lib/Slicer-${Slicer_VERSION_MAJOR}.${Slicer_VERSION_MINOR}")
473 set(Slicer_INCLUDE_DIR "include/Slicer-${Slicer_VERSION_MAJOR}.${Slicer_VERSION_MINOR}")
474 set(Slicer_SHARE_DIR "share/Slicer-${Slicer_VERSION_MAJOR}.${Slicer_VERSION_MINOR}")
475 set(Slicer_LIBEXEC_DIR "libexec/Slicer-${Slicer_VERSION_MAJOR}.${Slicer_VERSION_MINOR}")
476 set(Slicer_ITKFACTORIES_DIR "${Slicer_LIB_DIR}/ITKFactories")
477 set(Slicer_QM_DIR "${Slicer_BIN_DIR}/Translations")
478
479 if(Slicer_BUILD_CLI_SUPPORT)
480 # NOTE: Make sure to update vtkSlicerApplicationLogic::GetModuleShareDirectory()
481 # if the following variables are changed.
482
483 set(Slicer_CLIMODULES_SUBDIR "cli-modules")
484
485 set(Slicer_CLIMODULES_BIN_DIR "${Slicer_LIB_DIR}/${Slicer_CLIMODULES_SUBDIR}")
486 set(Slicer_CLIMODULES_LIB_DIR "${Slicer_LIB_DIR}/${Slicer_CLIMODULES_SUBDIR}")
487 set(Slicer_CLIMODULES_SHARE_DIR "${Slicer_SHARE_DIR}/${Slicer_CLIMODULES_SUBDIR}")
488 endif()
489
490 #-----------------------------------------------------------------------------
491 # Slicer install directories
492 #-----------------------------------------------------------------------------
493 set(Slicer_INSTALL_ROOT "./")
494 set(Slicer_BUNDLE_LOCATION "${Slicer_MAIN_PROJECT_APPLICATION_NAME}.app/Contents")
495 # NOTE: Make sure to update vtkSlicerApplicationLogic::IsEmbeddedModule if
496 # the following variables are changed.
497 set(Slicer_EXTENSIONS_DIRBASENAME "Extensions")
498 set(Slicer_EXTENSIONS_DIRNAME "${Slicer_EXTENSIONS_DIRBASENAME}-${Slicer_WC_REVISION}")
499 if(APPLE)
500 set(Slicer_INSTALL_ROOT "${Slicer_BUNDLE_LOCATION}/") # Set to create Bundle
501 endif()
502
503 set(Slicer_INSTALL_BIN_DIR "${Slicer_INSTALL_ROOT}${Slicer_BIN_DIR}")
504 set(Slicer_INSTALL_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_LIB_DIR}")
505 set(Slicer_INSTALL_INCLUDE_DIR "${Slicer_INSTALL_ROOT}${Slicer_INCLUDE_DIR}")
506 set(Slicer_INSTALL_SHARE_DIR "${Slicer_INSTALL_ROOT}${Slicer_SHARE_DIR}")
507 set(Slicer_INSTALL_LIBEXEC_DIR "${Slicer_INSTALL_ROOT}${Slicer_LIBEXEC_DIR}")
508 set(Slicer_INSTALL_ITKFACTORIES_DIR "${Slicer_INSTALL_LIB_DIR}/ITKFactories")
509 set(Slicer_INSTALL_QM_DIR "${Slicer_INSTALL_ROOT}${Slicer_QM_DIR}")
510
511 if(Slicer_BUILD_CLI_SUPPORT)
512 set(Slicer_INSTALL_CLIMODULES_BIN_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_BIN_DIR}")
513 set(Slicer_INSTALL_CLIMODULES_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_LIB_DIR}")
514 set(Slicer_INSTALL_CLIMODULES_SHARE_DIR "${Slicer_INSTALL_ROOT}${Slicer_CLIMODULES_SHARE_DIR}")
515 endif()
516
517 #-----------------------------------------------------------------------------
518 # VTKv7 - Slicer_VTK_COMPONENTS
519 #-----------------------------------------------------------------------------
520 set(Slicer_VTK_RENDERING_BACKEND "OpenGL" CACHE STRING "Choose the rendering backend.")
521 set_property(CACHE Slicer_VTK_RENDERING_BACKEND PROPERTY STRINGS "OpenGL" "OpenGL2")
522 mark_as_superbuild(Slicer_VTK_RENDERING_BACKEND)
523 set(Slicer_VTK_RENDERING_USE_${Slicer_VTK_RENDERING_BACKEND}_BACKEND 1)
524
525 set(Slicer_VTK_COMPONENTS
526 vtkFiltersExtraction
527 vtkFiltersFlowPaths
528 vtkFiltersGeometry
529 vtkGUISupportQtOpenGL
530 vtkGUISupportQtSQL
531 vtkIOExport
532 vtkIOImage
533 vtkIOLegacy
534 vtkIOPLY
535 vtkIOXML
536 vtkImagingMath
537 vtkImagingMorphological
538 vtkImagingStatistics
539 vtkImagingStencil
540 vtkInteractionImage
541 vtkRenderingContext${Slicer_VTK_RENDERING_BACKEND}
542 vtkRenderingQt
543 vtkRenderingVolume${Slicer_VTK_RENDERING_BACKEND}
544 vtkTestingRendering
545 vtkViewsQt
546 vtkzlib
547 )
548 if(Slicer_USE_PYTHONQT)
549 list(APPEND Slicer_VTK_COMPONENTS
550 vtkWrappingPythonCore
551 )
552 endif()
553 if(UNIX AND NOT APPLE)
554 find_package(FontConfig QUIET)
555 if(FONTCONFIG_FOUND)
556 list(APPEND Slicer_VTK_COMPONENTS
557 vtkRenderingFreeTypeFontConfig
558 # vtkRenderingFreeTypeOpenGL # Since commit 4f7460a5 (> 6.2.0), vtkRenderingFreeTypeOpenGL
559 # has been removed. This mean Slicer will not compile
560 # against version of VTK folder than 6.3.0 having FontConfig
561 # capabilities.
562 # If this is needed, a configure test would have to
563 # be added to check if the module is available or not.
564 )
565 if(TARGET vtkRenderingFreeTypeOpenGL)
566 list(APPEND VTK_LIBRARIES vtkRenderingFreeTypeOpenGL)
567 endif()
568 endif()
569 endif()
570
571 #-----------------------------------------------------------------------------
572 # Qt - Slicer_REQUIRED_QT_MODULES
573 #-----------------------------------------------------------------------------
574 # Module name should be specified as they appear in FindQt4.cmake
575 # For example, the module name associated with the variable QT_USE_QTXML is QTXML.
576 # Note that the modules will be installed when packaging.
577 set(Slicer_REQUIRED_QT_MODULES
578 QTCORE QTGUI
579 QTNETWORK QTOPENGL
580 QTUITOOLS #no dll
581 QTXML QTXMLPATTERNS
582 QTWEBKIT
583 QTSVG QTSQL
584 )
585 if(WIN32)
586 list(APPEND Slicer_REQUIRED_QT_MODULES PHONON) # webkit requires phonon
587 endif()
588 if(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT)
589 list(APPEND Slicer_REQUIRED_QT_MODULES QTSCRIPT)
590 endif()
591 if(BUILD_TESTING)
592 list(APPEND Slicer_REQUIRED_QT_MODULES QTTEST)
593 endif()
594 list(APPEND Slicer_REQUIRED_QT_MODULES ${Slicer_ADDITIONAL_REQUIRED_QT_MODULES})
595
596 if(DEFINED Slicer_ADDITIONAL_REQUIRED_QT_MODULES)
597 mark_as_superbuild(Slicer_ADDITIONAL_REQUIRED_QT_MODULES:STRING)
598 endif()
599
600 mark_as_superbuild(Slicer_USE_SYSTEM_QT:BOOL)
601
602 #-----------------------------------------------------------------------------
603 # Qt plugins (designer, imageformats, ...) relative directories
604 #-----------------------------------------------------------------------------
605 set(Slicer_QtPlugins_DIR "lib/QtPlugins")
606 set(Slicer_INSTALL_QtPlugins_DIR "${Slicer_INSTALL_ROOT}${Slicer_QtPlugins_DIR}")
607
608 #-----------------------------------------------------------------------------
609 # Qt
610 #-----------------------------------------------------------------------------
611 include(SlicerBlockFindQtAndCheckVersion)
612 mark_as_superbuild(VARS QT_QMAKE_EXECUTABLE LABELS "FIND_PACKAGE")
613
614 #-----------------------------------------------------------------------------
615 # Testing
616 #-----------------------------------------------------------------------------
617 # NOTE: For CTEST_USE_LAUNCHER to work, it's required to include CTest at the superbuild level.
618 # See http://www.kitware.com/blog/home/post/11
619
620 set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1) # Do not add CTest default targets
621 include(CTest)
622
623 # Add Experimental target - Adapted from CTestTargets.cmake
624 set(__conf_types "")
625 if(CMAKE_CONFIGURATION_TYPES)
626 # We need to pass the configuration type on the test command line.
627 set(__conf_types -C "${CMAKE_CFG_INTDIR}")
628 endif()
629 add_custom_target(Experimental ${CMAKE_CTEST_COMMAND} ${__conf_types} -D Experimental)
630
631 #-----------------------------------------------------------------------------
632 # Superbuild script
633 #-----------------------------------------------------------------------------
634 if(Slicer_SUPERBUILD)
635 include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
636 return()
637 endif()
638
639 foreach(dep QT ${Slicer_DEPENDENCIES})
640 if(Slicer_USE_SYSTEM_${dep})
641 message(STATUS "Using system ${dep}")
642 endif()
643 endforeach()
644
645 #-----------------------------------------------------------------------------
646 # Folders
647 #-----------------------------------------------------------------------------
648 set_property(GLOBAL PROPERTY USE_FOLDERS ${Slicer_USE_FOLDERS})
649
650 #-----------------------------------------------------------------------------
651 # Clear SlicerTargets.cmake
652 #-----------------------------------------------------------------------------
653 file(WRITE "${Slicer_BINARY_DIR}/SlicerTargets.cmake" "")
654
655 #-----------------------------------------------------------------------------
656 # Output directories.
657 #------------------------------------------------------------------------------
658 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Slicer_BINARY_DIR}/${Slicer_BIN_DIR})
659 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Slicer_BINARY_DIR}/${Slicer_BIN_DIR})
660 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Slicer_BINARY_DIR}/${Slicer_LIB_DIR})
661
662 #-----------------------------------------------------------------------------
663 # Slicer Home
664 #------------------------------------------------------------------------------
665 set(Slicer_HOME "${Slicer_BINARY_DIR}")
666
667 #-----------------------------------------------------------------------------
668 # Avoid linker bug in Mac OS 10.5
669 # See http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
670 #
671 if(APPLE)
672 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")
673 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")
674 endif()
675
676 #-----------------------------------------------------------------------------
677 # Slicer include and libraries subdirectory
678 #
679
680 set(Slicer_Base_LIBRARIES CACHE INTERNAL "Slicer Base libraries" FORCE)
681 set(Slicer_Base_INCLUDE_DIRS CACHE INTERNAL "Slicer Base includes" FORCE)
682 set(Slicer_ModuleLogic_INCLUDE_DIRS CACHE INTERNAL "Slicer Module logic includes" FORCE)
683 set(Slicer_ModuleMRML_INCLUDE_DIRS CACHE INTERNAL "Slicer Module MRML includes" FORCE)
684 set(Slicer_ModuleWidgets_INCLUDE_DIRS CACHE INTERNAL "Slicer Module Widgets includes" FORCE)
685
686 #-----------------------------------------------------------------------------
687 # Get operating system, architecture and bitness
688 #-----------------------------------------------------------------------------
689 SlicerMacroGetOperatingSystemArchitectureBitness(VAR_PREFIX Slicer)
690 message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} for [${Slicer_OS}-${Slicer_ARCHITECTURE}]")
691
692 #-----------------------------------------------------------------------------
693 # ExternalData configuration for test data
694 #-----------------------------------------------------------------------------
695 set(Slicer_ExternalData_DATA_MANAGEMENT_TARGET ${PROJECT_NAME}Data)
696 list(APPEND ExternalData_URL_TEMPLATES "http://slicer.kitware.com/midas3/api/rest?method=midas.bitstream.download&checksum=%(hash)")
697 set(ExternalData_OBJECT_STORES ${Slicer_BINARY_DIR}/ExternalData/Objects)
698 include(ExternalData)
699 set(Slicer_ExternalData_OBJECT_STORES ${ExternalData_OBJECT_STORES})
700 set(Slicer_ExternalData_URL_TEMPLATES ${ExternalData_URL_TEMPLATES})
701
702 #-----------------------------------------------------------------------------
703 # Testing
704 #-----------------------------------------------------------------------------
705 set(Slicer_LAUNCHER_EXECUTABLE ${Slicer_BINARY_DIR}/${Slicer_MAIN_PROJECT_APPLICATION_NAME}${CMAKE_EXECUTABLE_SUFFIX})
706 set(Slicer_LAUNCH_COMMAND ${Slicer_LAUNCHER_EXECUTABLE} --launcher-no-splash --launch)
707
708 include(SlicerMacroConfigureModuleCxxTestDriver)
709 include(SlicerMacroSimpleTest)
710 include(SlicerMacroPythonTesting)
711 include(SlicerMacroConfigureGenericCxxModuleTests)
712 include(SlicerMacroConfigureGenericPythonModuleTests)
713
714 if(BUILD_TESTING)
715 include(MIDAS)
716 set(MIDAS_REST_URL "http://midas.kitware.com/api/rest" CACHE STRING "The MIDAS server where testing data resides")
717 set(MIDAS_KEY_DIR "${Slicer_SOURCE_DIR}/Testing/Data")
718 set(MIDAS_DATA_DIR "${Slicer_BINARY_DIR}/MIDAS_Data")
719
720 # The variable CXX_TEST_PATH should *NOT* be used when adding tests.
721 # Instead the the $<TARGET_FILE:...> generator expression should be
722 # considered. See r16586 for more details.
723 set(CXX_TEST_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # XXX
724
725 configure_file(
726 ${Slicer_SOURCE_DIR}/CTestConfig.cmake
727 ${Slicer_BINARY_DIR}/${Slicer_BIN_DIR}/CTestConfig.cmake
728 COPYONLY)
729
730 add_subdirectory(CMake/Testing)
731 add_subdirectory(Extensions/CMake/Testing)
732
733 if(Slicer_BUILD_CLI_SUPPORT)
734 set(SEM_LAUNCH_COMMAND ${Slicer_LAUNCH_COMMAND})
735 if(USE_VALGRIND)
736 set(SEM_LAUNCH_COMMAND "${Slicer_BINARY_DIR}/Scripts/runValgrindForOneModule.sh")
737 endif()
738 endif()
739 endif()
740
741 #-----------------------------------------------------------------------------
742 # NOTE: How to include dependent packages ?
743 #-----------------------------------------------------------------------------
744
745 # Every Slicer sub project, library or module is responsible
746 # to call find_package (optionally specifying a list of components)
747 # and (if it applies) include the associated "use file".
748 #
749 # This means that moving forward most of the find_package calls listed below
750 # will be removed.
751
752 #-----------------------------------------------------------------------------
753 # VTK
754 #-----------------------------------------------------------------------------
755 find_package(VTK 7.1 COMPONENTS ${Slicer_VTK_COMPONENTS} REQUIRED NO_MODULE)
756 if(NOT TARGET vtkGUISupportQt)
757 message(FATAL_ERROR "error: VTK was not configured to use QT, you probably need "
758 "to recompile it with VTK_USE_GUISUPPORT ON, VTK_Group_Qt ON, "
759 "DESIRED_QT_VERSION 4 and QT_QMAKE_EXECUTABLE set appropriatly. "
760 "Note that Qt >= ${Slicer_REQUIRED_QT_VERSION} is *required*")
761 endif()
762 include(${VTK_USE_FILE})
763 if(NOT DEFINED VTK_RENDERING_BACKEND)
764 set(VTK_RENDERING_BACKEND "OpenGL")
765 endif()
766
767 #-----------------------------------------------------------------------------
768 # CTK
769 #-----------------------------------------------------------------------------
770 find_package(CTK REQUIRED)
771 include(${CTK_USE_FILE})
772
773 #-----------------------------------------------------------------------------
774 # Update CMake module path
775 #-----------------------------------------------------------------------------
776 set(CMAKE_MODULE_PATH
777 ${CTK_CMAKE_DIR}
778 ${CMAKE_MODULE_PATH}
779 ${CTK_CMAKE_UTILITIES_DIR})
780
781 #-----------------------------------------------------------------------------
782 # Set Slicer_PYTHON_VERSION and Slicer_PYTHON_VERSION_DOT
783 #-----------------------------------------------------------------------------
784 if(Slicer_USE_PYTHONQT)
785 find_package(PythonLibs REQUIRED)
786 find_package(PythonInterp REQUIRED)
787 # Extract python lib path
788 get_filename_component(PYTHON_DIR_PATH ${PYTHON_EXECUTABLE} PATH)
789 set(PYTHON_LIBRARY_PATH ${PYTHON_DIR_PATH}/../lib)
790 if(WIN32)
791 set(PYTHON_LIBRARY_PATH ${PYTHON_DIR_PATH})
792 endif()
793 ctkMacroSetPaths("${PYTHON_LIBRARY_PATH}")
794 execute_process(
795 COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print sys.version[:3]"
796 OUTPUT_VARIABLE Slicer_PYTHON_VERSION_DOT
797 OUTPUT_STRIP_TRAILING_WHITESPACE)
798 string(REGEX REPLACE "[.]" "" Slicer_PYTHON_VERSION ${Slicer_PYTHON_VERSION_DOT})
799 message(STATUS "Configuring ${Slicer_MAIN_PROJECT_APPLICATION_NAME} with python ${Slicer_PYTHON_VERSION_DOT}")
800
801 set(CTK_COMPILE_PYTHON_SCRIPTS_GLOBAL_TARGET_NAME "Slicer")
802 endif()
803
804 #-----------------------------------------------------------------------------
805 # PythonQt
806 #-----------------------------------------------------------------------------
807 if(Slicer_USE_PYTHONQT)
808 # Find PythonQt package so that PYTHONQT_USE_RELEASE_PYTHON_FALLBACK is defined
809 # See https://github.com/commontk/PythonQt/issues/7
810 # and https://github.com/commontk/PythonQt/issues/8
811 find_package(PythonQt REQUIRED)
812 link_directories(${PYTHONQT_INSTALL_DIR}/lib)
813 include(ctkMacroWrapPythonQt)
814 include(ctkMacroCompilePythonScript)
815
816 # Enable qMRMLWidgets python wrapping
817 set(MRMLWidgets_WRAP_PYTHON ON)
818 endif()
819
820 #-----------------------------------------------------------------------------
821 # Teem
822 #-----------------------------------------------------------------------------
823 # XXX Waiting teem provide a correct TeemConfig.cmake exporting targets, this is needed
824 # to ensure the link_directories for teem is defined and avoid error like:
825 # warning: libteem.so.1, needed by ../../../../bin/libvtkTeem.so, may conflict with libteem.so.2
826 find_package(Teem REQUIRED)
827 include(${Teem_USE_FILE})
828
829 #-----------------------------------------------------------------------------
830 # SlicerExecutionModel settings
831 #-----------------------------------------------------------------------------
832 set(SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES "" CACHE INTERNAL "SlicerExecutionModel extra includes" FORCE)
833 set(SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES "" CACHE INTERNAL "SlicerExecutionModel extra executable target libraries" FORCE)
834
835 #-----------------------------------------------------------------------------
836 # Set Slicer buildin libraries *_DIR variables
837 #-----------------------------------------------------------------------------
838 set(GenerateLM_DIR ${Slicer_BINARY_DIR}/Libs/GenerateLM)
839 set(vtkAddon_DIR ${Slicer_BINARY_DIR}/Libs/vtkAddon)
840 set(vtkITK_DIR ${Slicer_BINARY_DIR}/Libs/vtkITK)
841
842 #-----------------------------------------------------------------------------
843 # Qt Loadable and Scripted Modules relative directories
844 #-----------------------------------------------------------------------------
845
846 # NOTE: Make sure to update vtkSlicerApplicationLogic::GetModuleShareDirectory()
847 # if the following variables are changed.
848
849 set(Slicer_QTLOADABLEMODULES_SUBDIR "qt-loadable-modules")
850
851 set(Slicer_QTLOADABLEMODULES_BIN_DIR "${Slicer_LIB_DIR}/${Slicer_QTLOADABLEMODULES_SUBDIR}")
852 set(Slicer_QTLOADABLEMODULES_LIB_DIR "${Slicer_LIB_DIR}/${Slicer_QTLOADABLEMODULES_SUBDIR}")
853 set(Slicer_QTLOADABLEMODULES_PYTHON_LIB_DIR "${Slicer_LIB_DIR}/${Slicer_QTLOADABLEMODULES_SUBDIR}/Python")
854 set(Slicer_QTLOADABLEMODULES_INCLUDE_DIR "${Slicer_INCLUDE_DIR}/${Slicer_QTLOADABLEMODULES_SUBDIR}")
855 set(Slicer_QTLOADABLEMODULES_SHARE_DIR "${Slicer_SHARE_DIR}/${Slicer_QTLOADABLEMODULES_SUBDIR}")
856
857 set(Slicer_INSTALL_QTLOADABLEMODULES_BIN_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTLOADABLEMODULES_BIN_DIR}")
858 set(Slicer_INSTALL_QTLOADABLEMODULES_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTLOADABLEMODULES_LIB_DIR}")
859 set(Slicer_INSTALL_QTLOADABLEMODULES_PYTHON_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTLOADABLEMODULES_PYTHON_LIB_DIR}")
860 set(Slicer_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTLOADABLEMODULES_INCLUDE_DIR}")
861 set(Slicer_INSTALL_QTLOADABLEMODULES_SHARE_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTLOADABLEMODULES_SHARE_DIR}")
862
863 if(Slicer_USE_PYTHONQT)
864 set(Slicer_QTSCRIPTEDMODULES_SUBDIR "qt-scripted-modules")
865
866 set(Slicer_QTSCRIPTEDMODULES_BIN_DIR "${Slicer_LIB_DIR}/${Slicer_QTSCRIPTEDMODULES_SUBDIR}")
867 set(Slicer_QTSCRIPTEDMODULES_LIB_DIR "${Slicer_LIB_DIR}/${Slicer_QTSCRIPTEDMODULES_SUBDIR}")
868 set(Slicer_QTSCRIPTEDMODULES_INCLUDE_DIR "${Slicer_INCLUDE_DIR}/${Slicer_QTSCRIPTEDMODULES_SUBDIR}")
869 set(Slicer_QTSCRIPTEDMODULES_SHARE_DIR "${Slicer_SHARE_DIR}/${Slicer_QTSCRIPTEDMODULES_SUBDIR}")
870
871 set(Slicer_INSTALL_QTSCRIPTEDMODULES_BIN_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTSCRIPTEDMODULES_BIN_DIR}")
872 set(Slicer_INSTALL_QTSCRIPTEDMODULES_LIB_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTSCRIPTEDMODULES_LIB_DIR}")
873 set(Slicer_INSTALL_QTSCRIPTEDMODULES_INCLUDE_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTSCRIPTEDMODULES_INCLUDE_DIR}")
874 set(Slicer_INSTALL_QTSCRIPTEDMODULES_SHARE_DIR "${Slicer_INSTALL_ROOT}${Slicer_QTSCRIPTEDMODULES_SHARE_DIR}")
875 endif()
876
877 #-----------------------------------------------------------------------------
878 # Set COVERAGE_{C,CXX}_FLAGS variables
879 #-----------------------------------------------------------------------------
880 include(SlicerBlockCXXCoverageFlags)
881
882 #-----------------------------------------------------------------------------
883 # Set ITK_REQUIRED_{C,CXX}_FLAGS variables
884 #-----------------------------------------------------------------------------
885 include(ITKPlatformSpecificChecks)
886
887 #-----------------------------------------------------------------------------
888 # Set CMAKE_{C,CXX}_FLAGS variables
889 #-----------------------------------------------------------------------------
890 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${Slicer_REQUIRED_C_FLAGS} ${ITK_REQUIRED_C_FLAGS} ${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}" CACHE STRING "CMake C Flags" FORCE)
891 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${Slicer_REQUIRED_CXX_FLAGS} ${ITK_REQUIRED_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}" CACHE STRING "CMake CXX Flags" FORCE)
892
893 #-----------------------------------------------------------------------------
894 # Set the header template which defines custom export/import macros
895 # for shared libraries
896 #-----------------------------------------------------------------------------
897 set(QMRML_EXPORT_HEADER_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/Libs/MRML/Widgets/CMake/qMRMLExport.h.in")
898
899 #-----------------------------------------------------------------------------
900 # Configure testing scripts
901 #-----------------------------------------------------------------------------
902 set(files
903 Utilities/Scripts/runValgrind.sh
904 Utilities/Scripts/runValgrindForOneModule.sh
905 Utilities/Scripts/runValgrindForOneModuleWithSlicer4AndQT.sh
906 Utilities/Scripts/computeCodeCoverageLocally.sh
907 Utilities/Scripts/computeCodeCoverageForOneTest.sh
908 Utilities/Scripts/runExperimentalOffScreen.sh
909 Utilities/Scripts/setupSlicerEnvironment.sh
910 )
911 foreach(f ${files})
912 configure_file(
913 ${CMAKE_CURRENT_SOURCE_DIR}/${f}.in
914 ${CMAKE_CURRENT_BINARY_DIR}/${f}
915 )
916 endforeach()
917
918 #-----------------------------------------------------------------------------
919 # Includes
920 #-----------------------------------------------------------------------------
921 include_directories(
922 ${CMAKE_CURRENT_SOURCE_DIR}/CMake
923 ${CMAKE_CURRENT_SOURCE_DIR}
924 ${CMAKE_CURRENT_BINARY_DIR}
925 )
926
927 #-----------------------------------------------------------------------------
928 # Subdirectories
929 #-----------------------------------------------------------------------------
930
931 add_subdirectory(Libs)
932 add_subdirectory(Base)
933 add_subdirectory(Resources)
934 add_subdirectory(Utilities/Scripts)
935 add_subdirectory(Utilities/Scripts/SlicerWizard)
936 add_subdirectory(Utilities/Templates)
937
938 #-----------------------------------------------------------------------------
939 # Macro useful to build ModuleLogic, ModuleMRML and ModuleWidgets libraries
940 #-----------------------------------------------------------------------------
941 include(SlicerMacroBuildModuleQtLibrary)
942 include(SlicerMacroBuildModuleVTKLibrary)
943 include(SlicerMacroPythonWrapModuleVTKLibrary)
944 include(SlicerMacroBuildModuleLogic)
945 include(SlicerMacroBuildModuleMRML)
946 include(SlicerMacroBuildModuleWidgets)
947
948 #-----------------------------------------------------------------------------
949 # Slicer Core and GUI library
950 #-----------------------------------------------------------------------------
951 set(Slicer_CORE_LIBRARY qSlicerBaseQTCore)
952 set(Slicer_GUI_LIBRARY qSlicerBaseQTApp)
953
954 #-----------------------------------------------------------------------------
955 # Applications
956 #-----------------------------------------------------------------------------
957 add_subdirectory(Modules/Core)
958 add_subdirectory(Base/QTApp)
959 add_subdirectory(Modules)
960 if (NOT Slicer_APPLICATIONS_DIR)
961 add_subdirectory(Applications)
962 else()
963 add_subdirectory(${Slicer_APPLICATIONS_DIR}
964 ${CMAKE_CURRENT_BINARY_DIR}/Applications
965 )
966 endif()
967
968
969 #-----------------------------------------------------------------------------
970 set(Slicer_USE_FILE ${Slicer_BINARY_DIR}/UseSlicer.cmake)
971 configure_file(
972 ${Slicer_SOURCE_DIR}/CMake/UseSlicer.cmake.in
973 ${Slicer_USE_FILE} COPYONLY)
974
975 configure_file(
976 ${Slicer_SOURCE_DIR}/CMake/SlicerConfigVersion.cmake.in
977 ${Slicer_BINARY_DIR}/SlicerConfigVersion.cmake @ONLY)
978
979 set(Slicer_EXTENSION_CPACK ${Slicer_SOURCE_DIR}/CMake/SlicerExtensionCPack.cmake)
980
981
982 # --------------------------------------------------------------------------
983 # Bundle extension(s)
984 # --------------------------------------------------------------------------
985
986 set(extensions_build_dir "${Slicer_BINARY_DIR}/E")
987
988 # Configure SlicerConfig for bundled extension(s) or module(s)
989 set(Slicer_DIR ${extensions_build_dir})
990 configure_file(
991 ${Slicer_SOURCE_DIR}/CMake/SlicerConfig.cmake.in
992 ${Slicer_DIR}/SlicerConfig.cmake @ONLY)
993
994 message(STATUS "--------------------------------------------------")
995 message(STATUS "Configuring remote modules")
996 message(STATUS "--------------------------------------------------")
997 add_subdirectory(Modules/Remote)
998
999 # Add remote extension source directories.
1000 #
1001 # Directories can be set in two ways:
1002 #
1003 # (1) Automatically by specifying the label 'REMOTE_EXTENSION' when
1004 # calling 'Slicer_Remote_Add' from SuperBuild.cmake.
1005 #
1006 # (2) Expicitly by configuring the project using the following syntax:
1007 # cmake -DSlicer_EXTENSION_SOURCE_DIRS:STRING=/path/to/ExtensionA;/path/to/ExtensionB /path/to/source/Slicer
1008 #
1009 foreach(varname ${Slicer_EP_LABEL_REMOTE_EXTENSION})
1010 list(APPEND Slicer_EXTENSION_SOURCE_DIRS ${${varname}})
1011 endforeach()
1012 foreach(extension_source_dir ${Slicer_EXTENSION_SOURCE_DIRS})
1013 get_filename_component(extension_source_dir ${extension_source_dir} REALPATH)
1014 get_filename_component(extension_source_dirname ${extension_source_dir} NAME_WE)
1015 message(STATUS "--------------------------------------------------")
1016 message(STATUS "Configuring extension: ${extension_source_dirname}")
1017 set(ExternalData_SOURCE_ROOT ${extension_source_dir})
1018 set(${extension_source_dirname}_SOURCE_DIR ${extension_source_dir})
1019 set(${extension_source_dirname}_BINARY_DIR ${extensions_build_dir}/${extension_source_dirname})
1020 add_subdirectory(
1021 ${${extension_source_dirname}_SOURCE_DIR}
1022 ${${extension_source_dirname}_BINARY_DIR}
1023 )
1024 endforeach()
1025 unset(Slicer_DIR)
1026
1027 # --------------------------------------------------------------------------
1028 # Recover the QM output directories
1029 # --------------------------------------------------------------------------
1030 get_property(Slicer_QM_OUTPUT_DIRS GLOBAL PROPERTY Slicer_QM_OUTPUT_DIRS)
1031
1032 # --------------------------------------------------------------------------
1033 # Configure and install headers
1034 # --------------------------------------------------------------------------
1035
1036 set(files
1037 vtkSlicerConfigure.h
1038 vtkSlicerVersionConfigureInternal.h
1039 )
1040 foreach(f ${files})
1041 configure_file(
1042 ${CMAKE_CURRENT_SOURCE_DIR}/CMake/${f}.in
1043 ${CMAKE_CURRENT_BINARY_DIR}/${f}
1044 )
1045 endforeach()
1046
1047 # Add target configuring 'vtkSlicerVersionConfigure.h' at build time.
1048 include(SlicerConfigureVersionHeaderTarget)
1049 add_dependencies(SlicerBaseLogic SlicerConfigureVersionHeader)
1050
1051 list(APPEND files ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerVersionConfigure.h)
1052
1053 if(NOT Slicer_INSTALL_NO_DEVELOPMENT)
1054 install(
1055 FILES ${files}
1056 DESTINATION ${Slicer_INSTALL_INCLUDE_DIR} COMPONENT Development
1057 )
1058 endif()
1059
1060 #-----------------------------------------------------------------------------
1061 # Testing
1062 #-----------------------------------------------------------------------------
1063
1064 if(BUILD_TESTING)
1065 add_subdirectory(Testing)
1066 endif()
1067
1068 # Install testing data
1069
1070 if(NOT Slicer_INSTALL_NO_DEVELOPMENT)
1071 install(DIRECTORY
1072 Testing
1073 DESTINATION ${Slicer_INSTALL_SHARE_DIR} COMPONENT Development
1074 PATTERN ".svn" EXCLUDE
1075 PATTERN "CMakeLists.txt" EXCLUDE
1076 )
1077 endif()
1078
1079 #-----------------------------------------------------------------------------
1080 # Documentation
1081 #-----------------------------------------------------------------------------
1082
1083 # Automatically generate documentation at build time
1084 set(all_arg)
1085 if(DOCUMENTATION_TARGET_IN_ALL)
1086 set(all_arg "ALL")
1087 endif()
1088 add_custom_target(doc ${all_arg})
1089 add_custom_target(doc-tarballs ${all_arg})
1090
1091 add_subdirectory(Utilities/Doxygen)
1092 add_subdirectory(Utilities/Scripts/SlicerWizard/doc)
1093
1094 if(NOT Slicer_INSTALL_NO_DEVELOPMENT)
1095 file(GLOB cmake_files "${CMAKE_CURRENT_SOURCE_DIR}/CMake/*.cmake")
1096 install(
1097 FILES ${cmake_files}
1098 DESTINATION ${Slicer_INSTALL_LIB_DIR}/CMake COMPONENT Development
1099 )
1100
1101 install(FILES
1102 ${Slicer_BINARY_DIR}/UseSlicer.cmake
1103 ${Slicer_BINARY_DIR}/SlicerConfig.cmake
1104 ${Slicer_BINARY_DIR}/SlicerConfigVersion.cmake
1105 DESTINATION ${Slicer_INSTALL_LIB_DIR}
1106 COMPONENT Development
1107 )
1108 endif()
1109
1110 #-----------------------------------------------------------------------------
1111 # Create target to download data from the <Slicer_ExternalData_DATA_MANAGEMENT_TARGET> group.
1112 # This must come after all tests have been added that reference the group, so we put it last.
1113 ExternalData_Add_Target(${Slicer_ExternalData_DATA_MANAGEMENT_TARGET})
1114
1115 #-----------------------------------------------------------------------------
1116 # Create targets CopySlicerPython{Resource, Script}Files, CompileSlicerPythonFiles
1117 if(Slicer_USE_PYTHONQT)
1118 slicerFunctionAddPythonQtResourcesTargets(SlicerPythonResources)
1119 ctkFunctionAddCompilePythonScriptTargets(
1120 ${CTK_COMPILE_PYTHON_SCRIPTS_GLOBAL_TARGET_NAME}
1121 DEPENDS SlicerPythonResources
1122 )
1123 endif()
1124
1125 #-----------------------------------------------------------------------------
1126 # The commands in this directory are intended to be executed as
1127 # the end of the whole configuration process, as a "last step".
1128 # This directory is typically the last add_subdirectory in the main CMakeLists.txt.
1129 add_subdirectory(CMake/LastConfigureStep)

  ViewVC Help
Powered by ViewVC 1.1.22