[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.
This commit is contained in:
Mahmoud Al-Qudsi 2018-06-18 00:21:23 -05:00
parent cda18be6b4
commit 1ab9fe663f

View File

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