diff options
-rw-r--r-- | CMakeLists.txt | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eb79a18747..844c02f7e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,16 +64,25 @@ if(TRAVIS_CI_BUILD) add_definitions(-Werror) endif() -add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) +# Set custom build flags for RelWithDebInfo. +# -DNDEBUG purposely omitted because we want assertions. +if(CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g" + CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE) +else() + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" + CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE) +endif() -add_definitions(-DHAVE_CONFIG_H) if(CMAKE_BUILD_TYPE MATCHES Debug) - # cmake automatically appends -g to the compiler flags set(DEBUG 1) else() set(DEBUG 0) endif() +add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) +add_definitions(-DHAVE_CONFIG_H) + if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "Linux") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") |