From 1ab9fe663fdde3f6a73692e487f089cfb9cba540 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 18 Jun 2018 00:21:23 -0500 Subject: [PATCH] [cmake] Add flags for different build types and set default value Default to RelWithDebInfo (-O2 -g) if no custom CMAKE_BUILD_TYPE is defined. Also add flags for use with CMAKE_BUILD_TYPEs Debug, Release, and RelWithDebInfo. --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6514c4c4..405343e50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,15 @@ PROJECT(fish) # We are C++11. SET(CMAKE_CXX_STANDARD 11) +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2") +SET(DEFAULT_BUILD_TYPE "RelWithDebInfo") + +IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + MESSAGE(STATUS "Setting build type to default '${DEFAULT_BUILD_TYPE}'") + SET(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}") +ENDIF() # Disable exception handling. ADD_COMPILE_OPTIONS(-fno-exceptions)