SlicerConfig.cmake.in 15.2 KB
Newer Older
1
#
2
# This file has been primarly designed for the purpose of Slicer extension development.
3
#
4 5
# This file is configured by Slicer and used by UseSlicer.cmake module
# to load Slicer's settings for an external project. External projects
6 7
# can use these setting to build new modules against a Slicer build tree.
#
8 9
#

10
# --------------------------------------------------------------------------
11
# Slicer options
12
# --------------------------------------------------------------------------
13 14 15
set(Slicer_USE_BatchMake "@Slicer_USE_BatchMake@")
set(Slicer_USE_MIDAS "@Slicer_USE_MIDAS@")
set(Slicer_USE_NUMPY "@Slicer_USE_NUMPY@")
16
set(Slicer_USE_OpenIGTLink "@Slicer_USE_OpenIGTLink@")
17 18
set(Slicer_USE_PYTHONQT "@Slicer_USE_PYTHONQT@")
set(Slicer_USE_PYTHONQT_WITH_TCL "@Slicer_USE_PYTHONQT_WITH_TCL@")
19
set(Slicer_USE_QtTesting "@Slicer_USE_QtTesting@")
20
set(Slicer_BUILD_CLI_SUPPORT "@Slicer_BUILD_CLI_SUPPORT@")
21
set(Slicer_BUILD_DICOM_SUPPORT "@Slicer_BUILD_DICOM_SUPPORT@")
22
set(Slicer_BUILD_DIFFUSION_SUPPORT "@Slicer_BUILD_DIFFUSION_SUPPORT@")
23
set(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT "@Slicer_BUILD_EXTENSIONMANAGER_SUPPORT@")
24
set(Slicer_BUILD_TESTING "@BUILD_TESTING@")
25 26 27 28 29

set(Slicer_REQUIRED_QT_VERSION "@Slicer_REQUIRED_QT_VERSION@")
set(Slicer_REQUIRED_QT_MODULES "@Slicer_REQUIRED_QT_MODULES@")

set(Slicer_CMAKE_DIR "@Slicer_CMAKE_DIR@")
30
set(Slicer_EXTENSIONS_CMAKE_DIR "@Slicer_EXTENSIONS_CMAKE_DIR@")
31

32 33 34 35
# Launcher command
set(Slicer_LAUNCHER_EXECUTABLE "@Slicer_LAUNCHER_EXECUTABLE_CONFIG@")
set(Slicer_LAUNCH_COMMAND "@Slicer_LAUNCH_COMMAND_CONFIG@")

36 37 38 39 40
# Slicer working copy Revision, URL and Root
set(Slicer_WC_REVISION "@Slicer_WC_REVISION@")
set(Slicer_WC_URL "@Slicer_WC_URL@")
set(Slicer_WC_ROOT "@Slicer_WC_ROOT@")

41 42
# Slicer os and architecture
set(Slicer_OS "@Slicer_OS@")
43
set(Slicer_ARCHITECTURE "@Slicer_ARCHITECTURE@")
44

45 46 47 48
# Slicer main application
set(Slicer_MAIN_PROJECT "@Slicer_MAIN_PROJECT@")
set(Slicer_MAIN_PROJECT_APPLICATION_NAME "@Slicer_MAIN_PROJECT_APPLICATION_NAME@")

49 50 51 52
# License and Readme file
set(Slicer_LICENSE_FILE "@Slicer_LICENSE_FILE_CONFIG@")
set(Slicer_README_FILE "@Slicer_README_FILE_CONFIG@")

53 54
# Test templates directory
set(Slicer_CXX_MODULE_TEST_TEMPLATES_DIR "@Slicer_CXX_MODULE_TEST_TEMPLATES_DIR_CONFIG@")
55 56
set(Slicer_PYTHON_MODULE_TEST_TEMPLATES_DIR "@Slicer_PYTHON_MODULE_TEST_TEMPLATES_DIR_CONFIG@")

57 58
# Path to extension CPack script
set(Slicer_EXTENSION_CPACK "@Slicer_EXTENSION_CPACK_CONFIG@")
59
set(Slicer_EXTENSION_CPACK_BUNDLE_FIXUP "@Slicer_EXTENSION_CPACK_BUNDLE_FIXUP_CONFIG@")
60
set(Slicer_EXTENSIONS_DIRNAME "@Slicer_EXTENSIONS_DIRNAME@")
61

62
# Whether Slicer was built with modules and CLI support.
63
set(Slicer_BUILD_CLI "@Slicer_BUILD_CLI@")
64
set(Slicer_BUILD_QTLOADABLEMODULES "@Slicer_BUILD_QTLOADABLEMODULES@")
65
set(Slicer_BUILD_QTSCRIPTEDMODULES "@Slicer_BUILD_QTSCRIPTEDMODULES@")
66

67
# Whether Slicer was built with shared libraries.
68
set(Slicer_BUILD_SHARED "@BUILD_SHARED_LIBS@")
69
set(Slicer_LIBRARY_PROPERTIES "@Slicer_LIBRARY_PROPERTIES@")
70

71
# Export header for BuildModuleLogic and BuildQTModule
72 73
set(Slicer_EXPORT_HEADER_TEMPLATE "@Slicer_EXPORT_HEADER_TEMPLATE@")
set(Slicer_LOGOS_RESOURCE "@Slicer_LOGOS_RESOURCE@")
74

75
# Slicer home (top of the tree)
76
set(Slicer_HOME "@Slicer_HOME@")
77

78 79 80 81 82 83
# Slicer Core library
set(Slicer_CORE_LIBRARY @Slicer_CORE_LIBRARY_CONFIG@)

# Slicer GUI library
set(Slicer_GUI_LIBRARY @Slicer_GUI_LIBRARY_CONFIG@)

jcfr's avatar
jcfr committed
84
# MRML libraries - This variable regroup all related MRML libraries
85
set(MRML_LIBRARIES @MRML_LIBRARIES@)
86

87 88 89
# Slicer Libs VTK wrapped libraries
set(Slicer_Libs_VTK_WRAPPED_LIBRARIES "@Slicer_Libs_VTK_WRAPPED_LIBRARIES@")

90
# Slicer Libs include file directories.
91
set(Slicer_Libs_INCLUDE_DIRS "@Slicer_Libs_INCLUDE_DIRS_CONFIG@")
92

93
# Slicer Base include file directories.
94
set(Slicer_Base_INCLUDE_DIRS "@Slicer_BINARY_DIR@" "@Slicer_Base_INCLUDE_DIRS_CONFIG@")
95

96
# Slicer Module logic include file directories.
97 98
set(Slicer_ModuleLogic_INCLUDE_DIRS "@Slicer_ModuleLogic_INCLUDE_DIRS_CONFIG@"
  CACHE INTERNAL "Slicer Module logic includes" FORCE)
99

100
# Slicer Module MRML include file directories.
101 102
set(Slicer_ModuleMRML_INCLUDE_DIRS "@Slicer_ModuleMRML_INCLUDE_DIRS_CONFIG@"
  CACHE INTERNAL "Slicer Module MRML includes" FORCE)
103

104
# Slicer Module Widgets include file directories.
105 106
set(Slicer_ModuleWidgets_INCLUDE_DIRS "@Slicer_ModuleWidgets_INCLUDE_DIRS_CONFIG@"
  CACHE INTERNAL "Slicer Module widgets includes" FORCE)
107

108
# The location of the UseSlicer.cmake file.
109
set(Slicer_USE_FILE "@Slicer_USE_FILE_CONFIG@")
110

111 112
set(Slicer_BINARY_INNER_SUBDIR "@Slicer_BINARY_INNER_SUBDIR@")

