CMakeLists.txt 11.2 KB
Newer Older
1
2
3
4
5
6
7
8
##============================================================================
##  Copyright (c) Kitware, Inc.
##  All rights reserved.
##  See LICENSE.txt for details.
##  This software is distributed WITHOUT ANY WARRANTY; without even
##  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
##  PURPOSE.  See the above copyright notice for more information.
##
Kenneth Moreland's avatar
Kenneth Moreland committed
9
##  Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10
##  Copyright 2014 UT-Battelle, LLC.
11
##  Copyright 2014 Los Alamos National Security.
12
##
Kenneth Moreland's avatar
Kenneth Moreland committed
13
##  Under the terms of Contract DE-NA0003525 with NTESS,
14
15
16
17
18
19
20
##  the U.S. Government retains certain rights in this software.
##
##  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
##  Laboratory (LANL), the U.S. Government retains certain rights in
##  this software.
##============================================================================

21
22
# We require CMake 3.3 for Modern CMake which as features such as:
#   - Support for target_sources
23
24
#   - Support for usage requirements
#
25
26
# If you want CUDA support, you will need to have CMake 3.9 on Linux/OSX or
# CMake 3.10 on windows.
27
cmake_minimum_required(VERSION 3.3)
28
29
project (VTKm)

30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Update module path
set(VTKm_CMAKE_MODULE_PATH ${VTKm_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})

# Determine VTK-m version
include(Utilities/Git/Git.cmake)
include(VTKmDetermineVersion)

# Load hardcoded version in case this is not a Git repository
file(STRINGS version.txt version_txt)
extract_version_components("${version_txt}" "VTKm")
# Get the version from git if we can
determine_version(${VTKm_SOURCE_DIR} ${GIT_EXECUTABLE} "VTKm")

44
if (NOT DEFINED VTKm_INSTALL_INCLUDE_DIR)
45
  set(VTKm_INSTALL_INCLUDE_DIR "include/vtkm-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}")
46
47
endif()
if (NOT DEFINED VTKm_INSTALL_CONFIG_DIR)
48
  set(VTKm_INSTALL_CONFIG_DIR "lib/cmake/vtkm-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}")
49
50
51
52
53
54
55
endif()
if (NOT DEFINED VTKm_INSTALL_LIB_DIR)
  set(VTKm_INSTALL_LIB_DIR "lib")
endif()
if (NOT DEFINED VTKm_INSTALL_BIN_DIR)
  set(VTKm_INSTALL_BIN_DIR "bin")
endif()
56
57
58
if (NOT DEFINED VTKm_INSTALL_SHARE_DIR)
  set(VTKm_INSTALL_SHARE_DIR "share/vtkm-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}")
endif()
59
if (NOT DEFINED VTKm_INSTALL_CMAKE_MODULE_DIR)
60
  set(VTKm_INSTALL_CMAKE_MODULE_DIR "${VTKm_INSTALL_SHARE_DIR}/cmake")
61
endif()
62
63
64
if (NOT DEFINED VTKm_BUILD_CMAKE_BASE_DIR)
  set(VTKm_BUILD_CMAKE_BASE_DIR "${VTKm_BINARY_DIR}")
endif ()
65

66
set(VTKm_BINARY_INCLUDE_DIR "${VTKm_BINARY_DIR}/include")
67

68
69
if (NOT DEFINED VTKm_EXPORT_NAME)
  set(VTKm_EXPORT_NAME "VTKmTargets")
70
71
endif()

72
#-----------------------------------------------------------------------------
73
74
75
76
77
78
79
80
# vtkm_option(variable doc [initial])
#   Provides an option if it is not already defined.
macro (vtkm_option variable)
  if (NOT DEFINED "${variable}")
    option("${variable}" ${ARGN})
  endif ()
endmacro ()

81
# Configurable Options
82
83
84
85
86
87
vtkm_option(VTKm_ENABLE_CUDA "Enable Cuda support" OFF)
vtkm_option(VTKm_ENABLE_TBB "Enable TBB support" OFF)
vtkm_option(VTKm_ENABLE_RENDERING "Enable rendering library" ON)
vtkm_option(VTKm_ENABLE_TESTING "Enable VTKm Testing" ON)
vtkm_option(VTKm_ENABLE_BENCHMARKS "Enable VTKm Benchmarking" OFF)
vtkm_option(VTKm_ENABLE_MPI "Enable MPI support" OFF)
88

89
90
vtkm_option(VTKm_ENABLE_DOCUMENTATION "Build Doxygen documentation" OFF)
vtkm_option(VTKm_ENABLE_EXAMPLES "Build examples" OFF)
91

92
93
vtkm_option(VTKm_USE_DOUBLE_PRECISION "Use double precision for floating point calculations" OFF)
vtkm_option(VTKm_USE_64BIT_IDS "Use 64-bit indices." ON)
94

