Skip to content

Commit

Permalink
Add new function tribits_package_is_enabled_or_unset()
Browse files Browse the repository at this point in the history
This helps to make the code more clear.

NOTE: This is tested as part of higher-level code and tests
(e.g. DependencyUnitTests tests).
  • Loading branch information
bartlettroscoe committed Aug 30, 2024
1 parent 7d0e8e8 commit 5d4e5b2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tribits/core/package_arch/TribitsAdjustPackageEnables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,9 @@ macro(tribits_private_disable_required_package_enables
fwdDepPkgName packageName libraryDep
)
tribits_get_package_enable_status(${fwdDepPkgName} "" fwdDepPkgEnableVarName)
if (${fwdDepPkgEnableVarName} OR "${${fwdDepPkgEnableVarName}}" STREQUAL "")
tribits_package_is_enabled_or_unset(${fwdDepPkgEnableVarName}
fwdDepPkgIsEnabledOrUnset)
if (fwdDepPkgIsEnabledOrUnset)
if ("${libraryDep}" STREQUAL "TRUE")
tribits_private_print_disable_required_package_enable(
${packageName} ${fwdDepPkgEnableVarName}
Expand Down
28 changes: 28 additions & 0 deletions tribits/core/package_arch/TribitsGetPackageEnableStatus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,34 @@ function(tribits_get_package_enable_status packageName packageEnableOut
endfunction()


# @FUNCTION: tribits_package_is_enabled_or_unset()
#
# Function that determines if a package's enable variable evaluates to true or
# is unset.
#
# Usage::
#
# tribits_package_is_enabled_or_unset((<packageEnableVarName>
# <packageIsEnabledOrUnsetOut>)
#
# On return, the value of ``<packageIsEnabledOrUnsetOut>`` will set to
# ``TRUE`` if the variable ``<packageEnableVarName>`` evaluates to true and
# or is empty "". Otherwise, ``<packageIsEnabledOrUnsetOut>`` will set
# to ``FALSE`` on return.
#
function(tribits_package_is_enabled_or_unset packageEnableVarName
packageIsEnabledOrUnsetOut
)
if (${packageEnableVarName} OR ("${${packageEnableVarName}}" STREQUAL ""))
set(packageIsEnabledOrUnset TRUE)
else()
set(packageIsEnabledOrUnset FALSE)
endif()
set(${packageIsEnabledOrUnsetOut} ${packageIsEnabledOrUnset}
PARENT_SCOPE)
endfunction()


# @FUNCTION: tribits_package_is_explicitly_disabled()
#
# Function that determines if a package's enable variable is
Expand Down
1 change: 1 addition & 0 deletions tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@MACRO: tribits_package_def() +
@MACRO: tribits_package_define_dependencies() +
@MACRO: tribits_process_enabled_standard_tpl() +
@FUNCTION: tribits_package_is_enabled_or_unset() +
@FUNCTION: tribits_package_is_explicitly_disabled() +
@MACRO: tribits_package_postprocess() +
@MACRO: tribits_process_subpackages() +
Expand Down

0 comments on commit 5d4e5b2

Please sign in to comment.