[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 03/04: cmake: added a check for the set bui
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 03/04: cmake: added a check for the set build type. |
Date: |
Wed, 23 Jul 2014 16:14:42 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 07d01b36a046e2e19d1419c3cee526d52b9e636f
Author: Tom Rondeau <address@hidden>
Date: Wed Jul 23 12:12:06 2014 -0400
cmake: added a check for the set build type.
---
CMakeLists.txt | 1 +
cmake/Modules/GrBuildTypes.cmake | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 39edf49..e6f93c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,7 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
+GR_CHECK_BUILD_TYPE(${CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.")
diff --git a/cmake/Modules/GrBuildTypes.cmake b/cmake/Modules/GrBuildTypes.cmake
index 4a157e4..aa59d00 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: