3277b990b6f50b28f4580660feed330f96990348
[socket_wrapper.git] / cmake / Modules / DefineCompilerFlags.cmake
1 if (UNIX AND NOT WIN32)
2     # Activate with: -DCMAKE_BUILD_TYPE=Profiling
3     set(CMAKE_C_FLAGS_PROFILING "-O0 -g -fprofile-arcs -ftest-coverage"
4         CACHE STRING "Flags used by the C compiler during PROFILING builds.")
5     set(CMAKE_CXX_FLAGS_PROFILING "-O0 -g -fprofile-arcs -ftest-coverage"
6         CACHE STRING "Flags used by the CXX compiler during PROFILING builds.")
7     set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage"
8         CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.")
9     set(CMAKE_MODULE_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage"
10         CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.")
11     set(CMAKE_EXEC_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage"
12         CACHE STRING "Flags used by the linker during PROFILING builds.")
13
14     # Activate with: -DCMAKE_BUILD_TYPE=AddressSanitizer
15     set(CMAKE_C_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer"
16         CACHE STRING "Flags used by the C compiler during ADDRESSSANITIZER builds.")
17     set(CMAKE_CXX_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer"
18         CACHE STRING "Flags used by the CXX compiler during ADDRESSSANITIZER builds.")
19     set(CMAKE_SHARED_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
20         CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.")
21     set(CMAKE_MODULE_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
22         CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.")
23     set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
24         CACHE STRING "Flags used by the linker during ADDRESSSANITIZER builds.")
25
26     # Activate with: -DCMAKE_BUILD_TYPE=UndefinedSanitizer
27     set(CMAKE_C_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover"
28         CACHE STRING "Flags used by the C compiler during UNDEFINEDSANITIZER builds.")
29     set(CMAKE_CXX_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover"
30         CACHE STRING "Flags used by the CXX compiler during UNDEFINEDSANITIZER builds.")
31     set(CMAKE_SHARED_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
32         CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
33     set(CMAKE_MODULE_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
34         CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
35     set(CMAKE_EXEC_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
36         CACHE STRING "Flags used by the linker during UNDEFINEDSANITIZER builds.")
37 endif()