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

View File

@ -37,8 +37,6 @@ add_library (common ${SRCS})
if (WITH_COVERAGE) if (WITH_COVERAGE)
target_compile_definitions(common PUBLIC WITH_COVERAGE=1) 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 () else ()
target_compile_definitions(common PUBLIC WITH_COVERAGE=0) target_compile_definitions(common PUBLIC WITH_COVERAGE=0)
endif () endif ()

View File

@ -15,7 +15,10 @@ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
if (WITH_COVERAGE) 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() endif()
if (SANITIZE STREQUAL "undefined") if (SANITIZE STREQUAL "undefined")