From 7a31afdc1aeb0a0d4a56440a89825aaa55c3dbb5 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 17 Apr 2023 13:48:30 -0400 Subject: [PATCH] Fix #2296, add option to link to generated files Update the "generate_config_includefile" to be aware of generated files. This should not call cfe_locate_implementation_file() in this context because the file may not exist at the time. For this type of use case it should just directly link the file without any checking. --- cmake/global_functions.cmake | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/cmake/global_functions.cmake b/cmake/global_functions.cmake index 9a50fd94d..ba68c447e 100644 --- a/cmake/global_functions.cmake +++ b/cmake/global_functions.cmake @@ -151,7 +151,7 @@ endfunction(generate_c_headerfile) # function(generate_config_includefile) - cmake_parse_arguments(GENCONFIG_ARG "" "OUTPUT_DIRECTORY;FILE_NAME;FALLBACK_FILE;MATCH_SUFFIX" "PREFIXES" ${ARGN} ) + cmake_parse_arguments(GENCONFIG_ARG "" "OUTPUT_DIRECTORY;FILE_NAME;FALLBACK_FILE;MATCH_SUFFIX" "PREFIXES;GENERATED_FILE" ${ARGN} ) if (NOT GENCONFIG_ARG_OUTPUT_DIRECTORY) set(GENCONFIG_ARG_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc") endif (NOT GENCONFIG_ARG_OUTPUT_DIRECTORY) @@ -168,13 +168,20 @@ function(generate_config_includefile) set(TGTFILE ${GENCONFIG_ARG_FILE_NAME}) endif() - # Use the common search function to find the candidate(s) - cfe_locate_implementation_file(SRC_LOCAL_PATH_LIST "${TGTFILE}" - ALLOW_LIST - FALLBACK_FILE "${GENCONFIG_ARG_FALLBACK_FILE}" - PREFIX ${GENCONFIG_ARG_PREFIXES} ${ARCH_PREFIXES} - SUBDIR config - ) + if (GENCONFIG_ARG_GENERATED_FILE) + # A generated file may not yet exist at the time this runs, so just use + # what the caller said, no searching. + set(SRC_LOCAL_PATH_LIST ${GENCONFIG_ARG_GENERATED_FILE}) + message(STATUS "Using file: [generated] ${SRC_LOCAL_PATH_LIST} for ${TGTFILE}") + else() + # Use the common search function to find the candidate(s) + cfe_locate_implementation_file(SRC_LOCAL_PATH_LIST "${TGTFILE}" + ALLOW_LIST + FALLBACK_FILE "${GENCONFIG_ARG_FALLBACK_FILE}" + PREFIX ${GENCONFIG_ARG_PREFIXES} ${ARCH_PREFIXES} + SUBDIR config + ) + endif() set(WRAPPER_FILE_CONTENT) foreach(SELECTED_FILE ${SRC_LOCAL_PATH_LIST})