Skip to content

Commit

Permalink
Merge pull request #12320 from bartlettroscoe/tribits-582-raw-cmake-t…
Browse files Browse the repository at this point in the history
…ribits

Bring in TriBITS snapshot 2023-09-22
  • Loading branch information
bartlettroscoe authored Sep 26, 2023
2 parents 30ce954 + cb8e964 commit 5806afd
Show file tree
Hide file tree
Showing 60 changed files with 866 additions and 258 deletions.
53 changes: 50 additions & 3 deletions cmake/tribits/README.DIRECTORY_CONTENTS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ TriBITS refactorings of TriBITS.

.. _TriBITS Core:

**core/**: Core TriBITS package-based architecture for CMake projects. This
only depends on raw CMake and contains just the minimal support for building,
testing, installing, and deployment. Only depends on CMake and nothing else.
**core/**: Core TriBITS test support and package-based architecture for CMake
projects. This only depends on raw CMake and contains just the minimal support
for building, testing, installing, and deployment. This CMake code depends
only on CMake and nothing else.

**python_utils/**: Some basic Python utilities that are not specific to
TriBITS but are used in TriBITS CI and testing support software. There are
Expand Down Expand Up @@ -86,3 +87,49 @@ subdirectory. It supports the argument ``--components`` with values ``core``,
* ``examples`` => (external tribits installation)
* ``doc`` => ``core``, ``ci_support``, ``examples``
* ``devtools_install`` => ``python_utils``


TriBITS Core Directory Contents
...............................

The TriBITS ``core/`` directory is broken down into several subdirectories of
its own:

**core/utils**: General CMake utilities that are not specific to the TriBITS
system and can be reused in any CMake project.

**core/common**: As small set of common modules that the different TriBITS
Core module files in different directories depend on. These include things
like common TriBITS constants and TriBITS CMake policies.

**core/test_support**: Modules that help define CTest tests using functions
like `tribits_add_test()`_ and `tribits_add_advanced_test()`_. These can be
used in CMake projects that are not full-blown TriBITS projects.

**core/config_tests**: Some basic configure-time tests used by the TriBITS
package architecture framework.

**core/std_tpls**: Some ``Find<tplName>.cmake`` files for key external
dependencies handled as TriBITS TPLs but are more central to the TriBITS
system. (Examples include CUDA and MPI support.)

**core/installation**: A collection of ``*.cmake.in`` and related Cmake code
supporting installations.

**core/package_arch**: Modules for the full-blown TriBITS package architecture
framework including package dependency management, multi-repository support,
installations (including the generation of ``<Package>Config.cmake`` files),
etc.

The dependencies between these different TriBITS `core` subdirectories are:

* ``core/utils`` => (external CMake)
* ``core/common`` => ``core/utils``
* ``core/test_support`` => ``core/utils``, ``core/common``
* ``core/config_tests`` => (external CMake)
* ``core/std_tpls`` => (external CMake)
* ``core/installation`` <=> ``core/package_arch`` (bidirectional)
* ``core/package_arch`` => ``core/utils``, ``core/common``,
``core/test_support``, ``core/config_tests``, ``core/std_tpls``,
``core/installation``

8 changes: 4 additions & 4 deletions cmake/tribits/ci_support/TribitsDumpDepsXmlScript.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ endif()
get_filename_component( ${PROJECT_NAME}_TRIBITS_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE )
message("-- Setting ${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}")

include("${CMAKE_CURRENT_LIST_DIR}/../core/common/TribitsConstants.cmake")
tribits_asesrt_minimum_cmake_version()
include("${CMAKE_CURRENT_LIST_DIR}/../core/common/TribitsCMakePolicies.cmake" NO_POLICY_SCOPE)

set( CMAKE_MODULE_PATH
"${${PROJECT_NAME}_TRIBITS_DIR}/core/utils"
"${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch"
"${${PROJECT_NAME}_TRIBITS_DIR}/ci_support"
)

include(TribitsConstants)
tribits_asesrt_minimum_cmake_version()
include(TribitsCMakePolicies NO_POLICY_SCOPE)

include(TribitsGlobalMacros)
include(TribitsPrintDependencyInfo)
include(TribitsWriteXmlDependenciesFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ set(${PROJECT_NAME}_CHECK_EXTRAREPOS_EXIST ${CHECK_EXTRAREPOS_EXIST})
# B) Include files from TriBITS
#

include("${CMAKE_CURRENT_LIST_DIR}/../core/common/TribitsCMakePolicies.cmake" NO_POLICY_SCOPE)

set( CMAKE_MODULE_PATH
"${${PROJECT_NAME}_TRIBITS_DIR}/core/utils"
"${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch"
)
include(TribitsCMakePolicies NO_POLICY_SCOPE)
include(Split)
include(AppendStringVar)
include(SetDefaultAndFromEnv) # Used in ExtraRepositoriesList.cmake file?
Expand Down
4 changes: 2 additions & 2 deletions cmake/tribits/core/package_arch/TribitsAddExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
# @HEADER


include(TribitsAddExecutableTestHelpers)
include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsAddExecutableTestHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsAddTestHelpers.cmake")
include(TribitsCommonArgsHelpers)
include(TribitsAddTestHelpers)
include(TribitsGeneralMacros)
include(TribitsLibIsTestOnly)
include(TribitsReportInvalidTribitsUsage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
# @HEADER


include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsAddTest.cmake")

include(TribitsAddExecutable)
include(TribitsAddTest)
include(TribitsDeprecatedHelpers)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
# @HEADER


include(TribitsAddTestHelpers)
include(CMakeParseArguments)


Expand Down
25 changes: 12 additions & 13 deletions cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@
# @HEADER

# Standard TriBITS system includes
include(TribitsConstants)

include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsTestCategories.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsAddTestHelpers.cmake")

include(TribitsSetupMPI)
include(TribitsTestCategories)
include(TribitsGeneralMacros)
include(TribitsAddTestHelpers)
include(TribitsVerbosePrintVar)
include(TribitsProcessEnabledTpls)
include(TribitsInstallHeaders)
Expand Down Expand Up @@ -464,13 +467,6 @@ macro(tribits_define_global_options_and_define_extra_repos)
"Make the ${PROJECT_NAME} configure process verbose."
)

if ("${${PROJECT_NAME}_TRACE_ADD_TEST_DEFAULT}" STREQUAL "")
set(${PROJECT_NAME}_TRACE_ADD_TEST_DEFAULT ${${PROJECT_NAME}_VERBOSE_CONFIGURE})
endif()
advanced_set(${PROJECT_NAME}_TRACE_ADD_TEST ${${PROJECT_NAME}_TRACE_ADD_TEST_DEFAULT}
CACHE BOOL
"Show a configure time trace of every test added or not added any why (one line)." )

advanced_option(${PROJECT_NAME}_DUMP_LINK_LIBS
"Dump the link libraries for every library and executable created."
"${${PROJECT_NAME}_VERBOSE_CONFIGURE}" )
Expand Down Expand Up @@ -2072,17 +2068,20 @@ macro(tribits_configure_enabled_packages)
tribits_trace_file_processing(PACKAGE ADD_SUBDIR
"${TRIBITS_PACKAGE_CMAKELIST_FILE}")
if (NOT ${TRIBITS_PACKAGE}_SOURCE_DIR STREQUAL ${PROJECT_NAME}_SOURCE_DIR)
add_subdirectory(${${TRIBITS_PACKAGE}_SOURCE_DIR} ${${TRIBITS_PACKAGE}_BINARY_DIR})
add_subdirectory(${${TRIBITS_PACKAGE}_SOURCE_DIR}
${${TRIBITS_PACKAGE}_BINARY_DIR})
else()
include("${TRIBITS_PACKAGE_CMAKELIST_FILE}")
endif()
if (NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS)
if ((NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS) AND
(NOT TARGET ${PACKAGE_NAME}::all_libs)
)
tribits_report_invalid_tribits_usage(
"ERROR: Forgot to call tribits_package_postprocess() in"
" ${TRIBITS_PACKAGE_CMAKELIST_FILE}")
endif()

list(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}_libs)
list(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}::all_libs)
list(APPEND ${PROJECT_NAME}_LIBRARIES ${${TRIBITS_PACKAGE}_LIBRARIES})

tribits_package_config_code_stop_timer(PROCESS_THIS_PACKAGE_TIME_START_SECONDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ function(tribits_write_package_client_export_files PACKAGE_NAME)

tribits_write_flexible_package_client_export_files(${EXPORT_FILES_ARGS})

tribits_write_package_client_export_files_install_targets(${EXPORT_FILES_ARGS})
tribits_write_package_client_export_files_export_and_install_targets(${EXPORT_FILES_ARGS})

endfunction()


# @FUNCTION: tribits_write_package_client_export_files_install_targets()
# @FUNCTION: tribits_write_package_client_export_files_export_and_install_targets()
#
# Create the ``<Package>ConfigTargets.cmake`` file and install rules and the
# install() target for the previously generated
Expand All @@ -98,7 +98,7 @@ endfunction()
#
# Usage::
#
# tribits_write_package_client_export_files_install_targets(
# tribits_write_package_client_export_files_export_and_install_targets(
# PACKAGE_NAME <packageName>
# PACKAGE_CONFIG_FOR_BUILD_BASE_DIR <packageConfigForBuildBaseDir>
# PACKAGE_CONFIG_FOR_INSTALL_BASE_DIR <packageConfigForInstallBaseDir>
Expand All @@ -107,7 +107,7 @@ endfunction()
# The install() commands must be in a different subroutine or CMake will not
# allow you to call the routine, even if you if() it out!
#
function(tribits_write_package_client_export_files_install_targets)
function(tribits_write_package_client_export_files_export_and_install_targets)

cmake_parse_arguments(
#prefix
Expand Down Expand Up @@ -333,10 +333,10 @@ endfunction()

# @FUNCTION: tribits_write_flexible_package_client_export_files()
#
# Utility function for writing ``${PACKAGE_NAME}Config.cmake`` files for
# package ``${PACKAGE_NAME}`` with some greater flexibility than what is
# provided by the function ``tribits_write_package_client_export_files()`` and
# to allow unit testing the generation of these files..
# Utility function for writing the ``${PACKAGE_NAME}Config.cmake`` files for
# the build dir and/or for the install dir for the package ``<packageName>``
# with some flexibility . (See NOTE below for what is actually generated and
# what is *NOT* generated.)
#
# Usage::
#
Expand All @@ -352,7 +352,8 @@ endfunction()
# ``PACKAGE_NAME <packageName>``
#
# Gives the name of the TriBITS package for which the export files should
# be created.
# be created. (This must match the export set for the libraries for the
# generated/exported ``<packageName>ConfigTargets.cmake`` file.)
#
# ``EXPORT_FILE_VAR_PREFIX <exportFileVarPrefix>``
#
Expand All @@ -362,28 +363,39 @@ endfunction()
#
# ``PACKAGE_CONFIG_FOR_BUILD_BASE_DIR <packageConfigForBuildBaseDir>``
#
# If specified, then the package's ``<packageName>Config.cmake`` file and
# supporting files will be written under the directory
# ``<packageConfigForBuildBaseDir>/`` (and any subdirs that does exist
# will be created). The generated file ``<packageName>Config.cmake`` is
# for usage of the package in the build tree (not the install tree) and
# points to include directories and libraries in the build tree.
# If specified, then the package's ``<packageName>Config.cmake`` file will
# be written under the directory ``<packageConfigForBuildBaseDir>/`` (and
# any subdirs that do not exist will be created). The generated file
# ``<packageName>Config.cmake`` is for usage of the package in the build
# tree (not the install tree) and points to include directories and
# libraries in the build tree. (NOTE: The included
# ``<packageName>Targets.cmake`` file is *NOT* generated in this
# function.)
#
# ``PACKAGE_CONFIG_FOR_INSTALL_BASE_DIR <packageConfigForInstallBaseDir>``
#
# If specified, then the package's ``<packageName>Config_install.cmake``
# file and supporting files will be written under the directory
# ``<packageConfigForInstallBaseDir>/`` (and any subdirs that does exist
# file will be written under the directory
# ``<packageConfigForInstallBaseDir>/`` (and any subdirs that do not exist
# will be created). The file ``${PACKAGE_NAME}Config_install.cmake`` is
# meant to be installed renamed as ``<packageName>Config.cmake`` in the
# install tree and it points to installed include directories and
# libraries.
#
# NOTE: This function does *not* contain any ``install()`` command itself
# because CMake will not allow those to even be present in scripting mode that
# is used for unit testing this function. Instead, the commands to install
# the files are added by the function
# ``tribits_write_package_client_export_files_install_targets()``.
# libraries. (NOTE: The included ``<packageName>Targets.cmake``
# file is *NOT* generated in this function.)
#
# NOTE: This function does *not* generate the ``<packageName>Config.cmake``
# files (which will be created later using ``export()`` or ``include()`) which
# are included in these generated package config files and this function.
# Also, this function does *not* invoke the ``install()`` command to install
# the package config file for the install directory. The ``export()`` and
# ``install()`` project commands are bot allowed in `cmake -P` scripting mode
# that is used for unit testing this function. Instead, the commands to
# generate the ``<packageName>Targets.cmake`` files and install the package
# config file for the install tree are produced by the function
# ``tribits_write_package_client_export_files_export_and_install_targets()``
# which is called after this function. This allows this function
# ``tribits_write_package_client_export_files()`` to be run in unit testing
# with a `cmake -P` script.
#
function(tribits_write_flexible_package_client_export_files)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@

include_guard()

include(TribitsCMakePolicies NO_POLICY_SCOPE)
include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsCMakePolicies.cmake"
NO_POLICY_SCOPE)

include(TribitsParseArgumentsHelpers)
include(MessageWrapper)
Expand Down
5 changes: 3 additions & 2 deletions cmake/tribits/core/package_arch/TribitsPackageMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ include(PrependGlobalSet)
include(RemoveGlobalDuplicates)
include(TribitsGatherBuildTargets)

include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsAddTest.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsAddAdvancedTest.cmake")

include(TribitsAddOptionAndDefine)
include(TribitsPkgExportCacheVars)
include(TribitsLibraryMacros)
include(TribitsAddExecutable)
include(TribitsAddExecutableAndTest)
include(TribitsAddTest)
include(TribitsAddAdvancedTest)
include(TribitsCopyFilesToBinaryDir)
include(TribitsReportInvalidTribitsUsage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# @HEADER


include(TribitsConstants)
include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake")
include(TribitsListHelpers)

include(PrintVar)
Expand Down
2 changes: 1 addition & 1 deletion cmake/tribits/core/package_arch/TribitsProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (${PROJECT_NAME}_VERBOSE_CONFIGURE)
endif()

# Overrides that we have for CMake functions
include(TribitsCMakePolicies NO_POLICY_SCOPE)
include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsCMakePolicies.cmake" NO_POLICY_SCOPE)
include(TribitsProjectImpl)


Expand Down
6 changes: 4 additions & 2 deletions cmake/tribits/core/package_arch/TribitsProjectImpl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cmake
${${PROJECT_NAME}_TRIBITS_DIR}/core/utils
${${PROJECT_NAME}_TRIBITS_DIR}/core/common
${${PROJECT_NAME}_TRIBITS_DIR}/core/test_support
${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch
${${PROJECT_NAME}_TRIBITS_DIR}/core/config_tests
${${PROJECT_NAME}_TRIBITS_DIR}/core/modules
Expand All @@ -57,9 +59,9 @@ if (${PROJECT_NAME}_VERBOSE_CONFIGURE)
message("CMAKE_MODULE_PATH='${CMAKE_MODULE_PATH}'")
endif()

include(TribitsConstants)
include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake")
tribits_asesrt_minimum_cmake_version()
include(TribitsCMakePolicies NO_POLICY_SCOPE)
include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsCMakePolicies.cmake" NO_POLICY_SCOPE)

# TriBITS package_arch includes
include(TribitsIncludeDirectories)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@


# Standard TriBITS system includes
include(TribitsConstants)
include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake")
include(TribitsProcessExtraRepositoriesList)
include(TribitsProcessPackagesAndDirsLists)
include(TribitsProcessTplsLists)
Expand Down
Loading

0 comments on commit 5806afd

Please sign in to comment.