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

View of /trunk/CMakeLists.txt

Parent Directory Parent Directory Revision Log Revision Log


Revision 26350  Download Blame
File MIME type: text/plain
File size: 53708 byte(s)
COMP: Remove unused Slicer3PluginsMacros CMake module

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

  Subversion  TortoiseSVN  ViewVC