From 2653a44a4cbdbd2b45eb31d11cb6aaa2cb30fbfc Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 11 Sep 2020 12:06:28 +0200 Subject: [PATCH] set default CMake build type to RelWithDebInfo This enables both optimizations (-O2) and debug symbols (-g), so strip the latter during the install rule. While at it, increase verbosity for the default build. --- .travis.sh | 3 ++- CMakeLists.txt | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.sh b/.travis.sh index 0c39d69f..4dc63da7 100755 --- a/.travis.sh +++ b/.travis.sh @@ -9,9 +9,10 @@ if [ "$ANALYZE" = "true" ] ; then exit $RET else set -e + export VERBOSE=1 mkdir build && cd build cmake -G "Unix Makefiles" .. make - make install DESTDIR=/tmp/whatever + make install/strip DESTDIR=/tmp/whatever make package fi diff --git a/CMakeLists.txt b/CMakeLists.txt index e506d31e..a736e068 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,17 @@ project("Woof" HOMEPAGE_URL "https://github.com/fabiangreffrath/woof" LANGUAGES C) +# Set a default build type if none was specified +set(default_build_type "RelWithDebInfo") +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() + # Prevent in-tree builds. if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "In-tree builds are not supported.")