aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/cmake.d/01-build_options.cmake31
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()