play nicer with system flags 0.9.18
authorhasufell
Sun, 04 Nov 2012 16:28:04 +0100
branch0.9.18
changeset 7944 a94f4ef5ba2b
parent 7942 17b3937de37b
child 7946 a99a79bbd857
play nicer with system flags
CMakeLists.txt
--- a/CMakeLists.txt	Sun Nov 04 15:45:45 2012 +0100
+++ b/CMakeLists.txt	Sun Nov 04 16:28:04 2012 +0100
@@ -58,7 +58,7 @@
 
 option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
 option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF)
-
+option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
 
 #bundle .app setup
 if(APPLE OR CROSSAPPLE)
@@ -158,14 +158,21 @@
     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE)
 endif (CMAKE_BUILD_TYPE)
 
-
-#set default flags values for all projects
-set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
-set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
-set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}")
-set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
-set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
-set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+#set default flags values for all projects (unless MINIMAL_FLAGS is true)
+if(NOT MINIMAL_FLAGS)
+    set(CMAKE_C_FLAGS "-pipe")
+    set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer")
+    set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG")
+    set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
+    set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
+    set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+else()
+    #CMake adds a lot of additional configuration flags, so let's clear them up
+    set(CMAKE_C_FLAGS_RELEASE "")
+    set(CMAKE_C_FLAGS_DEBUG "-Wall -DDEBUG")
+    set(CMAKE_CXX_FLAGS_RELEASE "")
+    set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
+endif()
 
 #parse additional parameters
 if(FPFLAGS OR GHFLAGS)