Skip to content

Commit

Permalink
HOTFIX 20210312, updates to work with older CMake
Browse files Browse the repository at this point in the history
Certain operations in the recent baseline were dependent on a
recent version of CMake.  In particular object libraries cannot
be used in the intended way in the older versions.  This adds
workarounds for those cases.

Tested against CMake versions 3.5.1, 3.10.2, and 3.16.3.
  • Loading branch information
jphickey committed Mar 12, 2021
1 parent 9bc7bfd commit c889d18
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmake/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,17 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
else()
message("NOTE: Selected ${TBL_SRC} as source for ${TBLWE}")
endif()

add_library(${TGT}_${TBLWE}-obj OBJECT ${TBL_SRC})

# NOTE: On newer CMake versions this should become an OBJECT library which makes this simpler.
# On older versions one may not referece the TARGET_OBJECTS property from the custom command.
# As a workaround this is built into a static library, and then the desired object is extracted
# before passing to elf2cfetbl. It is roundabout but it works.
add_library(${TGT}_${TBLWE}-obj STATIC ${TBL_SRC})
target_link_libraries(${TGT}_${TBLWE}-obj PRIVATE core_api)

get_filename_component(TBLOBJ ${TBL} NAME)
string(APPEND TBLOBJ ${CMAKE_C_OUTPUT_EXTENSION})

# IMPORTANT: This rule assumes that the output filename of elf2cfetbl matches
# the input file name but with a different extension (.o -> .tbl)
# The actual output filename is embedded in the source file (.c), however
Expand All @@ -201,7 +208,8 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
# current content of a dependency (rightfully so).
add_custom_command(
OUTPUT "${TABLE_DESTDIR}/${TBLWE}.tbl"
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl $<TARGET_OBJECTS:${TGT}_${TBLWE}-obj>
COMMAND ${CMAKE_AR} x $<TARGET_FILE:${TGT}_${TBLWE}-obj>
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl "${TBLOBJ}"
DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TGT}_${TBLWE}-obj
WORKING_DIRECTORY ${TABLE_DESTDIR}
)
Expand Down Expand Up @@ -462,7 +470,7 @@ function(cfs_app_check_intf MODULE_NAME)
configure_file(${CFE_SOURCE_DIR}/cmake/check_header.c.in ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
list(APPEND ${MODULE_NAME}_hdrcheck_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
endforeach(HDR ${ARGN})
add_library(${MODULE_NAME}_headercheck OBJECT ${${MODULE_NAME}_hdrcheck_SOURCES})
add_library(${MODULE_NAME}_headercheck STATIC EXCLUDE_FROM_ALL ${${MODULE_NAME}_hdrcheck_SOURCES})

# This causes the check to compile with the same set of defines and include dirs as specified
# in the "INTERFACE" properties of the actual module
Expand Down

0 comments on commit c889d18

Please sign in to comment.