113 114 115 116 117 118 119
# Slicer relative build directories.
set(Slicer_BIN_DIR "@Slicer_BIN_DIR@")
set(Slicer_LIB_DIR "@Slicer_LIB_DIR@")
set(Slicer_INCLUDE_DIR "@Slicer_INCLUDE_DIR@")
set(Slicer_SHARE_DIR "@Slicer_SHARE_DIR@")
set(Slicer_ITKFACTORIES_DIR "@Slicer_ITKFACTORIES_DIR@")

120
set(Slicer_CLIMODULES_SUBDIR "@Slicer_CLIMODULES_SUBDIR@")
121
set(Slicer_CLIMODULES_BIN_DIR "@Slicer_CLIMODULES_BIN_DIR@")
122
set(Slicer_CLIMODULES_LIB_DIR "@Slicer_CLIMODULES_LIB_DIR@")
123
set(Slicer_CLIMODULES_SHARE_DIR "@Slicer_CLIMODULES_SHARE_DIR@")
124

125
set(Slicer_QTLOADABLEMODULES_SUBDIR "@Slicer_QTLOADABLEMODULES_SUBDIR@")
126 127 128 129 130
set(Slicer_QTLOADABLEMODULES_BIN_DIR "@Slicer_QTLOADABLEMODULES_BIN_DIR@")
set(Slicer_QTLOADABLEMODULES_LIB_DIR "@Slicer_QTLOADABLEMODULES_LIB_DIR@")
set(Slicer_QTLOADABLEMODULES_INCLUDE_DIR "@Slicer_QTLOADABLEMODULES_INCLUDE_DIR@")
set(Slicer_QTLOADABLEMODULES_SHARE_DIR "@Slicer_QTLOADABLEMODULES_SHARE_DIR@")
set(Slicer_QTLOADABLEMODULES_PYTHON_LIB_DIR "@Slicer_QTLOADABLEMODULES_PYTHON_LIB_DIR@")
131

132
if(Slicer_USE_PYTHONQT)
133
  set(Slicer_QTSCRIPTEDMODULES_SUBDIR "@Slicer_QTSCRIPTEDMODULES_SUBDIR@")
134 135 136 137
  set(Slicer_QTSCRIPTEDMODULES_BIN_DIR "@Slicer_QTSCRIPTEDMODULES_BIN_DIR@")
  set(Slicer_QTSCRIPTEDMODULES_LIB_DIR "@Slicer_QTSCRIPTEDMODULES_LIB_DIR@")
  set(Slicer_QTSCRIPTEDMODULES_INCLUDE_DIR "@Slicer_QTSCRIPTEDMODULES_INCLUDE_DIR@")
  set(Slicer_QTSCRIPTEDMODULES_SHARE_DIR "@Slicer_QTSCRIPTEDMODULES_SHARE_DIR@")
138
endif()
139

140 141 142
# Slicer install root
set(Slicer_INSTALL_ROOT "@Slicer_INSTALL_ROOT@")

143
# Slicer relative install directories.
144 145 146 147 148 149
set(Slicer_INSTALL_BIN_DIR "@Slicer_INSTALL_BIN_DIR@")
set(Slicer_INSTALL_LIB_DIR "@Slicer_INSTALL_LIB_DIR@")
set(Slicer_INSTALL_INCLUDE_DIR "@Slicer_INSTALL_INCLUDE_DIR@")
set(Slicer_INSTALL_SHARE_DIR "@Slicer_INSTALL_SHARE_DIR@")
set(Slicer_INSTALL_ITKFACTORIES_DIR "@Slicer_INSTALL_ITKFACTORIES_DIR@")

150
set(Slicer_INSTALL_CLIMODULES_BIN_DIR "@Slicer_INSTALL_CLIMODULES_BIN_DIR@")
151
set(Slicer_INSTALL_CLIMODULES_LIB_DIR "@Slicer_INSTALL_CLIMODULES_LIB_DIR@")
152
set(Slicer_INSTALL_CLIMODULES_SHARE_DIR "@Slicer_INSTALL_CLIMODULES_SHARE_DIR@")
153

