Skip to content

Commit

Permalink
Add special handling for fully TriBITS-compliant external packages (#63)
Browse files Browse the repository at this point in the history
Now we don't need to find upstream TPLs already found in upstream TriBITS
package configure and build.  In this case, we don't need to find
HeaderOnlyTpl or SimpleTpl already found in the configure and build of
SimpleCxx.
  • Loading branch information
bartlettroscoe committed Jan 27, 2023
1 parent d3353b6 commit 2baeb7e
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 68 deletions.
19 changes: 9 additions & 10 deletions test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2569,7 +2569,7 @@ tribits_add_advanced_test( TribitsExampleProject_HeaderOnlyTpl_FailThenPass
"When you reconfigure, just grep the cmake stdout for 'HeaderOnlyTpl'"
"and then follow the disables that occur as a result to see what impact"
"this TPL disable has on the configuration of TribitsExProj."
"CMake Error at .+/TribitsProcessEnabledTpl[.]cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
" ERROR: TPL_HeaderOnlyTpl_NOT_FOUND=TRUE, aborting!"
"Call Stack .most recent call first.:"
"-- Configuring incomplete, errors occurred!"
Expand Down Expand Up @@ -2624,7 +2624,7 @@ tribits_add_advanced_test( TribitsExampleProject_HeaderOnlyTpl_HardEnable_Fail
"and then follow the disables that occur as a result to see what impact"
"this TPL disable has on the configuration of TribitsExProj."
"-- ERROR: Failed finding all of the parts of TPL 'HeaderOnlyTpl' .see above., Aborting!"
"CMake Error at .+/TribitsProcessEnabledTpl[.]cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
" ERROR: TPL_HeaderOnlyTpl_NOT_FOUND=TRUE, aborting!"
"Call Stack .most recent call first.:"
"-- Configuring incomplete, errors occurred!"
Expand Down Expand Up @@ -3293,14 +3293,12 @@ tribits_add_advanced_test( TribitsExampleProject_SimpleCxx_External
-DCMAKE_PREFIX_PATH=../install/simple_cxx
-DTPL_ENABLE_MPI=OFF
-DTPL_ENABLE_SimpleTpl=ON
-DSimpleTpl_INCLUDE_DIRS=${SimpleTpl_install_STATIC_DIR}/install/include
-DSimpleTpl_LIBRARY_DIRS=${SimpleTpl_install_STATIC_DIR}/install/lib
# ToDo: Remove how to find SimpleTpl because SimpleCxx should already
# have that found and we should just use what it found!
../TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Adjust the set of internal and external packages:"
"-- Treating internal package SimpleCxx as EXTERNAL because TPL_ENABLE_SimpleCxx=ON"
"-- NOTE: HeaderOnlyTpl is directly downstream from an fully TriBITS-compatible external package SimpleCxx"
"-- NOTE: SimpleTpl is directly downstream from an fully TriBITS-compatible external package SimpleCxx"

"Final set of enabled top-level packages: MixedLang WithSubpackages WrapExternal 3"
"Final set of enabled packages: MixedLang WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages WrapExternal 6"
Expand All @@ -3311,15 +3309,16 @@ tribits_add_advanced_test( TribitsExampleProject_SimpleCxx_External
"Final set of non-enabled top-level external packages/TPLs: MPI 1"
"Final set of non-enabled external packages/TPLs: MPI 1"

"Getting information for all enabled external packages/TPLs ..."
"Getting information for all enabled fully TriBITS-compatible or upstream external packages/TPLs ..."
"Processing enabled external package/TPL: HeaderOnlyTpl [(]enabled by SimpleCxx, disable with -DTPL_ENABLE_HeaderOnlyTpl=OFF[)]"
"-- TPL_HeaderOnlyTpl_INCLUDE_DIRS='.*/tribits/examples/tpls/HeaderOnlyTpl'"
"-- The external package/TPL HeaderOnlyTpl will be read in by a downstream fully TriBITS-compliant external package"
"Processing enabled external package/TPL: SimpleTpl [(]enabled explicitly, disable with -DTPL_ENABLE_SimpleTpl=OFF[)]"
"-- TPL_SimpleTpl_LIBRARIES='.*/TriBITS_SimpleTpl_install_STATIC/install/lib/libsimpletpl.a'"
"-- TPL_SimpleTpl_INCLUDE_DIRS='.*/TriBITS_SimpleTpl_install_STATIC/install/include'"
"-- The external package/TPL SimpleTpl will be read in by a downstream fully TriBITS-compliant external package"
"Processing enabled external package/TPL: SimpleCxx [(]enabled explicitly, disable with -DTPL_ENABLE_SimpleCxx=OFF[)]"
"-- Calling find_package[(]SimpleCxx[)] for TriBITS-compatible package ..."

"Getting information for all enabled external packages/TPLs ..."

"Configuring individual enabled TribitsExProj packages ..."
"Processing enabled top-level package: MixedLang [(]Libs, Tests, Examples[)]"
"Processing enabled top-level package: WithSubpackages [(]A, B, C, Tests, Examples[)]"
Expand Down
18 changes: 9 additions & 9 deletions test/core/ProcessEnabledTpls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ create_process_enabled_tpls_test_case(
"When you reconfigure, just grep the cmake stdout for 'HeaderOnlyTpl'"
"and then follow the disables that occur as a result to see what impact"
"this TPL disable has on the configuration of DummyProj."
"CMake Error at .+/TribitsProcessEnabledTpl[.]cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeaderOnlyTpl_NOT_FOUND=TRUE, aborting!"
)

Expand All @@ -244,7 +244,7 @@ create_process_enabled_tpls_test_case(
"and then follow the disables that occur as a result to see what impact"
"this TPL disable has on the configuration of ${MOCK_PROJECT_NAME}."
"-- ERROR: Failed finding all of the parts of TPL 'HeaderOnlyTpl' .see above., Aborting!"
"CMake Error at .+/TribitsProcessEnabledTpl[.]cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeaderOnlyTpl_NOT_FOUND=TRUE, aborting!"
)

Expand Down Expand Up @@ -481,7 +481,7 @@ create_process_enabled_tpls_test_case(
"When you reconfigure, just grep the cmake stdout for 'HeadersAndLibsTpl'"
"and then follow the disables that occur as a result to see what impact"
"this TPL disable has on the configuration of DummyProj."
"CMake Error at .+/TribitsProcessEnabledTpl.cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeadersAndLibsTpl_NOT_FOUND=TRUE, aborting!"
)

Expand All @@ -503,7 +503,7 @@ create_process_enabled_tpls_test_case(
"-- TIP: If the TPL 'HeadersAndLibsTpl' is on your system then you can set:"
"-- ERROR: Failed finding all of the parts of TPL 'HeadersAndLibsTpl' .see above., Aborting!"
"TIP: One way to get past the configure failure for the"
"CMake Error at .+/TribitsProcessEnabledTpl.cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeadersAndLibsTpl_NOT_FOUND=TRUE, aborting!"
)

Expand All @@ -526,7 +526,7 @@ create_process_enabled_tpls_test_case(
"-- TIP: If the TPL 'HeadersAndLibsTpl' is on your system then you can set:"
"-- ERROR: Failed finding all of the parts of TPL 'HeadersAndLibsTpl' .see above., Aborting!"
"TIP: One way to get past the configure failure for the"
"CMake Error at .+/TribitsProcessEnabledTpl.cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeadersAndLibsTpl_NOT_FOUND=TRUE, aborting!"
)

Expand All @@ -545,7 +545,7 @@ create_process_enabled_tpls_test_case(
"-- Searching for libs in HeadersAndLibsTpl_LIBRARY_DIRS='.+/HeadersAndLibsTpl/lib'"
"-- Searching for a lib in the set .badlibname.:"
"-- NOTE: Did not find a lib in the lib set .badlibname. for the TPL 'HeadersAndLibsTpl'!"
"CMake Error at .+/TribitsProcessEnabledTpl.cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeadersAndLibsTpl_NOT_FOUND=TRUE, aborting!"
)

Expand All @@ -563,7 +563,7 @@ create_process_enabled_tpls_test_case(
"-- Searching for libs in HeadersAndLibsTpl_LIBRARY_DIRS='.+/HeadersAndLibsTpl/lib'"
"-- Searching for a lib in the set .badlibname.:"
"-- ERROR: Did not find a lib in the lib set .badlibname. for the TPL 'HeadersAndLibsTpl'!"
"CMake Error at .+/TribitsProcessEnabledTpl.cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeadersAndLibsTpl_NOT_FOUND=TRUE, aborting!"
)

Expand Down Expand Up @@ -603,7 +603,7 @@ create_process_enabled_tpls_test_case(
"-- Searching for libs in HeadersAndLibsTpl_LIBRARY_DIRS='.+/HeadersAndLibsTpl/lib'"
"-- Searching for a lib in the set .badlibname.:"
"-- ERROR: Did not find a lib in the lib set .badlibname. for the TPL 'HeadersAndLibsTpl'!"
"CMake Error at .+/TribitsProcessEnabledTpl.cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeadersAndLibsTpl_NOT_FOUND=TRUE, aborting!"
)

Expand All @@ -626,7 +626,7 @@ create_process_enabled_tpls_test_case(
"-- TIP: If the TPL 'HeadersAndLibsTpl' is on your system then you can set:"
"-- ERROR: Failed finding all of the parts of TPL 'HeadersAndLibsTpl' .see above., Aborting!"
"TIP: Even though the TPL 'HeadersAndLibsTpl' was explicitly enabled in input,"
"CMake Error at .+/TribitsProcessEnabledTpl.cmake:[0-9]+ [(]message[)]:"
"CMake Error at .+/TribitsProcessEnabledTpls[.]cmake:[0-9]+ [(]message[)]:"
"ERROR: TPL_HeadersAndLibsTpl_NOT_FOUND=TRUE, aborting!"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ set( CMAKE_MODULE_PATH
"${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch"
)

include(TribitsProcessEnabledTpl)
include(TribitsProcessEnabledTpls)

# Passed in on command-line
print_var("TPL_NAME")
Expand All @@ -72,7 +72,7 @@ endif()

# Do the processing of the TPL
message("")
tribits_process_enabled_tpl(${TPL_NAME})
tribits_process_enabled_standard_tpl(${TPL_NAME})
message("")
message("Exported TPL_ENABLE_${TPL_NAME}='${TPL_ENABLE_${TPL_NAME}}'")
message("Exported TPL_${TPL_NAME}_NOT_FOUND='${TPL_${TPL_NAME}_NOT_FOUND}'")
Expand Down
72 changes: 63 additions & 9 deletions tribits/core/package_arch/TribitsAdjustPackageEnables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,11 @@ macro(tribits_set_package_and_related_upstream_packages_to_external packageName
tribits_set_upstream_dep_packages_as_external(${packageName}
${subpackageTriggeredParentPackageExternal})

if (${packageName}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL")
tribits_set_package_and_deps_as_processed_by_downstream_tribits_external_package(
${packageName})
endif()

endmacro()
# NOTE: In the above macro, if ${packageName} is made EXTERNAL because it one
# of its subpackages is considered EXTERNAL, then the loop over all of the
Expand Down Expand Up @@ -1315,6 +1320,48 @@ macro(tribits_set_upstream_dep_packages_as_external packageName
endmacro()


# Macro that sets all of the direct upstream dependent packages as being
# processed by a downstream fully TriBITS compliant external package.
macro(tribits_set_package_and_deps_as_processed_by_downstream_tribits_external_package
packageName
)

if ("${${packageName}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE}"
STREQUAL ""
)
set(${packageName}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE FALSE)
endif()

tribits_get_package_enable_status(${packageName} packageEnable "")

if (${packageName}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL"
AND (${packageName}_IS_FULLY_TRIBITS_COMPLIANT
OR ${packageName}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE)
)

if (${packageName}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE)
set(directOrIndirectStr "indirectly")
set(downstreamPkgStr "")
else()
set(directOrIndirectStr "directly")
set(downstreamPkgStr " ${packageName}")
endif()

foreach(depPkg IN LISTS ${packageName}_LIB_DEFINED_DEPENDENCIES)
tribits_get_package_enable_status(${depPkg} depPkgEnable "")
if (depPkgEnable)
message("-- "
"NOTE: ${depPkg} is ${directOrIndirectStr} downstream from an fully"
" TriBITS-compatible external package${downstreamPkgStr}")
endif()
set(${depPkg}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE TRUE)
endforeach()

endif()

endmacro()


# Macro that sets ``<ParentPackage>_ENABLE_<SubPackage>=ON`` if not already
# enabled for all enabled subpackages of a parent package.
#
Expand Down Expand Up @@ -1360,21 +1407,28 @@ endmacro()
#
# Usage::
#
# tribits_set_internal_package_to_external(<packageName> "<becauseMsg1>"
# tribits_set_internal_package_to_external(<depPkgName> "<becauseMsg1>"
# "<becauseMsg2>" ...)
#
# This always sets ``<packageName>_PACKAGE_BUILD_STATUS=EXTERNAL`` but only
# prints the message if ``<packageName>`` is enabled.
# This always sets ``<depPkgName>_PACKAGE_BUILD_STATUS=EXTERNAL`` but only
# prints the message if ``<depPkgName>`` is enabled.
#
macro(tribits_set_internal_package_to_external packageName)
tribits_get_package_enable_status(${packageName} packageEnable packageEnableVar)
if (packageEnable)
macro(tribits_set_internal_package_to_external depPkgName)
tribits_get_package_enable_status(${depPkgName} depPkgEnable "")
if (depPkgEnable)
message("-- "
"Treating internal package ${packageName} as EXTERNAL because"
"Treating internal package ${depPkgName} as EXTERNAL because"
" " ${ARGN})
endif()
set(${packageName}_PACKAGE_BUILD_STATUS EXTERNAL)
set(${packageName}_FINDMOD TRIBITS_PKG)
set(${depPkgName}_PACKAGE_BUILD_STATUS EXTERNAL)
set(${depPkgName}_FINDMOD TRIBITS_PKG)
endmacro()


macro(tribits_set_as_processed_by_downstream_tribits_external_package packageName
depPkgName
)

endmacro()


Expand Down
19 changes: 0 additions & 19 deletions tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1482,25 +1482,6 @@ macro(tribits_handle_project_extra_link_flags_as_a_tpl)
endmacro()


# Gather information from enabled TPLs
#
macro(tribits_process_enabled_tpls)

tribits_config_code_start_timer(CONFIGURE_TPLS_TIME_START_SECONDS)

tribits_filter_package_list_from_var(${PROJECT_NAME}_DEFINED_TOPLEVEL_PACKAGES
EXTERNAL ON NONEMPTY ${PROJECT_NAME}_enabledExternalTopLevelPackages)

foreach(TPL_NAME IN LISTS ${PROJECT_NAME}_enabledExternalTopLevelPackages)
tribits_process_enabled_tpl(${TPL_NAME})
endforeach()

tribits_config_code_stop_timer(CONFIGURE_TPLS_TIME_START_SECONDS
"\nTotal time to configure enabled external packages/TPLs")

endmacro()


#
# Macros for setting up the standard environment
#
Expand Down
74 changes: 64 additions & 10 deletions tribits/core/package_arch/TribitsProcessEnabledTpls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,69 @@ include(AppendStringVar)
include(TribitsStandardizePaths)


# @MACRO: tribits_process_enabled_tpl()
# Gather information from enabled TPLs
#
macro(tribits_process_enabled_tpls)

tribits_config_code_start_timer(CONFIGURE_TPLS_TIME_START_SECONDS)

tribits_filter_package_list_from_var(${PROJECT_NAME}_DEFINED_TOPLEVEL_PACKAGES
EXTERNAL ON NONEMPTY ${PROJECT_NAME}_enabledExternalTopLevelPackages)

message("")
message("Getting information for all enabled fully TriBITS-compatible"
" or upstream external packages/TPLs ...")
message("")

foreach(TPL_NAME IN LISTS ${PROJECT_NAME}_enabledExternalTopLevelPackages)
if (${TPL_NAME}_IS_FULLY_TRIBITS_COMPLIANT
OR ${TPL_NAME}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE
)
tribits_process_enabled_fully_tribits_compatible_or_upstream_tpl(${TPL_NAME})
endif()
endforeach()

message("")
message("Getting information for all enabled external packages/TPLs ...")
message("")

foreach(TPL_NAME IN LISTS ${PROJECT_NAME}_enabledExternalTopLevelPackages)
if ((NOT ${TPL_NAME}_IS_FULLY_TRIBITS_COMPLIANT)
AND (NOT ${TPL_NAME}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE)
)
tribits_process_enabled_standard_tpl(${TPL_NAME})
endif()
endforeach()

tribits_config_code_stop_timer(CONFIGURE_TPLS_TIME_START_SECONDS
"\nTotal time to configure enabled external packages/TPLs")

endmacro()


macro(tribits_process_enabled_fully_tribits_compatible_or_upstream_tpl TPL_NAME)

tribits_get_enabled_tpl_processing_string(${TPL_NAME} tplProcessingString)
message("${tplProcessingString}")

if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY)
if (NOT ${TPL_NAME}_PROCESSED_BY_DOWNSTREAM_TRIBITS_EXTERNAL_PACKAGE)
tribits_process_enabled_tribits_compatible_tpl(${TPL_NAME})
else()
message("-- "
"The external package/TPL ${TPL_NAME} will be read in by a downstream"
" fully TriBITS-compliant external package")
endif()
endif()

endmacro()


# @MACRO: tribits_process_enabled_standard_tpl()
#
# Process an enabled TPL's FindTPL${TPL_NAME}.cmake module.
#
macro(tribits_process_enabled_tpl TPL_NAME)
macro(tribits_process_enabled_standard_tpl TPL_NAME)

tribits_get_enabled_tpl_processing_string(${TPL_NAME} tplProcessingString)
message("${tplProcessingString}")
Expand All @@ -65,14 +123,10 @@ macro(tribits_process_enabled_tpl TPL_NAME)
print_var(${TPL_NAME}_FINDMOD)
endif()

if (${TPL_NAME}_FINDMOD STREQUAL "TRIBITS_PKG")
tribits_process_enabled_tribits_compatible_tpl(${TPL_NAME})
else()
tribits_process_enabled_tribits_find_tpl_mod_file(${TPL_NAME})
tribits_address_failed_tpl_find(${TPL_NAME})
tribits_generate_tpl_version_file_and_add_package_config_install_targets(
${TPL_NAME})
endif()
tribits_process_enabled_tribits_find_tpl_mod_file(${TPL_NAME})
tribits_address_failed_tpl_find(${TPL_NAME})
tribits_generate_tpl_version_file_and_add_package_config_install_targets(
${TPL_NAME})

endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ macro(tribits_process_packages_and_dirs_lists REPOSITORY_NAME REPOSITORY_DIR)
set(${TRIBITS_PACKAGE}_PARENT_REPOSITORY ${REPOSITORY_NAME})
tribits_insert_standard_package_options(${TRIBITS_PACKAGE} ${PACKAGE_TESTGROUP})
set(${TRIBITS_PACKAGE}_PACKAGE_BUILD_STATUS INTERNAL)
set(${TRIBITS_PACKAGE}_IS_FULLY_TRIBITS_COMPLIANT TRUE)
else()
if (${PROJECT_NAME}_VERBOSE_CONFIGURE)
message(
Expand All @@ -593,6 +594,7 @@ macro(tribits_process_packages_and_dirs_lists REPOSITORY_NAME REPOSITORY_DIR)
print_var(${TRIBITS_PACKAGE}_PARENT_PACKAGE)
print_var(${TRIBITS_PACKAGE}_PARENT_REPOSITORY)
print_var(${TRIBITS_PACKAGE}_PACKAGE_BUILD_STATUS)
print_var(${TRIBITS_PACKAGE}_IS_FULLY_TRIBITS_COMPLIANT)
endif()

if (TRIBITS_PROCESS_PACKAGES_AND_DIRS_LISTS_VERBOSE)
Expand Down
Loading

0 comments on commit 2baeb7e

Please sign in to comment.