Skip to content

Commit

Permalink
Improve printing and documentation on missing packages (TriBITSPub#63)
Browse files Browse the repository at this point in the history
Noticed some of these issues while working on earlier commits.

Some stuff I did here:

* Update documentation for printing about missing packages to include reduced
  tarballs.

* Added another configure case test to
  TribitsExampleProject_NoFortran_reduced_tarball to test only printing notes
  about missing packages (so configure takes place twice and deletes the build
  directory each time).

* Changed logic for when warning about missing packages to not just be when
  setting ${depPkg}_ALLOW_MISSING_EXTERNAL_PACKAGE=TRUE but also for values of
  ${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES not in
  ${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES_ERROR_VALUES_LIST.

* Added prefix "-- " top some "NOTE:" print lines.

* Update TribitsReadAllProjectDepsFilesCreateDepsGraph.cmake unit tests to
  read in info about the TPLs to avoid printing about missing external
  packages/tpls

* Update the documentation for tribits_process_tpls_lists() and
  tribits_process_packages_and_dirs_lists() to correctly describe usage.
  • Loading branch information
bartlettroscoe committed Oct 10, 2023
1 parent a9eb92e commit 15d655f
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 36 deletions.
33 changes: 31 additions & 2 deletions test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ tribits_add_advanced_test( TribitsExampleProject_NoFortran_reduced_tarball
ARGS -E make_directory tribitsexproj-1.1-Source/packages/mixed_lang

TEST_5
MESSAGE "Configure from the untarred reduced source tree"
MESSAGE "Configure from the untarred reduced source tree warning about missing packages and test tribits_disable_optional_dependency()"
WORKING_DIRECTORY BUILD2
CMND ${CMAKE_COMMAND}
ARGS
Expand Down Expand Up @@ -652,6 +652,35 @@ tribits_add_advanced_test( TribitsExampleProject_NoFortran_reduced_tarball
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_6
MESSAGE "Configure from the untarred reduced source tree only noting missing packages to test that"
WORKING_DIRECTORY BUILD2
CMND ${CMAKE_COMMAND}
ARGS
${TribitsExampleProject_COMMON_CONFIG_ARGS}
-DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DTribitsExProj_ENABLE_Fortran=OFF
-DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON
-DTribitsExProj_ENABLE_ALL_PACKAGES=ON
-DTribitsExProj_ENABLE_TESTS=ON
-DTribitsExProj_ASSERT_DEFINED_DEPENDENCIES=OFF
-DTribitsExProj_WARN_ABOUT_MISSING_EXTERNAL_PACKAGES=ON
../tribitsexproj-1.1-Source
PASS_REGULAR_EXPRESSION_ALL
"-- NOTE: InsertedPkg is being ignored since its directory is missing and InsertedPkg_ALLOW_MISSING_EXTERNAL_PACKAGE = TRUE"
"-- NOTE: MixedLang is being ignored since its directory is missing and TribitsExProj_ASSERT_DEFINED_DEPENDENCIES = OFF"
"Final set of enabled top-level packages: SimpleCxx WithSubpackages 2"
"Final set of enabled packages: SimpleCxx WithSubpackagesA WithSubpackagesB WithSubpackages 4"
"Final set of non-enabled top-level packages: 0"
"Final set of non-enabled packages: 0"
"Processing enabled top-level package: SimpleCxx [(]Libs, Tests, Examples[)]"
"Processing enabled top-level package: WithSubpackages [(]A, B, Tests, Examples[)]"
"-- Configuring done"
"-- Generating done"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_7
MESSAGE "Build reduced project default 'all' target using raw 'make'"
WORKING_DIRECTORY BUILD2
SKIP_CLEAN_WORKING_DIRECTORY
Expand All @@ -662,7 +691,7 @@ tribits_add_advanced_test( TribitsExampleProject_NoFortran_reduced_tarball
"Built target pws_b"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_7
TEST_8
MESSAGE "Run all the tests in reduced project with raw 'ctest'"
WORKING_DIRECTORY BUILD2
SKIP_CLEAN_WORKING_DIRECTORY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,19 @@ set(${PROJECT_NAME}_EXTRA_REPOSITORIES extraRepoTwoPackages)
# For running other lower-level functions

set(REPOSITORY_NAME "Trilinos")
set(${REPOSITORY_NAME}_TPLS_FILE
${CMAKE_CURRENT_LIST_DIR}/MiniMockTrilinosFiles/TPLsList.cmake)
include(${${REPOSITORY_NAME}_TPLS_FILE})

include(${CMAKE_CURRENT_LIST_DIR}/MiniMockTrilinosFiles/PackagesList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/MiniMockTrilinosFiles/TPLsList.cmake)

set(EXTRA_REPO_NAME extraRepoTwoPackages)
set(EXTRA_REPO_DIR extraRepoTwoPackages)

set(REPOSITORY_NAME ${EXTRA_REPO_NAME})
include(${PROJECT_SOURCE_DIR}/${EXTRA_REPO_NAME}/PackagesList.cmake)

set(${EXTRA_REPO_NAME}_TPLS_FINDMODS_CLASSIFICATIONS)
set(${EXTRA_REPO_NAME}_TPLS_FINDMODS_CLASSIFICATIONS "")

set(${PROJECT_NAME}_ALL_REPOSITORIES "." "${EXTRA_REPO_NAME}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ function(unittest_extra_repo_missing_optional_package)
#set(TRIBITS_PROCESS_PACKAGES_AND_DIRS_LISTS ON)
#set(${PROJECT_NAME}_VERBOSE_CONFIGURE ON)

tribits_process_tpls_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${EXTRA_REPO_NAME} ${EXTRA_REPO_DIR})

Expand Down Expand Up @@ -617,14 +618,15 @@ function(unittest_extra_repo_missing_optional_package_verbose)
#set(TRIBITS_PROCESS_PACKAGES_AND_DIRS_LISTS ON)
#set(${PROJECT_NAME}_VERBOSE_CONFIGURE ON)

tribits_process_tpls_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${EXTRA_REPO_NAME} ${EXTRA_REPO_DIR})

global_set(MESSAGE_WRAPPER_INPUT)
global_set(MESSAGE_WRAPPER_INPUT)
tribits_read_deps_files_create_deps_graph()

unittest_compare_const(MESSAGE_WRAPPER_INPUT
"NOTE: MissingUpstreamPackage is being ignored since its directory; is missing and MissingUpstreamPackage_ALLOW_MISSING_EXTERNAL_PACKAGE =; TRUE!;-- ;Trilinos_NUM_DEFINED_INTERNAL_PACKAGES='4'")
"-- NOTE: MissingUpstreamPackage is being ignored since its directory; is missing and MissingUpstreamPackage_ALLOW_MISSING_EXTERNAL_PACKAGE =; TRUE!;-- ;Trilinos_NUM_DEFINED_INTERNAL_PACKAGES='4'")
unittest_compare_const( ${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES
"Teuchos;RTOp;Ex2Package1;Ex2Package2")
unittest_compare_const(${PROJECT_NAME}_ENABLE_Ex2Package1 "")
Expand All @@ -646,14 +648,15 @@ function(unittest_extra_repo_missing_required_package)
#set(TRIBITS_PROCESS_PACKAGES_AND_DIRS_LISTS ON)
#set(${PROJECT_NAME}_VERBOSE_CONFIGURE ON)

tribits_process_tpls_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${EXTRA_REPO_NAME} ${EXTRA_REPO_DIR})

global_set(MESSAGE_WRAPPER_INPUT)
global_set(MESSAGE_WRAPPER_INPUT)
tribits_read_deps_files_create_deps_graph()

unittest_compare_const(MESSAGE_WRAPPER_INPUT
"NOTE: Setting Trilinos_ENABLE_Ex2Package1=OFF because; package Ex2Package1 has a required dependency on missing; package MissingUpstreamPackage!;-- ;Trilinos_NUM_DEFINED_INTERNAL_PACKAGES='4'")
"-- NOTE: Setting Trilinos_ENABLE_Ex2Package1=OFF because; package Ex2Package1 has a required dependency on missing; package MissingUpstreamPackage!;-- ;Trilinos_NUM_DEFINED_INTERNAL_PACKAGES='4'")
unittest_compare_const( ${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES
"Teuchos;RTOp;Ex2Package1;Ex2Package2")
unittest_compare_const(${PROJECT_NAME}_ENABLE_Ex2Package1 OFF)
Expand All @@ -678,14 +681,15 @@ function(unittest_extra_repo_missing_required_package_verbose)
#set(TRIBITS_PROCESS_PACKAGES_AND_DIRS_LISTS ON)
#set(${PROJECT_NAME}_VERBOSE_CONFIGURE ON)

tribits_process_tpls_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${PROJECT_NAME} ".")
tribits_process_packages_and_dirs_lists(${EXTRA_REPO_NAME} ${EXTRA_REPO_DIR})

global_set(MESSAGE_WRAPPER_INPUT)
tribits_read_deps_files_create_deps_graph()

unittest_compare_const(MESSAGE_WRAPPER_INPUT
"NOTE: MissingUpstreamPackage is being ignored since its directory; is missing and MissingUpstreamPackage_ALLOW_MISSING_EXTERNAL_PACKAGE =; TRUE!;NOTE: Setting Trilinos_ENABLE_Ex2Package1=OFF because; package Ex2Package1 has a required dependency on missing; package MissingUpstreamPackage!;-- ;Trilinos_NUM_DEFINED_INTERNAL_PACKAGES='4'")
"-- NOTE: MissingUpstreamPackage is being ignored since its directory; is missing and MissingUpstreamPackage_ALLOW_MISSING_EXTERNAL_PACKAGE =; TRUE!;-- NOTE: Setting Trilinos_ENABLE_Ex2Package1=OFF because; package Ex2Package1 has a required dependency on missing; package MissingUpstreamPackage!;-- ;Trilinos_NUM_DEFINED_INTERNAL_PACKAGES='4'")
unittest_compare_const( ${PROJECT_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES
"Teuchos;RTOp;Ex2Package1;Ex2Package2")
unittest_compare_const(${PROJECT_NAME}_ENABLE_Ex2Package1 OFF)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,13 @@ endfunction()

# @MACRO: tribits_process_packages_and_dirs_lists()
#
# Read in a list of packages and basic info info
#
# Usage::
#
# tribits_process_packages_and_dirs_lists()
# tribits_process_packages_and_dirs_lists(<repoName> <repoDir>)
#
# Macro that processes the list variable::
# This macro processes the list variable::
#
# ${REPOSITORY_NAME}_PACKAGES_AND_DIRS_AND_CLASSIFICATIONS
#
Expand Down
14 changes: 11 additions & 3 deletions tribits/core/package_arch/TribitsProcessTplsLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,24 @@ endmacro()

# @MACRO: tribits_process_tpls_lists()
#
# This macro that processes the project-level variable::
# Reads in the list of external packages/TPLs and the location of there
# definition files.
#
# Usage::
#
# tribits_process_tpls_lists(<repoName> <repoDir>)
#
# This macro processes the project-level variable::
#
# ${REPOSITORY_NAME}_TPLS_FINDMODS_CLASSIFICATIONS
#
# This updates the project-level variables:
# from a `<repoDir>/TPLsList.cmake` file that just got read in and updates the
# project-level non-cache variables:
#
# * `${PROJECT_NAME}_DEFINED_TPLS`_
# * `${PROJECT_NAME}_NUM_DEFINED_TPLS`_
#
# For each TPL, it also sets the variables:
# For each external package/TPL, it also sets the variables:
#
# * `${TPL_NAME}_FINDMOD`_
# * `${TPL_NAME}_TESTGROUP`_
Expand Down
43 changes: 30 additions & 13 deletions tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -571,22 +571,19 @@ macro(tribits_set_dep_packages__handle_undefined_pkg packageName depPkg
if (errorOutForUndefinedDepPkg)
tribits_abort_on_missing_package("${depPkg}" "${packageName}")
else()
if (${depPkg}_ALLOW_MISSING_EXTERNAL_PACKAGE)
if (${PROJECT_NAME}_WARN_ABOUT_MISSING_EXTERNAL_PACKAGES)
message_wrapper("NOTE: ${depPkg} is being ignored since its directory"
" is missing and ${depPkg}_ALLOW_MISSING_EXTERNAL_PACKAGE ="
" ${${depPkg}_ALLOW_MISSING_EXTERNAL_PACKAGE}!")
endif()
if ("${requiredOrOptional}" STREQUAL "REQUIRED")
message_wrapper("NOTE: Setting ${packageEnableVar}=OFF because"
" package ${packageName} has a required dependency on missing"
" package ${depPkg}!")
set(${packageEnableVar} OFF)
endif()
tribits_warn_about_ignored_missing_pkg_dep("${packageName}" "${depPkg}"
"${requiredOrOptional}" "${packageEnableVar}" )
# Must set the package itself off if it is a required dependency
if ("${requiredOrOptional}" STREQUAL "REQUIRED")
message_wrapper("-- NOTE: Setting ${packageEnableVar}=OFF because"
" package ${packageName} has a required dependency on missing"
" package ${depPkg}!")
set(${packageEnableVar} OFF)
endif()
# Must set enable vars for missing package to off so that logic in
# existing downstream packages that key off of these vars will still
# work.
# work. (NOTE: If this is a required dependency, it is also good to set
# these to off as well and not incorrect.)
set(${PROJECT_NAME}_ENABLE_${depPkg} OFF)
set(${packageName}_ENABLE_${depPkg} OFF)
tribits_get_have_package_dependency_macro_name(${packageName} ${depPkg}
Expand All @@ -596,6 +593,26 @@ macro(tribits_set_dep_packages__handle_undefined_pkg packageName depPkg
endmacro()


function(tribits_warn_about_ignored_missing_pkg_dep packageName depPkg
requiredOrOptional packageEnableVar
)
# message_wrapper("\ntribits_warn_about_ignored_missing_pkg_dep('${packageName}' '${depPkg}' '${requiredOrOptional}' '${packageEnableVar}')")
if (${PROJECT_NAME}_WARN_ABOUT_MISSING_EXTERNAL_PACKAGES)
if (${depPkg}_ALLOW_MISSING_EXTERNAL_PACKAGE)
message_wrapper("-- NOTE: ${depPkg} is being ignored since its directory"
" is missing and ${depPkg}_ALLOW_MISSING_EXTERNAL_PACKAGE ="
" ${${depPkg}_ALLOW_MISSING_EXTERNAL_PACKAGE}!")
elseif (NOT ${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES IN_LIST
${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES_ERROR_VALUES_LIST
)
message_wrapper("-- NOTE: ${depPkg} is being ignored since its directory"
" is missing and ${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES ="
" ${${PROJECT_NAME}_ASSERT_DEFINED_DEPENDENCIES}!")
endif()
endif()
endfunction()


# @MACRO: tribits_append_forward_dep_packages()
#
# Appends forward/downstream package dependency lists for the upstream
Expand Down
20 changes: 11 additions & 9 deletions tribits/doc/build_ref/TribitsBuildReferenceBody.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3023,9 +3023,9 @@ One of the CMake configure-time debug-mode checks performed as part of
``<Project>_ENABLE_DEVELOPMENT_MODE=ON`` is to assert the existence of TriBITS
package directories. In development mode, the failure to find a package
directory is usually a programming error (i.e. a miss-spelled package
directory name). But in a tarball release of the project, package directories
may be purposefully missing (see `Creating a tarball of the source tree`_) and
must be ignored.
directory name). But in a reduced tarball release of the project, package
directories may be purposefully missing (see `Creating a tarball of the source
tree`_) and must be ignored.

When building from a reduced source tarball created from the
development sources, set::
Expand All @@ -3043,15 +3043,17 @@ Another type of checking is for optional inserted/external packages
(e.g. packages who's source can optionally be included and is flagged with
``tribits_allow_missing_external_packages()``). Any of these package
directories that are missing result in the packages being silently ignored by
default. However, notes on what missing packages are being ignored can
printed by configuring with::
default. Also, when there are packages that are purposefully missing in a
reduced tarball build (which are allowed by setting
``<Project>_ASSERT_DEFINED_DEPENDENCIES=OFF``), these are also silently
ignored. However, notes on which of these packages are missing can be printed
to the CMAKE STDOUT by setting::

-D <Project>_WARN_ABOUT_MISSING_EXTERNAL_PACKAGES=TRUE

These warnings starting with 'NOTE' (not starting with 'WARNING' that would
otherwise trigger warnings in CDash) about missing inserted/external packages
will print regardless of the setting for
``<Project>_ASSERT_DEFINED_DEPENDENCIES``.
These STDOUT lines starting with 'NOTE' (not starting with 'WARNING' that
would otherwise trigger warnings in CDash) about missing packages will print
regardless of the setting for ``<Project>_ASSERT_DEFINED_DEPENDENCIES``.

Finally, ``<Project>_ENABLE_DEVELOPMENT_MODE=ON`` results in a number of
checks for invalid usage of TriBITS in the project's ``CMakeLists.txt`` files
Expand Down

0 comments on commit 15d655f

Please sign in to comment.