CMakeLists.txt 9.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
##============================================================================
##  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.
##
##  Copyright 2014 Sandia Corporation.
##  Copyright 2014 UT-Battelle, LLC.
11
##  Copyright 2014 Los Alamos National Security.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
##
##  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
##  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.
##============================================================================

cmake_minimum_required(VERSION 2.8.10)
project (VTKm)

set(VTKm_MAJOR_VERSION 0)
set(VTKm_MINOR_VERSION 1)
set(VTKm_PATCH_VERSION 0)
set(VTKm_VERSION "${VTKm_MAJOR_VERSION}.${VTKm_MINOR_VERSION}.${VTKm_PATCH_VERSION}")

set(VTKm_INSTALL_INCLUDE_DIR "include")
set(VTKm_INSTALL_CONFIG_DIR "include")
set(VTKm_INSTALL_CMAKE_MODULE_DIR "share/vtkm/cmake")

33
set(VTKm_REQUIRED_BOOST_VERSION "1.48")
34 35 36 37 38 39

# include some vtkm-specific cmake code.
include(CMake/VTKmMacros.cmake)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_SOURCE_DIR}/CMake)

40 41 42 43 44 45 46 47 48 49 50
#-----------------------------------------------------------------------------
# List of Boost features used:
# * Smart Ptr
# * Meta programming language
# We check for boost first, as the device configuration code requires boost
# to be found
find_package(BoostHeaders ${VTKm_REQUIRED_BOOST_VERSION} REQUIRED)
if(NOT Boost_FOUND)
  message(FATAL_ERROR "Please specify where to find boost headers (${VTKm_REQUIRED_BOOST_VERSION}+)" )
endif()

51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#-----------------------------------------------------------------------------
# Check for Cxx11 support.
option(VTKm_FORCE_ANSI
 "Turn off compiling any features not compatible with ISO-C++98 (ANSI)." OFF)
if (NOT VTKm_FORCE_ANSI)
  include(CMake/CheckCXX11Features.cmake)
else (NOT VTKm_FORCE_ANSI)
  set(VTKm_NO_VARIADIC_TEMPLATE TRUE)
endif ()

#-----------------------------------------------------------------------------
# Add supplemental compiler warnings, and GCC visibility support.
include(CMake/VTKmCompilerExtras.cmake)

#-----------------------------------------------------------------------------
# Configurable Options
67
option(VTKm_ENABLE_CUDA "Enable Cuda support" OFF)
Sujin Philip's avatar
Sujin Philip committed
68
option(VTKm_ENABLE_TBB "Enable TBB support" OFF)
69
option(VTKm_ENABLE_TESTING "Enable VTKm Testing" ON)
Will Usher's avatar
Will Usher committed
70
option(VTKm_ENABLE_BENCHMARKS "Enable VTKm Benchmarking" OFF)
71

72 73
option(VTKm_BUILD_DOCUMENTATION "Build Doxygen documentation" OFF)

74 75 76 77
option(VTKm_USE_DOUBLE_PRECISION
  "Use double precision for floating point calculations"
  OFF
  )
Sujin Philip's avatar
Sujin Philip committed
78
option(VTKm_USE_64BIT_IDS "Use 64-bit indices." ON)
79 80 81 82 83 84

if (VTKm_ENABLE_TESTING)
  enable_testing()
  include(CTest)
endif()

85 86 87 88 89 90
#-----------------------------------------------------------------------------
# Set up devices selected.
vtkm_configure_device(Serial)
if (VTKm_ENABLE_CUDA)
  vtkm_configure_device(Cuda)
endif (VTKm_ENABLE_CUDA)
Sujin Philip's avatar
Sujin Philip committed
91 92 93
if (VTKm_ENABLE_TBB)
  vtkm_configure_device(TBB)
endif (VTKm_ENABLE_TBB)
94

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#-----------------------------------------------------------------------------

## Set the directory where the binaries will be stored
set( EXECUTABLE_OUTPUT_PATH
  ${PROJECT_BINARY_DIR}/bin
  CACHE PATH
  "Directory where all executable will be stored"
)

## Set the directory where the libraries will be stored
set( LIBRARY_OUTPUT_PATH
  ${PROJECT_BINARY_DIR}/libs
  CACHE PATH
  "Directory where all the libraries will be stored"
)
mark_as_advanced(
  EXECUTABLE_OUTPUT_PATH
  LIBRARY_OUTPUT_PATH)

include_directories(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  )

#-----------------------------------------------------------------------------
# Add test to check for copyright statement on all source files.
Kenneth Moreland's avatar
Kenneth Moreland committed
121
# Also add test to output system information.
122 123 124 125
if (VTKm_ENABLE_TESTING)
  add_test(NAME CopyrightStatement
    COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckCopyright.cmake"
    )
Kenneth Moreland's avatar
Kenneth Moreland committed
126
  add_test(NAME SystemInformation
127
    COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" "-DVTKm_BINARY_DIR=${VTKm_BINARY_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmSystemInformation.cmake"
Kenneth Moreland's avatar
Kenneth Moreland committed
128
    )
129 130 131 132 133 134 135 136
endif (VTKm_ENABLE_TESTING)

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

check_type_size(float VTKm_SIZE_FLOAT BUILTIN_TYPES_ONLY)
check_type_size(double VTKm_SIZE_DOUBLE BUILTIN_TYPES_ONLY)
137 138
check_type_size(char VTKm_SIZE_CHAR BUILTIN_TYPES_ONLY)
check_type_size(short VTKm_SIZE_SHORT BUILTIN_TYPES_ONLY)
139 140 141 142 143 144
check_type_size(int VTKm_SIZE_INT BUILTIN_TYPES_ONLY)
check_type_size(long VTKm_SIZE_LONG BUILTIN_TYPES_ONLY)
check_type_size("long long" VTKm_SIZE_LONG_LONG BUILTIN_TYPES_ONLY)

#-----------------------------------------------------------------------------
# Build the configure file.
145 146 147 148 149
# need to set VTKM_USE_DOUBLE_PRECISION, and VTKM_USE_64BIT_IDS as that
# is the spelling we use for our defines.
set(VTKM_USE_DOUBLE_PRECISION ${VTKm_USE_DOUBLE_PRECISION})
set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS})

