CMakeLists.txt 21.5 KB
Newer Older
1
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
2

3 4 5 6 7 8 9
option(VTK_ENABLE_KITS "Build VTK using kits instead of modules." OFF)
mark_as_advanced(VTK_ENABLE_KITS)
if(VTK_ENABLE_KITS)
  # Kits use INTERFACE libraries which were introduced in 3.0.
  cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
endif()

10 11 12
foreach(p
    CMP0020 # CMake 2.8.11
    CMP0022 # CMake 2.8.12
13
    CMP0025 # CMake 3.0
14
    CMP0053 # CMake 3.1
15
    CMP0054 # CMake 3.1
16 17 18 19 20
    )
  if(POLICY ${p})
    cmake_policy(SET ${p} NEW)
  endif()
endforeach()
21

22 23 24 25 26 27 28
# Set a consistent MACOSX_RPATH default across all CMake versions.
# When CMake 2.8.12 is required, change this default to 1.
# When CMake 3.0.0 is required, remove this block (see CMP0042).
if(NOT DEFINED CMAKE_MACOSX_RPATH)
  set(CMAKE_MACOSX_RPATH 0)
endif()

29
project(VTK)
30

31 32 33 34 35
# Objective-C++ compile flags.
# CMake has no equivalent of CMAKE_CXX_FLAGS for Objective-C++ (bug #4756)
# so we provide this in case the user needs to specify flags specifically
# for Objective-C++ source files.  For example, to build with garbage
# collection support, the -fobjc-gc flag would be used.
36
IF(APPLE)
37
  SET(VTK_OBJCXX_FLAGS_DEFAULT "")
38 39
  SET(VTK_REQUIRED_OBJCXX_FLAGS ${VTK_OBJCXX_FLAGS_DEFAULT} CACHE STRING "Extra flags for Objective-C++ compilation")
  MARK_AS_ADVANCED(VTK_REQUIRED_OBJCXX_FLAGS)
40
ENDIF()
41

42 43 44 45
set(VTK_CMAKE_DIR "${VTK_SOURCE_DIR}/CMake")
set(CMAKE_MODULE_PATH ${VTK_CMAKE_DIR} ${CMAKE_MODULE_PATH})

include(vtkModuleMacros)
Brad King's avatar
Brad King committed
46
include(vtkExternalData)
47

48 49 50 51 52 53 54 55 56 57 58 59
#-----------------------------------------------------------------------------
# Forbid downloading resources from the network during a build. This helps
# when building on systems without network connectivity to determine which
# resources much be obtained manually and made available to the build.
option(VTK_FORBID_DOWNLOADS "Do not download source code or data from the network" OFF)
mark_as_advanced(VTK_FORBID_DOWNLOADS)
macro(vtk_download_attempt_check _name)
  if(VTK_FORBID_DOWNLOADS)
    message(SEND_ERROR "Attempted to download ${_name} when VTK_FORBID_DOWNLOADS is ON")
  endif()
endmacro()

60 61 62 63 64 65 66 67 68
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'Debug' as none was specified.")
  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
endif()

