Skip to content

Commit

Permalink
Merge branch 'tribits_github_snapshot' into tribits-299-modern-cmake-…
Browse files Browse the repository at this point in the history
…targets-1-again-2
  • Loading branch information
bartlettroscoe committed Jul 18, 2022
2 parents fa06795 + da79f36 commit 55cc5e4
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ doxygen_objdb_*.tmp

# Trilinos extra repos
/TriBITS/
/TriBITS
/preCopyrightTrilinos/
/DrekarBase/
/DrekarResearch/
Expand Down
4 changes: 3 additions & 1 deletion cmake/tribits/ci_support/TribitsDumpDepsXmlScript.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
# -P <tribitsDir>/ci_support/TribitsDumpDepsXmlScript.cmake
#

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)

# A) Echo input options (must be specified with -D arguments to CMake command)

# PROJECT_SOURCE_DIR
Expand Down Expand Up @@ -106,7 +108,7 @@ set( CMAKE_MODULE_PATH

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

include(TribitsGlobalMacros)
include(TribitsPrintDependencyInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ set( CMAKE_MODULE_PATH
"${${PROJECT_NAME}_TRIBITS_DIR}/core/utils"
"${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch"
)
include(TribitsCMakePolicies)
include(TribitsCMakePolicies NO_POLICY_SCOPE)
include(Split)
include(AppendStringVar)
include(SetDefaultAndFromEnv) # Used in ExtraRepositoriesList.cmake file?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,28 @@ endif()
# the required components wasn't found.
set(${PROJECT_NAME}_FOUND TRUE)
set(${PROJECT_NAME}_NOT_FOUND_MESSAGE "")
set(selectedComponentsFound "")
foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST})
set(
INCLUDE_FILE
set(compPkgConfigFile
${PDOLLAR}{CMAKE_CURRENT_LIST_DIR}/../${PDOLLAR}{comp}/${PDOLLAR}{comp}Config.cmake
)
if (EXISTS ${PDOLLAR}{INCLUDE_FILE})
# Set ${PROJECT_NAME}_<component>_FOUND.
set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND TRUE)
# Include the package file.
include(${PDOLLAR}{INCLUDE_FILE})
# Add variables to lists.
list(APPEND ${PROJECT_NAME}_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARIES})
list(APPEND ${PROJECT_NAME}_TPL_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARIES})
else()
set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND FALSE)
if(${PROJECT_NAME}_FIND_REQUIRED_${PDOLLAR}{comp})
string(APPEND ${PROJECT_NAME}_NOT_FOUND_MESSAGE
"ERROR: Could not find component '${PDOLLAR}{comp}'!\n")
set(${PROJECT_NAME}_FOUND FALSE)
endif()
endif()
if (EXISTS ${PDOLLAR}{compPkgConfigFile})
# Set ${PROJECT_NAME}_<component>_FOUND.
set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND TRUE)
# Include the package file.
include(${PDOLLAR}{compPkgConfigFile})
# Add variables to lists.
list(APPEND ${PROJECT_NAME}_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARIES})
list(APPEND ${PROJECT_NAME}_TPL_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARIES})
list(APPEND selectedComponentsFound ${PDOLLAR}{comp})
else()
set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND FALSE)
if(${PROJECT_NAME}_FIND_REQUIRED_${PDOLLAR}{comp})
string(APPEND ${PROJECT_NAME}_NOT_FOUND_MESSAGE
"ERROR: Could not find component '${PDOLLAR}{comp}'!\n")
set(${PROJECT_NAME}_FOUND FALSE)
endif()
endif()
endforeach()

