From 30cebb749d2d663c44d2cf87d0d4c47b023da4d4 Mon Sep 17 00:00:00 2001 From: "Molock, Dwaine S 550328410" Date: Thu, 4 Jun 2026 17:30:45 -0400 Subject: [PATCH 1/4] Fix #133, Add math library dependency to LC --- CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95b68ab..1a59726 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,29 @@ project(CFS_LC C) +include(CheckSourceCompiles) + +# Determine if math library required for "isnan" and "isfinite" +check_source_compiles( + C + "#include + #include + int main() + { + float FloatValue = 1.1f; + if (isnan(FloatValue) || !isfinite(FloatValue)) + return 1; + else + return 0; + }" + HAS_MATH_LIB +) + +# Add math library dependency if test code failed to compile and link +if (NOT HAS_MATH_LIB) + 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 From 9cd160a5c86e4571232423aac8d10ff3808a0483 Mon Sep 17 00:00:00 2001 From: "Molock, Dwaine S 550328410" Date: Fri, 5 Jun 2026 17:04:23 -0400 Subject: [PATCH 2/4] Fix #133, Add math library dependency to LC unit tests for QNX --- CMakeLists.txt | 24 ------------------------ unit-test/CMakeLists.txt | 6 +++++- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a59726..95b68ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,29 +1,5 @@ project(CFS_LC C) -include(CheckSourceCompiles) - -# Determine if math library required for "isnan" and "isfinite" -check_source_compiles( - C - "#include - #include - int main() - { - float FloatValue = 1.1f; - if (isnan(FloatValue) || !isfinite(FloatValue)) - return 1; - else - return 0; - }" - HAS_MATH_LIB -) - -# Add math library dependency if test code failed to compile and link -if (NOT HAS_MATH_LIB) - 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..3559d04 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -20,7 +20,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 (QNX_SDP_VERSION) + 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) From 837f976db8ea56a842442925722ebf3550b911aa Mon Sep 17 00:00:00 2001 From: "Molock, Dwaine S 550328410" Date: Fri, 5 Jun 2026 20:19:53 -0400 Subject: [PATCH 3/4] Fix #133, Add math library dependency to LC App and unit tests --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 From 39fa85a1ae4681e648da154d3a210b250a335866 Mon Sep 17 00:00:00 2001 From: "Molock, Dwaine S 550328410" Date: Tue, 9 Jun 2026 14:39:02 -0400 Subject: [PATCH 4/4] Fix #133, Add math library dependency to LC App and unit tests --- unit-test/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index 3559d04..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,7 @@ add_cfe_coverage_stubs("lc_internal" ) # Link with the cfe core stubs and unit test assert libs -if (QNX_SDP_VERSION) +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)