From: Nathan Moinvaziri Date: Sun, 23 Jan 2022 21:26:36 +0000 (-0800) Subject: Use add_link_options in cmake code coverage detection. X-Git-Tag: 2.1.0-beta1~415 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c78eaee79670b68e2aaee247522c3a0100f97d30;p=thirdparty%2Fzlib-ng.git Use add_link_options in cmake code coverage detection. --- diff --git a/cmake/detect-coverage.cmake b/cmake/detect-coverage.cmake index 96478f677..ba5e8af94 100644 --- a/cmake/detect-coverage.cmake +++ b/cmake/detect-coverage.cmake @@ -14,8 +14,7 @@ macro(add_code_coverage) if(HAVE_COVERAGE) set(CMAKE_C_FLAGS "-O0 ${CMAKE_C_FLAGS} -coverage") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -coverage") + add_link_options(-coverage) else() # Some versions of GCC don't support -coverage shorthand if(CMAKE_VERSION VERSION_LESS 3.14) @@ -29,8 +28,7 @@ macro(add_code_coverage) if(HAVE_TEST_COVERAGE) set(CMAKE_C_FLAGS "-O0 ${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs -fprofile-values") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov -fprofile-arcs") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcov -fprofile-arcs") + add_link_options(-lgcov -fprofile-arcs) else() message(WARNING "Compiler does not support code coverage") endif()