Skip to content

Commit 1c93786

Browse files
committed
Change -fno-elide-constructors compilation scope
This option only applies to C++, however it was being applied to both C and C++ compilation calls. Using the CMake generator expression limits the inclusion of this option to just the compiling of C++ files.
1 parent 2e654ef commit 1c93786

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

code-coverage.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ function(target_code_coverage TARGET_NAME)
258258
-fprofile-instr-generate -fcoverage-mapping)
259259
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES
260260
"GNU")
261-
target_compile_options(${TARGET_NAME} ${TARGET_VISIBILITY} -fprofile-arcs
262-
-ftest-coverage -fno-elide-constructors -fno-default-inline)
261+
target_compile_options(
262+
${TARGET_NAME} ${TARGET_VISIBILITY} -fprofile-arcs -ftest-coverage
263+
$<$<COMPILE_LANGUAGE:CXX>:-fno-elide-constructors> -fno-default-inline)
263264
target_link_libraries(${TARGET_NAME} ${TARGET_LINK_VISIBILITY} gcov)
264265
endif()
265266

@@ -501,7 +502,9 @@ function(add_code_coverage)
501502
add_link_options(-fprofile-instr-generate -fcoverage-mapping)
502503
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES
503504
"GNU")
504-
add_compile_options(-fprofile-arcs -ftest-coverage -fno-elide-constructors -fno-default-inline)
505+
add_compile_options(
506+
-fprofile-arcs -ftest-coverage
507+
$<$<COMPILE_LANGUAGE:CXX>:-fno-elide-constructors> -fno-default-inline)
505508
link_libraries(gcov)
506509
endif()
507510
endif()

0 commit comments

Comments
 (0)