From 439636c579413fd9c9a3b925c7329ced500dba6b Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 15 Mar 2016 13:37:51 +0100 Subject: [PATCH] cmake: set CMAKE_BUILD_TYPE=RelWithDebInfo by default NOTE: RelWithDebInfo *disables* assertions by default. To keep assertions, use CMAKE_BUILD_TYPE=Debug or CMAKE_BUILD_TYPE=None. --- .travis.yml | 2 +- CMakeLists.txt | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa7bafc0..3267434b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,7 @@ before_script: - if [ "$CI_BUILD" = "autotools" ]; then autoreconf -i; fi - git submodule update --init - if [ "$CI_BUILD" = "autotools" ]; then ./configure --enable-werror --with-mruby --with-neverbleed LIBSPDYLAY_CFLAGS="-I$SPDYLAY_HOME/lib/includes" LIBSPDYLAY_LIBS="-L$SPDYLAY_HOME/lib/.libs -lspdylay"; fi - - if [ "$CI_BUILD" = "cmake" ]; then cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1 -DSPDYLAY_INCLUDE_DIR="$SPDYLAY_HOME/lib/includes" -DSPDYLAY_LIBRARY="$SPDYLAY_HOME/lib/.libs/libspdylay.so"; fi + - if [ "$CI_BUILD" = "cmake" ]; then cmake -DCMAKE_BUILD_TYPE=None -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1 -DSPDYLAY_INCLUDE_DIR="$SPDYLAY_HOME/lib/includes" -DSPDYLAY_LIBRARY="$SPDYLAY_HOME/lib/.libs/libspdylay.so"; fi script: - make - make check diff --git a/CMakeLists.txt b/CMakeLists.txt index c7a0f4c0..29277fac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,17 @@ set(LT_VERSION "${LT_SOVERSION}.${LT_AGE}.${LT_REVISION}") set(PACKAGE_VERSION "${PROJECT_VERSION}") HexVersion(PACKAGE_VERSION_NUM ${PROJECT_VERSION_MAJOR} ${PROJECT_VERSION_MINOR} ${PROJECT_VERSION_PATCH}) +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + # Note that RelWithDebInfo disables assertions, use Debug or None to keep them. + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the build type" FORCE) + + # Include "None" as option to disable any additional (optimization) flags, + # relying on just CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (which are empty by + # default). These strings are presented in cmake-gui. + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "None" "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + include(GNUInstallDirs) # For Python bindings and documentation @@ -227,7 +238,6 @@ else() endif() # Checks for header files. -# XXX AC_HEADER_ASSERT adds --disable-assert which sets -DNDEBUG include(CheckIncludeFile) check_include_file("arpa/inet.h" HAVE_ARPA_INET_H) check_include_file("fcntl.h" HAVE_FCNTL_H)