154 155 156 157 158
set(Slicer_INSTALL_QTLOADABLEMODULES_BIN_DIR "@Slicer_INSTALL_QTLOADABLEMODULES_BIN_DIR@")
set(Slicer_INSTALL_QTLOADABLEMODULES_LIB_DIR "@Slicer_INSTALL_QTLOADABLEMODULES_LIB_DIR@")
set(Slicer_INSTALL_QTLOADABLEMODULES_PYTHON_LIB_DIR "@Slicer_INSTALL_QTLOADABLEMODULES_PYTHON_LIB_DIR@")
set(Slicer_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR "@Slicer_INSTALL_QTLOADABLEMODULES_INCLUDE_DIR@")
set(Slicer_INSTALL_QTLOADABLEMODULES_SHARE_DIR "@Slicer_INSTALL_QTLOADABLEMODULES_SHARE_DIR@")
jcfr's avatar
jcfr committed
159

160
if(Slicer_USE_PYTHONQT)
161 162 163 164
  set(Slicer_INSTALL_QTSCRIPTEDMODULES_BIN_DIR "@Slicer_INSTALL_QTSCRIPTEDMODULES_BIN_DIR@")
  set(Slicer_INSTALL_QTSCRIPTEDMODULES_LIB_DIR "@Slicer_INSTALL_QTSCRIPTEDMODULES_LIB_DIR@")
  set(Slicer_INSTALL_QTSCRIPTEDMODULES_INCLUDE_DIR "@Slicer_INSTALL_QTSCRIPTEDMODULES_INCLUDE_DIR@")
  set(Slicer_INSTALL_QTSCRIPTEDMODULES_SHARE_DIR "@Slicer_INSTALL_QTSCRIPTEDMODULES_SHARE_DIR@")
165
endif()
166

167
# The Slicer install prefix (*not* defined in the install tree)
168
set(Slicer_INSTALL_PREFIX  "@CMAKE_INSTALL_PREFIX@")
169

170 171 172 173 174 175
# --------------------------------------------------------------------------
# External data
# --------------------------------------------------------------------------
set(Slicer_ExternalData_OBJECT_STORES "@Slicer_ExternalData_OBJECT_STORES@")
set(Slicer_ExternalData_URL_TEMPLATES "@Slicer_ExternalData_URL_TEMPLATES@")

176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
# --------------------------------------------------------------------------
# External projects
# --------------------------------------------------------------------------

# With the help of SuperBuild, Slicer has been configured and built against a collection
# of external projects.
#
# Considering that, by default, Slicer and most of its dependent external projects are
# built as shared library, it's important to make sure that the project including
# SlicerConfig.cmake (this file) is built against the same set of external projects if it applies.
#
# Let's consider the example of a project dependending on both VTK and Slicer. With the help of
# the macro 'slicer_config_set_ep', the build system will check that the path of the already
# defined VTK_DIR matches the VTK_DIR used to build Slicer.
#
# A typical use of this macro is illustrated below:
#
#    slicer_config_set_ep("VTK_DIR", "@VTK_DIR_CONFIG@")
#
#
macro(slicer_config_set_ep var value)
  if(NOT "${value}" STREQUAL "")
    if(DEFINED ${var})
      get_filename_component(var_realpath "${${var}}" REALPATH)
      get_filename_component(value_realpath ${value} REALPATH)
      if(NOT ${var_realpath} STREQUAL ${value_realpath})
        message(FATAL_ERROR "Variable ${var} defined prior calling 'find_package(Slicer)' does NOT "
                            "match value used to configure Slicer. It probably means that a different "
                            "${var} has been used to configure this project and Slicer.\n"
                            "${var}=${${var}}\n"
                            "Slicer_${var}=${value}")
      endif()
    endif()
    set(${var} "${value}" ${ARGN})
  endif()
endmacro()

213
# For sake of simplification, the macro 'slicer_config_set_ep' is not invoked conditionally, if
214 215 216 217 218 219 220 221 222 223 224 225
# the configured 'value' parameter is an empty string, the macro 'slicer_config_set_ep' is a no-op.

