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)