Skip to content

Commit

Permalink
Merge pull request #613 from jphickey/fix-612-ut-coverage-flags
Browse files Browse the repository at this point in the history
Fix #612, Update coverage compile/link flag options
  • Loading branch information
astrogeco authored Apr 15, 2020
2 parents ba709ed + d9b7455 commit 1eb380c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions fsw/cfe-core/unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ foreach(MODULE ${CFE_CORE_MODULES})

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

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

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

# Also add the UT_COVERAGE_LINK_FLAGS to the link command
# This should enable coverage analysis on platforms that support this
target_link_libraries(${UT_TARGET_NAME}_UT
${UT_COVERAGE_LINK_FLAGS}
ut_${CFE_CORE_TARGET}_support
ut_cfe-core_stubs
ut_assert)

# Also add the C FLAGS to the link command
# This should enable coverage analysis on platforms that support this
set_target_properties(${UT_TARGET_NAME}_UT PROPERTIES
LINK_FLAGS "${UT_C_FLAGS}")

add_test(${UT_TARGET_NAME}_UT ${UT_TARGET_NAME}_UT)
install(TARGETS ${UT_TARGET_NAME}_UT DESTINATION ${TGTNAME}/${UT_INSTALL_SUBDIR})
endforeach(MODULE ${CFE_CORE_MODULES})
Expand Down

0 comments on commit 1eb380c

Please sign in to comment.