95
96
97
# When VTK-m is embedded into larger projects they may desire to turn off
# VTK-m internal assert checks when in debug mode to improve debug runtime
# performance.
98
vtkm_option(VTKm_NO_ASSERT "Disable assertions in debugging builds." OFF)
99
100
101
102

# When VTK-m is embedded into larger projects that wish to make end user
# applications they want to only install libraries and don't want CMake/headers
# installed.
103
vtkm_option(VTKm_INSTALL_ONLY_LIBRARIES "install only vtk-m libraries and no headers" OFF)
104

105
106
107
108
109
# VTK-m is setup by default not to export symbols unless explicitly stated.
# We prefer to only export symbols of a small set of user facing classes,
# rather than exporting all symbols. This flag is added so that consumers
# which require static builds can force all symbols on, which is something
# VTK does.
110
vtkm_option(VTKm_USE_DEFAULT_SYMBOL_VISIBILITY "Don't explicitly hide symbols from libraries." OFF)
111

Ben Boeckel's avatar
Ben Boeckel committed
112
vtkm_option(BUILD_SHARED_LIBS "Build VTK-m with shared libraries" ON)
113
114
set(VTKm_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})

115
116
117
118
119
mark_as_advanced(
  VTKm_NO_ASSERT
  VTKm_INSTALL_ONLY_LIBRARIES
  VTKm_USE_DEFAULT_SYMBOL_VISIBILITY
  )
120

121
#-----------------------------------------------------------------------------
122
123
124
# When using C++11 support make sure you use the standard C++ extensions rather
# than compiler-specific versions of the extensions (to preserve portability).
set(CMAKE_CXX_EXTENSIONS False)
125

126
127
128
# Setup default build types
include(VTKmBuildType)

129
130
131
# Create vtkm_compiler_flags library. This is an interface library that
# holds all the C++ compiler flags that are needed for consumers and
# when building VTK-m.
132
133
134
include(VTKmCompilerFlags)
include(VTKmWrappers)

135
136
137
138
#-----------------------------------------------------------------------------
# When building VTK-m it self we want to explicitly disable compiler extensions
set(CMAKE_CXX_EXTENSIONS OFF)

139
140
141
#-----------------------------------------------------------------------------