# Deprecated (see #299)!
Expand Down Expand Up @@ -174,7 +175,7 @@ set(${PROJECT_NAME}_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LI
set(${PROJECT_NAME}_PACKAGE_LIST "${FULL_PACKAGE_SET}")

## The selected packages for this project
set(${PROJECT_NAME}_SELECTED_PACKAGE_LIST "${PDOLLAR}{COMPONENTS_LIST}")
set(${PROJECT_NAME}_SELECTED_PACKAGE_LIST "${PDOLLAR}{selectedComponentsFound}")

## The TPLs enabled for this project
set(${PROJECT_NAME}_TPL_LIST "${FULL_TPL_SET}")
Expand All @@ -197,7 +198,7 @@ endif()
# ${PROJECT_NAME}::all_selected_libs (Depend on COMPONENTS)
if (NOT TARGET ${PROJECT_NAME}::all_selected_libs)
set(${PROJECT_NAME}_ALL_SELECTED_PACKAGES_TARGETS)
foreach (pkg IN ITEMS ${PDOLLAR}{COMPONENTS_LIST})
foreach (pkg IN ITEMS ${PDOLLAR}{selectedComponentsFound})
list(APPEND ${PROJECT_NAME}_ALL_SELECTED_PACKAGES_TARGETS ${PDOLLAR}{pkg}::all_libs)
endforeach()
add_library(${PROJECT_NAME}::all_selected_libs IMPORTED INTERFACE GLOBAL)
Expand Down
19 changes: 6 additions & 13 deletions cmake/tribits/core/package_arch/TribitsAddAdvancedTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# ************************************************************************
# @HEADER

include(TribitsCMakePolicies NO_POLICY_SCOPE)

include(TribitsAddAdvancedTestHelpers)
include(TribitsConstants)
Expand All @@ -46,13 +47,6 @@ include(AppendStringVar)
include(PrintVar)


# Avoid quoted strings lookup variables
cmake_policy(SET CMP0054 NEW)
# NOTE: For some reason, setting this policy at the top level with TriBITS
# in TribitsCMakePolices.cmake does not affect this function. Therefore, I
# have to set it again here.


# @FUNCTION: tribits_add_advanced_test()
#
# Function that creates an advanced test defined by stringing together one or
Expand Down Expand Up @@ -527,8 +521,8 @@ cmake_policy(SET CMP0054 NEW)
# **any** of the given regular expressions. This will be applied and take
# precedence over other above pass criteria. For example, if even if
# ``PASS_REGULAR_EXPRESSION`` or ``PASS_REGULAR_EXPRESSION_ALL`` match,
# then the test will be marked as failed if this fail regex matches the
# output.
# then the test will be marked as failed if any of the fail regexes match
# the output.
#
# ``ALWAYS_FAIL_ON_NONZERO_RETURN``
#
Expand Down Expand Up @@ -611,7 +605,7 @@ cmake_policy(SET CMP0054 NEW)
# The logic given below can be used to determine pass/fail criteria for a test
# case both based on what is printed in the test output **and** the return
# code for the test block command. Raw CTest, as of version 3.23, does not
# allow that. With raw CTest, one can only set determine pass/fail based the
# allow that. With raw CTest, one can only set pass/fail criteria based the
# test output **or** the return code, but not both. This make
# `tribits_add_advanced_test()`_ more attractive to use than
# `tribits_add_test()`_ or raw ``add_test()`` in cases where it is important
Expand Down Expand Up @@ -688,9 +682,8 @@ cmake_policy(SET CMP0054 NEW)
# ``FINAL_PASS_REGULAR_EXPRESSION "<regex0>" "<regex1>" ...``
#
# If specified, the test will be assumed to pass if the output matches
# **any** of the provided regular expressions ``<regexi>``. Otherwise, it
# will be assumed to fail. (Sets the CTest property
# ``PASS_REGULAR_EXPRESSION`` for the overall test.)
# **any** of the provided regular expressions ``<regexi>``. (Sets the
# CTest property ``PASS_REGULAR_EXPRESSION`` for the overall test.)
#
# ``FINAL_FAIL_REGULAR_EXPRESSION "<regex0>" "<regex1>" ...``
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
# ************************************************************************
# @HEADER

include(TribitsCMakePolicies NO_POLICY_SCOPE)

include(AdvancedSet)
include(MessageWrapper)

Expand Down
3 changes: 1 addition & 2 deletions cmake/tribits/core/package_arch/TribitsAddTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
# ************************************************************************
# @HEADER

include(TribitsCMakePolicies NO_POLICY_SCOPE)
include(TribitsAddTestHelpers)

cmake_policy(SET CMP0007 NEW) # Don't ignore empty list elements


# @FUNCTION: tribits_add_test()
#
Expand Down
11 changes: 6 additions & 5 deletions cmake/tribits/core/package_arch/TribitsCMakePolicies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@

# Define policies for CMake
# It is assumed that the project has already called CMAKE_MINIMUM_REQUIRED.
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0007 NEW)
cmake_policy(SET CMP0011 NEW)
cmake_policy(SET CMP0053 NEW)
cmake_policy(SET CMP0082 NEW)
cmake_policy(SET CMP0003 NEW) # Don't split up full lib paths to linker args
cmake_policy(SET CMP0007 NEW) # Don't ignore empty list items
cmake_policy(SET CMP0053 NEW) # Make var references much faster
cmake_policy(SET CMP0054 NEW) # Avoid quoted strings lookup variables
cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... )
cmake_policy(SET CMP0082 NEW) # Install rules follow order install() called in subdirs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ include(TribitsPackageDependencies)

