Skip to content

Commit

Permalink
Fix failing test for <ParentPackage>Config.cmake missing subpackage i…
Browse files Browse the repository at this point in the history
…ncludes (#299)

This sets <ParentPackage>_ENABLE_<SubPackage>=ON if the subpackage is enabled
even if optional packages are disabled.  This will fix trilinos/Trilinos#9972
and trilinos/Trilinos#9973.

This also updates the logic that generates <Package>Config.cmake files to only
include <UpstreamPackage>Config.cmake files for direct dependencies, not all
dependencies.  (The indirect includes should take care of the rest.)
  • Loading branch information
bartlettroscoe committed Dec 3, 2021
1 parent 8dc2f24 commit dde5f41
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
6 changes: 6 additions & 0 deletions test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ function(TribitsExampleApp_NoOptionalPackages_test byProjectOrPackage sharedOrSt
${buildSharedLibsArg}
-DCMAKE_INSTALL_PREFIX=${testDir}/install
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"-- Setting TribitsExProj_ENABLE_WithSubpackages=ON because TribitsExProj_ENABLE_WithSubpackagesA=ON"
"-- Setting WithSubpackages_ENABLE_WithSubpackagesA=ON because TribitsExProj_ENABLE_WithSubpackagesA=ON"
"-- Setting WithSubpackages_ENABLE_WithSubpackagesB=ON because TribitsExProj_ENABLE_WithSubpackagesB=ON"
"-- Setting WithSubpackages_ENABLE_WithSubpackagesC=ON because TribitsExProj_ENABLE_WithSubpackagesC=ON"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_1
MESSAGE "Build and install TribitsExampleProject locally"
Expand Down
25 changes: 24 additions & 1 deletion tribits/core/package_arch/TribitsAdjustPackageEnables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ include(MessageWrapper)
include(DualScopeSet)
include(CMakeParseArguments)


#
# Private helper macros
#
Expand Down Expand Up @@ -314,7 +315,6 @@ macro(tribits_disable_parents_subpackages PARENT_PACKAGE_NAME)
endmacro()


#
# Macro that enables all of the subpackages of a parent package.
#
macro(tribits_enable_parents_subpackages PARENT_PACKAGE_NAME)
Expand Down Expand Up @@ -698,6 +698,8 @@ macro(tribits_postprocess_package_with_subpackages_enables PACKAGE_NAME)
"Setting ${PROJECT_NAME}_ENABLE_${PACKAGE_NAME}=ON"
" because ${PROJECT_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}=ON")
set(${PROJECT_NAME}_ENABLE_${PACKAGE_NAME} ON)
tribits_postprocess_package_with_subpackages_optional_subpackage_enables(
${PACKAGE_NAME})
tribits_postprocess_package_with_subpackages_test_example_enables(
${PACKAGE_NAME} TESTS)
tribits_postprocess_package_with_subpackages_test_example_enables(
Expand All @@ -711,6 +713,27 @@ macro(tribits_postprocess_package_with_subpackages_enables PACKAGE_NAME)
endmacro()


# Set <ParentPackage>_ENABLE_<SubPackage>=ON if not already enabled for all
# subpackages of a parent package.
#
macro(tribits_postprocess_package_with_subpackages_optional_subpackage_enables
PACKAGE_NAME
)
#message("TRIBITS_POSTPROCESS_PACKAGE_WITH_SUBPACKAGES_TEST_EXAMPLE_ENABLES '${PACKAGE_NAME}'")
foreach(TRIBITS_SUBPACKAGE ${${PACKAGE_NAME}_SUBPACKAGES})
set(SUBPACKAGE_FULLNAME ${PACKAGE_NAME}${TRIBITS_SUBPACKAGE})
if (${PROJECT_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}
AND "${${PACKAGE_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}}" STREQUAL ""
)
message("-- "
"Setting ${PACKAGE_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}=ON"
" because ${PROJECT_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}=ON")
set(${PACKAGE_NAME}_ENABLE_${SUBPACKAGE_FULLNAME} ON)
endif()
endforeach()
endmacro()


# Set the parent package tests/examples enables if one subpackage is enabled
# and has its tests/examples
#
Expand Down
13 changes: 10 additions & 3 deletions tribits/core/package_arch/TribitsWriteClientExportFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,17 @@ function(tribits_append_dependent_package_config_file_includes packageName)
# Include configurations of dependent packages
string(APPEND configFileStr
"# Include configuration of dependent packages\n")
foreach(depPkg IN LISTS ${packageName}_FULL_ENABLED_DEP_PACKAGES)
set(cmakePkgDir "${pkgConfigFileBaseDir}/${depPkg}")
foreach(depPkg IN LISTS ${packageName}_LIB_REQUIRED_DEP_PACKAGES)
set(cmakeTplDir "${pkgConfigFileBaseDir}/${depPkg}")
string(APPEND configFileStr
"include(\"${cmakePkgDir}/${depPkg}Config.cmake\")\n")
"include(\"${cmakeTplDir}/${depPkg}Config.cmake\")\n")
endforeach()
foreach(depPkg IN LISTS ${packageName}_LIB_OPTIONAL_DEP_PACKAGES)
if (${packageName}_ENABLE_${depPkg})
set(cmakeTplDir "${pkgConfigFileBaseDir}/${depPkg}")
string(APPEND configFileStr
"include(\"${cmakeTplDir}/${depPkg}Config.cmake\")\n")
endif()
endforeach()

# Include configurations of dependent external packages/TPLs
Expand Down

0 comments on commit dde5f41

Please sign in to comment.