## Set the directory where the binaries will be stored
142
143
144
if(NOT VTKm_EXECUTABLE_OUTPUT_PATH)
  set(VTKm_EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
endif()
145
146

## Set the directory where the libraries will be stored
147
148
149
if(NOT VTKm_LIBRARY_OUTPUT_PATH)
  set(VTKm_LIBRARY_OUTPUT_PATH  ${PROJECT_BINARY_DIR}/lib)
endif()
150

151
#-----------------------------------------------------------------------------
152
if (VTKm_ENABLE_TESTING)
153
154
155
156
  enable_testing()
  include(CTest)
  configure_file(${VTKm_SOURCE_DIR}/CTestCustom.cmake.in
    ${VTKm_BINARY_DIR}/CTestCustom.cmake @ONLY)
157
158
159
160
161
162

  #-----------------------------------------------------------------------------
  # Add "meta" tests that check the state of the repository
  # SystemInformation prints out information about the current configuration
  # CopyrightStatement checks that the copyright statement is in all source files
  # SourceInBuild checks that all source files are listed in the build
163
164
165
  add_test(NAME SystemInformation
    COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" "-DVTKm_BINARY_DIR=${VTKm_BINARY_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmSystemInformation.cmake"
    )
166
167
168
  add_test(NAME CopyrightStatement
    COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckCopyright.cmake"
    )
169
170
  add_test(NAME SourceInBuild
    COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckSourceInBuild.cmake"
Kenneth Moreland's avatar
Kenneth Moreland committed
171
    )
172
173
174

  #-----------------------------------------------------------------------------
  # Find the Python interpreter, which we will use during the build process
175
  find_package(PythonInterp QUIET)
176
177
178
179

  #-----------------------------------------------------------------------------
  # Find Pyexpander in case somebody wants to update the auto generated
  # faux variadic template code
180
  find_package(Pyexpander QUIET)
181
182
183
184
185
186
187
188
189
190
191
endif (VTKm_ENABLE_TESTING)

#-----------------------------------------------------------------------------
# Check basic type sizes.
include(CheckTypeSize)

check_type_size(long VTKm_SIZE_LONG BUILTIN_TYPES_ONLY)
check_type_size("long long" VTKm_SIZE_LONG_LONG BUILTIN_TYPES_ONLY)

#-----------------------------------------------------------------------------
# Add subdirectories
192
193
194
if(VTKm_ENABLE_MPI)
  # This `if` is temporary and will be removed once `diy` supports building
  # without MPI.
195
196
197
  if (NOT MPI_C_FOUND)
    find_package(MPI ${VTKm_FIND_PACKAGE_QUIETLY})
  endif()
198
endif()
199

200
201
add_subdirectory(vtkm)

202
203
#-----------------------------------------------------------------------------
# Build documentation
204
if (VTKm_ENABLE_DOCUMENTATION)
205
206
207
208
  include(CMake/VTKmBuildDocumentation.cmake)
endif()

#-----------------------------------------------------------------------------
209
210
211
# Ready files for find_package
include(CMakePackageConfigHelpers)

212
configure_package_config_file(
213
  ${VTKm_SOURCE_DIR}/CMake/VTKmConfig.cmake.in
214
  ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmConfig.cmake
215
  INSTALL_DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
216
217
218
219
220
221
  PATH_VARS
    VTKm_INSTALL_INCLUDE_DIR
    VTKm_INSTALL_CONFIG_DIR
    VTKm_INSTALL_LIB_DIR
    VTKm_INSTALL_BIN_DIR
    VTKm_INSTALL_CMAKE_MODULE_DIR
222
223
  )

224
write_basic_package_version_file(
225
  ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmConfigVersion.cmake
226
227
  VERSION ${VTKm_VERSION}
  COMPATIBILITY ExactVersion )
228

229
230
231
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
  install(
    FILES
232
233
      ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmConfig.cmake
      ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmConfigVersion.cmake
234
235
    DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
    )
236

237
238
  # Install the readme and license files.
  install(FILES ${VTKm_SOURCE_DIR}/README.md
239
    DESTINATION ${VTKm_INSTALL_SHARE_DIR}
240
241
242
    RENAME VTKmREADME.md
    )
  install(FILES ${VTKm_SOURCE_DIR}/LICENSE.txt
243
    DESTINATION ${VTKm_INSTALL_SHARE_DIR}
244
245
    RENAME VTKmLICENSE.txt
    )
246

247
248
249
250
251
252
253
  # Install helper configure files.
  install(
    FILES
      ${VTKm_SOURCE_DIR}/CMake/FindTBB.cmake
      ${VTKm_SOURCE_DIR}/CMake/FindOpenGL.cmake
    DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
    )
254

255
256
257
  # Install support files.
  install(
    FILES
258
      ${VTKm_SOURCE_DIR}/CMake/VTKmCPUVectorization.cmake
259
      ${VTKm_SOURCE_DIR}/CMake/VTKmDetectCUDAVersion.cu
260
      ${VTKm_SOURCE_DIR}/CMake/VTKmDeviceAdapters.cmake
261
      ${VTKm_SOURCE_DIR}/CMake/VTKmExportHeaderTemplate.h.in
262
263
      ${VTKm_SOURCE_DIR}/CMake/VTKmRenderingContexts.cmake
      ${VTKm_SOURCE_DIR}/CMake/VTKmWrappers.cmake
264
265
266
267
268
269
270
271
272
273
274
275
    DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
    )

  # Create and install exports for external projects
  export(EXPORT ${VTKm_EXPORT_NAME}
    FILE ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmTargets.cmake
    )
  install(EXPORT ${VTKm_EXPORT_NAME}
    DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
    FILE VTKmTargets.cmake
    )
endif()
276

277
278
279
280
281
282
283
284
285
286
287
288
289
290
vtkm_option(VTKm_ENABLE_CPACK "Enable CPack packaging of VTKm" ON)
if (VTKm_ENABLE_CPACK)
  # Enable CPack packaging
  set(CPACK_PACKAGE_DESCRIPTION_FILE ${VTKm_SOURCE_DIR}/README.md)
  set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The VTKm Toolkit")
  set(CPACK_PACKAGE_NAME "VTKm")
  set(CPACK_PACKAGE_VERSION_MAJOR ${VTKm_VERSION_MAJOR})
  set(CPACK_PACKAGE_VERSION_MINOR ${VTKm_VERSION_MINOR})
  set(CPACK_PACKAGE_VERSION_PATCH ${VTKm_VERSION_PATCH})
  set(CPACK_PACKAGE_FILE_NAME "VTKm-${VTKm_VERSION}")
  set(CPACK_RESOURCE_FILE_LICENSE ${VTKm_SOURCE_DIR}/LICENSE.txt)
  set(CPACK_RESOURCE_FILE_README ${VTKm_SOURCE_DIR}/README.md)
  include(CPack)
endif ()
291

292
293
294
295
296
297
#-----------------------------------------------------------------------------
#add the benchmarking folder
if(VTKm_ENABLE_BENCHMARKS)
    add_subdirectory(benchmarking)
endif()

298
299
#-----------------------------------------------------------------------------
# Build examples
300
if(VTKm_ENABLE_EXAMPLES)
301
  add_subdirectory(examples)
302
endif(VTKm_ENABLE_EXAMPLES)