69
# Test input data staging directory.
70 71
file(RELATIVE_PATH vtk_reldir "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
set(VTK_TEST_DATA_DIR "${ExternalData_BINARY_ROOT}/${vtk_reldir}/Testing")
72

73 74 75
# Test input data directory.
set(VTK_TEST_INPUT_DIR "${VTK_SOURCE_DIR}/Testing/Data")

76 77 78
# Test output directory.
set(VTK_TEST_OUTPUT_DIR "${VTK_BINARY_DIR}/Testing/Temporary")

79 80
# Set up our directory structure for output libraries and binaries
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
81
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${VTK_BINARY_DIR}/bin")
82 83 84
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
  if(UNIX)
85
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${VTK_BINARY_DIR}/lib")
86
  else()
87
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${VTK_BINARY_DIR}/bin")
88 89 90
  endif()
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
91
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${VTK_BINARY_DIR}/lib")
92 93 94 95 96 97
endif()
mark_as_advanced(CMAKE_RUNTIME_OUTPUT_DIRECTORY
  CMAKE_LIBRARY_OUTPUT_DIRECTORY
  CMAKE_ARCHIVE_OUTPUT_DIRECTORY
  )

98 99 100 101
include(vtkVersion)
set(VTK_VERSION
    "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}")

Ken Martin's avatar
Ken Martin committed
102 103 104 105
#-----------------------------------------------------------------------------
# Do we want examples built?
OPTION(BUILD_EXAMPLES "Build VTK examples." OFF)

106 107 108 109 110 111 112 113 114 115 116
#-----------------------------------------------------------------------------
if(NOT EXISTS "${VTK_SOURCE_DIR}/.ExternalData/README.rst")
  # This file is always present in version-controlled source trees
  # so we must have been extracted from a source tarball with no
  # data objects needed for testing.  Turn off tests by default
  # since enabling them requires network access or manual data
  # store configuration.
  option(BUILD_TESTING "Build the testing tree." OFF)
endif()
include(CTest)

117 118 119 120 121 122
option(VTK_IOS_BUILD "Build vtk.framework for iOS" OFF)
if (VTK_IOS_BUILD)
  include(vtkiOS)
  return()
endif()

Tim Thirion's avatar
Tim Thirion committed
123 124 125 126 127 128
option(VTK_ANDROID_BUILD "Build VTK for Android" OFF)
if (VTK_ANDROID_BUILD)
  include(vtkAndroid)
  return()
endif()

Ken Martin's avatar
Ken Martin committed
129 130
# some specific defaults for Andriod to give folks
# a reasonable starting point
Ken Martin's avatar
Ken Martin committed
131
if (ANDROID OR APPLE_IOS)
Ken Martin's avatar
Ken Martin committed
132 133 134 135 136 137 138 139 140
  SET( CMAKE_REQUIRE_LARGE_FILE_SUPPORT 2
       CACHE STRING "Result from TRY_RUN" FORCE)
  SET( CMAKE_REQUIRE_LARGE_FILE_SUPPORT__TRYRUN_OUTPUT ""
       CACHE STRING "Output from TRY_RUN" FORCE)
  SET( KWSYS_LFS_WORKS 2
     CACHE STRING "Result from TRY_RUN" FORCE)
  SET( KWSYS_LFS_WORKS__TRYRUN_OUTPUT ""
     CACHE STRING "Output from TRY_RUN" FORCE)

141 142 143 144 145 146 147 148
  # need int version for CPP
  if (${OPENGL_ES_VERSION} MATCHES 2.0)
    set(OPENGL_ES_VERSION_INT 20)
  endif()
  if (${OPENGL_ES_VERSION} MATCHES 3.0)
    set(OPENGL_ES_VERSION_INT 30)
  endif()

Ken Martin's avatar
Ken Martin committed
149
  if (APPLE_IOS)
150 151 152 153 154 155 156 157 158 159
    unset(OPENGL_INCLUDE_DIR CACHE)
    if (${OPENGL_ES_VERSION} MATCHES 2.0)
      find_path(OPENGL_INCLUDE_DIR ES2/gl.h
                ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGLES.framework/Headers
                ${_OPENGL_INCLUDE_DIR})
    elseif (${OPENGL_ES_VERSION} MATCHES 3.0)
      find_path(OPENGL_INCLUDE_DIR ES3/gl.h
                ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGLES.framework/Headers
                ${_OPENGL_INCLUDE_DIR})
    endif()
Ken Martin's avatar
Ken Martin committed
160 161 162 163 164 165
    find_library(OPENGL_gl_LIBRARY
       NAMES OpenGLES
       PATHS
         ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks
         ${_OPENGL_LIB_PATH}
       )
Tim Thirion's avatar
Tim Thirion committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
  elseif (ANDROID)
    unset(OPENGL_INCLUDE_DIR CACHE)
    unset(OPENGL_gl_LIBRARY CACHE)
    unset(OPENGL_egl_LIBRARY CACHE)

    if (${OPENGL_ES_VERSION} MATCHES 2.0)
      find_path(OPENGL_INCLUDE_DIR GLES2/gl2.h
         ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include
         ${_OPENGL_INCLUDE_PATH}
         NO_DEFAULT_PATH
         )
      find_library(OPENGL_gl_LIBRARY
         NAMES GLESv2
         PATHS
           ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/lib
           ${_OPENGL_LIB_PATH}
         )
    elseif (${OPENGL_ES_VERSION} MATCHES 3.0)
      find_path(OPENGL_INCLUDE_DIR GLES3/gl3.h
         ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include
         ${_OPENGL_INCLUDE_PATH}
         )
      find_library(OPENGL_gl_LIBRARY
         NAMES GLESv3
         PATHS
           ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/lib
           ${_OPENGL_LIB_PATH}
         )
    endif()
Ken Martin's avatar
Ken Martin committed
195 196 197 198 199 200 201
    find_library(OPENGL_egl_LIBRARY
       NAMES EGL
       PATHS
         ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/lib
         ${_OPENGL_LIB_PATH}
       )
  endif()
Ken Martin's avatar
Ken Martin committed
202 203 204
else()
  # Choose static or shared libraries.
  option(BUILD_SHARED_LIBS "Build VTK with shared libraries." ON)
Ken Martin's avatar
Ken Martin committed
205 206
endif()

Ken Martin's avatar
Ken Martin committed
207 208
# default to not using the system GLEW as ours has fixes in it right now
set(VTK_USE_SYSTEM_GLEW OFF CACHE BOOL "do not use a system glew" FORCE)
209

210
set(VTK_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
211

212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
#-----------------------------------------------------------------------------
# VTK installation structure
if(NOT VTK_INSTALL_RUNTIME_DIR)
  set(VTK_INSTALL_RUNTIME_DIR bin)
endif()
if(NOT VTK_INSTALL_LIBRARY_DIR)
  set(VTK_INSTALL_LIBRARY_DIR lib)
endif()
if(NOT VTK_INSTALL_ARCHIVE_DIR)
  set(VTK_INSTALL_ARCHIVE_DIR lib)
endif()
if(NOT VTK_INSTALL_INCLUDE_DIR)
  set(VTK_INSTALL_INCLUDE_DIR include/vtk-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION})
endif()
if(NOT VTK_INSTALL_DATA_DIR)
  set(VTK_INSTALL_DATA_DIR share/vtk-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION})
