diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index e51547e1c..a78ec5639 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -169,7 +169,7 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) # no automatic way to do this (at least in the older cmakes) # Create the intermediate table objects using the target compiler, - # then use "elf2cfetbl" to convert to a .tbl file + # then use "elf2cfetbl" or TABLETOOL_EXE to convert to a .tbl file foreach(TBL ${TBL_SRC_FILES} ${ARGN}) # Get name without extension (NAME_WE) and append to list of tables @@ -181,6 +181,13 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) set(TABLE_BINARY "${TABLE_DESTDIR}/${TBLWE}.tbl") file(MAKE_DIRECTORY ${TABLE_DESTDIR}) + # Get TBLTOOL executable location from cmake cache variable if available -> into local var + if (TABLETOOL_EXE) + set(TABLE_TOOL_EXECUTABLE ${TABLETOOL_EXE}) + else() # else to default -> into local var + set(TABLE_TOOL_EXECUTABLE ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl) + endif() + # Check if an override exists at the mission level (recommended practice) # This allows a mission to implement a customized table without modifying # the original - this also makes for easier merging/updating if needed. @@ -226,10 +233,10 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) OUTPUT ${TABLE_BINARY} COMMAND ${CMAKE_COMMAND} -DCMAKE_AR=${CMAKE_AR} - -DTBLTOOL=${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl + -DTBLTOOL=${TABLE_TOOL_EXECUTABLE} -DLIB=$ -P ${CFE_SOURCE_DIR}/cmake/generate_table.cmake - DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TABLE_LIBNAME} + DEPENDS ${TABLE_TOOL_EXECUTABLE} ${TABLE_LIBNAME} WORKING_DIRECTORY ${TABLE_DESTDIR} ) diff --git a/cmake/generate_table.cmake b/cmake/generate_table.cmake index b817ce6da..2c97a789d 100644 --- a/cmake/generate_table.cmake +++ b/cmake/generate_table.cmake @@ -11,7 +11,7 @@ # # Required passed in values: # CMAKE_AR => path to "ar" utility for working with static lib files -# TBLTOOL => path to "elf2cfetbl" utility +# TBLTOOL => path to "elf2cfetbl" utility or equivalent utility # LIB => name of library file to convert # # This assumes/requires that the static library has a single object in it. @@ -37,7 +37,7 @@ if (NOT RESULT EQUAL 0) message(FATAL_ERROR "Failure running ${CMAKE_AR} x ${LIB} ${OBJNAME}") endif() -# Finally invoke the table tool (elf2cfetbl) on the object +# Finally invoke the table tool (elf2cfetbl or other tool executable) on the object message("Executing Process: ${TBLTOOL} ${OBJNAME}") execute_process(COMMAND ${TBLTOOL} "${OBJNAME}" RESULT_VARIABLE RESULT diff --git a/cmake/mission_build.cmake b/cmake/mission_build.cmake index 11095431c..2ead323f3 100644 --- a/cmake/mission_build.cmake +++ b/cmake/mission_build.cmake @@ -70,6 +70,11 @@ function(initialize_globals) # Export values to parent level set(MISSION_DEFS ${MISSION_SOURCE_DIR}/${MISSIONCONFIG}_defs CACHE PATH "Full path to mission definitions directory") + # ... -DTABLETOOL_EXECUTABLE=/path/to/my/custom/tabletool + if (${TABLETOOL_EXECUTABLE} AND (${TABLETOOL_EXE} NOT DEFINED)) + set(TABLETOOL_EXE ${TABLETOOL_EXECUTABLE} CACHE FILEPATH "Set executable used instead of default elf2cfetbl.") + endif() + endfunction(initialize_globals) ################################################################## @@ -386,9 +391,13 @@ function(prepare) ) add_subdirectory(${MISSION_SOURCE_DIR}/tools tools) - # Add a dependency on the table generator tool as this is required for table builds - # The "elf2cfetbl" target should have been added by the "tools" above - add_dependencies(mission-prebuild elf2cfetbl) + # If no alternative table tool executable was set by cmake cache variable before, + # ...add default tool as dependency + if (NOT DEFINED ${TABLETOOL_EXE}) + # Add a dependency on the table generator tool as this is required for table builds + # The "elf2cfetbl" target should have been added by the "tools" above + add_dependencies(mission-prebuild elf2cfetbl) + endif() # Build version information should be generated as part of the pre-build process add_dependencies(mission-prebuild mission-version)