CMakeLists.txt 5.77 KB
Newer Older
1
cmake_minimum_required(VERSION 3.3...3.12 FATAL_ERROR)
2

3 4 5 6
if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_VERSION VERSION_LESS 3.7)
  message(FATAL_ERROR "CMake 3.7 or above is required to build for Android")
endif()

7
project(VTK)
8

9 10 11
set(VTK_CMAKE_DIR "${VTK_SOURCE_DIR}/CMake")
set(CMAKE_MODULE_PATH ${VTK_CMAKE_DIR} ${CMAKE_MODULE_PATH})

12 13 14 15
if (APPLE)
  include(vtkApple)
endif ()

Ken Martin's avatar
Ken Martin committed
16 17 18 19 20
# must be before the following iOS / Android
include(vtkVersion)
set(VTK_VERSION
    "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}")

21 22 23 24 25 26 27 28 29 30 31 32 33 34
option(VTK_IOS_BUILD "Build vtk.framework for iOS" OFF)
mark_as_advanced(VTK_IOS_BUILD)
if (VTK_IOS_BUILD)
  include(vtkiOS)
  return()
endif()

option(VTK_ANDROID_BUILD "Build VTK for Android" OFF)
mark_as_advanced(VTK_ANDROID_BUILD)
if (VTK_ANDROID_BUILD)
  include(vtkAndroid)
  return()
endif()

35
include(vtkCompilerChecks)
36
include(vtkCompilerPlatformFlags)
37
include(vtkCompilerExtraFlags)
38
include(vtkInitializeBuildType)
39
include(vtkSupportMacros)
40
include(vtkDownload)
41
include(vtkTesting)
42
include(vtkDirectories)
43
include(vtkMobileDevices)
44
include(vtkCrossCompiling)
45
include(vtkThirdParty)
46
include(vtkThreads)
47
include(vtkWrapSettings)
48

49 50 51 52
# Setup compiler flags for dynamic analysis
# Should be included after vtkTesting
include(vtkCompilerDynamicAnalysisFlags)

53
include(vtkModuleMacros)
54

Ken Martin's avatar
Ken Martin committed
55 56
#-----------------------------------------------------------------------------
# Do we want examples built?
57
option(BUILD_EXAMPLES "Build VTK examples." OFF)
Ken Martin's avatar
Ken Martin committed
58

59
set(VTK_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
60

61 62 63 64
#-----------------------------------------------------------------------------
# Add the Remote Subdirectory
add_subdirectory(Remote)

65 66
#-----------------------------------------------------------------------------
# Does VTK require support for 64 bit file systems
67 68
include(CheckCXXSourceRuns)
file(READ "${VTK_CMAKE_DIR}/vtkRequireLargeFilesSupport.cxx"
69
  VTK_REQUIRE_LARGE_FILE_SUPPORT_FILE)
70
check_cxx_source_runs("${VTK_REQUIRE_LARGE_FILE_SUPPORT_FILE}"
71
  CMAKE_REQUIRE_LARGE_FILE_SUPPORT "Support for 64 bit file systems")
72
set(VTK_REQUIRE_LARGE_FILE_SUPPORT ${CMAKE_REQUIRE_LARGE_FILE_SUPPORT})
73

74
#-----------------------------------------------------------------------------
75
# Provide compatibility options.
76
option(VTK_LEGACY_REMOVE "Remove all legacy code completely." OFF)
77 78
option(VTK_LEGACY_SILENT "Silence all legacy code messages." OFF)
mark_as_advanced(VTK_LEGACY_REMOVE VTK_LEGACY_SILENT)
79

80 81
# Tell VTK source files they are being built inside VTK.
add_definitions(-DVTK_IN_VTK)
82

83
include(CheckTypeSize)
Ken Martin's avatar
Ken Martin committed
84

85 86 87 88 89
# Kits bundle multiple modules together into a single library, this
# is used to dramatically reduce the number of generated libraries.
option(VTK_ENABLE_KITS "Build VTK using kits instead of modules." OFF)
mark_as_advanced(VTK_ENABLE_KITS)

90 91
include(vtkEncodeString)

92
#----------------------------------------------------------------------
93
# Load the module DAG, assess all modules etc.
94
include(vtkModuleTop)
95

96 97 98 99 100
# Now build the Python wrapping if necessary.
if(VTK_WRAP_PYTHON)
  add_subdirectory(Wrapping/Python)
endif()

101 102 103 104
if(BUILD_TESTING)
  add_subdirectory(Testing/Install)
endif()

105 106 107 108
if(BUILD_EXAMPLES)
  add_subdirectory(Examples)
endif()

109 110 111 112 113 114
# 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()

115 116 117 118 119 120 121
# 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()

122 123 124 125 126 127 128 129
# 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)
130 131 132

#-----------------------------------------------------------------------------
# Export all targets at once from the build tree in their final configuration.
133 134 135 136 137 138 139 140 141 142 143 144 145
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)
  add_dependencies(vtkCompileTools ${_vtk_compiletools_targets})
endif()
146 147
export(TARGETS ${_vtk_compiletools_targets}
  FILE ${VTK_BINARY_DIR}/VTKCompileToolsConfig.cmake)
148

149 150 151
unset(_vtk_targets)
unset(_vtk_compiletools_targets)
unset(_vtk_all_targets)
Brad King's avatar
Brad King committed
152 153 154 155

# 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)
156 157 158 159 160 161 162 163
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()
164 165 166 167

#-----------------------------------------------------------------------------
# Install the license file
install(FILES ${VTK_SOURCE_DIR}/Copyright.txt DESTINATION ${VTK_INSTALL_DOC_DIR})
168 169 170 171

#-----------------------------------------------------------------------------
# Do this at the end so the all variables it uses are setup.
include(vtkBuildPath)