150 151 152 153 154 155
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vtkm/internal/Configure.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/vtkm/internal/Configure.h
  @ONLY)
vtkm_install_headers(
  vtkm/internal ${CMAKE_CURRENT_BINARY_DIR}/vtkm/internal/Configure.h)

156 157 158
unset(VTKM_USE_DOUBLE_PRECISION)
unset(VTKM_USE_64BIT_IDS)

159

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
#-----------------------------------------------------------------------------
# Find OpenGL and GLEW, if both are found we can enable
# the OpenGL Interop support. We use
include(CMakeDependentOption)

# enable Interop only if we have OpenGL and GLEW
find_package(OpenGL)
find_package(GLEW)
find_package(GLUT)

#dependent option reads, value to set, if condition is true, otherwise
#use last value
CMAKE_DEPENDENT_OPTION(VTKm_ENABLE_OPENGL_INTEROP
                       "Enable OpenGL Interop will require GLEW"
                       ON "OPENGL_FOUND;GLEW_FOUND" OFF)

#Only enable OpenGL Interop tests if we have Interop enabled
#and we have GLUT
#dependent option reads, value to set, if condition is true, otherwise
#use last value
CMAKE_DEPENDENT_OPTION(VTKm_ENABLE_OPENGL_TESTS
                       "Enable OpenGL Interop Render Window Tests"
                       ON "VTKm_ENABLE_OPENGL_INTEROP;GLUT_FOUND" OFF)

184
find_package(Pyexpander)
185

186 187 188 189
#-----------------------------------------------------------------------------
# Add subdirectories
add_subdirectory(vtkm)

190 191 192 193 194 195 196 197
#-----------------------------------------------------------------------------
# Build documentation
if (VTKm_BUILD_DOCUMENTATION)
  include(CMake/VTKmBuildDocumentation.cmake)
  vtkm_build_documentation()
endif()

#-----------------------------------------------------------------------------
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
# Configuration for build directory.
set(VTKm_INCLUDE_DIRS_CONFIG "${VTKm_SOURCE_DIR};${VTKm_BINARY_DIR}")
set(VTKm_CMAKE_MODULE_PATH_CONFIG "${VTKm_SOURCE_DIR}/CMake")
configure_file(
  ${VTKm_SOURCE_DIR}/CMake/VTKmConfig.cmake.in
  ${VTKm_BINARY_DIR}/VTKmConfig.cmake
  @ONLY IMMEDIATE
  )

# Configuration for install.
set(VTKm_INCLUDE_DIRS_CONFIG "\${_install_dir}/${VTKm_INSTALL_INCLUDE_DIR}")
set(VTKm_CMAKE_MODULE_PATH_CONFIG "\${_install_dir}/${VTKm_INSTALL_CMAKE_MODULE_DIR}")
configure_file(
  ${VTKm_SOURCE_DIR}/CMake/VTKmConfig.cmake.in
  ${VTKm_BINARY_DIR}/VTKmConfig.cmake.install
  @ONLY IMMEDIATE
  )
install(FILES ${VTKm_BINARY_DIR}/VTKmConfig.cmake.install
  DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
  RENAME VTKmConfig.cmake
  )

# Create supplemental version configuration file.
configure_file(
  ${VTKm_SOURCE_DIR}/CMake/VTKmConfigVersion.cmake.in
  ${VTKm_BINARY_DIR}/VTKmConfigVersion.cmake
  @ONLY
  )
install(FILES ${VTKm_BINARY_DIR}/VTKmConfigVersion.cmake
  DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
  )

230 231 232 233 234 235 236 237 238 239 240 241 242 243
# Install the readme and license files.
install(FILES ${VTKm_SOURCE_DIR}/README.md
  DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
  RENAME VTKmREADME.md
  )
install(FILES ${VTKm_SOURCE_DIR}/LICENSE.txt
  DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
  RENAME VTKmLICENSE.txt
  )

# Install helper configure files.
install(
  FILES
    ${VTKm_SOURCE_DIR}/CMake/FindBoostHeaders.cmake
244 245 246
    ${VTKm_SOURCE_DIR}/CMake/FindGLEW.cmake
    ${VTKm_SOURCE_DIR}/CMake/FindTBB.cmake
    ${VTKm_SOURCE_DIR}/CMake/FindThrust.cmake
247 248 249
  DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
  )

250 251 252 253
# Install Use files.
install(
  FILES
    ${VTKm_SOURCE_DIR}/CMake/UseVTKmSerial.cmake
254
    ${VTKm_SOURCE_DIR}/CMake/UseVTKmTBB.cmake
255 256 257 258 259
    ${VTKm_SOURCE_DIR}/CMake/UseVTKmCuda.cmake
  DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
  )


260 261 262 263 264 265 266 267 268 269 270
# 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_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${VTKm_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${VTKm_PATCH_VERSION})
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)