endif()
if(NOT VTK_INSTALL_DOC_DIR)
  set(VTK_INSTALL_DOC_DIR share/doc/vtk-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION})
endif()
if(NOT VTK_INSTALL_PACKAGE_DIR)
  set(VTK_INSTALL_PACKAGE_DIR "lib/cmake/vtk-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}")
endif()
235 236 237
if(NOT VTK_INSTALL_DOXYGEN_DIR)
  set(VTK_INSTALL_DOXYGEN_DIR ${VTK_INSTALL_DOC_DIR}/doxygen)
endif()
238 239 240 241 242 243 244
if(NOT VTK_INSTALL_TCL_DIR)
  # tclsh searches <prefix>/lib/tcltk and its subdirectories for pkgIndex.tcl files
  set(VTK_INSTALL_TCL_DIR lib/tcltk/vtk-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION})
endif()
if(NOT VTK_INSTALL_EXPORT_NAME)
  set(VTK_INSTALL_EXPORT_NAME VTKTargets)
endif()
245 246 247
if(NOT VTK_MODULES_DIR)
  set(VTK_MODULES_DIR "${VTK_BINARY_DIR}/${VTK_INSTALL_PACKAGE_DIR}/Modules")
endif()
Zach's avatar
Zach committed
248 249 250
if(NOT VTK_WWW_DIR)
  set(VTK_WWW_DIR "${VTK_BINARY_DIR}/www")
endif()
251 252 253 254 255
if(NOT VTK_INSTALL_PYTHON_MODULE_DIR)
  set (VTK_INSTALL_PYTHON_MODULE_DIR "-NOTFOUND" CACHE
       PATH "Directory where python modules will be installed")
  mark_as_advanced(VTK_INSTALL_PYTHON_MODULE_DIR)
endif()
256 257 258 259 260
if(NOT VTK_BUILD_PYTHON_MODULE_DIR)
  set (VTK_BUILD_PYTHON_MODULE_DIR "-NOTFOUND" CACHE
       PATH "Directory where python modules will be put inside the build tree")
  mark_as_advanced(VTK_BUILD_PYTHON_MODULE_DIR)
