VTK-m now provides a default and a list of types for CMAKE_BUILD_TYPE.

CMake has several default build types, but if nothing is specified when
configuring your project it defaults to an empty string and no optimization
flags are used.

It will now default to using a debug build if the source directory is a git
clone, or a release build if not. Additionally when using ccmake or cmake-gui
this will provide a nice list of possible options for CMAKE_BUILD_TYPE.
This commit is contained in:
Robert Maynard 2017-08-10 09:55:50 -04:00
parent 89b2700298
commit ad3e0f320e
2 changed files with 38 additions and 0 deletions

34
CMake/VTKmBuildType.cmake Normal file

@ -0,0 +1,34 @@
##============================================================================
## 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.
## Copyright 2014 Los Alamos National Security.
##
## 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.
##============================================================================
# Set a default build type if none was specified
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" 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()

@ -38,9 +38,13 @@ set(VTKm_EXPORT_NAME "VTKmTargets")
set(VTKm_CMAKE_MODULE_PATH ${VTKm_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
# Setup default build types
include(VTKmBuildType)
# 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")