include(MessageWrapper)

cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... )


# @FUNCTION: tribits_extpkg_write_config_file()
#
Expand Down
26 changes: 17 additions & 9 deletions cmake/tribits/core/package_arch/TribitsPackageDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@

include_guard()

include(TribitsCMakePolicies NO_POLICY_SCOPE)

include(TribitsParseArgumentsHelpers)
include(MessageWrapper)

cmake_policy(SET CMP0011 NEW) # include() does policy push and pop
cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... )


# @MACRO: tribits_extpkg_define_dependencies()
#
Expand Down Expand Up @@ -98,16 +97,19 @@ macro(tribits_extpkg_define_dependencies
tribits_check_for_unparsed_arguments(PARSE)
tribits_assert_parse_arg_one_or_more_values(PARSE DEPENDENCIES)

set(libAllDependencies "")
foreach (upstreamTplDepEntry IN LISTS PARSE_DEPENDENCIES)
list(APPEND libAllDependencies ${upstreamTplDepEntry})
endforeach()

set(${tplName}_LIB_ALL_DEPENDENCIES ${libAllDependencies} CACHE STRING
set(${tplName}_LIB_ALL_DEPENDENCIES ${PARSE_DEPENDENCIES} CACHE STRING
"List of all potential dependencies for external package/TPL '${tplName}'")
mark_as_advanced(${tplName}_LIB_ALL_DEPENDENCIES)

endmacro()
#
# NOTE: Above, we use a cache var for ${tplName}_LIB_ALL_DEPENDENCIES to allow
# the user to override what dependencies a TPL can depend on. Since this does
# not depend on what actual TPLs are enabled, it is okay to set this as a
# cache var. As with any genetic change to a CMakeLists.txt file, you always
# need to blow a way the cache and configure from scratch to get a correct
# configuration. (Only some types of changes to CMakeLists.txt files allow
# for correct reconfiguration.)


# @MACRO: tribits_extpkg_setup_enabled_dependencies()
Expand Down Expand Up @@ -158,6 +160,12 @@ macro(tribits_extpkg_setup_enabled_dependencies externalPkgName)
endforeach()

endmacro()
#
# NOTE: Above we set ${externalPkgName}_LIB_ENABLED_DEPENDENCIES as a regular
# project-level variable, not as a cache var. That is because we want it to
# update when the set of enabled TPLs changes without having to reconfigure
# from scratch. However, we use the if statement to allow the user to
# override the default logic on the dependencies for an enabled TPL.


# @FUNCTION: tribits_extpkg_get_dep_name_and_vis()
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)
include(TribitsCMakePolicies NO_POLICY_SCOPE)
include(TribitsProjectImpl)


Expand Down
2 changes: 1 addition & 1 deletion cmake/tribits/core/package_arch/TribitsProjectImpl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ endif()

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

include(TribitsIncludeDirectories)
include(TribitsFindPythonInterp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# -P tribits_get_version_date.cmake
#

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)

# A) Validate input

if ("${PROJECT_NAME}" STREQUAL "")
Expand Down
4 changes: 3 additions & 1 deletion cmake/tribits/core/utils/UnitTestHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
include(CMakeParseArguments)
include(GlobalSet)

cmake_policy(SET CMP0007 NEW)
# Set policy here instead of including TribitCTestPolicis.cmake since we want
# this to be a standalone module
cmake_policy(SET CMP0007 NEW) # Don't ignore empty list items


# @MACRO: unittest_initialize_vars()
Expand Down
2 changes: 1 addition & 1 deletion cmake/tribits/ctest_driver/TribitsCTestDriverCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ set( CMAKE_MODULE_PATH

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

include(Split)
include(PrintVar)
Expand Down
2 changes: 2 additions & 0 deletions cmake/tribits/ctest_driver/TribitsGetCTestTestXmlDir.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# then prints the directory <build>/Testing/<buildstarttime> to STDOUT.
#

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)

if ("${PROJECT_NAME}" STREQUAL "")
message(FATAL_ERROR "Error, PROJECT_NAME must be set!")
endif()
Expand Down
2 changes: 2 additions & 0 deletions cmake/tribits/ctest_driver/TribitsReadTagFile.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Set policy here instead of including TribitCTestPolicis.cmake since we want
# this to be a standalone module
cmake_policy(SET CMP0007 NEW)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# 3.12) crash in that case.
#

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)

