| 1 |
# @HEADER |
| 2 |
# ***************************************************************************** |
| 3 |
# TriBITS: Tribal Build, Integrate, and Test System |
| 4 |
# |
| 5 |
# Copyright 2013-2016 NTESS and the TriBITS contributors. |
| 6 |
# SPDX-License-Identifier: BSD-3-Clause |
| 7 |
# ***************************************************************************** |
| 8 |
# @HEADER |
| 9 |
|
| 10 |
|
| 11 |
include(TribitsProcessPackagesAndDirsLists) |
| 12 |
include(TribitsAddOptionAndDefine) |
| 13 |
include(TribitsGeneralMacros) |
| 14 |
include(TribitsPrintEnabledPackagesLists) |
| 15 |
include(TribitsPrintDependencyInfo) |
| 16 |
include(TribitsPackageDependencies) |
| 17 |
include(TribitsGetPackageEnableStatus) |
| 18 |
|
| 19 |
include(AdvancedOption) |
| 20 |
include(AdvancedSet) |
| 21 |
include(AppendStringVar) |
| 22 |
include(CMakeBuildTypesList) |
| 23 |
include(FindListElement) |
| 24 |
include(GlobalNullSet) |
| 25 |
include(PrintNonemptyVar) |
| 26 |
include(PrintVarWithSpaces) |
| 27 |
include(PrintNonemptyVarWithSpaces) |
| 28 |
include(PrintVar) |
| 29 |
include(RemoveGlobalDuplicates) |
| 30 |
include(SetDefault) |
| 31 |
include(MessageWrapper) |
| 32 |
include(DualScopeSet) |
| 33 |
include(CMakeParseArguments) |
| 34 |
include(TribitsCreateReverseList) |
| 35 |
|
| 36 |
|
| 37 |
# NOTE: A nice way to view and navigate the contents of this file is to use |
| 38 |
# the emacs 'occur' string: |
| 39 |
# |
| 40 |
# "\(^##########\|^# .*-level\|^function\|^macro\)" |
| 41 |
|
| 42 |
|
| 43 |
# @MACRO: tribits_adjust_package_enables() |
| 44 |
# |
| 45 |
# Usage: |
| 46 |
# |
| 47 |
# tribits_adjust_package_enables() |
| 48 |
# |
| 49 |
# Macro that adjusts all of the package enables from what the user input to |
| 50 |
# the final set that will be used to enable packages. |
| 51 |
# |
| 52 |
macro(tribits_adjust_package_enables) |
| 53 |
tribits_unenable_enabled_packages() |
| 54 |
tribits_sweep_forward_apply_disables() |
| 55 |
tribits_sweep_forward_apply_enables() |
| 56 |
tribits_disable_and_enable_tests_and_examples() |
| 57 |
tribits_sweep_backward_enable_upstream_packages() |
| 58 |
tribits_set_cache_vars_for_current_enabled_packages() |
| 59 |
tribits_do_final_parent_packages_enables_for_subpackage_enables() |
| 60 |
tribits_adjust_internal_external_packages() |
| 61 |
tribits_setup_enabled_lists_and_pkg_idxs() |
| 62 |
tribits_setup_direct_packages_dependencies_lists_and_lib_required_enable_vars() |
| 63 |
tribits_print_direct_packages_dependencies_lists() |
| 64 |
endmacro() |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
################################################################################ |
| 69 |
# |
| 70 |
# First-level macros called directly from ``tribits_adjust_package_enables()`` |
| 71 |
# |
| 72 |
# NOTE: In the below macros, local variables are prefixed by 'tap1_' in all of |
| 73 |
# the macros() which will not clash because they are at the same level in the |
| 74 |
# call stack (and are initialized in each macro). |
| 75 |
# |
| 76 |
################################################################################ |
| 77 |
|
| 78 |
|
| 79 |
# @MACRO: tribits_unenable_enabled_packages() |
| 80 |
# |
| 81 |
# Macro to enable all unenabled packages if asked. |
| 82 |
# |
| 83 |
# See implementation for details. |
| 84 |
# |
| 85 |
macro(tribits_unenable_enabled_packages) |
| 86 |
if (${PROJECT_NAME}_UNENABLE_ENABLED_PACKAGES) |
| 87 |
message("\nSetting to empty '' all enabled packages because" |
| 88 |
" ${PROJECT_NAME}_UNENABLE_ENABLED_PACKAGES=" |
| 89 |
"'${${PROJECT_NAME}_UNENABLE_ENABLED_PACKAGES}'\n") |
| 90 |
foreach(tap1_tribitsPkg IN LISTS ${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES) |
| 91 |
if (${PROJECT_NAME}_ENABLE_${tap1_tribitsPkg}) |
| 92 |
message("-- " "Setting ${PROJECT_NAME}_ENABLE_${tap1_tribitsPkg}=''") |
| 93 |
set_cache_on_off_empty(${PROJECT_NAME}_ENABLE_${tap1_tribitsPkg} "" |
| 94 |
"Forced to empty '' by ${PROJECT_NAME}_UNENABLE_ENABLED_PACKAGES=ON" FORCE) |
| 95 |
endif() |
| 96 |
# NOTE: Above, we don't want to set to empty those packages that have hard |
| 97 |
# disables because this will mess up the logic in later invocations. |
| 98 |
endforeach() |
| 99 |
advanced_set(${PROJECT_NAME}_UNENABLE_ENABLED_PACKAGES OFF CACHE BOOL |
| 100 |
"Forced to FALSE after use" FORCE) |
| 101 |
endif() |
| 102 |
endmacro() |
| 103 |
|
| 104 |
|
| 105 |
# @MACRO: tribits_sweep_forward_apply_disables() |
| 106 |
# |
| 107 |
# Sweep forward and apply all disables in order first. |
| 108 |
# |
| 109 |
# See implementation for details. |
| 110 |
# |
| 111 |
macro(tribits_sweep_forward_apply_disables) |
| 112 |
|
| 113 |
message("\nDisabling all packages that have a required dependency" |
| 114 |
" on disabled TPLs and optional package TPL support based on TPL_ENABLE_<TPL>=OFF ...\n") |
| 115 |
|
| 116 |
message("\nDisabling subpackages for hard disables of parent packages" |
| 117 |
" due to ${PROJECT_NAME}_ENABLE_<PARENT_PACKAGE>=OFF ...\n") |
| 118 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES) |
| 119 |
tribits_disable_parents_subpackages(${tad1_tribitsPkg}) |
| 120 |
endforeach() |
| 121 |
|
| 122 |
message("\nDisabling forward required packages and optional intra-package" |
| 123 |
" support that have a dependency on disabled packages" |
| 124 |
" ${PROJECT_NAME}_ENABLE_<TRIBITS_PACKAGE>=OFF (or" |
| 125 |
" TPL_ENABLE_<TRIBITS_EXTERNAL_PACKAGE>=OFF) ...\n") |
| 126 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_DEFINED_PACKAGES) |
| 127 |
tribits_disable_forward_required_dep_packages(${tad1_tribitsPkg}) |
| 128 |
endforeach() |
| 129 |
|
| 130 |
endmacro() |
| 131 |
|
| 132 |
|
| 133 |
# @MACRO: tribits_sweep_forward_apply_enables() |
| 134 |
# |
| 135 |
# Updates the following variables in the local scope: |
| 136 |
# |
| 137 |
# * ``${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES`` |
| 138 |
# * `${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES`_ |
| 139 |
# |
| 140 |
# See implementation for details. |
| 141 |
# |
| 142 |
macro(tribits_sweep_forward_apply_enables) |
| 143 |
|
| 144 |
tribits_get_sublist_nondisabled( ${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES |
| 145 |
${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES "") |
| 146 |
tribits_create_reverse_list(${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES |
| 147 |
${PROJECT_NAME}_REVERSE_NOTDISABLED_INTERNAL_PACKAGES) |
| 148 |
|
| 149 |
message("\nEnabling subpackages for hard enables of parent packages" |
| 150 |
" due to ${PROJECT_NAME}_ENABLE_<PARENT_PACKAGE>=ON ...\n") |
| 151 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES) |
| 152 |
tribits_enable_parents_subpackages(${tad1_tribitsPkg}) |
| 153 |
endforeach() |
| 154 |
|
| 155 |
if (${PROJECT_NAME}_ENABLE_ALL_PACKAGES) |
| 156 |
message("\nEnabling all packages that are not currently disabled because of" |
| 157 |
" ${PROJECT_NAME}_ENABLE_ALL_PACKAGES=ON" |
| 158 |
" (${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE=" |
| 159 |
"${${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE}) ...\n") |
| 160 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES) |
| 161 |
tribits_apply_all_package_enables(${tad1_tribitsPkg}) |
| 162 |
endforeach() |
| 163 |
endif() |
| 164 |
|
| 165 |
if (${PROJECT_NAME}_ENABLE_ALL_FORWARD_DEP_PACKAGES) |
| 166 |
message("\nSweep forward enabling all forward library dependent packages because" |
| 167 |
" ${PROJECT_NAME}_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON ...\n") |
| 168 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES) |
| 169 |
tribits_enable_forward_lib_package_enables(${tad1_tribitsPkg}) |
| 170 |
endforeach() |
| 171 |
|
| 172 |
tribits_get_sublist_enabled( ${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES |
| 173 |
${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES "") |
| 174 |
tribits_create_reverse_list(${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES |
| 175 |
${PROJECT_NAME}_REVERSE_ENABLED_INTERNAL_PACKAGES) |
| 176 |
|
| 177 |
message("\nSweep backward enabling all forward test dependent packages because" |
| 178 |
" ${PROJECT_NAME}_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON ...\n") |
| 179 |
foreach(tad1_tribitsPkg IN LISTS |
| 180 |
${PROJECT_NAME}_REVERSE_ENABLED_INTERNAL_PACKAGES |
| 181 |
) |
| 182 |
tribits_enable_forward_test_package_enables(${tad1_tribitsPkg}) |
| 183 |
endforeach() |
| 184 |
# NOTE: Above, we want to sweep backward to enable test-dependent packages |
| 185 |
# because we don't want to enable package Z just because package Y was enabled |
| 186 |
# because it had a test-only dependency on package X. Sweeping backwards through |
| 187 |
# the packages makes sure this does not happen. |
| 188 |
set(${PROJECT_NAME}_ENABLE_ALL_OPTIONAL_PACKAGES ON) |
| 189 |
endif() |
| 190 |
|
| 191 |
tribits_get_sublist_enabled( ${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES |
| 192 |
${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES "") |
| 193 |
|
| 194 |
endmacro() |
| 195 |
# NOTE: Above, we are sweeping over *all* of the not-disabled packages listed |
| 196 |
# in ${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES, including those package that |
| 197 |
# might have <Package>_PACKAGE_BUILD_STATUS=EXTERNAL. That makes sense |
| 198 |
# because these are TriBITS (or TriBITS-compliant) packages so we should |
| 199 |
# assume that all of their downstream packages, whether internal or external, |
| 200 |
# should be enabled as well. If we find this is not the desirable behavior, |
| 201 |
# then we can change this later. |
| 202 |
|
| 203 |
|
| 204 |
# @MACRO: tribits_disable_and_enable_tests_and_examples() |
| 205 |
# |
| 206 |
# Adjust test and example enables based on different criteria. |
| 207 |
# |
| 208 |
# See implementation for details. |
| 209 |
# |
| 210 |
macro(tribits_disable_and_enable_tests_and_examples) |
| 211 |
|
| 212 |
message("\nDisabling subpackage tests/examples based on parent package" |
| 213 |
" tests/examples disables ...\n") |
| 214 |
foreach(tad1_tribitsPkg IN LISTS |
| 215 |
${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES |
| 216 |
) |
| 217 |
tribits_apply_package_examples_disable(${tad1_tribitsPkg} TESTS) |
| 218 |
tribits_apply_subpackage_tests_or_examples_disables(${tad1_tribitsPkg} TESTS) |
| 219 |
tribits_apply_subpackage_tests_or_examples_disables(${tad1_tribitsPkg} EXAMPLES) |
| 220 |
endforeach() |
| 221 |
|
| 222 |
if (${PROJECT_NAME}_ENABLE_TESTS OR ${PROJECT_NAME}_ENABLE_EXAMPLES) |
| 223 |
message("\nEnabling all tests and/or examples that have not been" |
| 224 |
" explicitly disabled because ${PROJECT_NAME}_ENABLE_[TESTS,EXAMPLES]=ON ...\n") |
| 225 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES) |
| 226 |
tribits_apply_test_example_enables(${tad1_tribitsPkg}) |
| 227 |
endforeach() |
| 228 |
endif() |
| 229 |
# NOTE: Above, we enable tests and examples here, before the remaining required |
| 230 |
# packages so that we don't enable tests that don't need to be enabled based |
| 231 |
# on the use of the option ${PROJECT_NAME}_ENABLE_ALL_FORWARD_DEP_PACKAGES. |
| 232 |
|
| 233 |
message("\nEnabling subpackage tests/examples based on parent package tests/examples enables ...\n") |
| 234 |
foreach(tad1_tribitsPkg IN LISTS |
| 235 |
${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES |
| 236 |
) |
| 237 |
tribits_apply_subpackage_tests_examples_enables(${tad1_tribitsPkg}) |
| 238 |
endforeach() |
| 239 |
# NOTE: We want to apply this logic here instead of later after the backward |
| 240 |
# sweep of package enables because we don't want to enable the |
| 241 |
# tests/examples for a subpackage if it is not needed based on set of |
| 242 |
# requested subpackages and packages to be enabled and the optional forward |
| 243 |
# sweep of downstream packages. |
| 244 |
|
| 245 |
endmacro() |
| 246 |
|
| 247 |
|
| 248 |
# @MACRO: tribits_sweep_backward_enable_upstream_packages() |
| 249 |
# |
| 250 |
# Sweep backwards and enable required (and optional) upstream packages. |
| 251 |
# |
| 252 |
# This sets the final value for: |
| 253 |
# |
| 254 |
# * `${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES`_ |
| 255 |
# |
| 256 |
# See implementation for details. |
| 257 |
# |
| 258 |
macro(tribits_sweep_backward_enable_upstream_packages) |
| 259 |
|
| 260 |
set(tap1_extraMsgStr "") |
| 261 |
if (${PROJECT_NAME}_ENABLE_ALL_OPTIONAL_PACKAGES) |
| 262 |
set(tap1_extraMsgStr |
| 263 |
" (and optional since ${PROJECT_NAME}_ENABLE_ALL_OPTIONAL_PACKAGES=ON)") |
| 264 |
endif() |
| 265 |
|
| 266 |
tribits_get_sublist_nondisabled( ${PROJECT_NAME}_DEFINED_PACKAGES |
| 267 |
${PROJECT_NAME}_NOTDISABLED_PACKAGES "") |
| 268 |
tribits_create_reverse_list(${PROJECT_NAME}_NOTDISABLED_PACKAGES |
| 269 |
${PROJECT_NAME}_REVERSE_NOTDISABLED_PACKAGES) |
| 270 |
|
| 271 |
message("\nEnabling all required${tap1_extraMsgStr} upstream packages for current" |
| 272 |
" set of enabled packages (${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE=" |
| 273 |
"${${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE}) ...\n") |
| 274 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_REVERSE_NOTDISABLED_PACKAGES) |
| 275 |
tribits_enable_upstream_packages(${tad1_tribitsPkg}) |
| 276 |
endforeach() |
| 277 |
# NOTE: Above, we have to loop through the packages backward to enable all |
| 278 |
# the packages that this package depends on. This has to include *all* |
| 279 |
# upstream package enables including required packages, and optional |
| 280 |
# packages (when ${PROJECT_NAME}_ENABLE_ALL_OPTIONAL_PACKAGES). |
| 281 |
|
| 282 |
tribits_get_sublist_enabled( ${PROJECT_NAME}_NOTDISABLED_INTERNAL_PACKAGES |
| 283 |
${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES "") |
| 284 |
|
| 285 |
message("\nEnabling all optional intra-package enables" |
| 286 |
" <TRIBITS_PACKAGE>_ENABLE_<DEPPACKAGE> that are not currently disabled" |
| 287 |
" if both sets of packages are enabled ...\n") |
| 288 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES) |
| 289 |
tribits_postprocess_optional_package_enables(${tad1_tribitsPkg}) |
| 290 |
endforeach() |
| 291 |
|
| 292 |
endmacro() |
| 293 |
|
| 294 |
|
| 295 |
# @MACRO: tribits_set_cache_vars_for_current_enabled_packages() |
| 296 |
# |
| 297 |
macro(tribits_set_cache_vars_for_current_enabled_packages) |
| 298 |
message("\nSet cache entries for optional packages/TPLs and tests/examples for packages actually enabled ...\n") |
| 299 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES) |
| 300 |
tribits_setup_optional_package_enables_and_cache_vars(${tad1_tribitsPkg}) |
| 301 |
endforeach() |
| 302 |
endmacro() |
| 303 |
|
| 304 |
|
| 305 |
# @MACRO: tribits_do_final_parent_packages_enables_for_subpackage_enables() |
| 306 |
# |
| 307 |
macro(tribits_do_final_parent_packages_enables_for_subpackage_enables) |
| 308 |
|
| 309 |
message("\nEnabling the shell of non-enabled parent packages (mostly for show)" |
| 310 |
" that have at least one subpackage enabled ...\n") |
| 311 |
foreach(tad1_tribitsPkg IN LISTS |
| 312 |
${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES |
| 313 |
) |
| 314 |
tribits_enable_parent_package_for_subpackage_enables(${tad1_tribitsPkg}) |
| 315 |
endforeach() |
| 316 |
# NOTE: The above ensures that loops involving the parent package will |
| 317 |
# process the parent package. But this has to be done after all of the |
| 318 |
# other enable/disable logic to ensure no downstream dependencies will be |
| 319 |
# enabled based on this. |
| 320 |
|
| 321 |
endmacro() |
| 322 |
|
| 323 |
|
| 324 |
# @MACRO: tribits_adjust_internal_external_packages() |
| 325 |
# |
| 326 |
# Macro to adjust the set of internal and external packages by changing |
| 327 |
# `<Package>_PACKAGE_BUILD_STATUS`. |
| 328 |
# |
| 329 |
# This macro sweeps backwards over the dependency graph setting. |
| 330 |
# |
| 331 |
# NOTE: This is called **after** all of the logic that determines what |
| 332 |
# packages are enabled or disabled. This is because we don't want to change |
| 333 |
# the enable/disable logic when one or more initially internal packages are |
| 334 |
# made external. We are going to just assume that if an initially internal |
| 335 |
# package that is declared external should be disabled, then the user will |
| 336 |
# need to make that decision explicitly. |
| 337 |
# |
| 338 |
macro(tribits_adjust_internal_external_packages) |
| 339 |
tribits_create_reverse_list(${PROJECT_NAME}_DEFINED_PACKAGES |
| 340 |
${PROJECT_NAME}_REVERSE_DEFINED_PACKAGES) |
| 341 |
message("\nAdjust the set of internal and external packages:\n") |
| 342 |
foreach(packageName IN LISTS ${PROJECT_NAME}_REVERSE_DEFINED_PACKAGES) |
| 343 |
tribits_set_package_and_related_upstream_packages_to_external(${packageName}) |
| 344 |
endforeach() |
| 345 |
endmacro() |
| 346 |
|
| 347 |
|
| 348 |
# Macro that sets up the basic lists of enabled packages and packages. |
| 349 |
# |
| 350 |
macro(tribits_setup_enabled_lists_and_pkg_idxs) |
| 351 |
|
| 352 |
# ${PROJECT_NAME}_ENABLED_PACKAGES |
| 353 |
tribits_get_sublist_enabled( |
| 354 |
${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES |
| 355 |
${PROJECT_NAME}_ENABLED_INTERNAL_TOPLEVEL_PACKAGES |
| 356 |
${PROJECT_NAME}_NUM_ENABLED_INTERNAL_TOPLEVEL_PACKAGES) |
| 357 |
|
| 358 |
# ${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES |
| 359 |
tribits_get_sublist_enabled( ${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES |
| 360 |
${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES |
| 361 |
${PROJECT_NAME}_NUM_ENABLED_INTERNAL_PACKAGES) |
| 362 |
|
| 363 |
# ${PROJECT_NAME}_REVERSE_ENABLED_INTERNAL_PACKAGES |
| 364 |
unset(${PROJECT_NAME}_REVERSE_ENABLED_INTERNAL_PACKAGES) # Wipe out temp value |
| 365 |
|
| 366 |
# Set ${tribitsPackage}_PKG_IDX for each enabled package |
| 367 |
set(pkgIdx 0) |
| 368 |
foreach(tribitsPackage ${${PROJECT_NAME}_ENABLED_INTERNAL_PACKAGES}) |
| 369 |
set(${tribitsPackage}_PKG_IDX ${pkgIdx}) |
| 370 |
math(EXPR pkgIdx "${pkgIdx} + 1") |
| 371 |
endforeach() |
| 372 |
|
| 373 |
endmacro() |
| 374 |
|
| 375 |
|
| 376 |
# @MACRO: tribits_setup_direct_packages_dependencies_lists_and_lib_required_enable_vars() |
| 377 |
# |
| 378 |
# Set up flat list of direct external and inner package dependencies (even for |
| 379 |
# non-enabled packages) and enabled package dependencies for enabled packages. |
| 380 |
# |
| 381 |
macro(tribits_setup_direct_packages_dependencies_lists_and_lib_required_enable_vars) |
| 382 |
|
| 383 |
foreach(tad1_externalPkgName IN LISTS ${PROJECT_NAME}_DEFINED_TPLS) |
| 384 |
tribits_extpkg_setup_enabled_dependencies(${tad1_externalPkgName}) |
| 385 |
# ToDo: Assert that all of the listed dependencies in |
| 386 |
# ${tad1_externalPkgName}_LIB_ENABLED_DEPENDENCIES exist and are |
| 387 |
# upstream from ${tad1_externalPkgName} |
| 388 |
endforeach() |
| 389 |
|
| 390 |
foreach(tad1_internalPkgName IN LISTS ${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES) |
| 391 |
tribits_setup_enabled_dependencies_lists_and_enable_vars(${tad1_internalPkgName}) |
| 392 |
endforeach() |
| 393 |
|
| 394 |
endmacro() |
| 395 |
|
| 396 |
|
| 397 |
# @MACRO: tribits_print_direct_packages_dependencies_lists() |
| 398 |
# |
| 399 |
macro(tribits_print_direct_packages_dependencies_lists) |
| 400 |
if (${PROJECT_NAME}_DUMP_PACKAGE_DEPENDENCIES) |
| 401 |
message("\nDumping direct enabled dependencies for each package ...") |
| 402 |
foreach(tad1_tribitsPkg IN LISTS ${PROJECT_NAME}_DEFINED_PACKAGES) |
| 403 |
tribits_print_direct_package_dependencies_lists(${tad1_tribitsPkg}) |
| 404 |
endforeach() |
| 405 |
endif() |
| 406 |
endmacro() |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
################################################################################ |
| 411 |
# |
| 412 |
# Second-level macros called indirectly from ``tribits_adjust_package_enables()`` |
| 413 |
# |
| 414 |
################################################################################ |
| 415 |
|
| 416 |
|
| 417 |
# Macro that disables all of the subpackages of a parent package. |
| 418 |
# |
| 419 |
macro(tribits_disable_parents_subpackages parentPackageName) |
| 420 |
|
| 421 |
tribits_package_is_explicitly_disabled(${PROJECT_NAME}_ENABLE_${parentPackageName} |
| 422 |
parentPackageIsExplicityDisabled) |
| 423 |
|
| 424 |
if(parentPackageIsExplicityDisabled) |
| 425 |
|
| 426 |
foreach(tap2_subPkgName IN LISTS ${parentPackageName}_SUBPACKAGES) |
| 427 |
|
| 428 |
set(subpkgFullName ${parentPackageName}${tap2_subPkgName}) |
| 429 |
|
| 430 |
set(subpkgBeingDisabledVarName ${PROJECT_NAME}_ENABLE_${subpkgFullName}) |
| 431 |
tribits_package_is_explicitly_disabled(${subpkgBeingDisabledVarName} |
| 432 |
subpkgIExplicitlyDisabled) |
| 433 |
if (NOT subpkgIsExplicitlyDisabled) |
| 434 |
message("-- " |
| 435 |
"Setting subpackage enable ${subpkgBeingDisabledVarName}=OFF" |
| 436 |
" because parent package ${PROJECT_NAME}_ENABLE_${parentPackageName}=OFF") |
| 437 |
set(${subpkgBeingDisabledVarName} OFF) |
| 438 |
endif() |
| 439 |
|
| 440 |
endforeach() |
| 441 |
|
| 442 |
endif() |
| 443 |
|
| 444 |
endmacro() |
| 445 |
# |
| 446 |
# NOTE: Above, we don't need to use the function |
| 447 |
# tribits_get_package_enable_status() because a subpackage in this context |
| 448 |
# will never be an external package and therefore the enable var name will |
| 449 |
# always be ${PROJECT_NAME}_ENABLE_${subpkgFullName}. (At least I can't think |
| 450 |
# of a use case where that would occur.) |
| 451 |
|
| 452 |
|
| 453 |
# Macro that disables forward package that depends on the passed-in package |
| 454 |
# |
| 455 |
macro(tribits_disable_forward_required_dep_packages packageName) |
| 456 |
tribits_get_package_enable_status(${packageName} packageEnable "") |
| 457 |
tribits_package_is_explicitly_disabled(packageEnable packageIsExplicitlyDisabled) |
| 458 |
if (packageIsExplicitlyDisabled) |
| 459 |
foreach(fwdDepPkg IN LISTS ${packageName}_FORWARD_LIB_DEFINED_DEPENDENCIES) |
| 460 |
if (${fwdDepPkg}_LIB_DEP_REQUIRED_${packageName}) |
| 461 |
tribits_private_disable_required_package_enables(${fwdDepPkg} |
| 462 |
${packageName} TRUE) |
| 463 |
else() |
| 464 |
tribits_private_disable_optional_package_enables(${fwdDepPkg} |
| 465 |
${packageName} TRUE) |
| 466 |
endif() |
| 467 |
endforeach() |
| 468 |
foreach(fwdDepPkg IN LISTS ${packageName}_FORWARD_TEST_DEFINED_DEPENDENCIES) |
| 469 |
if (${fwdDepPkg}_TEST_DEP_REQUIRED_${packageName}) |
| 470 |
tribits_private_disable_required_package_enables(${fwdDepPkg} |
| 471 |
${packageName} FALSE) |
| 472 |
endif() |
| 473 |
endforeach() |
| 474 |
endif() |
| 475 |
endmacro() |
| 476 |
|
| 477 |
|
| 478 |
# Macro that enables all of the subpackages of a parent package. |
| 479 |
# |
| 480 |
macro(tribits_enable_parents_subpackages parentPackageName) |
| 481 |
|
| 482 |
if(${PROJECT_NAME}_ENABLE_${parentPackageName}) |
| 483 |
|
| 484 |
set(subpkgIdx 0) |
| 485 |
foreach(tap2_subPkgName IN LISTS ${parentPackageName}_SUBPACKAGES) |
| 486 |
|
| 487 |
set(subpkgFullName ${parentPackageName}${tap2_subPkgName}) |
| 488 |
tribits_package_is_explicitly_disabled(${PROJECT_NAME}_ENABLE_${subpkgFullName} |
| 489 |
subpkgIsExplicitlyDisabled) |
| 490 |
|
| 491 |
if (subpkgIsExplicitlyDisabled) |
| 492 |
# The subpackage is already explicitly disabled |
| 493 |
elseif (${PROJECT_NAME}_ENABLE_${subpkgFullName}) |
| 494 |
# The subpackage is already enabled so there is no reason to enable it |
| 495 |
else() |
| 496 |
# The subpackage is not hard off or on so turn it on by default |
| 497 |
tribits_implicit_package_enable_is_allowed( "" ${subpkgFullName} |
| 498 |
subpkgAllowImplicitEnable) |
| 499 |
if (subpkgAllowImplicitEnable) |
| 500 |
set(enableVarName ${PROJECT_NAME}_ENABLE_${subpkgFullName}) |
| 501 |
message("-- " |
| 502 |
"Setting subpackage enable ${enableVarName}=ON" |
| 503 |
" because parent package ${PROJECT_NAME}_ENABLE_${parentPackageName}=" |
| 504 |
"${${PROJECT_NAME}_ENABLE_${parentPackageName}}") |
| 505 |
set(${enableVarName} ON) |
| 506 |
endif() |
| 507 |
endif() |
| 508 |
|
| 509 |
math(EXPR subpkgIdx "${subpkgIdx}+1") |
| 510 |
|
| 511 |
endforeach() |
| 512 |
|
| 513 |
endif() |
| 514 |
|
| 515 |
endmacro() |
| 516 |
|
| 517 |
|
| 518 |
# Macro used to set ${PROJECT_NAME}_ENABLE_<packageName> based on |
| 519 |
# ${PROJECT_NAME}_ENABLE_ALL_PACKAGES |
| 520 |
# |
| 521 |
macro(tribits_apply_all_package_enables packageName) |
| 522 |
tribits_is_primary_meta_project_package(${packageName} packageIsPmpp) |
| 523 |
tribits_implicit_package_enable_is_allowed( "" ${packageName} |
| 524 |
processThisPackageEnable ) |
| 525 |
if (packageIsPmpp AND processThisPackageEnable) |
| 526 |
tribits_enable_package_based_on_project_enable_on( |
| 527 |
${PROJECT_NAME}_ENABLE_ALL_PACKAGES ${PROJECT_NAME}_ENABLE_${packageName} ) |
| 528 |
endif() |
| 529 |
endmacro() |
| 530 |
|
| 531 |
|
| 532 |
# Macro used to set ${PROJECT_NAME}_ENABLE_${FWD_PACKAGE_NAME}=ON for all |
| 533 |
# forward required or optional LIB dependency on ${packageName} |
| 534 |
# |
| 535 |
macro(tribits_enable_forward_lib_package_enables packageName) |
| 536 |
if (${PROJECT_NAME}_ENABLE_${packageName}) |
| 537 |
foreach(fwdDepPkgName IN LISTS ${packageName}_FORWARD_LIB_DEFINED_DEPENDENCIES) |
| 538 |
tribits_private_enable_forward_package(${fwdDepPkgName} ${packageName}) |
| 539 |
endforeach() |
| 540 |
endif() |
| 541 |
endmacro() |
| 542 |
|
| 543 |
|
| 544 |
# Macro used to set ${PROJECT_NAME}_ENABLE_${FWD_PACKAGE_NAME}=ON for all |
| 545 |
# forward required or optional TEST dependency on ${packageName} |
| 546 |
# |
| 547 |
macro(tribits_enable_forward_test_package_enables packageName) |
| 548 |
foreach(fwdDepPkgName IN LISTS ${packageName}_FORWARD_TEST_DEFINED_DEPENDENCIES) |
| 549 |
tribits_private_enable_forward_package(${fwdDepPkgName} ${packageName}) |
| 550 |
endforeach() |
| 551 |
endmacro() |
| 552 |
# NOTE: The above macro does not need to check if ${packageName} is enabled |
| 553 |
# because it will only be called for packages that are enabled already. This |
| 554 |
# not only improves performance but it also aids in testing. |
| 555 |
|
| 556 |
|
| 557 |
# Macro to disable ${parentPackageName)_ENABLE_ENABLES by default if |
| 558 |
# ${parentPackageName)_ENABLE_TESTS is explicitly disabled. |
| 559 |
# |
| 560 |
macro(tribits_apply_package_examples_disable parentPackageName) |
| 561 |
tribits_package_is_explicitly_disabled(${parentPackageName}_ENABLE_TESTS |
| 562 |
parentPackageTestsIsExplicitlyDisabled) |
| 563 |
if (parentPackageTestsIsExplicitlyDisabled |
| 564 |
AND ("${${parentPackageName}_ENABLE_EXAMPLES}" STREQUAL "") |
| 565 |
) |
| 566 |
message("-- " "Setting" |
| 567 |
" ${parentPackageName}_ENABLE_EXAMPLES" |
| 568 |
"=${${parentPackageName}_ENABLE_TESTS}" |
| 569 |
" because" |
| 570 |
" ${parentPackageName}_ENABLE_TESTS" |
| 571 |
"=${${parentPackageName}_ENABLE_TESTS}" ) |
| 572 |
set(${parentPackageName}_ENABLE_EXAMPLES ${${parentPackageName}_ENABLE_TESTS}) |
| 573 |
endif() |
| 574 |
endmacro() |
| 575 |
# NOTE: Above, the top-level package ${parentPackageName} may not even be |
| 576 |
# enabled yet when this gets called but its subpackages might and we need to |
| 577 |
# process this default disable in case their are any enabled subpackages. |
| 578 |
|
| 579 |
|
| 580 |
# Macro to disable <tribitsSubPackage>_ENABLE_TESTS and |
| 581 |
# <tribitsSubPackage>_ENABLE_EXAMPLES based on |
| 582 |
# <parentPackageName>_ENABLE_TESTS or <parentPackageName>_ENABLE_EXAMPLES |
| 583 |
# |
| 584 |
macro(tribits_apply_subpackage_tests_or_examples_disables parentPackageName |
| 585 |
testsOrExamples |
| 586 |
) |
| 587 |
set(parentPkgEnableVar ${parentPackageName}_ENABLE_${testsOrExamples}) |
| 588 |
tribits_package_is_explicitly_disabled(${parentPkgEnableVar} |
| 589 |
parentPkgIsExplicitlyDisabled) |
| 590 |
if (parentPkgIsExplicitlyDisabled) |
| 591 |
foreach(subpkgName IN LISTS ${parentPackageName}_SUBPACKAGES) |
| 592 |
set(fullSpkgName ${parentPackageName}${subpkgName}) |
| 593 |
if (${PROJECT_NAME}_ENABLE_${fullSpkgName}) |
| 594 |
if ("${${fullSpkgName}_ENABLE_${testsOrExamples}}" STREQUAL "") |
| 595 |
message("-- " "Setting" |
| 596 |
" ${fullSpkgName}_ENABLE_${testsOrExamples}=${${parentPkgEnableVar}}" |
| 597 |
" because parent package" |
| 598 |
" ${parentPkgEnableVar}=${${parentPkgEnableVar}}") |
| 599 |
set(${fullSpkgName}_ENABLE_${testsOrExamples} ${${parentPkgEnableVar}}) |
| 600 |
endif() |
| 601 |
endif() |
| 602 |
endforeach() |
| 603 |
endif() |
| 604 |
endmacro() |
| 605 |
|
| 606 |
|
| 607 |
# Macro used to set <packageName>_ENABLE_TESTS and |
| 608 |
# <packageName>_ENABLE_EXAMPLES based on ${PROJECT_NAME}_ENABLE_TESTS and |
| 609 |
# ${PROJECT_NAME}_ENABLE_EXAMPLES |
| 610 |
# |
| 611 |
macro(tribits_apply_test_example_enables packageName) |
| 612 |
if (${PROJECT_NAME}_ENABLE_${packageName}) |
| 613 |
tribits_is_primary_meta_project_package(${packageName} packageIsPmmp) |
| 614 |
if (packageIsPmmp) |
| 615 |
tribits_enable_package_based_on_project_enable_on( |
| 616 |
${PROJECT_NAME}_ENABLE_TESTS ${packageName}_ENABLE_TESTS ) |
| 617 |
tribits_enable_package_based_on_project_enable_on( |
| 618 |
${PROJECT_NAME}_ENABLE_EXAMPLES ${packageName}_ENABLE_EXAMPLES ) |
| 619 |
endif() |
| 620 |
endif() |
| 621 |
endmacro() |
| 622 |
|
| 623 |
|
| 624 |
# Macro to enable subpackage tests and examples based on parent package tests |
| 625 |
# and examples enables |
| 626 |
# |
| 627 |
macro(tribits_apply_subpackage_tests_examples_enables parentPackageName) |
| 628 |
# Set default for ${parentPackageName}_ENABLE_EXAMPLES=OFF if tests disabled |
| 629 |
if ( ("${${parentPackageName}_ENABLE_EXAMPLES}" STREQUAL "") |
| 630 |
AND ${parentPackageName}_ENABLE_TESTS |
| 631 |
) |
| 632 |
message("-- " "Setting" |
| 633 |
" ${parentPackageName}_ENABLE_EXAMPLES=${${parentPackageName}_ENABLE_TESTS}" |
| 634 |
" because" |
| 635 |
" ${parentPackageName}_ENABLE_TESTS=${${parentPackageName}_ENABLE_TESTS}") |
| 636 |
set(${parentPackageName}_ENABLE_EXAMPLES ${${parentPackageName}_ENABLE_TESTS}) |
| 637 |
endif() |
| 638 |
# Set defaults for <fullSubpackageName>_ENABLE_[TESTS|EXAMPLES] |
| 639 |
set(parentEnableExamples ${${parentPackageName}_ENABLE_EXAMPLES}) |
| 640 |
set(parentEnableTests ${${parentPackageName}_ENABLE_TESTS}) |
| 641 |
foreach(subpkgName IN LISTS ${parentPackageName}_SUBPACKAGES) |
| 642 |
set(fullSpkgName ${parentPackageName}${subpkgName}) |
| 643 |
if (${PROJECT_NAME}_ENABLE_${fullSpkgName}) |
| 644 |
if (parentEnableTests AND ("${${fullSpkgName}_ENABLE_TESTS}" STREQUAL "")) |
| 645 |
message("-- " "Setting" |
| 646 |
" ${fullSpkgName}_ENABLE_TESTS=${parentEnableTests}" |
| 647 |
" because parent package" |
| 648 |
" ${parentPackageName}_ENABLE_TESTS=${parentEnableTests}") |
| 649 |
set(${fullSpkgName}_ENABLE_TESTS ${parentEnableTests}) |
| 650 |
endif() |
| 651 |
if (parentEnableExamples AND ("${${fullSpkgName}_ENABLE_EXAMPLES}" STREQUAL "")) |
| 652 |
message("-- " "Setting" |
| 653 |
" ${fullSpkgName}_ENABLE_EXAMPLES=${parentEnableExamples}" |
| 654 |
" because parent package" |
| 655 |
" ${parentPackageName}_ENABLE_EXAMPLES=${parentEnableExamples}") |
| 656 |
set(${fullSpkgName}_ENABLE_EXAMPLES ${parentEnableExamples}) |
| 657 |
endif() |
| 658 |
endif() |
| 659 |
endforeach() |
| 660 |
endmacro() |
| 661 |
# NOTE: Above, the parent package may not actually be enabled yet |
| 662 |
# (i.e. ${PROJECT_NAME}_ENABLE_${parentPackageName} my not be TRUE) if only |
| 663 |
# subpackages needed to be enabled in the forward sweep but we want the tests |
| 664 |
# and examples for a subpackage to be enabled if the tests and examples for |
| 665 |
# the parent package, respectfully, are enabled. |
| 666 |
|
| 667 |
|
| 668 |
# Macro that enables upstream (required and optional) packages for a given |
| 669 |
# package |
| 670 |
# |
| 671 |
macro(tribits_enable_upstream_packages packageName) |
| 672 |
|
| 673 |
tribits_get_package_enable_status(${packageName} packageEnable packageEnableVar) |
| 674 |
|
| 675 |
if (packageEnable) |
| 676 |
|
| 677 |
foreach(depPkg IN LISTS ${packageName}_LIB_DEFINED_DEPENDENCIES) |
| 678 |
tribits_private_enable_dep_package(${packageName} ${depPkg} LIB) |
| 679 |
endforeach() |
| 680 |
|
| 681 |
foreach(depPkg IN LISTS ${packageName}_TEST_DEFINED_DEPENDENCIES) |
| 682 |
tribits_private_enable_dep_package(${packageName} ${depPkg} TEST) |
| 683 |
endforeach() |
| 684 |
|
| 685 |
endif() |
| 686 |
|
| 687 |
endmacro() |
| 688 |
# NOTE: The above macro has a defect. It is enabling upstream test dependent |
| 689 |
# packages even if tests nor examples are not enabled (see |
| 690 |
# TriBITSPub/TriBITS#56). But fixing this will break backward compatibility |
| 691 |
# and therefore require upgrading the packages that currently only work |
| 692 |
# correctly because of this defect. |
| 693 |
|
| 694 |
|
| 695 |
# Macro that post-processes optional dependencies after all other |
| 696 |
# dependencies have been worked out |
| 697 |
# |
| 698 |
macro(tribits_postprocess_optional_package_enables packageName) |
| 699 |
|
| 700 |
if (${PROJECT_NAME}_ENABLE_${packageName}) |
| 701 |
|
| 702 |
foreach(depPkg ${${packageName}_LIB_DEFINED_DEPENDENCIES}) |
| 703 |
tribits_private_postprocess_optional_package_enable( |
| 704 |
${packageName} ${depPkg} ) |
| 705 |
endforeach() |
| 706 |
|
| 707 |
foreach(depPkg ${${packageName}_TEST_DEFINED_DEPENDENCIES}) |
| 708 |
tribits_private_postprocess_optional_package_enable( |
| 709 |
${packageName} ${depPkg} ) |
| 710 |
endforeach() |
| 711 |
|
| 712 |
endif() |
| 713 |
|
| 714 |
endmacro() |
| 715 |
# NOTE: Above, it is harmless to process required dependencies as well so we |
| 716 |
# leave of the if () statement based on |
| 717 |
# ${packageName}_[LIB|TEST]_DEP_REQUIRED_${depPkg}. |
| 718 |
|
| 719 |
|
| 720 |
# Macro that sets cache vars for optional package interdependencies |
| 721 |
# |
| 722 |
# This also will set ${PACKAGE_NAME}_ENABLE_TESTS and |
| 723 |
# ${PACKAGE_NAME}_ENABLE_EXAMPLES to empty non-cache vars |
| 724 |
# |
| 725 |
macro(tribits_setup_optional_package_enables_and_cache_vars packageName) |
| 726 |
|
| 727 |
assert_defined(${PROJECT_NAME}_ENABLE_${packageName}) |
| 728 |
set(setAsCacheVar ${${PROJECT_NAME}_ENABLE_${packageName}}) |
| 729 |
|
| 730 |
if (setAsCacheVar) |
| 731 |
|
| 732 |
multiline_set(docStr |
| 733 |
"Build tests for the package ${packageName}. Set to 'ON', 'OFF', or leave empty ''" |
| 734 |
" to allow for other logic to decide." |
| 735 |
) |
| 736 |
set_cache_on_off_empty( ${packageName}_ENABLE_TESTS "" ${docStr} ) |
| 737 |
|
| 738 |
multiline_set(docStr |
| 739 |
"Build examples for the package ${packageName}. Set to 'ON', 'OFF', or leave empty ''" |
| 740 |
" to allow for other logic to decide." |
| 741 |
) |
| 742 |
set_cache_on_off_empty( ${packageName}_ENABLE_EXAMPLES "" ${docStr} ) |
| 743 |
|
| 744 |
multiline_set(docStr |
| 745 |
"Build examples for the package ${packageName}. Set to 'ON', 'OFF', or leave empty ''" |
| 746 |
" to allow for other logic to decide." |
| 747 |
) |
| 748 |
set( ${packageName}_SKIP_CTEST_ADD_TEST |
| 749 |
"${${PROJECT_NAME}_SKIP_CTEST_ADD_TEST}" CACHE BOOL ${docStr} ) |
| 750 |
|
| 751 |
else() |
| 752 |
|
| 753 |
if (NOT DEFINED ${packageName}_ENABLE_TESTS) |
| 754 |
set( ${packageName}_ENABLE_TESTS "" ) |
| 755 |
endif() |
| 756 |
if (NOT DEFINED ${packageName}_ENABLE_EXAMPLES) |
| 757 |
set( ${packageName}_ENABLE_EXAMPLES "" ) |
| 758 |
endif() |
| 759 |
|
| 760 |
endif() |
| 761 |
|
| 762 |
foreach(optDepPkg ${${packageName}_LIB_DEFINED_DEPENDENCIES}) |
| 763 |
tribits_private_add_optional_package_enable( |
| 764 |
${packageName} ${optDepPkg} "library" "${setAsCacheVar}" ) |
| 765 |
endforeach() |
| 766 |
|
| 767 |
foreach(optDepPkg ${${packageName}_TEST_DEFINED_DEPENDENCIES}) |
| 768 |
tribits_private_add_optional_package_enable( |
| 769 |
${packageName} ${optDepPkg} "test" "${setAsCacheVar}" ) |
| 770 |
endforeach() |
| 771 |
|
| 772 |
endmacro() |
| 773 |
|
| 774 |
|
| 775 |
# Macro that enables a the top-level parent package enable if any of its |
| 776 |
# subpackages are enabled. |
| 777 |
# |
| 778 |
macro(tribits_enable_parent_package_for_subpackage_enables toplevelPackageName) |
| 779 |
foreach(tap2_subPkgName IN LISTS ${toplevelPackageName}_SUBPACKAGES) |
| 780 |
set(subpkgFullName ${toplevelPackageName}${tap2_subPkgName}) |
| 781 |
tribits_get_package_enable_status(${toplevelPackageName} |
| 782 |
toplevelPackageEnable toplevelPackageEnableVarName) |
| 783 |
tribits_get_package_enable_status(${subpkgFullName} |
| 784 |
subpkgEnable subpkgEnableVarName) |
| 785 |
if (subpkgEnable AND (NOT toplevelPackageEnable)) |
| 786 |
message("-- " |
| 787 |
"Setting ${toplevelPackageEnableVarName}=ON because" |
| 788 |
" ${subpkgEnableVarName}=${subpkgEnable}") |
| 789 |
set(${toplevelPackageEnableVarName} ON) |
| 790 |
tribits_set_parent_package_subpackage_enable_for_enabled_subpackages( |
| 791 |
${toplevelPackageName}) |
| 792 |
tribits_set_parent_package_test_example_enable_for_enabled_subpackages( |
| 793 |
${toplevelPackageName} TESTS) |
| 794 |
tribits_set_parent_package_test_example_enable_for_enabled_subpackages( |
| 795 |
${toplevelPackageName} EXAMPLES) |
| 796 |
# NOTE: Above, we need to enable the parent package even if it was |
| 797 |
# disabled by some means before this. (There are use cases where the |
| 798 |
# parent package my be disabled but that may not trigger the disable of |
| 799 |
# subpackages of that package.) Other logic should ensure that the |
| 800 |
# parent package is never explicitly disabled and a subpackage is |
| 801 |
# allowed to be enabled. |
| 802 |
break() # We only need trigger above code for single enabled subpackage! |
| 803 |
endif() |
| 804 |
endforeach() |
| 805 |
endmacro() |
| 806 |
|
| 807 |
|
| 808 |
# Macro that sets $``{packageName}_PACKAGE_BUILD_STATUS=EXTERNAL and direct |
| 809 |
# upstream dependent packages ``${depPkg}_PACKAGE_BUILD_STATUS=EXTERNAL`` if |
| 810 |
# required. |
| 811 |
# |
| 812 |
# * Set an INTERNAL package as EXTERNAL if ``TPL_ENABLE_${packageName}`` is |
| 813 |
# ``TRUE`` |
| 814 |
# |
| 815 |
# * Set a top-level package to EXTERNAL if any of its subpackages are EXTERNAL |
| 816 |
# (or ``TPL_ENABLE_${subpkgFullName}`` is TRUE). |
| 817 |
# |
| 818 |
# This macro must be called in a backward/reverse sweep over the dependency |
| 819 |
# graph to work correctly. It sets upstream packages as EXTERNAL if the given |
| 820 |
# downstream package ``<packageName>`` is EXTERNAL. There is also special |
| 821 |
# logic for handling a package that has subpackages. That is, if any |
| 822 |
# subpackage of ``<packageName>`` is determined is EXTERNAL, then the parent |
| 823 |
# package is set to EXTERNAL and all of the other subpackages in parent |
| 824 |
# package ``<packageName>`` are set as EXTERNAL as well. (We don't allow a |
| 825 |
# subset of subpackages in a parent package to be EXTERNAL and the other |
| 826 |
# subpackages to be INTERNAL. That would be way too complicated to implement |
| 827 |
# and be way too confusing for implementers and users.) |
| 828 |
# |
| 829 |
macro(tribits_set_package_and_related_upstream_packages_to_external packageName) |
| 830 |
|
| 831 |
tribits_set_parent_package_external_if_subpackage_external(${packageName} |
| 832 |
subpackageTriggeredParentPackageExternal) |
| 833 |
|
| 834 |
tribits_set_package_to_external_if_requested_by_user(${packageName}) |
| 835 |
|
| 836 |
tribits_set_upstream_dep_packages_as_external(${packageName} |
| 837 |
${subpackageTriggeredParentPackageExternal}) |
| 838 |
|
| 839 |
tribits_mark_package_as_upstream_of_tribits_compliant_external_package(${packageName}) |
| 840 |
|
| 841 |
endmacro() |
| 842 |
# NOTE: In the above macro, if ${packageName} is made EXTERNAL because it one |
| 843 |
# of its subpackages is considered EXTERNAL, then the loop over all of the |
| 844 |
# package's upstream dependencies listed in |
| 845 |
# ${packageName}_LIB_DEFINED_DEPENDENCIES results in all of the other |
| 846 |
# subpackages in that package to also be treated as external. (I.e., there is |
| 847 |
# no need for a special loop over subpackages for the parent package. And the |
| 848 |
# only direct dependencies for a parent package should be its subpackages. If |
| 849 |
# that is not the case, then, technically, this would be setting more packages |
| 850 |
# as EXTERNAL than need to be.) |
| 851 |
|
| 852 |
|
| 853 |
# Macro that sets up the flat list of direct package dependencies and enabled |
| 854 |
# package dependencies and sets ${packageName}_ENABLE_${depPkg} for LIB |
| 855 |
# dependencies |
| 856 |
# |
| 857 |
# This makes it easy to just loop over all of the direct upstream dependencies |
| 858 |
# for a package or just the enabled dependencies. |
| 859 |
# |
| 860 |
# NOTES: |
| 861 |
# |
| 862 |
# * ${packageName}_LIB_ENABLED_DEPENDENCIES is only set if ${packageName} is |
| 863 |
# enabled and will only contain the names of direct library upstream |
| 864 |
# internal and external packages ${depPkg} that are required or are |
| 865 |
# optional and ${packageName}_ENABLE_${depPkg} is set to ON. |
| 866 |
# |
| 867 |
# * ${packageName}_TEST_ENABLED_DEPENDENCIES is only set if ${packageName} is |
| 868 |
# enabled and will only contain the names of direct test/example upstream |
| 869 |
# internal and external packages ${depPkg} that are required or are |
| 870 |
# optional and ${packageName}_ENABLE_${depPkg} is set to ON. |
| 871 |
# |
| 872 |
# * Sets ${packageName}_ENABLE_${depPkg}=ON for every required dep package |
| 873 |
# for LIB dependencies (but not TEST dependencies). This allows looping |
| 874 |
# over just ${packageName}_LIB_DEFINED_DEPENDENCIES looking at |
| 875 |
# ${packageName}_ENABLE_${depPkg} to see if the package is enable or not. |
| 876 |
# This also includes special logic for required subpackages for parent |
| 877 |
# packages where only the shell of the parent package is enabled and not |
| 878 |
# all of its required subpackages are enabled. |
| 879 |
# |
| 880 |
macro(tribits_setup_enabled_dependencies_lists_and_enable_vars packageName) |
| 881 |
|
| 882 |
tribits_get_package_enable_status(${packageName} packageEnable packageEnableVar) |
| 883 |
|
| 884 |
set(${packageName}_LIB_ENABLED_DEPENDENCIES "") |
| 885 |
foreach(depPkg IN LISTS ${packageName}_LIB_DEFINED_DEPENDENCIES) |
| 886 |
tribits_get_package_enable_status(${depPkg} depPkgEnable depPkgEnableVar) |
| 887 |
if (${packageName}_LIB_DEP_REQUIRED_${depPkg}) |
| 888 |
if (packageEnable AND depPkgEnable) |
| 889 |
set(${packageName}_ENABLE_${depPkg} ON) |
| 890 |
# See below NOTE about required subpackage dependencies not being |
| 891 |
# enabled in some cases |
| 892 |
list(APPEND ${packageName}_LIB_ENABLED_DEPENDENCIES ${depPkg}) |
| 893 |
endif() |
| 894 |
else() |
| 895 |
if (packageEnable AND ${packageName}_ENABLE_${depPkg}) |
| 896 |
list(APPEND ${packageName}_LIB_ENABLED_DEPENDENCIES ${depPkg}) |
| 897 |
endif() |
| 898 |
endif() |
| 899 |
endforeach() |
| 900 |
|
| 901 |
set(${packageName}_TEST_ENABLED_DEPENDENCIES "") |
| 902 |
if (packageEnable AND (${packageName}_ENABLE_TESTS OR ${packageName}_ENABLE_EXAMPLES)) |
| 903 |
foreach(depPkg IN LISTS ${packageName}_TEST_DEFINED_DEPENDENCIES) |
| 904 |
if (${packageName}_TEST_DEP_REQUIRED_${depPkg}) |
| 905 |
list(APPEND ${packageName}_TEST_ENABLED_DEPENDENCIES ${depPkg}) |
| 906 |
else() |
| 907 |
if (${packageName}_ENABLE_${depPkg}) |
| 908 |
list(APPEND ${packageName}_TEST_ENABLED_DEPENDENCIES ${depPkg}) |
| 909 |
endif() |
| 910 |
endif() |
| 911 |
endforeach() |
| 912 |
endif() |
| 913 |
|
| 914 |
endmacro() |
| 915 |
# NOTE: Above, a required dependency of an enabled package may not actually be |
| 916 |
# enabled if the upstream depPkg is a required subpackage of a parent package |
| 917 |
# and the parent package was not actually enabled due to a dependency, but |
| 918 |
# instead, only the shell of the parent package was enabled at the very end |
| 919 |
# (in tribits_do_final_parent_packages_enables_for_subpackage_enables()). |
| 920 |
# This is one of the more confusing aspects of the TriBITS dependency system. |
| 921 |
|
| 922 |
|
| 923 |
# Function to print the direct package dependency lists |
| 924 |
# |
| 925 |
function(tribits_print_direct_package_dependencies_lists packageName) |
| 926 |
message("") |
| 927 |
set(printedVar "") |
| 928 |
tribits_print_nonempty_package_deps_list(${packageName} LIB ENABLED printedVar) |
| 929 |
tribits_print_nonempty_package_deps_list(${packageName} TEST ENABLED printedVar) |
| 930 |
if (NOT printedVar) |
| 931 |
message("-- ${packageName}: No enabled dependencies!") |
| 932 |
endif() |
| 933 |
endfunction() |
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
################################################################################ |
| 938 |
# |
| 939 |
# Third and lower-level macros called indirectly from |
| 940 |
# ``tribits_adjust_package_enables()`` |
| 941 |
# |
| 942 |
################################################################################ |
| 943 |
|
| 944 |
|
| 945 |
# Only turn off ${fwdDepPkgName} libraries or test/examples if it is currently |
| 946 |
# enabled or could be enabled |
| 947 |
# |
| 948 |
macro(tribits_private_disable_required_package_enables |
| 949 |
fwdDepPkgName packageName libraryDep |
| 950 |
) |
| 951 |
tribits_get_package_enable_status(${fwdDepPkgName} "" fwdDepPkgEnableVarName) |
| 952 |
tribits_package_is_enabled_or_unset(${fwdDepPkgEnableVarName} |
| 953 |
fwdDepPkgIsEnabledOrUnset) |
| 954 |
if (fwdDepPkgIsEnabledOrUnset) |
| 955 |
if ("${libraryDep}" STREQUAL "TRUE") |
| 956 |
tribits_private_print_disable_required_package_enable( |
| 957 |
${packageName} ${fwdDepPkgEnableVarName} |
| 958 |
${fwdDepPkgName} "library" ) |
| 959 |
set(${fwdDepPkgEnableVarName} OFF) |
| 960 |
else() |
| 961 |
set(depTypeStr "test/example") |
| 962 |
tribits_package_is_enabled_or_unset(${fwdDepPkgName}_ENABLE_TESTS |
| 963 |
fwdDepPkgEnableTestsIsEnabledOrUnset) |
| 964 |
if (fwdDepPkgEnableTestsIsEnabledOrUnset) |
| 965 |
tribits_private_print_disable_required_package_enable( |
| 966 |
${packageName} ${fwdDepPkgName}_ENABLE_TESTS |
| 967 |
${fwdDepPkgName} "${depTypeStr}" ) |
| 968 |
set(${fwdDepPkgName}_ENABLE_TESTS OFF) |
| 969 |
endif() |
| 970 |
|
| 971 |
tribits_package_is_enabled_or_unset(${fwdDepPkgName}_ENABLE_EXAMPLES |
| 972 |
fwdDepPkgEnableExamplesIsEnabledOrUnset) |
| 973 |
if (fwdDepPkgEnableExamplesIsEnabledOrUnset) |
| 974 |
tribits_private_print_disable_required_package_enable( |
| 975 |
${packageName} ${fwdDepPkgName}_ENABLE_EXAMPLES |
| 976 |
${fwdDepPkgName} "${depTypeStr}" ) |
| 977 |
set(${fwdDepPkgName}_ENABLE_EXAMPLES OFF) |
| 978 |
endif() |
| 979 |
endif() |
| 980 |
endif() |
| 981 |
endmacro() |
| 982 |
|
| 983 |
function(tribits_private_print_disable_required_package_enable |
| 984 |
packageName packageEnableSomethingVarName fwdDepPkgName |
| 985 |
depTypeStr |
| 986 |
) |
| 987 |
tribits_private_print_disable( |
| 988 |
${packageEnableSomethingVarName} ${fwdDepPkgName} |
| 989 |
"${depTypeStr}" "package" ${packageName} ) |
| 990 |
endfunction() |
| 991 |
|
| 992 |
|
| 993 |
function(tribits_private_print_disable |
| 994 |
packageBeingDisabledVarName packageWithSomethingBeingDisabledName |
| 995 |
depTypeStr thingBeingDisabledType thingBeingDisabledName |
| 996 |
) |
| 997 |
if (${packageBeingDisabledVarName}) |
| 998 |
if (${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES) |
| 999 |
message( |
| 1000 |
" ***\n" |
| 1001 |
" *** NOTE: Setting ${packageBeingDisabledVarName}=OFF" |
| 1002 |
" which was '${${packageBeingDisabledVarName}}' because" |
| 1003 |
" ${packageWithSomethingBeingDisabledName} has" |
| 1004 |
" a required ${depTypeStr} dependence on disabled" |
| 1005 |
" ${thingBeingDisabledType} ${thingBeingDisabledName}" |
| 1006 |
" but ${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON!\n" |
| 1007 |
" ***\n" |
| 1008 |
) |
| 1009 |
else() |
| 1010 |
message(FATAL_ERROR |
| 1011 |
" ***\n" |
| 1012 |
" *** ERROR: Setting ${packageBeingDisabledVarName}=OFF" |
| 1013 |
" which was '${${packageBeingDisabledVarName}}' because" |
| 1014 |
" ${packageWithSomethingBeingDisabledName} has" |
| 1015 |
" a required ${depTypeStr} dependence on disabled" |
| 1016 |
" ${thingBeingDisabledType} ${thingBeingDisabledName}!\n" |
| 1017 |
" ***\n" |
| 1018 |
) |
| 1019 |
endif() |
| 1020 |
else() |
| 1021 |
message("-- " |
| 1022 |
"Setting ${packageBeingDisabledVarName}=OFF" |
| 1023 |
" because ${packageWithSomethingBeingDisabledName} has a required ${depTypeStr}" |
| 1024 |
" dependence on disabled ${thingBeingDisabledType} ${thingBeingDisabledName}") |
| 1025 |
endif() |
| 1026 |
endfunction() |
| 1027 |
|
| 1028 |
|
| 1029 |
macro(tribits_private_disable_optional_package_enables fwdDepPkgName packageName) |
| 1030 |
|
| 1031 |
tribits_package_is_enabled_or_unset(${fwdDepPkgName}_ENABLE_${packageName} |
| 1032 |
fwdDepPkgEnablePackageIsEnabledOrUnset) |
| 1033 |
if (fwdDepPkgEnablePackageIsEnabledOrUnset) |
| 1034 |
# Always disable the conditional enable but only print the message if the |
| 1035 |
# package is enabled or if a disable overrides an enable |
| 1036 |
if (${PROJECT_NAME}_ENABLE_${fwdDepPkgName}) |
| 1037 |
if (${fwdDepPkgName}_ENABLE_${packageName}) # is explicitly enabled already! |
| 1038 |
message("-- " |
| 1039 |
"NOTE: Setting ${fwdDepPkgName}_ENABLE_${packageName}=OFF" |
| 1040 |
" which was ${${fwdDepPkgName}_ENABLE_${packageName}}" |
| 1041 |
" because ${fwdDepPkgName} has an optional library dependence" |
| 1042 |
" on disabled package ${packageName}") |
| 1043 |
else() # Not explicitly set |
| 1044 |
message("-- " |
| 1045 |
"Setting ${fwdDepPkgName}_ENABLE_${packageName}=OFF" |
| 1046 |
" because ${fwdDepPkgName} has an optional library dependence" |
| 1047 |
" on disabled package ${packageName}") |
| 1048 |
endif() |
| 1049 |
endif() |
| 1050 |
tribits_package_is_explicitly_disabled(${PROJECT_NAME}_ENABLE_${packageName} |
| 1051 |
packageIsExplicitlyDisabled) |
| 1052 |
if (${fwdDepPkgName}_ENABLE_${packageName} AND packageIsExplicitlyDisabled) |
| 1053 |
message("-- " "NOTE: ${fwdDepPkgName}_ENABLE_${packageName}=" |
| 1054 |
"${${fwdDepPkgName}_ENABLE_${packageName}} but" |
| 1055 |
" ${PROJECT_NAME}_ENABLE_${packageName}=" |
| 1056 |
"${${PROJECT_NAME}_ENABLE_${packageName}} is set. Setting" |
| 1057 |
" ${fwdDepPkgName}_ENABLE_${packageName}=OFF!") |
| 1058 |
endif() |
| 1059 |
set(${fwdDepPkgName}_ENABLE_${packageName} OFF) |
| 1060 |
endif() |
| 1061 |
|
| 1062 |
endmacro() |
| 1063 |
|
| 1064 |
|
| 1065 |
# Set an individual package test or examples enable to on only if global |
| 1066 |
# enable var is on |
| 1067 |
# |
| 1068 |
macro(tribits_enable_package_based_on_project_enable_on projectEnableVar |
| 1069 |
packageEnableVar |
| 1070 |
) |
| 1071 |
if (("${${packageEnableVar}}" STREQUAL "") AND ${projectEnableVar}) |
| 1072 |
message("-- " "Setting ${packageEnableVar}=ON") |
| 1073 |
set(${packageEnableVar} ON) |
| 1074 |
endif() |
| 1075 |
endmacro() |
| 1076 |
|
| 1077 |
|
| 1078 |
macro(tribits_private_enable_dep_package packageName depPkgName libOrTest) |
| 1079 |
tribits_get_package_enable_status(${depPkgName} depPkgEnable depPkgEnableVar) |
| 1080 |
if (depPkgEnable) |
| 1081 |
#message("The package is already enabled so there is nothing to enable!") |
| 1082 |
elseif ("${depPkgEnable}" STREQUAL "") |
| 1083 |
set(tpedp_enableDepPkg "") |
| 1084 |
if (${packageName}_${libOrTest}_DEP_REQUIRED_${depPkgName} |
| 1085 |
AND (NOT "${${packageName}_SOURCE_DIR}" STREQUAL "") |
| 1086 |
) |
| 1087 |
message("-- " "Setting ${depPkgEnableVar}=ON" |
| 1088 |
" because ${packageName} has a required dependence on ${depPkgName}") |
| 1089 |
set(tpedp_enableDepPkg ON) |
| 1090 |
elseif (${packageName}_ENABLE_${depPkgName}) |
| 1091 |
# Enable the upstream package if the user directly specified the |
| 1092 |
# optional package enable regardless if it is PT or ST or even EX. |
| 1093 |
message("-- " "Setting ${depPkgEnableVar}=ON" |
| 1094 |
" because ${packageName}_ENABLE_${depPkgName}=ON") |
| 1095 |
set(tpedp_enableDepPkg ON) |
| 1096 |
elseif (${PROJECT_NAME}_ENABLE_ALL_OPTIONAL_PACKAGES) |
| 1097 |
# Enable the package if there is an optional dependence and we are asked |
| 1098 |
# to enabled optional dependencies. |
| 1099 |
tribits_implicit_package_enable_is_allowed(${packageName} ${depPkgName} |
| 1100 |
allowImplicitEnable) |
| 1101 |
if (allowImplicitEnable) |
| 1102 |
message("-- " "Setting ${depPkgEnableVar}=ON" |
| 1103 |
" because ${packageName} has an optional dependence on ${depPkgName}") |
| 1104 |
set(tpedp_enableDepPkg ON) |
| 1105 |
endif() |
| 1106 |
endif() |
| 1107 |
# Enable the upstream package |
| 1108 |
if (tpedp_enableDepPkg) |
| 1109 |
set(${depPkgEnableVar} ON) |
| 1110 |
set(${depPkgName}_ENABLING_PKG ${packageName}) |
| 1111 |
endif() |
| 1112 |
endif() |
| 1113 |
endmacro() |
| 1114 |
|
| 1115 |
|
| 1116 |
# Enable optional intra-package support for enabled target package |
| 1117 |
# ${packageName} (i.e. ${PROJECT_NAME}_ENABLE_${packageName} is assumed to |
| 1118 |
# be TRUE before calling this macro. |
| 1119 |
# |
| 1120 |
macro(tribits_private_postprocess_optional_package_enable packageName optDepPkg) |
| 1121 |
|
| 1122 |
tribits_get_package_enable_status(${optDepPkg} optDepPkgEnable optDepPkgEnableVar) |
| 1123 |
tribits_get_package_enable_status(${packageName} packageEnable packageEnableVar) |
| 1124 |
tribits_package_is_explicitly_disabled(${packageName}_ENABLE_${optDepPkg} |
| 1125 |
package_Enable_OptDeptPkg_IsExplicitlyDisabled) |
| 1126 |
|
| 1127 |
if (${packageName}_ENABLE_${optDepPkg} AND optDepPkgEnable) |
| 1128 |
message("-- " "NOTE:" |
| 1129 |
" ${packageName}_ENABLE_${optDepPkg}=${${packageName}_ENABLE_${optDepPkg}}" |
| 1130 |
" is already set!") |
| 1131 |
elseif ("${${packageName}_ENABLE_${optDepPkg}}" STREQUAL "") |
| 1132 |
if (optDepPkgEnable) |
| 1133 |
message("-- " "Setting ${packageName}_ENABLE_${optDepPkg}=ON" |
| 1134 |
" since ${packageEnableVar}=ON AND" |
| 1135 |
" ${optDepPkgEnableVar}=ON") |
| 1136 |
set(${packageName}_ENABLE_${optDepPkg} ON) |
| 1137 |
else() |
| 1138 |
message("-- " "NOT setting ${packageName}_ENABLE_${optDepPkg}=ON" |
| 1139 |
" since ${optDepPkg} is NOT enabled at this point!") |
| 1140 |
endif() |
| 1141 |
elseif (package_Enable_OptDeptPkg_IsExplicitlyDisabled AND optDepPkgEnable) |
| 1142 |
message("-- " "NOTE: ${packageName}_ENABLE_${optDepPkg}=" |
| 1143 |
"${${packageName}_ENABLE_${optDepPkg}} is already set so not enabling even" |
| 1144 |
" though ${optDepPkgEnableVar}=" |
| 1145 |
"${optDepPkgEnable} is set!") |
| 1146 |
endif() |
| 1147 |
|
| 1148 |
string(TOUPPER ${packageName} packageName_UPPER) |
| 1149 |
string(TOUPPER ${optDepPkg} optDepPkg_UPPER) |
| 1150 |
set(macroDefineName HAVE_${packageName_UPPER}_${optDepPkg_UPPER}) |
| 1151 |
|
| 1152 |
if(${packageName}_ENABLE_${optDepPkg}) |
| 1153 |
set(${macroDefineName} ON) |
| 1154 |
else() |
| 1155 |
set(${macroDefineName} OFF) |
| 1156 |
endif() |
| 1157 |
|
| 1158 |
endmacro() |
| 1159 |
|
| 1160 |
|
| 1161 |
macro(tribits_private_enable_forward_package fwdDepPkgName packageName) |
| 1162 |
tribits_implicit_package_enable_is_allowed( "" ${fwdDepPkgName} allowFwdDepPkgEnable) |
| 1163 |
if ("${${PROJECT_NAME}_ENABLE_${fwdDepPkgName}}" STREQUAL "" AND allowFwdDepPkgEnable) |
| 1164 |
message("-- " "Setting ${PROJECT_NAME}_ENABLE_${fwdDepPkgName}=ON" |
| 1165 |
" because ${PROJECT_NAME}_ENABLE_${packageName}=ON") |
| 1166 |
set(${PROJECT_NAME}_ENABLE_${fwdDepPkgName} ON) |
| 1167 |
endif() |
| 1168 |
endmacro() |
| 1169 |
|
| 1170 |
|
| 1171 |
macro(tribits_private_add_optional_package_enable packageName optionalDepPkgName |
| 1172 |
libraryOrTest setAsCacheVar |
| 1173 |
) |
| 1174 |
|
| 1175 |
if (setAsCacheVar) |
| 1176 |
|
| 1177 |
multiline_set(docStr |
| 1178 |
"Enable optional ${libraryOrTest} support in the package ${packageName}" |
| 1179 |
" for the package ${optionalDepPkgName}." |
| 1180 |
" Set to 'ON', 'OFF', or leave empty" |
| 1181 |
" to allow for other logic to decide." |
| 1182 |
) |
| 1183 |
|
| 1184 |
set_cache_on_off_empty( ${packageName}_ENABLE_${optionalDepPkgName} "" |
| 1185 |
${docStr} ) |
| 1186 |
|
| 1187 |
else() |
| 1188 |
|
| 1189 |
if (NOT DEFINED ${packageName}_ENABLE_${optionalDepPkgName}) |
| 1190 |
set(${packageName}_ENABLE_${optionalDepPkgName} "" ) |
| 1191 |
endif() |
| 1192 |
|
| 1193 |
endif() |
| 1194 |
|
| 1195 |
endmacro() |
| 1196 |
|
| 1197 |
|
| 1198 |
# Set the parent package as EXTERNAL if any of its subpackages are being |
| 1199 |
# treated as EXTERNAL and return bool if that is the case. |
| 1200 |
# |
| 1201 |
# On output, ``<parentPackageName>_PACKAGE_BUILD_STATUS`` will have been set |
| 1202 |
# to ``EXTERNAL`` if the returned var |
| 1203 |
# ``subpackageTriggeredParentPackageExternalOut`` is ``TRUE``. |
| 1204 |
# |
| 1205 |
macro(tribits_set_parent_package_external_if_subpackage_external parentPackageName |
| 1206 |
subpackageTriggeredParentPackageExternalOut |
| 1207 |
) |
| 1208 |
|
| 1209 |
set(subpackageTriggeredParentPackageExternal FALSE) |
| 1210 |
|
| 1211 |
if (NOT ${parentPackageName}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") |
| 1212 |
foreach (tap2_subPkgName IN LISTS ${parentPackageName}_SUBPACKAGES) |
| 1213 |
set(subpkgFullName ${parentPackageName}${tap2_subPkgName}) |
| 1214 |
tribits_package_is_external(${subpkgFullName} subpkgIsExternal) |
| 1215 |
if (subpkgIsExternal) |
| 1216 |
set(becauseMsgStr "subpackage ${subpkgFullName} being treated as EXTERNAL") |
| 1217 |
if (TPL_ENABLE_${subpkgFullName}) |
| 1218 |
string(APPEND becauseMsgStr |
| 1219 |
" (TPL_ENABLE_${subpkgFullName}=${TPL_ENABLE_${subpkgFullName}})") |
| 1220 |
endif() |
| 1221 |
tribits_set_internal_package_to_external(${parentPackageName} "${becauseMsgStr}") |
| 1222 |
set(subpackageTriggeredParentPackageExternal TRUE) |
| 1223 |
break() |
| 1224 |
endif() |
| 1225 |
endforeach() |
| 1226 |
endif() |
| 1227 |
|
| 1228 |
set(${subpackageTriggeredParentPackageExternalOut} |
| 1229 |
${subpackageTriggeredParentPackageExternal}) |
| 1230 |
|
| 1231 |
endmacro() |
| 1232 |
|
| 1233 |
|
| 1234 |
# Macro that sets ``<packageName>_PACKAGE_BUILD_STATUS`` to ``EXTERNAL`` if |
| 1235 |
# requested by the user (e.g. by setting ``TPL_ENABLE_<packageName>``). |
| 1236 |
# |
| 1237 |
macro(tribits_set_package_to_external_if_requested_by_user packageName) |
| 1238 |
if (NOT ${packageName}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") |
| 1239 |
if (TPL_ENABLE_${packageName}) |
| 1240 |
tribits_set_internal_package_to_external(${packageName} |
| 1241 |
"TPL_ENABLE_${packageName}=${TPL_ENABLE_${packageName}}") |
| 1242 |
endif() |
| 1243 |
endif() |
| 1244 |
endmacro() |
| 1245 |
|
| 1246 |
|
| 1247 |
# Macro that sets all of the direct upstream dependent packages as EXTERNAL if |
| 1248 |
# they should be. |
| 1249 |
# |
| 1250 |
# NOTE: We only bother setting upstream dependencies as EXTERNAL if the |
| 1251 |
# package ``<packageName>`` is enabled or if it is a parent package (enabled |
| 1252 |
# or not) where at least one of its subpackages is enabled and is being |
| 1253 |
# treated as EXTERNAL. (In the latter case, any subpackages that are not |
| 1254 |
# enabled will still be set as EXTERNAL.) |
| 1255 |
# |
| 1256 |
macro(tribits_set_upstream_dep_packages_as_external packageName |
| 1257 |
subpackageTriggeredParentPackageExternal |
| 1258 |
) |
| 1259 |
|
| 1260 |
tribits_get_package_enable_status(${packageName} packageEnable "") |
| 1261 |
|
| 1262 |
if (${packageName}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") |
| 1263 |
foreach(depPkg IN LISTS ${packageName}_LIB_DEFINED_DEPENDENCIES) |
| 1264 |
if ((NOT ${depPkg}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") AND |
| 1265 |
(subpackageTriggeredParentPackageExternal OR packageEnable) |
| 1266 |
) |
| 1267 |
tribits_set_internal_package_to_external(${depPkg} |
| 1268 |
"downstream package ${packageName} being treated as EXTERNAL") |
| 1269 |
endif() |
| 1270 |
endforeach() |
| 1271 |
endif() |
| 1272 |
|
| 1273 |
endmacro() |
| 1274 |
|
| 1275 |
|
| 1276 |
# Mark a package as being upstream of a TriBITS-compliant external package |
| 1277 |
# (and therefore should be processed by a downstream TriBITS-complaint |
| 1278 |
# package) |
| 1279 |
# |
| 1280 |
# NOTE: These packages are initially marked by setting |
| 1281 |
# ``${packageName}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE=TRUE``. |
| 1282 |
# If this packages are not actually defined by a downstream TriBITS-compliant |
| 1283 |
# external package, then this variable will be set to ``FALSE`` later. |
| 1284 |
# |
| 1285 |
macro(tribits_mark_package_as_upstream_of_tribits_compliant_external_package packageName) |
| 1286 |
|
| 1287 |
set_default(${packageName}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE FALSE) |
| 1288 |
|
| 1289 |
tribits_get_package_enable_status(${packageName} packageEnable "") |
| 1290 |
|
| 1291 |
if (${packageName}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") |
| 1292 |
|
| 1293 |
foreach(fwdDepPkg IN LISTS ${packageName}_FORWARD_LIB_DEFINED_DEPENDENCIES) |
| 1294 |
|
| 1295 |
if((${fwdDepPkg}_IS_TRIBITS_COMPLIANT |
| 1296 |
OR ${fwdDepPkg}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE) |
| 1297 |
AND (${fwdDepPkg}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") |
| 1298 |
) |
| 1299 |
tribits_get_package_enable_status(${fwdDepPkg} fwdDepPkgEnable "") |
| 1300 |
if (${fwdDepPkg}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE) |
| 1301 |
set(directOrIndirectStr "indirectly") |
| 1302 |
set(downstreamPkgStr "") |
| 1303 |
else() |
| 1304 |
set(directOrIndirectStr "directly") |
| 1305 |
set(downstreamPkgStr " ${fwdDepPkg}") |
| 1306 |
endif() |
| 1307 |
if (packageEnable AND (NOT ${packageName}_IS_TRIBITS_COMPLIANT)) |
| 1308 |
message("-- " |
| 1309 |
"NOTE: ${packageName} is ${directOrIndirectStr} upstream from a" |
| 1310 |
" TriBITS-compliant external package${downstreamPkgStr}") |
| 1311 |
endif() |
| 1312 |
set(${packageName}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE TRUE) |
| 1313 |
break() |
| 1314 |
endif() |
| 1315 |
|
| 1316 |
endforeach() |
| 1317 |
|
| 1318 |
endif() |
| 1319 |
|
| 1320 |
endmacro() |
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
# Macro that sets ``<ParentPackage>_ENABLE_<SubPackage>=ON`` if not already |
| 1325 |
# enabled for all enabled subpackages of a parent package. |
| 1326 |
# |
| 1327 |
macro(tribits_set_parent_package_subpackage_enable_for_enabled_subpackages |
| 1328 |
toplevelPackageName |
| 1329 |
) |
| 1330 |
foreach(tap3_subPkg IN LISTS ${toplevelPackageName}_SUBPACKAGES) |
| 1331 |
set(subpkgFullName ${toplevelPackageName}${tap3_subPkg}) |
| 1332 |
if (${PROJECT_NAME}_ENABLE_${subpkgFullName} |
| 1333 |
AND "${${toplevelPackageName}_ENABLE_${subpkgFullName}}" STREQUAL "" |
| 1334 |
) |
| 1335 |
message("-- " |
| 1336 |
"Setting ${toplevelPackageName}_ENABLE_${subpkgFullName}=ON" |
| 1337 |
" because ${PROJECT_NAME}_ENABLE_${subpkgFullName}=ON") |
| 1338 |
set(${toplevelPackageName}_ENABLE_${subpkgFullName} ON) |
| 1339 |
endif() |
| 1340 |
endforeach() |
| 1341 |
endmacro() |
| 1342 |
|
| 1343 |
|
| 1344 |
# Macro that sets ``<ParentPacakge>_ENABLE_[TESTS|EXAMPLES]=ON`` if subpackage |
| 1345 |
# is enabled and has its tests/examples are enabled. |
| 1346 |
# |
| 1347 |
macro(tribits_set_parent_package_test_example_enable_for_enabled_subpackages |
| 1348 |
toplevelPackageName testOrExamples |
| 1349 |
) |
| 1350 |
foreach(tap3_subPkg IN LISTS ${toplevelPackageName}_SUBPACKAGES) |
| 1351 |
set(subpkgFullName ${toplevelPackageName}${tap3_subPkg}) |
| 1352 |
if (${subpkgFullName}_ENABLE_${testOrExamples} |
| 1353 |
AND "${${toplevelPackageName}_ENABLE_${testOrExamples}}" STREQUAL "" |
| 1354 |
) |
| 1355 |
message("-- " |
| 1356 |
"Setting ${toplevelPackageName}_ENABLE_${testOrExamples}=ON" |
| 1357 |
" because ${subpkgFullName}_ENABLE_${testOrExamples}=ON") |
| 1358 |
set(${toplevelPackageName}_ENABLE_${testOrExamples} ON) |
| 1359 |
endif() |
| 1360 |
endforeach() |
| 1361 |
endmacro() |
| 1362 |
|
| 1363 |
|
| 1364 |
# Macro that sets an internal package to EXTERNAL and print so and why (if the |
| 1365 |
# package is actually enabled) |
| 1366 |
# |
| 1367 |
# Usage:: |
| 1368 |
# |
| 1369 |
# tribits_set_internal_package_to_external(<depPkgName> "<becauseMsg1>" |
| 1370 |
# "<becauseMsg2>" ...) |
| 1371 |
# |
| 1372 |
# This always sets ``<depPkgName>_PACKAGE_BUILD_STATUS=EXTERNAL`` but only |
| 1373 |
# prints the message if ``<depPkgName>`` is enabled. |
| 1374 |
# |
| 1375 |
macro(tribits_set_internal_package_to_external depPkgName) |
| 1376 |
if (NOT ${depPkgName}_INTERNAL_PACKAGE_ALREADY_SET_EXTERNAL) |
| 1377 |
tribits_get_package_enable_status(${depPkgName} depPkgEnable "") |
| 1378 |
if (depPkgEnable) |
| 1379 |
message("-- " |
| 1380 |
"Treating internal package ${depPkgName} as EXTERNAL because" |
| 1381 |
" " ${ARGN}) |
| 1382 |
endif() |
| 1383 |
set(${depPkgName}_PACKAGE_BUILD_STATUS EXTERNAL) |
| 1384 |
set(${depPkgName}_FINDMOD TRIBITS_PKG) |
| 1385 |
set(${depPkgName}_INTERNAL_PACKAGE_ALREADY_SET_EXTERNAL TRUE) |
| 1386 |
endif() |
| 1387 |
endmacro() |
| 1388 |
|
| 1389 |
|
| 1390 |
# Function to return if <packageName> is to be treated as an EXTERNAL package |
| 1391 |
# in processing of the package |
| 1392 |
# |
| 1393 |
function(tribits_package_is_external packageName packageIsExternalOut) |
| 1394 |
if (TPL_ENABLE_${packageName}) |
| 1395 |
set(packageIsExternal TRUE) |
| 1396 |
elseif (${packageName}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") |
| 1397 |
set(packageIsExternal TRUE) |
| 1398 |
else() |
| 1399 |
set(packageIsExternal FALSE) |
| 1400 |
endif() |
| 1401 |
set(${packageIsExternalOut} ${packageIsExternal} PARENT_SCOPE) |
| 1402 |
endfunction() |
| 1403 |
|
| 1404 |
|
| 1405 |
# LocalWords: tribits TriBITS foreach endmacro endfunction |