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.
This commit is contained in:
Fabian Greffrath 2020-09-11 12:06:28 +02:00
parent 38a869a785
commit 2653a44a4c
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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.")