From b16a4c0dc65ebd824e0a0bc7084f30dcb6aa3381 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 2 May 2023 10:19:16 -0400 Subject: [PATCH] Fix #2315, uniqueness of tbl target names If the passed-in table name does not use a qualifier suffix, then generate one by computing a hash of the context information. This ensures that the generated intermediate target names will be unique. --- cmake/arch_build.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index d1fe5a5dc..a47d43490 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -194,6 +194,19 @@ function(add_cfe_tables TABLE_FQNAME TBL_DEFAULT_SRC_FILES) get_filename_component(APP_NAME ${TABLE_FQNAME} NAME_WE) + # The passed-in name allows for a qualifier (in the form of APP_NAME.QUALIFIER) to get + # uniqueness in the generated target names. If there is no qualifier, then there + # will potentially be a target name conflict. To avoid this, generate a hash of the + # context of this call - the current directory, app/tgt names, and source files. This + # should be unique but also produce the same hash when CMake is re-run. The hash + # can then be used as a qualifier. + if (TABLE_FQNAME STREQUAL APP_NAME) + string(SHA1 CONTEXT_HASH + "${CMAKE_CURRENT_LIST_DIR}+${TGTNAME}+${APP_NAME}+${TBL_DEFAULT_SRC_FILES};${ARGN}" + ) + set(TABLE_FQNAME "${APP_NAME}.t${CONTEXT_HASH}") + endif() + # If "TGTNAME" is set, then use it directly set(TABLE_TGTLIST ${TGTNAME}) set(TABLE_TEMPLATE "${CFE_SOURCE_DIR}/cmake/tables/table_rule_template.d.in")