endif()
261 262 263 264 265
if (CMAKE_CROSSCOMPILING AND NOT COMPILE_TOOLS_IMPORTED)
  # if CMAKE_CROSSCOMPILING is true, we need to import build-tools targets.
  find_package(VTKCompileTools REQUIRED)
  set (COMPILE_TOOLS_IMPORTED TRUE)
endif()
266

267 268 269 270
#-----------------------------------------------------------------------------
# Add the Remote Subdirectory
add_subdirectory(Remote)

271 272 273 274 275
#-----------------------------------------------------------------------------
# Do we try to use system libraries by default?
option(VTK_USE_SYSTEM_LIBRARIES "Use the system's libraries by default." OFF)
mark_as_advanced(VTK_USE_SYSTEM_LIBRARIES)

276
#-----------------------------------------------------------------------------
277 278
# The third party macros are still used in one or two third party builds.
include(vtkThirdParty)
279

280
#-----------------------------------------------------------------------------
281 282
include(vtkCompilerExtras)
include(vtkBuildPath)
283

284 285 286 287 288 289 290
#-----------------------------------------------------------------------------
if(APPLE)
  mark_as_advanced(
    CMAKE_OSX_ARCHITECTURES
    CMAKE_OSX_DEPLOYMENT_TARGET
    CMAKE_OSX_SYSROOT
    )
291

292 293
  if (CMAKE_OSX_DEPLOYMENT_TARGET AND
      CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.6)
294 295
    message(FATAL_ERROR "Minimun OS X deployment target is 10.6, please update CMAKE_OSX_DEPLOYMENT_TARGET.")
  endif ()
296 297
endif()

298 299 300 301 302 303 304
#-----------------------------------------------------------------------------
# Minimum compiler version check: GCC >= 4.2
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2)
  message(FATAL_ERROR "GCC 4.2 or later is required.")
endif ()

305
#-----------------------------------------------------------------------------
306
# Minimum compiler version check: LLVM Clang >= 3.0
307
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
308 309
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.0)
  message(FATAL_ERROR "LLVM Clang 3.0 or later is required.")
310 311 312
endif ()

#-----------------------------------------------------------------------------
313
# Minimum compiler version check: Apple Clang >= 3.0 (Xcode 4.2)
314
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
315 316
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.0)
  message(FATAL_ERROR "Apple Clang 3.0 or later is required.")
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
endif ()

#-----------------------------------------------------------------------------
# Minimum compiler version check: Microsoft C/C++ >= 15.0 (aka VS 2008 aka VS 9.0)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0)
  message(FATAL_ERROR "Microsoft Visual Studio 2008 or later is required.")
endif ()

#-----------------------------------------------------------------------------
# Minimum compiler version check: Intel C++ (ICC) >= 10.0
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
  message(FATAL_ERROR "Intel C++ (ICC) 10.0 or later is required.")
endif ()

333 334
#-----------------------------------------------------------------------------
# Does VTK require support for 64 bit file systems
335
INCLUDE(CheckCXXSourceRuns)
336 337 338
FILE(READ "${VTK_CMAKE_DIR}/vtkRequireLargeFilesSupport.cxx"
  VTK_REQUIRE_LARGE_FILE_SUPPORT_FILE)
CHECK_CXX_SOURCE_RUNS("${VTK_REQUIRE_LARGE_FILE_SUPPORT_FILE}"
339 340
  CMAKE_REQUIRE_LARGE_FILE_SUPPORT "Support for 64 bit file systems")
SET(VTK_REQUIRE_LARGE_FILE_SUPPORT ${CMAKE_REQUIRE_LARGE_FILE_SUPPORT})
341

