Skip to content

Statically linked apps interface directories are not linked #170

@mafoste3

Description

@mafoste3

Describe the bug
The Cmake build system does not include directories from statically linked apps therefore will fail the build at the table build step.

To Reproduce
Steps to reproduce the behavior:

  1. Modify targets.cmake to statically build and link the ci_lab app
  2. Build cFS native BSP
  3. See error
[  7%] Generating /home/cfs/build/tables/cpu1_to_lab.tbla0d6f7c6e66ad78aa3a1e5e8276d687c207b1f98.to_lab_sub.d
[  7%] Built target generate_table_cpu1_to_lab_to_lab_sub
[  7%] Building C object apps/sch_lab/CMakeFiles/tblobj_cpu1_sch_lab.tbld63915454be8d975ed82076090c29749730f0d8a.dir/fsw/tables/sch_lab_table.c.o
/home/cfs/apps/sch_lab/fsw/tables/sch_lab_table.c:59:10: fatal error: ci_lab_msgids.h: No such file or directory
   59 | #include "ci_lab_msgids.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.

Expected behavior
Expected behavior is for the build system to properly target the correct include directories whether an app is built dynamically or statically.

Code snips
Root cause is that the list TGTSYS_${SYSVAR}_APPS only caches dynamically linked apps. A quick workaround is to use the MISSION_APPS list which includes all cFS components.
FROM:

sch_lab/CMakeLists.txt

Lines 8 to 15 in 82645f5

foreach(EXT_APP ci_lab to_lab sample_app sc hs lc ds fm)
list (FIND TGTSYS_${SYSVAR}_APPS ${EXT_APP} HAVE_APP)
if (HAVE_APP GREATER_EQUAL 0)
include_directories($<TARGET_PROPERTY:${EXT_APP},INTERFACE_INCLUDE_DIRECTORIES>)
string(TOUPPER "HAVE_${EXT_APP}" APP_MACRO)
add_definitions(-D${APP_MACRO})
endif()
endforeach()

TO:

foreach(EXT_APP ci_lab sample_app hs fm ds sc lc)
  list (FIND MISSION_APPS ${EXT_APP} HAVE_APP)
  if (HAVE_APP GREATER_EQUAL 0)
    include_directories($<TARGET_PROPERTY:${EXT_APP},INTERFACE_INCLUDE_DIRECTORIES>)
    string(TOUPPER "HAVE_${EXT_APP}" APP_MACRO)
    add_definitions(-D${APP_MACRO})
  endif()
endforeach()

Additional context
This issue is hidden if the #ifdef HAVE_app_APP macros are used around other app include files and macro definitions. The build will not fail, however the statically linked app(s) will not be scheduled.

This issue is also found in the to_lab app: Statically linked apps interface directories are not linked #212

System observed on:

Reporter Info
Mark Foster
NASA / Johnson Space Center / ER6

Metadata

Metadata

Assignees

No one assigned

    Labels

    CCB:ReadyPull request is ready for discussion at the Configuration Control Board (CCB)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions