diff --git a/CMakeLists.txt b/CMakeLists.txt index 95b68ab..f8e30fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,18 @@ project(CFS_LC C) +include(CheckSymbolExists) + +# Check for "isnan" and "isfinite" is present in "math.h" +set(CMAKE_REQUIRED_LIBRARIES m) +check_symbol_exists(isnan "math.h" HAVE_ISNAN CMAKE_REQUIRED_LIBRARIES) +check_symbol_exists(isfinite "math.h" HAVE_ISFINITE CMAKE_REQUIRED_LIBRARIES) + +if (HAVE_ISNAN OR HAVE_ISFINITE) + # Add math library dependency to LC App + message(STATUS "Adding math library dependency to LC App...") + link_libraries(m) +endif() + set(APP_SRC_FILES fsw/src/lc_custom.c fsw/src/lc_app.c diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index 57e0e99..4984ee3 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -7,6 +7,9 @@ # ################################################################## +# Determine if math library is present +find_library(MATH_LIB_FOUND NAMES m) + add_cfe_coverage_stubs("lc_internal" utilities/lc_test_utils.c stubs/lc_app_stubs.c @@ -20,7 +23,11 @@ add_cfe_coverage_stubs("lc_internal" ) # Link with the cfe core stubs and unit test assert libs -target_link_libraries(coverage-lc_internal-stubs ut_core_api_stubs ut_assert) +if (MATH_LIB_FOUND) + target_link_libraries(coverage-lc_internal-stubs ut_core_api_stubs ut_assert m) +else() + target_link_libraries(coverage-lc_internal-stubs ut_core_api_stubs ut_assert) +endif() # Include and expose unit test utilities, fsw/inc, and fsw/src includes target_include_directories(coverage-lc_internal-stubs PUBLIC utilities)