Skip to content

Commit 1eb380c

Browse files
authored
Merge pull request #613 from jphickey/fix-612-ut-coverage-flags
Fix #612, Update coverage compile/link flag options
2 parents ba709ed + d9b7455 commit 1eb380c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

fsw/cfe-core/unit-test/CMakeLists.txt

+6-9
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ foreach(MODULE ${CFE_CORE_MODULES})
4242

4343
# Compile the unit(s) under test as an object library
4444
# this allows easy configuration of special flags and include paths
45-
# in particular this should use the UT_C_FLAGS for coverage instrumentation
45+
# in particular this should use the UT_COVERAGE_COMPILE_FLAGS for coverage instrumentation
4646
add_library(ut_${UT_TARGET_NAME}_object OBJECT
4747
${CFE_MODULE_FILES})
4848

49-
# Apply the UT_C_FLAGS to the units under test
49+
# Apply the UT_COVERAGE_COMPILE_FLAGS to the units under test
5050
# This should enable coverage analysis on platforms that support this
51-
set_target_properties(ut_${UT_TARGET_NAME}_object PROPERTIES
52-
COMPILE_FLAGS "${UT_C_FLAGS}")
51+
target_compile_options(ut_${UT_TARGET_NAME}_object PRIVATE ${UT_COVERAGE_COMPILE_FLAGS})
5352

5453
# For this object target only, the "override" includes should be injected
5554
# into the include path BEFORE any other include path. This is so the
@@ -61,16 +60,14 @@ foreach(MODULE ${CFE_CORE_MODULES})
6160
${MODULE}_UT.c
6261
$<TARGET_OBJECTS:ut_${UT_TARGET_NAME}_object>)
6362

63+
# Also add the UT_COVERAGE_LINK_FLAGS to the link command
64+
# This should enable coverage analysis on platforms that support this
6465
target_link_libraries(${UT_TARGET_NAME}_UT
66+
${UT_COVERAGE_LINK_FLAGS}
6567
ut_${CFE_CORE_TARGET}_support
6668
ut_cfe-core_stubs
6769
ut_assert)
6870

69-
# Also add the C FLAGS to the link command
70-
# This should enable coverage analysis on platforms that support this
71-
set_target_properties(${UT_TARGET_NAME}_UT PROPERTIES
72-
LINK_FLAGS "${UT_C_FLAGS}")
73-
7471
add_test(${UT_TARGET_NAME}_UT ${UT_TARGET_NAME}_UT)
7572
install(TARGETS ${UT_TARGET_NAME}_UT DESTINATION ${TGTNAME}/${UT_INSTALL_SUBDIR})
7673
endforeach(MODULE ${CFE_CORE_MODULES})

0 commit comments

Comments
 (0)