diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-07-23 12:12:06 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-07-23 12:13:33 -0400 |
commit | 07d01b36a046e2e19d1419c3cee526d52b9e636f (patch) | |
tree | 5f113d1e85467684af799f8a718b81aa651beaf6 /cmake/Modules | |
parent | 015db3a354ba29bfc09aef14daf29e4b672040ce (diff) |
cmake: added a check for the set build type.
Diffstat (limited to 'cmake/Modules')
-rw-r--r-- | cmake/Modules/GrBuildTypes.cmake | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cmake/Modules/GrBuildTypes.cmake b/cmake/Modules/GrBuildTypes.cmake index 4a157e4a97..aa59d0089f 100644 --- a/cmake/Modules/GrBuildTypes.cmake +++ b/cmake/Modules/GrBuildTypes.cmake @@ -23,15 +23,44 @@ endif() set(__INCLUDED_GR_BUILD_TYPES_CMAKE TRUE) # Standard CMake Build Types and their basic CFLAGS: +# - None: nothing set # - Debug: -O2 -g # - Release: -O3 # - RelWithDebInfo: -O3 -g +# - MinSizeRel: -OS # Addtional Build Types, defined below: # - NoOptWithASM: -O0 -g -save-temps # - O2WithASM: -O2 -g -save-temps # - O3WithASM: -O3 -g -save-temps +# Defines the list of acceptable cmake build types. When adding a new +# build type below, make sure to add it to this list. +list(APPEND AVAIL_BUILDTYPES + None Debug Release RelWithDebInfo MinSizeRel + NoOptWithASM O2WithASM O3WithASM +) + +######################################################################## +# GR_CHECK_BUILD_TYPE(build type) +# +# Use this to check that the build type set in CMAKE_BUILD_TYPE on the +# commandline is one of the valid build types used by this project. It +# checks the value set in the cmake interface against the list of +# known build types in AVAIL_BUILDTYPES. If the build type is found, +# the function exits immediately. If nothing is found by the end of +# checking all available build types, we exit with an error and list +# the avialable build types. +######################################################################## +function(GR_CHECK_BUILD_TYPE settype) + foreach(btype ${AVAIL_BUILDTYPES}) + if(${settype} STREQUAL ${btype}) + return() # found it; exit cleanly + endif(${settype} STREQUAL ${btype}) + endforeach(btype) + # Build type not found; error out + message(FATAL_ERROR "Build type '${settype}' not valid, must be one of: ${AVAIL_BUILDTYPES}") +endfunction(GR_CHECK_BUILD_TYPE) ######################################################################## # For GCC and Clang, we can set a build type: |