diff options
Diffstat (limited to 'cmake/compiler.cmake')
| -rw-r--r-- | cmake/compiler.cmake | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 6258cca0..5d452e02 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -31,42 +31,34 @@ test_and_set_c_compiler_flag_global(-Wdeclaration-after-statement) test_and_set_c_compiler_flag_global(-Winfinite-recursion) test_and_set_c_compiler_flag_global(-fmax-errors=5) -set(DISABLE_COVERAGE ON CACHE BOOL "Disable code coverage analysis") - -if (NOT DISABLE_COVERAGE) - test_and_set_c_compiler_flag_global(-g) - test_and_set_c_compiler_flag_global(--coverage) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") - set(ENABLE_COVERAGE ON) -else() - set(ENABLE_COVERAGE OFF) -endif() - -if (NOT CMAKE_BUILD_TYPE) +if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (Release, Debug, DebugASan, DebugTSan, DebugLSan, DebugUSan, DebugAnalyzer)" FORCE) endif() -if (CMAKE_BUILD_TYPE STREQUAL "Release") +if(CMAKE_BUILD_TYPE STREQUAL "Release") test_and_set_c_compiler_flag_global(-O3) -elseif (CMAKE_BUILD_TYPE STREQUAL "Debug") +elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") test_and_set_c_compiler_flag_global(-g) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugASan") +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugASan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=address) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugTSan") + add_link_options(-fsanitize=address) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugTSan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=thread) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugLSan") + add_link_options(-fsanitize=thread) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugLSan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=leak) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugUSan") + add_link_options(-fsanitize=leak) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugUSan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=undefined) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer") + add_link_options(-fsanitize=undefined) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fanalyzer) -else () - message(FATAL_ERROR "Unkown build type ${CMAKE_BUILD_TYPE}") -endif () +else() + message(FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE}") +endif() |
