Skip to content

Commit

Permalink
Only assert defined vars conditionally
Browse files Browse the repository at this point in the history
Use the value of ${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES to decide
whether or not to throw errors if cross-package enable variables are
undefined. This fixes potential breakages in reduced tarball testing.

User Support Ticket(s) or Story Referenced: TRILFRAME_596
  • Loading branch information
sebrowne authored and bartlettroscoe committed Jan 26, 2024
1 parent 9328b34 commit 9874c37
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tribits/core/package_arch/TribitsPackageMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,19 @@ macro(tribits_disable_optional_dependency upstreamPackageName reasonStr)
" Instead, please call this from the package's base CMakeLists.txt file"
" '${${PACKAGE_NAME}_SOURCE_DIR}/CMakeLists.txt'" )
endif()
# Get the variable names that are going to be set assert they exist already
# Get the variable names that are going to be set
set(packageEnableVarName ${PACKAGE_NAME}_ENABLE_${upstreamPackageName})
assert_defined(${packageEnableVarName})
string(TOUPPER ${upstreamPackageName} upstreamPackageName_UC)
set(havePackageUpstreamPackageMacroVarName
HAVE_${PACKAGE_NAME_UC}_${upstreamPackageName_UC})
assert_defined(${havePackageUpstreamPackageMacroVarName})
# Assert that the vars already exist (to make sure the package and dependency exist)
if (${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES IN_LIST
${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES_ERROR_VALUES_LIST
)
# We only assert if all packages have to exist, which is not true in a reduced source tree
assert_defined(${packageEnableVarName})
assert_defined(${havePackageUpstreamPackageMacroVarName})
endif()
# Set the variables to OFF in local and project-level scopes
if (NOT "${reasonStr}" STREQUAL "")
message("-- ${reasonStr}")
Expand Down

0 comments on commit 9874c37

Please sign in to comment.