diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-04 12:22:33 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-15 18:22:48 +0200 |
commit | e15ff1630cef8890fb6b8f3ccc18e6f9c962dfd4 (patch) | |
tree | ed6300bc5cf4e1e165791b9525cb89f53792db0f /cmake/cmake.d | |
parent | d6eebf53d98267885235d088722cc4b53b4166a3 (diff) |
Change the default debug compilation options.
Because fortify source need optimization then the most
correct optimization to chose is -0g for debugging purpose.
Also be able to specify options for Clang which could differ
slightly from GNU.
Change-Id: I166c0cb62cbf9fc171cffc29c29df993f5ccb8f5
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'cmake/cmake.d')
-rw-r--r-- | cmake/cmake.d/01-build_options.cmake | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/cmake/cmake.d/01-build_options.cmake b/cmake/cmake.d/01-build_options.cmake index 1f7bd9c..36830f1 100644 --- a/cmake/cmake.d/01-build_options.cmake +++ b/cmake/cmake.d/01-build_options.cmake @@ -39,13 +39,36 @@ set(CMP0048 1) # Default compilation options ############################################################################ link_libraries(-Wl,--as-needed -Wl,--gc-sections) -set(COMPILE_OPTIONS -Wall -Wextra -Wconversion -Wno-unused-parameter -Wno-sign-compare -Wno-sign-conversion -Werror=maybe-uninitialized -Werror=implicit-function-declaration -ffunction-sections -fdata-sections -fPIC CACHE STRING "Compilation flags") +set(COMPILE_OPTIONS -Wall + -Wextra + -Wconversion + -Wno-unused-parameter + -Wno-sign-compare + -Wno-sign-conversion + -Werror=implicit-function-declaration + -ffunction-sections + -fdata-sections + -fPIC CACHE STRING "Compilation flags") + +set(COMPILE_OPTIONS_GNU -Werror=maybe-uninitialized CACHE STRING "GNU Compile specific options") +set(COMPILE_OPTIONS_CLANG -Werror=uninitialized CACHE STRING "CLang compile specific options") # Compilation OPTIONS depending on language ######################################### foreach(option ${COMPILE_OPTIONS}) add_compile_options(${option}) endforeach() + +if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + foreach(option ${COMPILE_OPTIONS_GNU}) + add_compile_options(${option}) + endforeach() +elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + foreach(option ${COMPILE_OPTIONS_CLANG}) + add_compile_options(${option}) + endforeach() +endif() + foreach(option ${C_COMPILE_OPTIONS}) add_compile_options($<$<COMPILE_LANGUAGE:C>:${option}>) endforeach() @@ -56,9 +79,9 @@ endforeach() # Compilation option depending on CMAKE_BUILD_TYPE ################################################## set(PROFILING_COMPILE_OPTIONS -g -O0 -pg -Wp,-U_FORTIFY_SOURCE CACHE STRING "Compilation flags for PROFILING build type.") -set(DEBUG_COMPILE_OPTIONS -g -ggdb -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for DEBUG build type.") -set(COVERAGE_COMPILE_OPTIONS -g -O2 --coverage CACHE STRING "Compilation flags for COVERAGE build type.") -set(RELEASE_COMPILE_OPTIONS -g -O2 -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for RELEASE build type.") +set(DEBUG_COMPILE_OPTIONS -g -ggdb -Og -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for DEBUG build type.") +set(COVERAGE_COMPILE_OPTIONS -g --coverage CACHE STRING "Compilation flags for COVERAGE build type.") +set(RELEASE_COMPILE_OPTIONS -O2 -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for RELEASE build type.") foreach(option ${PROFILING_COMPILE_OPTIONS}) add_compile_options($<$<CONFIG:PROFILING>:${option}>) endforeach() |