slicer_config_set_ep(
  QT_QMAKE_EXECUTABLE
  "@QT_QMAKE_EXECUTABLE_CONFIG@"
  )

slicer_config_set_ep(
  BatchMake_DIR
  "@BatchMake_DIR_CONFIG@"
  CACHE PATH "Path to BatchMake build or install directory" FORCE)

226 227 228 229 230
slicer_config_set_ep(
  DCMTK_DIR
  "@DCMTK_DIR_CONFIG@"
  CACHE PATH "Path to DCMTK build or install directory" FORCE)

231 232 233 234 235
slicer_config_set_ep(
  CTK_DIR
  "@CTK_DIR_CONFIG@"
  CACHE PATH "Path to CTK build or install directory" FORCE)

236 237 238 239 240
slicer_config_set_ep(
  QtTesting_DIR
  "@QtTesting_DIR_CONFIG@"
  CACHE PATH "Path to QtTesting build or install directory" FORCE)

241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
slicer_config_set_ep(
  ITK_DIR
  "@ITK_DIR_CONFIG@"
  CACHE PATH "Path to ITK build or install directory" FORCE)

slicer_config_set_ep(
  OpenIGTLink_DIR
  "@OpenIGTLink_DIR_CONFIG@"
  CACHE PATH "Path to OpenIGTLink build or install directory" FORCE)

slicer_config_set_ep(
  PYTHON_EXECUTABLE
  "@PYTHON_EXECUTABLE_CONFIG@"
  CACHE PATH "Path to Python executable" FORCE)

slicer_config_set_ep(
  PYTHON_INCLUDE_DIR
  "@PYTHON_INCLUDE_DIR_CONFIG@"
  CACHE PATH "Path to Python include directory" FORCE)

slicer_config_set_ep(
  PYTHON_LIBRARY
  "@PYTHON_LIBRARY_CONFIG@"
  CACHE FILEPATH "Path to Python library" FORCE)

slicer_config_set_ep(
  PYTHON_DEBUG_LIBRARY
  "@PYTHON_DEBUG_LIBRARY_CONFIG@"
  CACHE FILEPATH "Path to Python debug library" FORCE)

slicer_config_set_ep(
  qMidasAPI_DIR
  "@qMidasAPI_DIR_CONFIG@"
  CACHE PATH "Path to qMidasAPI build or install directory" FORCE)

slicer_config_set_ep(
  SLICERLIBCURL_DIR
  "@SLICERLIBCURL_DIR_CONFIG@"
  CACHE PATH "Path to Curl build or install directory" FORCE)

281
# SlicerExecutionModel settings
282
set(SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES "@SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES_CONFIG@")
283
set(SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES "@SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES_CONFIG@")
284

285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
slicer_config_set_ep(
  SlicerExecutionModel_DIR
  "@SlicerExecutionModel_DIR_CONFIG@"
  CACHE PATH "Path to SlicerExecutionModel build or install directory" FORCE)

slicer_config_set_ep(
  Teem_DIR
  "@Teem_DIR_CONFIG@"
  CACHE PATH "Path to Teem build or install directory")

slicer_config_set_ep(
  VTK_DIR
  "@VTK_DIR_CONFIG@"
  CACHE PATH "Path to VTK build or install directory")

300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
# --------------------------------------------------------------------------
# Consistent Compiler Selections
# --------------------------------------------------------------------------
# Compilation Commands
set(Slicer_CMAKE_CXX_COMPILER "@Slicer_CMAKE_CXX_COMPILER_CONFIG@")
set(Slicer_CMAKE_C_COMPILER   "@Slicer_CMAKE_C_COMPILER_CONFIG@")
set(Slicer_CMAKE_CXX_FLAGS    "@Slicer_CMAKE_CXX_FLAGS_CONFIG@")
set(Slicer_CMAKE_C_FLAGS      "@Slicer_CMAKE_C_FLAGS_CONFIG@")