message("\ncmake -P tribits_ctest_update_commands.cmake:")
message("-- GIT_EXE=${GIT_EXE}")
message("-- REMOTE_NAME=${REMOTE_NAME}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# the output (and does not send it to CDash).
#

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)

message("\ncmake -P tribits_ctest_update_commands_wrapper.cmake:")
message("-- OUTPUT_FILE=${OUTPUT_FILE}\n")

Expand Down
16 changes: 13 additions & 3 deletions cmake/tribits/doc/build_ref/TribitsBuildReferenceBody.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1775,15 +1775,25 @@ must be specified correctly for the compile and links to work correctly. The
<Project> Project already defines these dependencies for the average situation
for all of these TPLs. However, there may be situations where the
dependencies may need to be tweaked to match how these TPLs were actually
installed on some systems. The dependencies for a TPL can be overridded by
setting::
installed on some systems. To redefine what dependencies a TPL can have (if
the upstream TPLs are enabled), set::

-D <TPLNAME>_LIB_ENABLED_DEPENDENCIES="<tpl_1>;<tpl_2>;..."
-D <TPLNAME>_LIB_ALL_DEPENDENCIES="<tpl_1>;<tpl_2>;..."

A dependency on an upstream TPL ``<tpl_i>`` will be set if the an upstream TPL
``<tpl_i>`` is actually enabled.

If any of the specified TPLs are listed after ``<TPLNAME>`` in the
``TPLsList.cmake`` file or are not enabled, then a configure-time error will
occur.

To take complete control over what dependencies an TPL has, set::

-D <TPLNAME>_LIB_ENABLED_DEPENDENCIES="<tpl_1>;<tpl_2>;..."

If the upstream TPLs listed here are not defined upstream and enabled TPLs,
then an error will occur.


Disabling support for a Third-Party Library (TPL)
--------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cmake/tribits/examples/MockTrilinos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
# ************************************************************************
# @HEADER

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)
include(${CMAKE_SOURCE_DIR}/ProjectName.cmake)
project(${PROJECT_NAME} NONE)
set(${PROJECT_NAME}_TRIBITS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "")
include("${${PROJECT_NAME}_TRIBITS_DIR}/TriBITS.cmake")
cmake_minimum_required(VERSION ${TRIBITS_CMAKE_MINIMUM_REQUIRED})
tribits_project()
2 changes: 1 addition & 1 deletion cmake/tribits/examples/ReducedMockTrilinos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)
include(${CMAKE_CURRENT_SOURCE_DIR}/ProjectName.cmake)
project(${PROJECT_NAME} NONE)
set(${PROJECT_NAME}_TRIBITS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "")
set(${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY ON CACHE BOOL "")
include("${${PROJECT_NAME}_TRIBITS_DIR}/TriBITS.cmake")
cmake_minimum_required(VERSION ${TRIBITS_CMAKE_MINIMUM_REQUIRED})
tribits_project()

0 comments on commit 55cc5e4

Please sign in to comment.