]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use add_link_options in cmake code coverage detection.
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 23 Jan 2022 21:26:36 +0000 (13:26 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 29 Jan 2022 15:44:21 +0000 (16:44 +0100)
cmake/detect-coverage.cmake

index 96478f6771c8f349e22fa8d4e3c9ba8eb3806bb6..ba5e8af948a209ee006d708a10ce0c24568c0c6f 100644 (file)
@@ -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()