# With the help of SuperBuild, Slicer has been configured with specific compiler
#
# Considering that, by default, Slicer and most of its dependent external projects are
# built with a particular compiler, it's important to make sure that the project including
# SlicerConfig.cmake (this file) is built against the same compliant compiler
#
# A typical use of this macro is illustrated below:
#    slicer_config_set_compiler_ep("CMAKE_C_COMPILER", "@Slicer_CMAKE_C_COMPILER@")
#    slicer_config_set_compiler_ep("CMAKE_CXX_COMPILER", "@Slicer_CMAKE_CXX_COMPILER@")
#
macro(slicer_config_set_compiler_ep var value)
  if(NOT "${value}" STREQUAL "")
    if(DEFINED ${var})
      get_filename_component(var_realpath "${${var}}" REALPATH)
      get_filename_component(value_realpath ${value} REALPATH)
324
      if(NOT MSVC AND NOT ${var_realpath} STREQUAL ${value_realpath})
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
        message(FATAL_ERROR "Variable ${var} defined prior calling 'find_package(Slicer)' does NOT "
                            "match value used to configure Slicer. It probably means that a different "
                            "${var} has been used to configure this project and Slicer.\n"
                            "${var}=${${var}}\n"
                            "Slicer_${var}=${value}")
      endif()
    endif()
    set(${var} "${value}" ${ARGN})
  endif()
endmacro()
slicer_config_set_compiler_ep( CMAKE_C_COMPILER   "@Slicer_CMAKE_C_COMPILER_CONFIG@"
   CACHE PATH "Path to C compiler used in Slicer build" FORCE )
slicer_config_set_compiler_ep( CMAKE_CXX_COMPILER "@Slicer_CMAKE_CXX_COMPILER_CONFIG@"
   CACHE PATH "Path to CXX compiler used in Slicer build" FORCE )

set(CMAKE_CXX_FLAGS    "@Slicer_CMAKE_CXX_FLAGS_CONFIG@")
set(CMAKE_C_FLAGS      "@Slicer_CMAKE_C_FLAGS_CONFIG@")

343 344 345 346
# List all required external project
set(Slicer_EXTERNAL_PROJECTS @Slicer_EXTERNAL_PROJECTS_CONFIG@)
set(Slicer_EXTERNAL_PROJECTS_NO_USEFILE @Slicer_EXTERNAL_PROJECTS_NO_USEFILE_CONFIG@)

347
# Update CMAKE_MODULE_PATH
348
set(CMAKE_MODULE_PATH
349 350 351 352
  ${Slicer_CMAKE_DIR}
  ${Slicer_EXTENSIONS_CMAKE_DIR}
  ${CMAKE_MODULE_PATH}
  )
353

354 355 356
# Include external projects
foreach(proj ${Slicer_EXTERNAL_PROJECTS})
  find_package(${proj} REQUIRED)
357 358 359 360 361 362 363 364 365 366 367 368 369
  # Add project CMake dir to module path
  if(DEFINED ${proj}_CMAKE_DIR)
    set(CMAKE_MODULE_PATH
      ${${proj}_CMAKE_DIR}
      ${CMAKE_MODULE_PATH}
      )
  endif()
  # Add project Utilities/CMake dir to module path
  if(DEFINED ${proj}_CMAKE_UTILITIES_DIR)
    set(CMAKE_MODULE_PATH
      ${${proj}_CMAKE_UTILITIES_DIR}
      ${CMAKE_MODULE_PATH}
      )
370
  endif()
371 372 373 374 375 376 377
endforeach()

# This block should be added after VTK and CTK are found.
# Indeed, it will check if both VTK_QT_QMAKE_EXECUTABLE and CTK_QT_QMAKE_EXECUTABLE are valid.
include(${Slicer_CMAKE_DIR}/SlicerBlockFindQtAndCheckVersion.cmake)

# --------------------------------------------------------------------------
378
if(EXISTS "@Slicer_TARGETS_FILE@" AND NOT TARGET SlicerBaseLogic)
379 380
  include("@Slicer_TARGETS_FILE@")
endif()