summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-04-28 22:28:22 +0300
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-04-29 22:47:33 +0300
commita0b80ca775e9ad4b840293f959d933e94d120fb8 (patch)
treee12d6fcd32bd6f4ddeb61243ed47d91f31d26027 /CMakeLists.txt
parent81a812539c95f2e709995d446065803c09e9136a (diff)
downloadsubsurface-a0b80ca775e9ad4b840293f959d933e94d120fb8.tar.gz
cmake: add the GCC_OPTIMIZATION_FLAGS variable
Instead of always adding -O2 for CMAKE_C_FLAGS_DEBUG and CMAKE_CXX_FLAGS_DEBUG allow the user to pass a custom value via GCC_OPTIMIZATION_FLAGS. Passing -DGCC_OPTIMIZATION_FLAGS:STRING=-O0 would disable all optimizations. Suggested-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt8
1 files changed, 5 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3b6c991d..d540f1187 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,9 +105,11 @@ endif()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
-# optimize -O2 even for debug builds
-set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O2")
-set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2")
+# by detault optimize with -O2 even for debug builds
+set (GCC_OPTIMIZATION_FLAGS "-O2" CACHE STRING "GCC optimization flags")
+message (STATUS "GCC optimization flags: " ${GCC_OPTIMIZATION_FLAGS})
+set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${GCC_OPTIMIZATION_FLAGS}")
+set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${GCC_OPTIMIZATION_FLAGS}")
# pkgconfig for required libraries
find_package(PkgConfig)