Slightly simplier cmake

This commit is contained in:
alesapin 2020-12-24 16:06:32 +03:00
parent e68bafd508
commit 3e9d177813
3 changed files with 7 additions and 6 deletions

View File

@ -252,15 +252,15 @@ endif ()
option(WITH_COVERAGE "Profile the resulting binary/binaries" OFF)
if (WITH_COVERAGE AND COMPILER_CLANG)
set(COMPILER_COVERAGE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
# If we want to disable coverage for specific translation units
set(WITHOUT_COVERAGE "-fno-profile-instr-generate -fno-coverage-mapping")
endif()
if (WITH_COVERAGE AND COMPILER_GCC)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-arcs -ftest-coverage")
set(COVERAGE_OPTION "-lgcov")
set(COMPILER_COVERAGE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
set(WITH_COVERAGE "-fprofile-arcs -ftest-coverage")
set(WITHOUT_COVERAGE "-fno-profile-arcs -fno-test-coverage")
endif()
set(COMPILER_FLAGS "${COMPILER_FLAGS}")

View File

@ -37,8 +37,6 @@ add_library (common ${SRCS})
if (WITH_COVERAGE)
target_compile_definitions(common PUBLIC WITH_COVERAGE=1)
target_compile_options(common PUBLIC ${COMPILER_COVERAGE_OPTIONS})
target_link_options(common PUBLIC ${COMPILER_COVERAGE_OPTIONS})
else ()
target_compile_definitions(common PUBLIC WITH_COVERAGE=0)
endif ()

View File

@ -15,7 +15,10 @@ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
if (WITH_COVERAGE)
add_compile_options(-O3 -DNDEBUG -finline)
set (WITHOUT_COVERAGE_LIST ${WITHOUT_COVERAGE})
separate_arguments(WITHOUT_COVERAGE_LIST)
# disable coverage for contib files and build with optimisations
add_compile_options(-O3 -DNDEBUG -finline-functions -finline-hint-functions ${WITHOUT_COVERAGE_LIST})
endif()
if (SANITIZE STREQUAL "undefined")