342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
#-----------------------------------------------------------------------------
# Does the const_reverse_iterator have the comparison operators? They were not
# present in older versions of gcc (ex: Apple fork of gcc 4.2).
include(CheckCXXSourceCompiles)
set(VTK_CONST_REVERSE_ITERATOR_COMPARISON_FILE
"#include <vector>
int main()
{
  std::vector<int> test;
  std::vector<int>::const_reverse_iterator it = test.rbegin();
  it != test.rend();
  return 0;
}")
check_cxx_source_compiles("${VTK_CONST_REVERSE_ITERATOR_COMPARISON_FILE}"
  VTK_CONST_REVERSE_ITERATOR_COMPARISON)

358 359
#-----------------------------------------------------------------------------
# Provide compatibility options.
360
option(VTK_LEGACY_REMOVE "Remove all legacy code completely." OFF)
361 362
option(VTK_LEGACY_SILENT "Silence all legacy code messages." OFF)
mark_as_advanced(VTK_LEGACY_REMOVE VTK_LEGACY_SILENT)
363

364
#-----------------------------------------------------------------------------
365 366
# VTK requires special compiler flags on some platforms.
include(vtkDetermineCompilerFlags)
367

368 369
# Tell VTK source files they are being built inside VTK.
add_definitions(-DVTK_IN_VTK)
370

371
#-----------------------------------------------------------------------------
372 373 374
if(BUILD_TESTING)
  include(vtkLegacyData)
endif()
375

376 377
# Provide an option for tests requiring "large" input data
option(VTK_USE_LARGE_DATA "Enable tests requiring \"large\" data" OFF)
378

379
#-----------------------------------------------------------------------------
380
# Platform configuration tests.
381
include(TestBigEndian)
382
TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
383 384 385 386 387 388

include(FindThreads)
set(VTK_USE_WIN32_THREADS 0)
set(VTK_USE_PTHREADS 0)
set(VTK_HP_PTHREADS 0)
set(VTK_USE_SPROC 0)
389 390 391
# if win32 threads and pthreads are available figure out which
# one the compiler is setup to use.  If you can not figure it
# out default to pthreads.
392
if(CMAKE_USE_PTHREADS_INIT AND CMAKE_USE_WIN32_THREADS_INIT)
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
  if(DEFINED VTK_THREAD_MODEL)
    set(output "${VTK_THREAD_MODEL}")
  else()
    execute_process(COMMAND "${CMAKE_C_COMPILER}" -v OUTPUT_VARIABLE output
      ERROR_VARIABLE output RESULT_VARIABLE result TIMEOUT 10)
  endif()
  if(output MATCHES "Thread model: posix")
    set(VTK_THREAD_MODEL "Thread model: posix" CACHE STRING
      "Thread model used by gcc.")
    set(CMAKE_USE_WIN32_THREADS_INIT 0)
  elseif(output MATCHES "Thread model: win32")
    set(VTK_THREAD_MODEL "Thread model: win32" CACHE STRING
      "Thread model used by gcc.")
    set(CMAKE_USE_PTHREADS_INIT 0)
  else()
    set(VTK_THREAD_MODEL "Thread model: posix" CACHE STRING
      "Thread model used by gcc.")
    set(CMAKE_USE_WIN32_THREADS_INIT 0)
  endif()
412
endif()
413
mark_as_advanced(VTK_THREAD_MODEL)
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
if(CMAKE_USE_WIN32_THREADS_INIT)
  set(VTK_USE_WIN32_THREADS 1)
  set(CMAKE_THREAD_LIBS_INIT "")
elseif(CMAKE_USE_PTHREADS_INIT)
  set(VTK_USE_PTHREADS 1)
  if(CMAKE_HP_PTHREADS_INIT)
    set(VTK_HP_PTHREADS 1)
  endif()
elseif(CMAKE_USE_SPROC_INIT)
  set(VTK_USE_SPROC 1)
endif()
set(CMAKE_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}" CACHE STRING "Thread library used.")
mark_as_advanced(CMAKE_THREAD_LIBS)
set(VTK_MAX_THREADS "64" CACHE STRING
  "Max number of threads vktMultiThreader will allocate.")
mark_as_advanced(VTK_MAX_THREADS)

431
include(CheckTypeSize)
Ken Martin's avatar
Ken Martin committed
432

433
# Socket tests etc.
434
#INCLUDE(Parallel/VTKParallelCMakeTests.cmake)
435

436
# Test for atomics and other compiler intrinsics
437
include(vtkTestBuiltins)
438

439 440
#-----------------------------------------------------------------------------
# Dispatch the build into the proper subdirectories.
441
SET(VTK_HAS_EXODUS 1)
442

443 444
#-----------------------------------------------------------------------------
# Configure files with settings for use by the build.
445

446 447 448 449 450 451
# Include the sockets test.
# FIXME: The test should be moved and rewritten.
include(VTKParallelCMakeTests)

# Add the option for build the Python wrapping to VTK.
option(VTK_WRAP_PYTHON "Should VTK Python wrapping be built?" OFF)
452
set(VTK_PYTHON_VERSION 2 CACHE STRING
453
    "Python version to use: 2, 2.x, 3, 3.x, or empty")
454 455 456 457 458 459 460

# Add the option for build the Python wrapping to VTK.
option(VTK_WRAP_JAVA "Should VTK Java wrapping be built?" OFF)

# FIXME: This variable should not be necessary once we are done
set(VTK_IGNORE_BTX ON CACHE INTERNAL "VTK modular always ignores BTX")

461 462 463 464 465 466 467 468
# Force reset of hints file location in cache if it was moved
if(VTK_WRAP_HINTS)
  if(NOT EXISTS ${VTK_WRAP_HINTS})
    set(VTK_WRAP_HINTS "VTK_WRAP_HINTS-NOTFOUND")
  endif()
endif()

find_file(VTK_WRAP_HINTS hints ${VTK_SOURCE_DIR}/Wrapping/Tools
469 470 471
  NO_CMAKE_FIND_ROOT_PATH)
mark_as_advanced(VTK_WRAP_HINTS)

472 473
if(BUILD_TESTING OR VTK_WRAP_PYTHON)
  # Need PYTHON_EXECUTABLE for HeaderTesting or python wrapping
474
  find_package(PythonInterp ${VTK_PYTHON_VERSION} QUIET)
475
  mark_as_advanced(PYTHON_EXECUTABLE)
476 477 478
endif()

if(VTK_WRAP_PYTHON)
479 480
  set(VTK_WRAP_PYTHON_EXE vtkWrapPython)
  set(VTK_WRAP_PYTHON_INIT_EXE vtkWrapPythonInit)
481 482
  # Force the WrappingPythonCore module to on if wrapping is on
  set(Module_vtkWrappingPythonCore ON CACHE BOOL "Core Python wrapping library"
483 484
    FORCE)
else()
485 486
  # if wrapping is not on then force WrappingPythonCore module to be off
  set(Module_vtkWrappingPythonCore OFF CACHE BOOL "Core Python wrapping library"
487
    FORCE)
488
endif()
489

490
if(VTK_WRAP_JAVA)
491
  set(VTK_WRAP_JAVA3_INIT_DIR "${VTK_SOURCE_DIR}/Wrapping/Java")
492
  # Wrapping executables.
493 494
  set(VTK_WRAP_JAVA_EXE  vtkWrapJava)
  set(VTK_PARSE_JAVA_EXE vtkParseJava)
495
  set(Module_vtkWrappingJava ON CACHE BOOL "Core Java wrapping library"
496
    FORCE)
497 498

  # Java package location.
499
  set(VTK_JAVA_JAR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vtk.jar)
500 501 502
  set(VTK_JAVA_HOME ${VTK_BINARY_DIR}/java/vtk)
  file(MAKE_DIRECTORY ${VTK_JAVA_HOME})
else()
503
  set(Module_vtkWrappingJava OFF CACHE BOOL "Core Java wrapping library"
504 505
    FORCE)
endif()
506

507 508 509 510 511 512 513 514
# Now for Tcl wrapping.
option(VTK_WRAP_TCL "Should VTK Tcl wrapping be built?" OFF)
if(VTK_WRAP_TCL)
  set(VTK_WRAP_TCL_EXE vtkWrapTcl)
  set(VTK_WRAP_TCL_INIT_EXE vtkWrapTclInit)
  set(VTK_TCL_EXE vtk)
  # Tcl package location.
  set(VTK_TCL_HOME ${VTK_BINARY_DIR}/Wrapping/Tcl)
515 516 517 518 519 520 521
  # Force the WrappingTcl module to on if wrapping is on
  set(Module_vtkWrappingTcl ON CACHE BOOL "Core Tcl wrapping library"
    FORCE)
else()
  # if wrapping is not on then force WrappingTcl module to be off
  set(Module_vtkWrappingTcl OFF CACHE BOOL "Core Tcl wrapping library"
    FORCE)
522
endif()
523

524 525 526
if(VTK_WRAP_PYTHON OR VTK_WRAP_TCL OR VTK_WRAP_JAVA)
  set(VTK_WRAP_HIERARCHY_EXE vtkWrapHierarchy)
endif()
527

528 529 530 531
# This is not normally necessary, but could be desirable in some circumstances.
option(VTK_MAKE_INSTANTIATORS "Should all modules build instantiators" OFF)
mark_as_advanced(VTK_MAKE_INSTANTIATORS)

532
#----------------------------------------------------------------------
533
# Load the module DAG, assess all modules etc.
534
include(vtkModuleTop)
535

536 537 538 539 540
# Now build the Python wrapping if necessary.
if(VTK_WRAP_PYTHON)
  add_subdirectory(Wrapping/Python)
endif()

541 542 543 544
if(BUILD_TESTING)
  add_subdirectory(Testing/Install)
endif()

545 546 547 548
if(BUILD_EXAMPLES)
  add_subdirectory(Examples)
endif()

549 550 551 552 553 554
# The doxygen documentation needs to be aware of all modules.
option(BUILD_DOCUMENTATION "Build the VTK documentation" OFF)
if(BUILD_DOCUMENTATION)
  add_subdirectory(Utilities/Doxygen)
endif()

555 556 557 558 559 560 561
# If python wrapping and testing is enabled then add driver scripts to run
# tests.  Note: Many pythong tests used to be automatically converted from TCL
# scripts. Hence the name vtkTclTest2Py
if(BUILD_TESTING AND VTK_WRAP_PYTHON)
  add_subdirectory(Utilities/vtkTclTest2Py)
endif()

562 563 564 565 566 567 568 569
# Configure the CTestCustom.cmake file now that everything is done.
set(memcheck_excluded_tests "  # These tests do not run any VTK code\n")
foreach(vtk-module ${VTK_MODULES_ALL})
  set(memcheck_excluded_tests
    "${memcheck_excluded_tests}  ${vtk-module}-HeaderTest\n")
endforeach()
configure_file("${VTK_CMAKE_DIR}/CTestCustom.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake" @ONLY)
570 571 572

#-----------------------------------------------------------------------------
# Export all targets at once from the build tree in their final configuration.
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
get_property(_vtk_targets GLOBAL PROPERTY VTK_TARGETS)
get_property(_vtk_compiletools_targets GLOBAL PROPERTY VTK_COMPILETOOLS_TARGETS)
set (_vtk_all_targets ${_vtk_targets} ${_vtk_compiletools_targets})
if (_vtk_all_targets)
  list(REMOVE_DUPLICATES _vtk_all_targets)
  export(TARGETS ${_vtk_all_targets} FILE ${VTK_BINARY_DIR}/VTKTargets.cmake)
endif()
# Add a virtual target that can be used to build all compile tools.
add_custom_target(vtkCompileTools)
if (_vtk_compiletools_targets)
  list(REMOVE_DUPLICATES _vtk_compiletools_targets)
  export(TARGETS ${_vtk_compiletools_targets}
         FILE ${VTK_BINARY_DIR}/VTKCompileToolsConfig.cmake)
  add_dependencies(vtkCompileTools ${_vtk_compiletools_targets})
endif()
588

589 590 591
unset(_vtk_targets)
unset(_vtk_compiletools_targets)
unset(_vtk_all_targets)
Brad King's avatar
Brad King committed
592 593 594 595

# Create target to download data from the VTKData group.  This must come after
# all tests have been added that reference the group, so we put it last.
ExternalData_Add_Target(VTKData)
596 597 598 599 600 601 602 603
if(VTK_DATA_EXCLUDE_FROM_ALL)
  set_property(TARGET VTKData PROPERTY EXCLUDE_FROM_ALL 1)
  if(BUILD_TESTING AND NOT VTK_DATA_EXCLUDE_FROM_ALL_NO_WARNING)
    message(WARNING "VTK_DATA_EXCLUDE_FROM_ALL is ON so test data "
      "(needed because BUILD_TESTING is ON) may not be available "
      "without manually building the 'VTKData' target.")
  endif()
endif()