Skip to content

Commit

Permalink
Fix nasa#2311, correct fallback file case
Browse files Browse the repository at this point in the history
Only include the "FALLBACK_FILE" if the normal search came up empty.
Do not return a list containing the fallback/default along with the
user-supplied files, only return the user-supplied files.  This was an
issue when using "ALLOW_LIST" in that it had both.
  • Loading branch information
jphickey committed Apr 27, 2023
1 parent c9b10f3 commit eb6f2d3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cmake/global_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ function(cfe_locate_implementation_file OUTPUT_VAR FILE_NAME)

# Build the list of possible locations for this file in REVERSE priority order
set(IMPL_SEARCH_PATH)
if (LOCATEIMPL_ARG_FALLBACK_FILE)
if (IS_ABSOLUTE "${LOCATEIMPL_ARG_FALLBACK_FILE}")
list(APPEND IMPL_SEARCH_PATH "${LOCATEIMPL_ARG_FALLBACK_FILE}")
else()
list(APPEND IMPL_SEARCH_PATH "${CMAKE_CURRENT_LIST_DIR}/${LOCATEIMPL_ARG_FALLBACK_FILE}")
endif()
endif()

# Check for the existence of the file in each of the dirs
foreach(BASEDIR ${IMPL_SEARCH_BASEDIRS})
list(APPEND IMPL_SEARCH_PATH "${BASEDIR}${FILE_NAME}")
Expand All @@ -74,6 +66,14 @@ function(cfe_locate_implementation_file OUTPUT_VAR FILE_NAME)
endif()
endforeach()

if (NOT SELECTED_FILE AND LOCATEIMPL_ARG_FALLBACK_FILE)
if (IS_ABSOLUTE "${LOCATEIMPL_ARG_FALLBACK_FILE}")
set(SELECTED_FILE "${LOCATEIMPL_ARG_FALLBACK_FILE}")
else()
set(SELECTED_FILE "${CMAKE_CURRENT_LIST_DIR}/${LOCATEIMPL_ARG_FALLBACK_FILE}")
endif()
endif()

if (SELECTED_FILE)
message(STATUS "Using file: ${SELECTED_FILE} for ${FILE_NAME}")
elseif(NOT LOCATEIMPL_ARG_OPTIONAL)
Expand Down

0 comments on commit eb6f2d3

Please sign in to comment.