Overwrite CMake default C[XX]FLAGS

CMake sets default flags for the standard build types.
We want to replace them, not merge them.

Reported by azalyn.
This commit is contained in:
dhewg 2011-12-15 17:48:59 +01:00 committed by Daniel Gibson
parent e3f2666f32
commit a7b3b9fb0b

View file

@ -116,33 +116,16 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_definitions(-march=pentium3)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-g)
add_definitions(-D_DEBUG)
add_definitions(-O1)
elseif (CMAKE_BUILD_TYPE STREQUAL "DebugAll")
add_definitions(-g)
add_definitions(-ggdb)
add_definitions(-D_DEBUG)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions(-O3)
add_definitions(-ffast-math)
add_definitions(-fno-unsafe-math-optimizations)
add_definitions(-fomit-frame-pointer)
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_definitions(-g)
add_definitions(-O3)
add_definitions(-ffast-math)
add_definitions(-fno-unsafe-math-optimizations)
add_definitions(-fomit-frame-pointer)
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
add_definitions(-Os)
add_definitions(-ffast-math)
add_definitions(-fno-unsafe-math-optimizations)
add_definitions(-fomit-frame-pointer)
else()
message(FATAL_ERROR "Unknown build type")
endif()
set(CMAKE_C_FLAGS_DEBUG "-g -D_DEBUG -O1")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_DEBUGALL "-g -ggdb -D_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUGALL ${CMAKE_C_FLAGS_DEBUGALL})
set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL})
add_definitions(-fno-strict-aliasing)