From 270dee8875bd1ce77e888194e5d1f9420c095c8e Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 13 Jul 2022 11:50:32 -0600 Subject: [PATCH 1/8] Change some set() to set( "") (#63) This is just a few places where I noticed that I had called set() expecting to set it to empty "" but that actually unsets the var and is equivalent to unset()! You initailize and empty var or list using set( ""). --- .../package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake b/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake index fce0e4325..6b209747e 100644 --- a/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake +++ b/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake @@ -179,7 +179,7 @@ endmacro() # macro(tribits_read_all_package_deps_files_create_deps_graph) - set(${PROJECT_NAME}_SE_PACKAGES) # Packages and subpackages + set(${PROJECT_NAME}_SE_PACKAGES "") # Packages and subpackages foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES}) tribits_read_toplevel_package_deps_files_add_to_graph(${TRIBITS_PACKAGE} @@ -476,7 +476,7 @@ function(tribits_set_dep_packages PACKAGE_NAME LIB_OR_TEST REQUIRED_OR_OPTIO endif() set(LIST_TYPE ${LIB_OR_TEST}_${REQUIRED_OR_OPTIONAL}_DEP_PACKAGES) - set(PACKAGE_DEPS_LIST) + set(PACKAGE_DEPS_LIST "") set(SE_PACKAGE_ENABLE_VAR ${PROJECT_NAME}_ENABLE_${PACKAGE_NAME}) foreach(DEP_PKG ${${LIST_TYPE}}) From 9f9a81ab6f320d18ac3b89e7c2aaae83d6e00614 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 13 Jul 2022 18:08:58 -0600 Subject: [PATCH 2/8] Add reference documentation for tribits_trace_file_processing() (#63, #299, #494) --- .../package_arch/TribitsGeneralMacros.cmake | 20 ++++++++++++++++--- .../TribitsSystemMacroFunctionDocTemplate.rst | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tribits/core/package_arch/TribitsGeneralMacros.cmake b/tribits/core/package_arch/TribitsGeneralMacros.cmake index bd05810ae..cf2a680cb 100644 --- a/tribits/core/package_arch/TribitsGeneralMacros.cmake +++ b/tribits/core/package_arch/TribitsGeneralMacros.cmake @@ -373,7 +373,23 @@ function( tribits_gather_enabled_items PACKAGE_NAME LISTTYPE_PREFIX endfunction() -# Print trace of file processing +# @FUNCTION: tribits_trace_file_processing() +# +# Print trace of file processing when +# ``${PROJECT_NAME}_TRACE_FILE_PROCESSING`` is ``TRUE``. +# +# Usage:: +# +# tribits_trace_file_processing( ) +# +# Arguments: +# +# * ````: Allowed values "PROJECT", "REPOSITORY", "PACKAGE", or "TPL" +# +# * ````: Allowed values "INCLUDE", "ADD_SUBDIR", "READ", or +# "CONFIGURE" +# +# * ````: Path of the file being processed # function(tribits_trace_file_processing TYPE_IN PROCESSING_TYPE_IN FILE_PATH) @@ -410,5 +426,3 @@ function(tribits_trace_file_processing TYPE_IN PROCESSING_TYPE_IN FILE_PATH) endif() endfunction() - - diff --git a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst index 0a8f74bf1..68206fdf2 100644 --- a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst @@ -42,6 +42,7 @@ understand the internals of TriBITS. @MACRO: tribits_read_deps_files_create_deps_graph() + @MACRO: tribits_save_off_dependency_vars() + @FUNCTION: tribits_set_dep_packages() + +@FUNCTION: tribits_trace_file_processing() + @FUNCTION: tribits_write_package_client_export_files_install_targets() + @MACRO: tribits_write_xml_dependency_files() + @FUNCTION: tribits_write_xml_dependency_files_if_supported() + From cff283f184a133f6d12f30893fb17a5691caed68 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 13 Jul 2022 18:13:45 -0600 Subject: [PATCH 3/8] Dump direct dependencies for external and internal packages (#63, #494) And with this I can strengthen the tests later. --- ...sts_EnableAllPackages_DumpDependencies.txt | 41 ++++++++++++++++++- .../TribitsExampleProject_Tests.cmake | 2 +- .../TribitsAdjustPackageEnables.cmake | 8 ++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/test/core/DependencyUnitTests/DepTests_EnableAllPackages_DumpDependencies.txt b/test/core/DependencyUnitTests/DepTests_EnableAllPackages_DumpDependencies.txt index 80b33d023..92c276c49 100644 --- a/test/core/DependencyUnitTests/DepTests_EnableAllPackages_DumpDependencies.txt +++ b/test/core/DependencyUnitTests/DepTests_EnableAllPackages_DumpDependencies.txt @@ -98,8 +98,47 @@ Printing package dependencies ... -- Panzer_LIB_REQUIRED_DEP_TPLS: MPI Boost -Dumping direct dependencies for each SE package ... +Dumping direct dependencies for each package ... +-- MPI_LIB_ALL_DEPENDENCIES: + +-- BLAS_LIB_ALL_DEPENDENCIES: + +-- LAPACK_LIB_ALL_DEPENDENCIES: + +-- Boost_LIB_ALL_DEPENDENCIES: + +-- Scotch_LIB_ALL_DEPENDENCIES: + +-- METIS_LIB_ALL_DEPENDENCIES: + +-- ParMETIS_LIB_ALL_DEPENDENCIES: + +-- CppUnit_LIB_ALL_DEPENDENCIES: + +-- ADOLC_LIB_ALL_DEPENDENCIES: + +-- ADIC_LIB_ALL_DEPENDENCIES: + +-- TVMET_LIB_ALL_DEPENDENCIES: + +-- y12m_LIB_ALL_DEPENDENCIES: + +-- SuperLUDist_LIB_ALL_DEPENDENCIES: + +-- SuperLU_LIB_ALL_DEPENDENCIES: + +-- UMFPACK_LIB_ALL_DEPENDENCIES: + +-- AMD_LIB_ALL_DEPENDENCIES: + +-- PETSC_LIB_ALL_DEPENDENCIES: + +-- MUMPS_LIB_ALL_DEPENDENCIES: + +-- DUMMY_LIB_ALL_DEPENDENCIES: + +-- TrilinosFramework_LIB_ALL_DEPENDENCIES: -- TrilinosFramework_TEST_ALL_DEPENDENCIES: MPI -- Teuchos_LIB_ENABLED_DEPENDENCIES: BLAS LAPACK diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 145182ced..8e15a9b9e 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -176,7 +176,7 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi) "Setting TribitsExProj_ENABLE_WithSubpackages=ON" "Setting TPL_ENABLE_HeaderOnlyTpl=ON because it is required by the enabled package SimpleCxx" "Set cache entries for optional packages/TPLs and tests/examples for packages actually enabled ..." - "Dumping direct dependencies for each SE package ..." + "Dumping direct dependencies for each package ..." "-- SimpleCxx_LIB_ENABLED_DEPENDENCIES: HeaderOnlyTpl" "-- SimpleCxx_LIB_ALL_DEPENDENCIES: HeaderOnlyTpl SimpleTpl" "-- MixedLang_LIB_ALL_DEPENDENCIES: " diff --git a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake index cd179089d..389d5b8e1 100644 --- a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake +++ b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake @@ -679,7 +679,7 @@ endmacro() # Function to print the direct package dependency lists # -function(tribits_print_direct_package_dependencies_lists packageName) +function(tribits_print_direct_package_dependencies_lists packageName) set(PRINTED_VAR "") message("") print_nonempty_var_with_spaces(${packageName}_LIB_ENABLED_DEPENDENCIES PRINTED_VAR) @@ -1480,9 +1480,9 @@ macro(tribits_adjust_package_enables) endforeach() if (${PROJECT_NAME}_DUMP_PACKAGE_DEPENDENCIES) - message("\nDumping direct dependencies for each SE package ...") - foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_SE_PACKAGES}) - tribits_print_direct_package_dependencies_lists(${TRIBITS_PACKAGE}) + message("\nDumping direct dependencies for each package ...") + foreach(tribitsPkg IN LISTS ${PROJECT_NAME}_DEFINED_TPLS ${PROJECT_NAME}_SE_PACKAGES) + tribits_print_direct_package_dependencies_lists(${tribitsPkg}) endforeach() endif() From 3a9cc8e73528f22615d0f2a5e9a959a89df5aea0 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 12 Jul 2022 20:34:16 -0600 Subject: [PATCH 4/8] Generalize and robustify external package/TPL dependendies (#63, #299, #494) Here is what I did in detail: * Created new module TribitsPackageDependencies.cmake (and unit test driver) to collect standard dependency defintion macros and functions into. * Created function tribits_external_package_define_dependencies() that sets _LIB_ALL_DEPENDENCIES and tribits_external_package_setup_enabled_dependencies() that sets _LIB_ENABLED_DEPENDENCIES based on what TPLs are actually enabled. (This should address #494.) * Renamed function tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis() to tribits_external_package_get_dep_name_and_vis() and moved from TribitsExternalPackageWriteConfigFile.cmake to TribitsPackageDependencies.cmake. * Improved a bit of the existing documentation. --- test/core/CMakeLists.txt | 16 +- ...rnalPackageWriteConfigFile_UnitTests.cmake | 67 +----- ...TribitsPackageDependencies_UnitTests.cmake | 187 ++++++++++++++++ .../TribitsAdjustPackageEnables.cmake | 17 +- ...ribitsExternalPackageWriteConfigFile.cmake | 70 ++---- .../TribitsPackageDependencies.cmake | 204 ++++++++++++++++++ .../package_arch/TribitsProjectImpl.cmake | 1 + .../TribitsMacroFunctionDocTemplate.rst | 3 +- .../TribitsSystemMacroFunctionDocTemplate.rst | 2 +- .../TribitsExampleProject2/TPLsList.cmake | 6 +- 10 files changed, 443 insertions(+), 130 deletions(-) create mode 100644 test/core/TribitsPackageDependencies_UnitTests.cmake create mode 100644 tribits/core/package_arch/TribitsPackageDependencies.cmake diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 5314c3bad..89d3fe518 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -136,6 +136,20 @@ tribits_add_advanced_test( TribitsWriteClientExportFiles_UnitTests ) +tribits_add_advanced_test( TribitsPackageDependencies_UnitTests + OVERALL_WORKING_DIRECTORY TEST_NAME + TEST_0 CMND ${CMAKE_COMMAND} + ARGS + -DPROJECT_NAME=${PROJECT_NAME} + -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DCURRENT_TEST_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR} + -P "${CMAKE_CURRENT_SOURCE_DIR}/TribitsPackageDependencies_UnitTests.cmake" + PASS_REGULAR_EXPRESSION_ALL + "Final UnitTests Result: num_run = 13" + "Final UnitTests Result: PASSED" + ) + + tribits_add_advanced_test( TribitsExternalPackageWriteConfigFile_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME TEST_0 CMND ${CMAKE_COMMAND} @@ -145,7 +159,7 @@ tribits_add_advanced_test( TribitsExternalPackageWriteConfigFile_UnitTests -DCURRENT_TEST_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/TribitsExternalPackageWriteConfigFile_UnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 85" + "Final UnitTests Result: num_run = 74" "Final UnitTests Result: PASSED" ) diff --git a/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake b/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake index b152c443b..2bf53e93d 100644 --- a/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake +++ b/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake @@ -191,69 +191,6 @@ function(unittest_tribits_external_package_get_libname_from_full_lib_path_apple) endfunction() -# -# Test for tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis() -# - - -function(unittest_tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis) - - message("\n***") - message("*** Testing tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis") - message("***\n") - - set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) - - message("\nTesting default visibility\n") - global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( - SomePackage upstreamTplDepNameOut upstreamTplDepVisOut) - unittest_compare_const( upstreamTplDepNameOut - "SomePackage" ) - unittest_compare_const( upstreamTplDepVisOut - "PRIVATE" ) - unittest_compare_const(MESSAGE_WRAPPER_INPUT "") - - message("\nTesting PUBLIC\n") - global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( - SomePackage:PUBLIC upstreamTplDepNameOut upstreamTplDepVisOut) - unittest_compare_const( upstreamTplDepNameOut - SomePackage ) - unittest_compare_const( upstreamTplDepVisOut - "PUBLIC" ) - unittest_compare_const(MESSAGE_WRAPPER_INPUT "") - - message("\nTesting PRIVATE\n") - global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( - SomePackage:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut) - unittest_compare_const( upstreamTplDepNameOut - SomePackage ) - unittest_compare_const( upstreamTplDepVisOut - "PRIVATE" ) - unittest_compare_const(MESSAGE_WRAPPER_INPUT "") - - message("\nTesting invalid visibility\n") - global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( - SomePackage:SPELLEDWRONG upstreamTplDepNameOut upstreamTplDepVisOut) - unittest_compare_const(MESSAGE_WRAPPER_INPUT - "FATAL_ERROR;ERROR: 'SomePackage:SPELLEDWRONG' has invalid visibility 'SPELLEDWRONG'.; Only 'PUBLIC' or 'PRIVATE' allowed!") - - message("\nTesting more than two elements splitting on ':'\n") - global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( - SomePackage:BadExtraEntry:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut) - unittest_compare_const(MESSAGE_WRAPPER_INPUT - "FATAL_ERROR;ERROR: 'SomePackage:BadExtraEntry:PRIVATE' has 2 ':' but only 1 is allowed!") - - # Reset global state - global_set(MESSAGE_WRAPPER_INPUT "") - -endfunction() - - # # Tests for tribits_external_package_process_libraries_list_incl() # @@ -1277,8 +1214,6 @@ unittest_tribits_external_package_get_libname_from_full_lib_path_linux() unittest_tribits_external_package_get_libname_from_full_lib_path_win32() unittest_tribits_external_package_get_libname_from_full_lib_path_apple() -unittest_tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis() - unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_1() unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_2() unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_3() @@ -1303,4 +1238,4 @@ unittest_tribits_external_package_write_config_file_str_incl_dirs_1_bad_lib_args unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_opts_2_2_deps_3() # Pass in the number of expected tests that must pass! -unittest_final_result(85) +unittest_final_result(74) diff --git a/test/core/TribitsPackageDependencies_UnitTests.cmake b/test/core/TribitsPackageDependencies_UnitTests.cmake new file mode 100644 index 000000000..11daf2577 --- /dev/null +++ b/test/core/TribitsPackageDependencies_UnitTests.cmake @@ -0,0 +1,187 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + +# Echo input arguments +message("PROJECT_NAME = '${PROJECT_NAME}'") +message("${PROJECT_NAME}_TRIBITS_DIR = '${${PROJECT_NAME}_TRIBITS_DIR}'") +message("CURRENT_TEST_DIRECTORY = '${CURRENT_TEST_DIRECTORY}'") + +set( CMAKE_MODULE_PATH + "${${PROJECT_NAME}_TRIBITS_DIR}/core/utils" + "${${PROJECT_NAME}_TRIBITS_DIR}/core/package_arch" + ) + +include(TribitsPackageDependencies) + +include(UnitTestHelpers) +include(GlobalNullSet) + + +##################################################################### +# +# Unit tests for code in TribitsPackageDependencies.cmake +# +##################################################################### + + +# +# Tests for tribits_external_package_get_dep_name_and_vis() +# + + +function(unittest_tribits_external_package_get_dep_name_and_vis) + + message("\n***") + message("*** Testing tribits_external_package_get_dep_name_and_vis()") + message("***\n") + + set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) + + message("\nTesting default visibility\n") + global_set(MESSAGE_WRAPPER_INPUT "") + tribits_external_package_get_dep_name_and_vis( + SomePackage upstreamTplDepNameOut upstreamTplDepVisOut) + unittest_compare_const( upstreamTplDepNameOut + "SomePackage" ) + unittest_compare_const( upstreamTplDepVisOut + "PRIVATE" ) + unittest_compare_const(MESSAGE_WRAPPER_INPUT "") + + message("\nTesting PUBLIC\n") + global_set(MESSAGE_WRAPPER_INPUT "") + tribits_external_package_get_dep_name_and_vis( + SomePackage:PUBLIC upstreamTplDepNameOut upstreamTplDepVisOut) + unittest_compare_const( upstreamTplDepNameOut + SomePackage ) + unittest_compare_const( upstreamTplDepVisOut + "PUBLIC" ) + unittest_compare_const(MESSAGE_WRAPPER_INPUT "") + + message("\nTesting PRIVATE\n") + global_set(MESSAGE_WRAPPER_INPUT "") + tribits_external_package_get_dep_name_and_vis( + SomePackage:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut) + unittest_compare_const( upstreamTplDepNameOut + SomePackage ) + unittest_compare_const( upstreamTplDepVisOut + "PRIVATE" ) + unittest_compare_const(MESSAGE_WRAPPER_INPUT "") + + message("\nTesting invalid visibility\n") + global_set(MESSAGE_WRAPPER_INPUT "") + tribits_external_package_get_dep_name_and_vis( + SomePackage:SPELLEDWRONG upstreamTplDepNameOut upstreamTplDepVisOut) + unittest_compare_const(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;ERROR: 'SomePackage:SPELLEDWRONG' has invalid visibility 'SPELLEDWRONG'.; Only 'PUBLIC' or 'PRIVATE' allowed!") + + message("\nTesting more than two elements splitting on ':'\n") + global_set(MESSAGE_WRAPPER_INPUT "") + tribits_external_package_get_dep_name_and_vis( + SomePackage:BadExtraEntry:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut) + unittest_compare_const(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;ERROR: 'SomePackage:BadExtraEntry:PRIVATE' has 2 ':' but only 1 is allowed!") + + # Reset global state + global_set(MESSAGE_WRAPPER_INPUT "") + +endfunction() + + +# +# Tests for tribits_external_package_define_dependencies() +# + + +function(unittest_tribits_external_package_define_dependencies_basic) + + message("\n***") + message("*** ${CMAKE_CURRENT_FUNCTION}()") + message("***\n") + + tribits_external_package_define_dependencies(someExtPkg + DEPENDENCIES upPkg1 upPkg2:PUBLIC upPkg3:PRIVATE upPkg4) + unittest_compare_const( someExtPkg_LIB_ALL_DEPENDENCIES + "upPkg1;upPkg2:PUBLIC;upPkg3:PRIVATE;upPkg4" ) + +endfunction() + + +# +# Tests for tribits_external_package_setup_enabled_dependencies() +# + + +function(unittest_tribits_external_package_setup_enabled_dependencies) + + message("\n***") + message("*** ${CMAKE_CURRENT_FUNCTION}()") + message("***\n") + + tribits_external_package_define_dependencies(someExtPkg + DEPENDENCIES upPkg1 upPkg2:PUBLIC upPkg3:PRIVATE upPkg4) + set(TPL_ENABLE_someExtPkg ON) + set(TPL_ENABLE_upPkg1 ON) + set(TPL_ENABLE_upPkg3 ON) + tribits_external_package_setup_enabled_dependencies(someExtPkg) + unittest_compare_const( someExtPkg_LIB_ENABLED_DEPENDENCIES + "upPkg1;upPkg3:PRIVATE" ) + +endfunction() + + +##################################################################### +# +# Execute the unit tests +# +##################################################################### + +unittest_initialize_vars() + +# +# Run the unit tests +# + +unittest_tribits_external_package_get_dep_name_and_vis() + +unittest_tribits_external_package_define_dependencies_basic() + +unittest_tribits_external_package_setup_enabled_dependencies() + +# Pass in the number of expected tests that must pass! +unittest_final_result(13) diff --git a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake index 389d5b8e1..984f91b81 100644 --- a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake +++ b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake @@ -42,6 +42,7 @@ include(TribitsProcessPackagesAndDirsLists) include(TribitsAddOptionAndDefine) include(TribitsGeneralMacros) include(TribitsPrintEnabledPackagesLists) +include(TribitsPackageDependencies) include(AdvancedOption) include(AdvancedSet) @@ -588,7 +589,9 @@ endmacro() # packages where only the shell of the parent package is enabled and not # all of its required subpackages are enabled. # -macro(tribits_setup_direct_package_dependencies_lists_and_lib_required_enable_vars packageName) +macro(tribits_setup_direct_package_dependencies_lists_and_lib_required_enable_vars + packageName + ) # LIB dependencies @@ -1470,10 +1473,18 @@ macro(tribits_adjust_package_enables) tribits_set_up_enabled_lists_and_se_pkg_idx() # - # H) Set up flat list of direct package dependencies (even for non-enabled - # packages) and enabled package dependencies for enabled packages + # H) Set up flat list of direct external and inner package dependencies (even + # for non-enabled packages) and enabled package dependencies for enabled + # packages # + foreach(externalPkgName ${${PROJECT_NAME}_TPLS}) + tribits_external_package_setup_enabled_dependencies(${externalPkgName}) + # ToDo: Assert that all of the listed dependencies in + # ${externalPkgName}_LIB_ENABLED_DEPENDENCIES exist and are upstream from + # ${externalPkgName} + endforeach() + foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_SE_PACKAGES}) tribits_setup_direct_package_dependencies_lists_and_lib_required_enable_vars( ${TRIBITS_PACKAGE}) diff --git a/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake b/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake index d5b2b6eb1..7766f3246 100644 --- a/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake +++ b/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake @@ -37,7 +37,11 @@ # ************************************************************************ # @HEADER + +include_guard() + include(TribitsGeneralMacros) +include(TribitsPackageDependencies) include(MessageWrapper) @@ -150,7 +154,7 @@ endfunction() # # ````: Full file path for the # ``ConfigVersion.cmake`` file that will be installed into the -# correct location. +# correct location ``${${PROJECT_NAME}_INSTALL_LIB_DIR}/external_packages/`` # function(tribits_external_package_install_config_version_file tplName tplConfigVersionFile @@ -298,7 +302,7 @@ endfunction() # tribits_external_package_add_find_upstream_dependencies_str(tplName # configFileFragStrInOut) # -# NOTE: This also requires that `_DIR` be set for each +# NOTE: This also requires that ``_DIR`` be set for each # external package/TPL listed in ``_LIB_ENABLED_DEPENDENCIES``. # function(tribits_external_package_add_find_upstream_dependencies_str @@ -325,7 +329,7 @@ function(tribits_external_package_add_find_upstream_dependencies_str "\n" ) foreach (upstreamTplDepEntry IN LISTS ${tplName}_LIB_ENABLED_DEPENDENCIES) - tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( + tribits_external_package_get_dep_name_and_vis( "${upstreamTplDepEntry}" upstreamTplDepName upstreamTplDepVis) if ("${${upstreamTplDepName}_DIR}" STREQUAL "") message(FATAL_ERROR "ERROR: ${upstreamTplDepName}_DIR is empty!") @@ -694,7 +698,7 @@ function(tribits_external_package_append_upstream_target_link_libraries_str string(APPEND configFileStr "target_link_libraries(${prefix_libname}\n") foreach (upstreamTplDepEntry IN LISTS ${tplName}_LIB_ENABLED_DEPENDENCIES) - tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( + tribits_external_package_get_dep_name_and_vis( "${upstreamTplDepEntry}" upstreamTplDepName upstreamTplDepVis) if (upstreamTplDepVis STREQUAL "PUBLIC") string(APPEND configFileStr @@ -722,53 +726,9 @@ endfunction() # libraries being listed on link lines for downstsream library and exec links. -# @FUNCTION: tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis() -# -# Extract ```` and ```` from ``[:]`` input with -# default ```` of `PRIVATE`. -# -# Usage:: -# -# tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis( -# upstreamTplDepEntry upstreamTplDepNameOut upstreamTplDepVisOut) -# -function(tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis - upstreamTplDepEntry upstreamTplDepNameOut upstreamTplDepVisOut - ) - # Split on ':' to get [:] - string(REPLACE ":" ";" upstreamTplAndVisList "${upstreamTplDepEntry}") - list(LENGTH upstreamTplAndVisList upstreamTplAndVisListLen) - # Validate one or two entries only - if (upstreamTplAndVisListLen GREATER 2) - math(EXPR numColons "${upstreamTplAndVisListLen}-1") - message_wrapper(FATAL_ERROR - "ERROR: '${upstreamTplDepEntry}' has ${numColons} ':' but only 1 is allowed!") - endif() - # Set - list(GET upstreamTplAndVisList 0 upstreamTplDepName) - # Set - if (upstreamTplAndVisListLen EQUAL 2) - list(GET upstreamTplAndVisList 1 upstreamTplDepVis) - else() - set(upstreamTplDepVis PRIVATE) - endif() - # Assert valid - set(validVisValues "PUBLIC" "PRIVATE") - if (NOT upstreamTplDepVis IN_LIST validVisValues) - message_wrapper(FATAL_ERROR - "ERROR: '${upstreamTplDepEntry}' has invalid visibility '${upstreamTplDepVis}'." - " Only 'PUBLIC' or 'PRIVATE' allowed!") - return() # Only executed in unit-test mode! - endif() - # Set outputs - set(${upstreamTplDepNameOut} ${upstreamTplDepName} PARENT_SCOPE) - set(${upstreamTplDepVisOut} ${upstreamTplDepVis} PARENT_SCOPE) -endfunction() - - # @FUNCTION: tribits_external_package_create_all_libs_target() # -# Creates the ::all_libs target command text using input info and +# Creates the ``::all_libs`` target command text using input info and # from ``TPL__INCLUDE_DIRS``. # # Usage:: @@ -782,16 +742,16 @@ endfunction() # # The arguments are: # -# ````: Name of the external package/TPL +# ````: [in] Name of the external package/TPL # -# ````: List of targets created from processing +# ````: [in] List of targets created from processing # ``TPL__LIBRARIES``. # -# ````: List of of ``-L`` library directory paths -# entries found while processing ``TPL__LIBRARIES``. +# ````: [in] List of of ``-L`` library directory +# paths entries found while processing ``TPL__LIBRARIES``. # -# ````: A string variable that will be appended with -# the ``::all_libs`` target statements. +# ````: [out] A string variable that will be +# appended with the ``::all_libs`` target statements. # function(tribits_external_package_create_all_libs_target tplName) diff --git a/tribits/core/package_arch/TribitsPackageDependencies.cmake b/tribits/core/package_arch/TribitsPackageDependencies.cmake new file mode 100644 index 000000000..741582078 --- /dev/null +++ b/tribits/core/package_arch/TribitsPackageDependencies.cmake @@ -0,0 +1,204 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + + +################################################################################ +# +# TribitPackageDependencies.cmake +# +# Contains macros and functions related to defining internal package and +# external package/TPL dependencies with a little bit of logic. +# +################################################################################ + + +include_guard() + +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_external_package_define_dependencies() +# +# Macro called from inside of a ``FindTPLDependencies.cmake`` file to +# define the direct upstream dependencies an external package/TPL. +# +# Usage:: +# +# tribits_external_package_define_dependencies( +# DEPENDENCIES : ... ) +# +# The listed upstream dependencies ```` are other external +# packages/TPLs listed before this external packages/TPL ```` in a +# `/TPLsList.cmake`_ file. Each upstream dependency can include a +# visibility specification ```` that can be added to the dependency +# using a colon ``:`` with ``:`` where ```` can +# take the allowed values: +# +# * ``PUBLIC``: The include directories along with the libraries will be +# propagated downstream to clients of ````. +# +# * ``PRIVATE``: Only the libraries will be propagated downstream to clients +# of ````. +# +# If ```` is not specified, then the default is ``PRIVATE``. (If a +# package needs the include directories from some external package/TPL, then +# it should list that external package/TPL as a direct dependency and not +# expect to get include directories from indirect dependencies.) +# +macro(tribits_external_package_define_dependencies + tplName + ) + + # Parse arguments + cmake_parse_arguments( + PARSE "" "" # prefix, options, one_value_keywords + "DEPENDENCIES" # multi_value_keywords + ${ARGN} + ) + 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 + "List of all potential dependencies for external package/TPL '${tplName}'") + mark_as_advanced(${tplName}_LIB_ALL_DEPENDENCIES) + +endmacro() + + +# @MACRO: tribits_external_package_setup_enabled_dependencies() +# +# Usage:: +# +# tribits_external_package_setup_enabled_dependencies() +# +# Macro that sets up the list of enabled external package/TPL dependencies +# +# Takes the list ``_LIB_ALL_DEPENDENCIES`` and sets the +# default entries of the non-cache var +# ``_LIB_ENABLED_DEPENDENCIES``. However, if +# ``${_LIB_ALL_DEPENDENCIES}`` is non-empty when this macro +# is called, then it will not be changed. That allows the user to override +# the list of enabled TPL dependencies in the cache. This also sets the +# non-cache vars ``_ENABLE_=ON`` for each +# enabled package listed in ``_LIB_ENABLED_DEPENDENCIES`` and +# to ``OFF`` for each ```` listed in +# ``_LIB_ENABLED_DEPENDENCIES`` but not in +# ``_LIB_ENABLED_DEPENDENCIES``. +# +macro(tribits_external_package_setup_enabled_dependencies externalPkgName) + + set(libEnabledDependencies "") + + if (TPL_ENABLE_${externalPkgName}) + foreach(upstreamPkgEntry IN LISTS ${externalPkgName}_LIB_ALL_DEPENDENCIES) + tribits_external_package_get_dep_name_and_vis(${upstreamPkgEntry} + upstreamPkgName upstreamPkgVis) + if (TPL_ENABLE_${upstreamPkgName}) + list(APPEND libEnabledDependencies ${upstreamPkgEntry}) + else() + set(${externalPkgName}_ENABLE_${upstreamPkgName} OFF) + endif() + endforeach() + endif() + + if ("${${externalPkgName}_LIB_ENABLED_DEPENDENCIES}" STREQUAL "") + # Only set of not already set as a cache var, for example + set(${externalPkgName}_LIB_ENABLED_DEPENDENCIES ${libEnabledDependencies}) + endif() + + foreach(upstreamPkgEntry IN LISTS ${externalPkgName}_LIB_ENABLED_DEPENDENCIES) + tribits_external_package_get_dep_name_and_vis( ${upstreamPkgEntry} + upstreamPkgName upstreamPkgVis) + set(${externalPkgName}_ENABLE_${upstreamPkgName} ON) + endforeach() + +endmacro() + + +# @FUNCTION: tribits_external_package_get_dep_name_and_vis() +# +# Extract ```` and ```` from ``[:]`` input with +# default ```` of ``PRIVATE``. +# +# Usage:: +# +# tribits_external_package_get_dep_name_and_vis( +# ) +# +function(tribits_external_package_get_dep_name_and_vis + upstreamTplDepEntry upstreamTplDepNameOut upstreamTplDepVisOut + ) + # Split on ':' to get [:] + string(REPLACE ":" ";" upstreamTplAndVisList "${upstreamTplDepEntry}") + list(LENGTH upstreamTplAndVisList upstreamTplAndVisListLen) + # Validate one or two entries only + if (upstreamTplAndVisListLen GREATER 2) + math(EXPR numColons "${upstreamTplAndVisListLen}-1") + message_wrapper(FATAL_ERROR + "ERROR: '${upstreamTplDepEntry}' has ${numColons} ':' but only 1 is allowed!") + endif() + # Set + list(GET upstreamTplAndVisList 0 upstreamTplDepName) + # Set + if (upstreamTplAndVisListLen EQUAL 2) + list(GET upstreamTplAndVisList 1 upstreamTplDepVis) + else() + set(upstreamTplDepVis PRIVATE) + endif() + # Assert valid + set(validVisValues "PUBLIC" "PRIVATE") + if (NOT upstreamTplDepVis IN_LIST validVisValues) + message_wrapper(FATAL_ERROR + "ERROR: '${upstreamTplDepEntry}' has invalid visibility '${upstreamTplDepVis}'." + " Only 'PUBLIC' or 'PRIVATE' allowed!") + return() # Only executed in unit-test mode! + endif() + # Set outputs + set(${upstreamTplDepNameOut} ${upstreamTplDepName} PARENT_SCOPE) + set(${upstreamTplDepVisOut} ${upstreamTplDepVis} PARENT_SCOPE) +endfunction() diff --git a/tribits/core/package_arch/TribitsProjectImpl.cmake b/tribits/core/package_arch/TribitsProjectImpl.cmake index 75c926eed..6f4ec38df 100644 --- a/tribits/core/package_arch/TribitsProjectImpl.cmake +++ b/tribits/core/package_arch/TribitsProjectImpl.cmake @@ -66,6 +66,7 @@ include(TribitsFindPythonInterp) include(TribitsGlobalMacros) include(TribitsConfigureCTestCustom) include(TribitsGenerateResourceSpecFile) +include(TribitsPackageDependencies) include(TribitsPrintDependencyInfo) include(AdvancedSet) diff --git a/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst b/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst index a6ebbe1c6..fb8a91838 100644 --- a/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst @@ -20,7 +20,8 @@ @FUNCTION: tribits_determine_if_current_package_needs_rebuilt() + @MACRO: tribits_disable_package_on_platforms() + @MACRO: tribits_exclude_files() + -@FUNCTION: tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis() + +@MACRO: tribits_external_package_define_dependencies() + +@FUNCTION: tribits_external_package_get_dep_name_and_vis() + @FUNCTION: tribits_external_package_create_imported_all_libs_target_and_config_file() + @FUNCTION: tribits_external_package_write_config_file() + @FUNCTION: tribits_external_package_write_config_file_str() + diff --git a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst index 68206fdf2..a6216f605 100644 --- a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst @@ -15,12 +15,12 @@ understand the internals of TriBITS. @MACRO: tribits_adjust_package_enables() + @FUNCTION: tribits_append_forward_dep_packages() + @MACRO: tribits_assert_read_dependency_vars() + -@FUCNTION: tribits_external_package_append_upstream_target_link_libraries_get_name_and_vis() + @FUNCTION: tribits_external_package_add_find_upstream_dependencies_str() + @FUNCTION: tribits_external_package_create_all_libs_target() + @FUNCTION: tribits_external_package_install_config_file() + @FUNCTION: tribits_external_package_install_config_version_file() + @FUNCTION: tribits_external_package_process_libraries_list() + +@MACRO: tribits_external_package_setup_enabled_dependencies() + @FUNCTION: tribits_external_package_write_config_version_file() + @FUNCTION: tribits_dump_package_dependencies_info() + @FUNCTION: tribits_print_initial_dependency_info() + diff --git a/tribits/examples/TribitsExampleProject2/TPLsList.cmake b/tribits/examples/TribitsExampleProject2/TPLsList.cmake index 9c9412503..ff4115a0a 100644 --- a/tribits/examples/TribitsExampleProject2/TPLsList.cmake +++ b/tribits/examples/TribitsExampleProject2/TPLsList.cmake @@ -6,6 +6,6 @@ tribits_repository_define_tpls( ) # Temp hack for setting up TPL dependencies -set(Tpl2_LIB_ENABLED_DEPENDENCIES Tpl1 CACHE STRING "Tpl2 upstream dependencies") -set(Tpl3_LIB_ENABLED_DEPENDENCIES Tpl2 CACHE STRING "Tpl3 upstream dependencies") -set(Tpl4_LIB_ENABLED_DEPENDENCIES "Tpl2;Tpl3" CACHE STRING "Tpl4 upstream dependencies") +tribits_external_package_define_dependencies(Tpl2 DEPENDENCIES Tpl1) +tribits_external_package_define_dependencies(Tpl3 DEPENDENCIES Tpl2) +tribits_external_package_define_dependencies(Tpl4 DEPENDENCIES Tpl2 Tpl3) From ebd83fd68ca44ae3602c2b82acc1f729b9e8de85 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 13 Jul 2022 20:14:24 -0600 Subject: [PATCH 5/8] Add support for FindTPLDependencies.cmake files, update docs (#63, #299, #494) This commit primarily adds support for FindTPLDependencies.cmake files so you don't need to call tribits_external_package_define_dependencies() from the TPLsList.cmake file (which was a terrible hack). As part of this, I also updated the documentation related to external packages/TPLs. More specifically I did the following: * Added support for FindTPLDependencies.cmake files which including adding a new TPL var _DEPENDENCIES_FILE. That included adding a new macro tribits_read_external_package_deps_files_add_to_graph() that gets run for each TPL during the generation of the project package dependencies (and added to teh call-graph for tribits_read_all_project_deps_files_create_deps_graph()). * Expanded documentation on TriBITS External Packages/TPLs: - Properly listed out FindTPL.cmake and FindTPLDependencies.cmake in the section 'TriBITS External Package/TPL Core Files' - Added linked documentation entries for FindTPL.cmake and FindTPLDependencies.cmake - Updated list of step to add a new TPL - Added a section 'Creating FindTPL.cmake file' with mini-toc to the subsections to make easy to navigate - Added MUST_FIND_ALL_LIBS to example calls of tribits_tpl_find_include_dirs_and_libraries() * Refactored TribitsExampleProject2: - Added FindTPLDepenencies.cmake files for Tpl2, Tpl3, and Tpl4. - Remove hacked calls to tribits_external_package_define_dependencies() in TPLsList.cmake * Other users and maintainers guides updates: - Sorted items in TribitsSystemMacroFunctionDocTemplate.rst - Changed from 'FindTPL*.cmake' to 'FindTPL.cmake' in the documentation (which I think looks better). - Other small documentation fixups I noticed while looking at this stuff. * Changed over to foreach ( ... IN LISTS ... ) for a few loops. --- ...TribitsExternalPackageFindTplHelpers.cmake | 4 +- .../TribitsPackageDependencies.cmake | 2 +- .../TribitsProcessTplsLists.cmake | 44 ++- .../TribitsReadDepsFilesCreateDepsGraph.cmake | 37 +- ...itsSystemDataStructuresMacrosFunctions.rst | 4 +- ...ribitsTplFindIncludeDirsAndLibraries.cmake | 4 +- .../ExpectedDependencies.txt | 16 +- tribits/doc/guides/TribitsGuidesBody.rst | 373 ++++++++++++------ .../TribitsSystemMacroFunctionDocTemplate.rst | 15 +- .../TribitsExampleProject2/TPLsList.cmake | 5 - .../cmake/tpls/FindTPLTpl2Dependencies.cmake | 2 + .../cmake/tpls/FindTPLTpl3Dependencies.cmake | 2 + .../cmake/tpls/FindTPLTpl4Dependencies.cmake | 2 + 13 files changed, 343 insertions(+), 167 deletions(-) create mode 100644 tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake create mode 100644 tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake create mode 100644 tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake diff --git a/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake b/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake index 474f42c5e..a0bf7b129 100644 --- a/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake +++ b/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake @@ -64,8 +64,8 @@ # ``find_dependency()`` (with no other argument) and then, again, # defines the correct imported library dependency. # -# For more details, see `Creating FindTPL*.cmake using find_package() with -# IMPORTED targets`_. +# For more details, see `Creating FindTPL.cmake using find_package() +# with IMPORTED targets`_. # function(tribits_external_package_create_imported_all_libs_target_and_config_file tplName diff --git a/tribits/core/package_arch/TribitsPackageDependencies.cmake b/tribits/core/package_arch/TribitsPackageDependencies.cmake index 741582078..a949d1109 100644 --- a/tribits/core/package_arch/TribitsPackageDependencies.cmake +++ b/tribits/core/package_arch/TribitsPackageDependencies.cmake @@ -59,7 +59,7 @@ cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... ) # @MACRO: tribits_external_package_define_dependencies() # -# Macro called from inside of a ``FindTPLDependencies.cmake`` file to +# Macro called from inside of a `FindTPLDependencies.cmake`_ file to # define the direct upstream dependencies an external package/TPL. # # Usage:: diff --git a/tribits/core/package_arch/TribitsProcessTplsLists.cmake b/tribits/core/package_arch/TribitsProcessTplsLists.cmake index f37f7bdba..f4a66094b 100644 --- a/tribits/core/package_arch/TribitsProcessTplsLists.cmake +++ b/tribits/core/package_arch/TribitsProcessTplsLists.cmake @@ -74,13 +74,13 @@ include(Split) # ``SOMETPL``). # # 1. **FINDMOD** (````): The relative path for the find module, -# usually with the name ``FindTPL.cmake``. This path is relative -# to the repository base directory. If just the base path for the find -# module is given, ending with ``"/"`` (e.g. ``"cmake/tpls/"``), then the -# find module will be assumed to be under that this directory with the -# standard name (e.g. ``cmake/tpls/FindTPL.cmake``). A standard -# way to write a ``FindTPL.cmake`` module is to use the function -# `tribits_tpl_find_include_dirs_and_libraries()`_. +# usually with the name `FindTPL.cmake`_. This path is relative +# to the repository base directory ````. If just the base path +# for the find module is given, ending with ``"/"`` +# (e.g. ``"cmake/tpls/"``), then the find module will be assumed to be +# under that this directory with the standard name +# ``FindTPL.cmake``. (See `Creating the FindTPL.cmake +# file`_.) # # 2. **CLASSIFICATION** (````): Gives the `SE Package Test # Group`_ `PT`_, `ST`_, or `EX`_ and the maturity level ``EP``, ``RS``, @@ -130,13 +130,15 @@ endmacro() # and updates the project-level variables:: # # ${PROJECT_NAME}_TPLS -# ${PROJECT_NAME}_NUM_TPLS, +# ${PROJECT_NAME}_NUM_TPLS # ${PROJECT_NAME}_REVERSE_TPLS # # For each TPL, it also sets the variables:: # # ${TPL_NAME}_FINDMOD # ${TPL_NAME}_TESTGROUP +# ${TPL_NAME}_DEPENDENCIES_FILE +# ${TPL_NAME}_TPLS_LIST_FILE # # See `Function call tree for constructing package dependency graph`_ # @@ -258,16 +260,31 @@ macro(tribits_process_tpls_lists REPOSITORY_NAME REPOSITORY_DIR) set(${TPL_NAME}_FINDMOD ${TPL_FINDMOD_STD_NAME}) endif() + # Set ${TPL_NAME}_DEPENDENCIES_FILE + + # Breakdown ${${TPL_NAME}_FINDMOD} into parts /. + get_filename_component(tpl_findmod_dir ${${TPL_NAME}_FINDMOD} DIRECTORY) + get_filename_component(tpl_findmod_base ${${TPL_NAME}_FINDMOD} NAME_WLE) + get_filename_component(tpl_findmod_ext ${${TPL_NAME}_FINDMOD} LAST_EXT) + + set(${TPL_NAME}_DEPENDENCIES_FILE + "${tpl_findmod_dir}/${tpl_findmod_base}Dependencies${tpl_findmod_ext}") + + # Set ${TPL_NAME}_TPLS_LIST_FILE + assert_defined(${REPOSITORY_NAME}_TPLS_FILE) set(${TPL_NAME}_TPLS_LIST_FILE ${${REPOSITORY_NAME}_TPLS_FILE}) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${TPL_NAME}_FINDMOD) + # Print variables/properties for the TPL + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE OR TRIBITS_PROCESS_TPLS_LISTS_VERBOSE) print_var(${TPL_NAME}_TESTGROUP) + print_var(${TPL_NAME}_FINDMOD) + print_var(${TPL_NAME}_DEPENDENCIES_FILE) print_var(${TPL_NAME}_TPLS_LIST_FILE) endif() - # Set the enable cache variable for ${TPL_NAME} + # Set cache var TPL_ENABLE_${TPL_NAME} with default "" multiline_set(DOCSTR "Enable support for the TPL ${TPL_NAME} in all supported ${PROJECT_NAME} packages." @@ -277,8 +294,9 @@ macro(tribits_process_tpls_lists REPOSITORY_NAME REPOSITORY_DIR) # 2008/11/25: rabartl: Above, we use the prefix TPL_ instead of # ${PROJECT_NAME}_ in order to make it clear that external TPLs are - # different from packages so users don't get confused and - # think that the project actually includes some TPL when it does not! + # different from packages so users don't get confused and think that the + # project actually includes the source code and internal build for some + # TPL when it does not! endforeach() diff --git a/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake b/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake index 6b209747e..803dca88b 100644 --- a/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake +++ b/tribits/core/package_arch/TribitsReadDepsFilesCreateDepsGraph.cmake @@ -179,17 +179,21 @@ endmacro() # macro(tribits_read_all_package_deps_files_create_deps_graph) + foreach(tribitsExternalPkg IN LISTS ${PROJECT_NAME}_DEFINED_TPLS) + tribits_read_external_package_deps_files_add_to_graph(${tribitsExternalPkg}) + endforeach() + set(${PROJECT_NAME}_SE_PACKAGES "") # Packages and subpackages - foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES}) + foreach(TRIBITS_PACKAGE IN LISTS ${PROJECT_NAME}_PACKAGES) tribits_read_toplevel_package_deps_files_add_to_graph(${TRIBITS_PACKAGE} ${${TRIBITS_PACKAGE}_REL_SOURCE_DIR}) endforeach() # Create a reverse SE packages list for later use - set(${PROJECT_NAME}_REVERSE_SE_PACKAGES ${${PROJECT_NAME}_SE_PACKAGES}) + set(${PROJECT_NAME}_REVERSE_SE_PACKAGES ${${PROJECT_NAME}_SE_PACKAGES}) if (${PROJECT_NAME}_REVERSE_SE_PACKAGES) - list(REVERSE ${PROJECT_NAME}_REVERSE_SE_PACKAGES) + list(REVERSE ${PROJECT_NAME}_REVERSE_SE_PACKAGES) endif() list(LENGTH ${PROJECT_NAME}_SE_PACKAGES ${PROJECT_NAME}_NUM_SE_PACKAGES) @@ -198,11 +202,36 @@ macro(tribits_read_all_package_deps_files_create_deps_graph) endmacro() +# @MACRO: tribits_read_external_package_deps_files_add_to_graph() +# +# Reads in dependencies for the external packages/TPL ```` and +# creates the package dependency graph entries for it. +# +# Usage:: +# +# tribits_read_external_package_deps_files_add_to_graph() +# +# This reads in the file ``${_DEPENDENCIES_FILE}`` and sets the +# varaible:: +# +# _LIB_ALL_DEPENDENCIES +# +# See `Function call tree for constructing package dependency graph`_ +# +macro(tribits_read_external_package_deps_files_add_to_graph tplName) + set(absTplDepsFile "${${PROJECT_NAME}_SOURCE_DIR}/${${tplName}_DEPENDENCIES_FILE}") + if (EXISTS "${absTplDepsFile}") + tribits_trace_file_processing(TPL INCLUDE "${absTplDepsFile}") + include(${absTplDepsFile}) + endif() +endmacro() + + # @MACRO: tribits_read_toplevel_package_deps_files_add_to_graph() # # Usage:: # -# tribits_read_toplevel_package_deps_files_add_to_graph() +# tribits_read_toplevel_package_deps_files_add_to_graph() # # Macro that reads in package dependencies for a top-level package from the # file `/cmake/Dependencies.cmake`_ and appends the forward diff --git a/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst b/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst index e3183fd22..bcf012bdd 100644 --- a/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst +++ b/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst @@ -495,7 +495,9 @@ lists and dependency data-structures described above. | `tribits_process_project_dependency_setup_file()`_ | ``include(`` `/cmake/ProjectDependenciesSetup.cmake`_ ``)`` | `tribits_read_all_package_deps_files_create_deps_graph()`_ -| Foreach ``TOPLEVEL_PACKAGE``: +| Foreach ``EXTERNAL_PACKAGE`` in ``${PROJECT_NAME}_DEFINED_TPLS``: +| `tribits_read_external_package_deps_files_add_to_graph()`_ +| Foreach ``TOPLEVEL_PACKAGE`` in ``${PACKAGE_NAME}_DEFINED_INTERNAL_TOPLEVEL_PACKAGES``: | `tribits_read_toplevel_package_deps_files_add_to_graph()`_ | `tribits_prep_to_read_dependencies()`_ | ``include(`` `/cmake/Dependencies.cmake`_ ``)`` diff --git a/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake b/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake index 3a514943d..e690c0d75 100644 --- a/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake +++ b/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake @@ -99,8 +99,8 @@ include(Split) # to disable the prefind call to ``find_package()`` even if it would be # allowed otherwise. # -# See `Creating FindTPL*.cmake using find_package() without IMPORTED targets`_ -# for details in how to use this function to create a +# See `Creating FindTPL.cmake using find_package() without IMPORTED +# targets`_ for details in how to use this function to create a # ``FindTPL.cmake`` module file. # function(tribits_tpl_allow_pre_find_package TPL_NAME ALLOW_PACKAGE_PREFIND_OUT) diff --git a/tribits/doc/guides/ReducedMockTrilinosOutput/ExpectedDependencies.txt b/tribits/doc/guides/ReducedMockTrilinosOutput/ExpectedDependencies.txt index 64677aa6d..e176a320e 100644 --- a/tribits/doc/guides/ReducedMockTrilinosOutput/ExpectedDependencies.txt +++ b/tribits/doc/guides/ReducedMockTrilinosOutput/ExpectedDependencies.txt @@ -27,7 +27,21 @@ Printing package dependencies ... -- Thyra_LIB_REQUIRED_DEP_PACKAGES: ThyraCoreLibs -- Thyra_LIB_OPTIONAL_DEP_PACKAGES: ThyraGoodStuff ThyraCrazyStuff ThyraEpetra ThyraEpetraExt -Dumping direct dependencies for each SE package ... +Dumping direct dependencies for each package ... + +-- MPI_LIB_ALL_DEPENDENCIES: + +-- BLAS_LIB_ALL_DEPENDENCIES: + +-- LAPACK_LIB_ALL_DEPENDENCIES: + +-- Boost_LIB_ALL_DEPENDENCIES: + +-- UMFPACK_LIB_ALL_DEPENDENCIES: + +-- AMD_LIB_ALL_DEPENDENCIES: + +-- PETSC_LIB_ALL_DEPENDENCIES: -- Teuchos_LIB_ENABLED_DEPENDENCIES: BLAS LAPACK -- Teuchos_LIB_ALL_DEPENDENCIES: BLAS LAPACK Boost MPI diff --git a/tribits/doc/guides/TribitsGuidesBody.rst b/tribits/doc/guides/TribitsGuidesBody.rst index 327960df2..8a84c1dbf 100644 --- a/tribits/doc/guides/TribitsGuidesBody.rst +++ b/tribits/doc/guides/TribitsGuidesBody.rst @@ -1571,6 +1571,7 @@ Other TriBITS macros/functions that can be called in this file include `tribits_tpl_tentatively_enable()`_ and `tribits_allow_missing_external_packages()`_. +.. __config.h.in: .. _/cmake/_config.h.in: **/cmake/_config.h.in**: [Optional] The package's @@ -2154,59 +2155,135 @@ subpackages that will be mentioned in other sections as well. TriBITS External Package/TPL ++++++++++++++++++++++++++++ -A *TriBITS TPL*: - -* Defines a set of pre-built libraries and/or header files and/or executables - and/or some other resources used by one or more TriBITS Packages for which - TriBITS publishes the list of include directories and/or libraries and/or - executables provided by the TPL to the TriBITS project. -* Has a globally unique name (see `Globally unique TriBITS TPL names`_) that - is declared in a `/TPLsList.cmake`_ file. +A *TriBITS External Package/TPL*: + +* Provides access to a set of pre-built/installed libraries and/or header + files and/or executables and/or some other resources through a standard + interface to one or more downstream TriBITS Packages. +* Has a globally unique name ```` (see `Globally unique TriBITS TPL + names`_) that is declared in a `/TPLsList.cmake`_ file. +* Has as `FindTPL.cmake`_ module that finds the pieces of an external + package/TPL and provides them to downstream packages through a required + INTERFACE target ``::all_libs`` (which gives the libraries, include + directories, and other usage requirements). * Is listed as an explicit optional or required dependency in one or more - TriBITS SE package's `/cmake/Dependencies.cmake`_ files. + downstream TriBITS packages' `/cmake/Dependencies.cmake`_ files. +* Can be enabled automatically or can trigger the disable of dependent + downstream packages (see `TriBITS Dependency Handling Behaviors`_). + +The TriBITS external package/TPL mechanism provides a uniform way to find and +provide access to any type of external resource no matter how it might be +installed or ways to provide access to it. Using a TriBITS TPL is to be +preferred over using raw CMake ``find_package()`` call because +the TriBITS system guarantees that only a single unique version of an external +package/TPL of the same version will be used all of the downstream packages +that uses it. Also, by defining a TriBITS TPL, automatic enable/disable logic +will be applied as described in `Package Dependencies and Enable/Disable +Logic`_. For example, if a TPL is explicitly disabled, all of the downstream +packages that depend on that TPL will be automatically disabled as well (see +`TPL disable triggers auto-disables of downstream dependencies`_). .. _Globally unique TriBITS TPL names: -**WARNING:** One must be very careful to pick **Globally unique TriBITS TPL -names** across all TPLs in all TriBITS repositories that ever might be cobbled -together into a single TriBITS (meta) project! However, choosing TPL names is -usually much easier and less risky than choosing `Globally unique TriBITS -package names`_ because the native TPLs themselves tend to be uniquely named. -For example, the TPL names ``BLAS`` and ``LAPACK`` are well defined in the -applied math and computational science community and are not likely to clash. - -Using a TriBITS TPL is to be preferred over using raw CMake -``find_package()`` because the TriBITS system guarantees -that only a single unique version of TPL of the same version will be used by -multiple packages that uses the TPL. Also, by defining a TriBITS TPL, -automatic enable/disable logic will be applied as described in `Package -Dependencies and Enable/Disable Logic`_. For example, if a TPL is explicitly -disabled, all of the downstream packages that depend on that TPL will be -automatically disabled as well (see `TPL disable triggers auto-disables of -downstream dependencies`_). +**WARNING:** One must be very careful to pick **Globally unique TriBITS +External Package/TPL names** ```` across all TPLs in all TriBITS +repositories that ever might be cobbled together into a single TriBITS (meta) +project! However, choosing TPL names is usually much easier and less risky +than choosing `Globally unique TriBITS package names`_ because the native TPLs +themselves tend to be uniquely named. For example, the TPL names ``BLAS`` and +``LAPACK`` are well defined in the applied math and computational science +community and are not likely to clash. TriBITS External Package/TPL Core Files ....................................... -For each external package/TPL referenced in a `/TPLsList.cmake`_ file -using the macro `tribits_repository_define_tpls()`_, there must exist a file, -typically called ``FindTPL.cmake``, that once processed, produces the -target ```::all_libs`` and generates a wrapper package config file -``Config.cmake``. A simple example of such a file is the common -TriBITS ``FindTPLPETSC.cmake`` module which is currently: +The core files that define a *TriBITS External Package/TPL* are:: + + / + FindTPL.cmake # The name is not fixed (see _FINDMOD) + FindTPLDependencies.cmake # [Optional], defines upstream dependencies + +Above, ``/`` can be a subdirectory under a TriBITS repository +``/`` (e.g. ``/cmake/tpls/``) or can be under a TriBITS +package directory ``/`` (e.g. ``/cmake/tpls/``). + +The following TriBITS External Package/TPL files are documented in more detail +below: + +* `/FindTPL.cmake`_ +* `/FindTPLDependencies.cmake`_ + + +.. _FindTPL.cmake: +.. _/FindTPL.cmake: + +**/FindTPL.cmake**: [Required] Defines how an external +package/TPL is found and provided for usage by a downstream TriBITS package by +providing the ``::all_libs`` target and a package config file +``Config.cmake`` that also defines the target +``::all_libs``. (The requirements for a ``FindTPL.cmake`` +file are given in `Requirements for FindTPL.cmake modules`_). + +The form of a simple ``FindTPL.cmake`` file that uses an internal +call to ``find_package()`` which provides modern IMPORTED CMake +targets looks like:: + + find_package( REQUIRED) + tribits_external_package_create_imported_all_libs_target_and_config_file( + + INNER_FIND_PACKAGE_NAME + IMPORTED_TARGETS_FOR_ALL_LIBS ... ) + +In this case, the purpose for the ``FindTPL.cmake`` file (as apposed +to a direct call to ``find_package()``) is to ensure the +definition of the complete target ``::all_libs`` which contains all +usage requirements for the external package/TPL (i.e. all of the libraries, +include directories, etc.). + +The form of a simple ``FindTPL.cmake`` file that just provides a list +of required header files and libraries that does **not** use an internal call +to ``find_package()`` looks like:: + + tribits_tpl_find_include_dirs_and_libraries( + REQUIRED_HEADERS ... + REQUIRED_LIBS_NAMES ... + MUST_FIND_ALL_LIBS + ) + +An example concrete file is ``tribits/common_tpls/FindTPLPETSC.cmake``: .. include:: ../../common_tpls/FindTPLPETSC.cmake :literal: -Many concrete ``FindTPL.cmake`` files use ``find_package()`` -internally and a standard CMake package find module or an installed -``Config.cmake`` file to fill in the guts of finding at TPL. In this -case, the purpose for the wrapping ``FindTPL.cmake`` file is to -ensure the definition of the complete target ``::all_libs`` which -contains all usage requirements for the external package/TPL (i.e. all of the -libraries, include directories, etc.). For more details creating or upgrading -a ``FindTPL.cmake`` file, see `How to add a new TriBITS TPL`_. +For complete details, see `Creating the FindTPL.cmake file`_. + + +.. _FindTPLDependencies.cmake: +.. _/FindTPLDependencies.cmake: + +**/FindTPLDependencies.cmake**: [Optional] +Declares dependencies on upstream external packages/TPLs for the external +package/TPL ````. Many external packages/TPLs defined with a +`FindTPL.cmake`_ file do not have any upstream dependencies or have +internal mechanisms to get those (such as when using +``find_package()`` where the ``Config.cmake`` file +which recursively uses ``find_dependency()`` to get its upstream +dependencies). But for ``FindTPL.cmake`` files that just use +`tribits_tpl_find_include_dirs_and_libraries()`_ (see `Creating a +FindTPL.cmake module without find_package()`_), TriBITS needs to be told +about any upstream external packages/TPLs that it may depend on so it can add +the dependencies between the created IMPORTED target libraries. + +The file ``FindTPLDependencies.cmake`` is typically just a single +call to `tribits_external_package_define_dependencies()`_ and takes the form:: + + tribits_external_package_define_dependencies( + DEPENDENCIES ... ) + +This defines all of the TPLs that ```` could directly depends on but +only dependencies for enabled upstream TPLs will be added to the IMPORTED +targets. TriBITS External Package/TPL Core Variables @@ -2216,53 +2293,65 @@ Once the `/TPLsList.cmake`_ files are all processed, then each defined TPL ``TPL_NAME`` is assigned the following global non-cache variables: .. _${PACKAGE_NAME}_FINDMOD: - + .. __FINDMOD: .. _${TPL_NAME}_FINDMOD: ``${TPL_NAME}_FINDMOD`` - Gives the location for the TPL's find module (typically called - ``FindTPL.cmake``, see `How to add a new TriBITS TPL`_). This is - set using the ``FINDMOD`` field in the call to - `tribits_repository_define_tpls()`_. The final value of the variable is - defined by the *last* `/TPLsList.cmake`_ file that is processed - that declares the TPL ``TPL_NAME``. For example, if - ``Repo1/TPLsList.cmake`` and ``Repo2/TPLsList.cmake`` both list the TPL - ``SomeTpl``, then if ``Repo2`` is processed after ``Repo1``, then - ``SomeTpl_FINDMOD`` is determined by ``Repo2/TPLsList.cmake`` and the find - module listed in ``Repo1/TPLsList.cmake`` is ignored. + Relative path (w.r.t. ``_) for the external package/TPL's find + module (typically named `FindTPL.cmake`_): This is set using the + ``FINDMOD`` field in the call to `tribits_repository_define_tpls()`_. The + final value of the variable is defined by the *last* + `/TPLsList.cmake`_ file that is processed that declares the TPL + ``TPL_NAME``. For example, if ``Repo1/TPLsList.cmake`` and + ``Repo2/TPLsList.cmake`` both list the TPL ``SomeTpl``, then if ``Repo2`` + is processed after ``Repo1``, then ``SomeTpl_FINDMOD`` is determined by + ``Repo2/TPLsList.cmake`` and the find module listed in + ``Repo1/TPLsList.cmake`` is ignored. + + .. __DEPENDENCIES_FILE: + .. _${TPL_NAME}_DEPENDENCIES_FILE: + + ``${TPL_NAME}_DEPENDENCIES_FILE`` + + Relative path (w.r.t. ``_) for the external package/TPL's + dependencies file (typically named `FindTPLDependencies.cmake`_) .. _${TPL_NAME}_TESTGROUP: ``${TPL_NAME}_TESTGROUP`` - Gives the TPL's `SE Package Test Group`_. This is set using the - ``CLASSIFICATION`` field in the call to - `tribits_repository_define_tpls()`_. If multiple repos define a given - TPL, then the *first* `/TPLsList.cmake`_ file that is processed - that declares the TPL ``TPL_NAME`` specifies the test group. For example, - if ``Repo1/TPLsList.cmake`` and ``Repo2/TPLsList.cmake`` both list the TPL - ``SomeTpl``, then if ``Repo2`` is processed after ``Repo1``, then - ``SomeTpl_TESTGROUP`` is determined by ``Repo1/TPLsList.cmake`` and the - test group in ``Repo2/TPLsList.cmake`` is ignored. However, if - ``${TPL_NAME}_TESTGROUP`` is already set before the + TPL's `SE Package Test Group`_: This is set using the ``CLASSIFICATION`` + field in the call to `tribits_repository_define_tpls()`_. If multiple + repos define a given TPL, then the *first* `/TPLsList.cmake`_ + file that is processed that declares the TPL ``TPL_NAME`` specifies the + test group. For example, if ``Repo1/TPLsList.cmake`` and + ``Repo2/TPLsList.cmake`` both list the TPL ``SomeTpl``, then if ``Repo2`` + is processed after ``Repo1``, then ``SomeTpl_TESTGROUP`` is determined by + ``Repo1/TPLsList.cmake`` and the test group in ``Repo2/TPLsList.cmake`` is + ignored. However, if ``${TPL_NAME}_TESTGROUP`` is already set before the `/TPLsList.cmake`_ files are processed, then that test group will be used. Therefore, the project can override the test group for a given - TPL if desired. + TPL if desired by setting ``${TPL_NAME}_TESTGROUP`` before the first + `/TPLsList.cmake`_ file gets processed. -As noted above, it is allowed for the same TPL to be listed in multiple -`/TPLsList.cmake`_ files. In this case, the rules for overrides of -the find module and the test group as as described above. + .. _+${TPL_NAME}_TPLS_LIST_FILE: -The specification given in `Enabling support for an optional Third-Party -Library (TPL)`_ and `How to add a new TriBITS TPL`_ describes to create a -``FindTPL.cmake`` module. However, all that is required is that -some CMake file fragment exist such that, once included, will define the -target ``::all_libs`` and create the ``Config.cmake`` file -in the correct location. + ``${TPL_NAME}_TPLS_LIST_FILE`` + Absolute path of the (last) `/TPLsList.cmake`_ file that declared + this external package/TPL. +As noted above, it is allowed for the same TPL to be listed in multiple +`/TPLsList.cmake`_ files. In this case, the rules for overrides of +the find module and the test group as described above. +The specification given in `Enabling support for an optional Third-Party +Library (TPL)`_ and `Creating the FindTPL.cmake file`_ describe how +to create a ``FindTPL.cmake`` module. However, all that is required +is that some CMake file fragment exist such that, once included, will define +the target ``::all_libs`` and create the ``Config.cmake`` +file in the correct location (see `Requirements for FindTPL.cmake modules`_). Processing of TriBITS Files: Ordering and Details @@ -5459,60 +5548,64 @@ subpackages, do the following: How to add a new TriBITS external package/TPL --------------------------------------------- -In order for a TriBITS package to define a dependency on a new external -package/TPL (i.e. a TPL that has not already been declared in the current -repo's or an upstream repo's `/TPLsList.cmake`_ file), one must add -and modify a few repository-level files in addition to modifying files within -the TriBITS packages that use the new external package/TPL. +In order for a TriBITS package to define a dependency on a new `TriBITS +External Package/TPL`_ (i.e. a TPL that has not already been declared in the +current repo's or an upstream repo's `/TPLsList.cmake`_ file), one +must add and modify a few repository-level files in addition to modifying +files within the TriBITS packages that use the new external package/TPL. To add a new TriBITS TPL, do the following: -1) Chose a name ```` for the new TPL (must be globally unique across - all TriBITS repos, see `Globally unique TriBITS TPL names`_) and which - TriBITS repository (````) to define the new TPL inside of. (The - right repo is usually the one where the package exists that needs the new - TPL dependency.) - -2) Create the TPL find module file ``FindTPL.cmake`` (or some other - name, see `TriBITS TPL`_) under some location under ```` - (e.g. ``/cmake/tpls/``) or under the package that uses it - (e.g. ``/cmake/tpls/``). How this file is defined depends on - if it uses ``find_package()`` or not and if that - ``find_package()`` command creates modern CMake IMPORTED - targets or not (see `Creating FindTPL*.cmake using find_package() with - IMPORTED targets`_ and `Creating FindTPL*.cmake using find_package() - without IMPORTED targets`_). If not using ``find_package()``, - follow the instructions in `Creating a FindTPL*.cmake module without - find_package()`_. - -3) Add a row for the new TPL to the `/TPLsList.cmake`_ file after any - TPLs that this new TPL may depend on. (One must also set the cache - variable ``_LIB_ENABLED_DEPENDENCIES`` to point the direct - dependencies of this new TPL. See the example in - ``TribitsExampleProject2/TPLsList.cmake``.) - -4) Configure the TriBITS project enabling the new TPL with - ``TPL_ENABLE_=ON`` and see that the new find module finds the TPL - correctly at configure time. - -5) List the new external packages/TPL in the package(s) that need this - dependency in the package's `/cmake/Dependencies.cmake`_ file - (or `//cmake/Dependencies.cmake`_ for a subpackage). - -6) If the TPL is optional for the package, then:: +1) **Chose a name ** for the new TPL (must be globally unique across + all TriBITS repos. (See `Globally unique TriBITS TPL names`_.) + +2) **Choose the subdirectory for the new TPL files**. These + files are usually placed under the TriBITS repository directory + ``/`` (e.g. ``/cmake/tpls/``) where the first downstream + dependent package is defined or can be under a TriBITS package directory + ``/`` (e.g. ``/cmake/tpls/``) if only one package + is using that TPL. + +3) **Create the FindTPL.cmake file** (or some other name, see + `_FINDMOD`_) under ``/``. (See `Creating the + FindTPL.cmake file`_.) + +4) **[Optional] Create the FindTPLDependencies.cmake file** in the + same directory as the ``FindTPL.cmake`` file, ``/``. + (See `FindTPLDependencies.cmake`_.) + +5) **Add a row to the /TPLsList.cmake file** for the new TPL after + any TPLs that this new TPL may depend on. (See + `/TPLsList.cmake`_.) + +6) **Configure the TriBITS project enabling the new TPL with + TPL_ENABLE_=ON** and see that the TPL is found correctly at + configure time. + +7) **Add to the package Dependencies.cmake files** of downstream + dependent packages that will use this TPL (see + `/cmake/Dependencies.cmake`_ or + `//cmake/Dependencies.cmake`_ for a subpackage). + +8) **[Optional] Add #cmakedefine for an optional package library TPL + dependency in the package's _config.h.in file** using:: #cmakedefine HAVE__ - should be added to the package's ``_config.h.in`` file (see - `tribits_configure_file()`_) so that the code knows if the TPL is defined - or not. + so that the package's code build knows if the TPL is defined or not (see + `_config.h.in`_ and `tribits_configure_file()`_). (NOTE: Do + **not** add this for a optional test-only TPL dependency. We don't want + all of the libraries in a package to have to be rebuild when we enable or + disable tests for the package.) + +9) **Use the TPL functionality in the packages** that define the dependency on + the new TPL, configure, test, etc. -7) Use the TPL in the packages that define the dependency on the new TPL, - configure, test, etc. +.. _Creating the FindTPL.cmake file: -The following subsections describe the various use cases for creating (or -upgrading) ``FindTPL*.cmake`` modules. The main axes of variation for -``FindTPL*.cmake`` modules are: +**Creating the FindTPL.cmake file** + +The main axes of variation in defining ``FindTPL.cmake`` modules are: a) Use an inner ``find_package()`` call or just use a simple list of header file names and library names? @@ -5524,9 +5617,21 @@ c) Maintain backward compatibility with the legacy TriBITS TPL system that allows the user to set cache variables for the include directories and link libraries or force users to always call ``find_package()``? +See the different variations in the below sections: + +* `Creating FindTPL.cmake using find_package()`_ + + * `Creating FindTPL.cmake using find_package() with IMPORTED targets`_ -Creating FindTPL*.cmake using find_package() -++++++++++++++++++++++++++++++++++++++++++++ + * `Creating FindTPL.cmake using find_package() without IMPORTED targets`_ + +* `Creating a FindTPL.cmake module without find_package()`_ + +* `Requirements for FindTPL.cmake modules`_ + + +Creating FindTPL.cmake using find_package() +++++++++++++++++++++++++++++++++++++++++++++++++++++ When defining a ``FindTPL.cmake`` file, it encouraged to utilize ``find_package( ...)`` to provide the default find operation (and @@ -5551,12 +5656,15 @@ to adapt the information and objects provided by the for consumption by downstream TriBITS-compatible packages. The following subsections will describe how to create these TriBITS-compatible -``FindTPL.cmake`` modules for all of the various cases using -``find_package( ...)``. +``FindTPL.cmake`` modules for all of the various cases using an +internal call to ``find_package( ...)``: +* `Creating FindTPL.cmake using find_package() with IMPORTED targets`_ +* `Creating FindTPL.cmake using find_package() without IMPORTED targets`_ -Creating FindTPL*.cmake using find_package() with IMPORTED targets -.................................................................. + +Creating FindTPL.cmake using find_package() with IMPORTED targets +.......................................................................... For cases where ``find_package()`` provides complete and proper modern (namespaced) IMPORTED targets (but is missing the @@ -5646,8 +5754,8 @@ A concrete (and tested) example of the latter case can be found in the file :literal: -Creating FindTPL*.cmake using find_package() without IMPORTED targets -..................................................................... +Creating FindTPL.cmake using find_package() without IMPORTED targets +............................................................................. There are cases where calling ``find_package()`` to find the parts of an external package does not create proper IMPORTED targets that can @@ -5703,7 +5811,8 @@ using the ``FindTPL.cmake`` module:: tribits_tpl_find_include_dirs_and_libraries( REQUIRED_HEADERS ${REQUIRED_HEADERS} - REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} ) + REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} + MUST_FIND_ALL_LIBS ) Above, if ``find_package()`` can't find ````, then the function ``tribits_tpl_find_include_dirs_and_libraries()`` will try to @@ -5742,7 +5851,8 @@ find must be used (to maintain backward compatibility). This tribits_tpl_find_include_dirs_and_libraries( REQUIRED_HEADERS ${REQUIRED_HEADERS} - REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} ) + REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} + MUST_FIND_ALL_LIBS ) The above will result in skipping the call of ``find_package()`` if any of the legacy TPL find variables are set. But if the legacy TPL find @@ -5790,8 +5900,8 @@ standard legacy TriBITS behavior described in `Enabling support for an optional Third-Party Library (TPL)`_. -Creating a FindTPL*.cmake module without find_package() -+++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Creating a FindTPL.cmake module without find_package() ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ For external packages that don't have a ``Find.cmake`` module or ``Config.cmake`` package config file, it may make sense to create @@ -5803,11 +5913,12 @@ header files and libraries that must be found. A simple tribits_tpl_find_include_dirs_and_libraries( REQUIRED_HEADERS ... REQUIRED_LIBS_NAMES ... + MUST_FIND_ALL_LIBS ) -Requirements for FindTPL*.cmake modules -+++++++++++++++++++++++++++++++++++++++ +Requirements for FindTPL.cmake modules ++++++++++++++++++++++++++++++++++++++++++++++++ It is possible to create a ``FindTPL.cmake`` module without using any TriBITS functions. The only firm requirements for a diff --git a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst index a6216f605..03acd2071 100644 --- a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst @@ -25,21 +25,22 @@ understand the internals of TriBITS. @FUNCTION: tribits_dump_package_dependencies_info() + @FUNCTION: tribits_print_initial_dependency_info() + @FUNCTION: tribits_print_tentatively_enabled_tpls() + +@MACRO: tribits_parse_subpackages_append_se_packages_add_options() + +@MACRO: tribits_prep_to_read_dependencies() + @MACRO: tribits_process_all_repository_deps_setup_files() + +@MACRO: tribits_process_package_dependencies_lists() + @MACRO: tribits_process_packages_and_dirs_lists() + @MACRO: tribits_process_project_dependency_setup_file() + @MACRO: tribits_process_tpls_lists() + @MACRO: tribits_read_all_package_deps_files_create_deps_graph() + -@MACRO: tribits_read_package_subpackage_deps_files_add_to_graph() + +@MACRO: tribits_read_all_project_deps_files_create_deps_graph() + @MACRO: tribits_read_back_dependencies_vars() + @MACRO: tribits_read_defined_external_and_internal_toplevel_packages_lists() + -@MACRO: tribits_read_all_project_deps_files_create_deps_graph() + -@MACRO: tribits_read_toplevel_package_deps_files_add_to_graph() + -@MACRO: tribits_read_subpackage_deps_file_add_to_graph() + -@MACRO: tribits_parse_subpackages_append_se_packages_add_options() + -@MACRO: tribits_prep_to_read_dependencies() + -@MACRO: tribits_process_package_dependencies_lists() + @MACRO: tribits_read_deps_files_create_deps_graph() + +@MACRO: tribits_read_external_package_deps_files_add_to_graph() + +@MACRO: tribits_read_package_subpackage_deps_files_add_to_graph() + +@MACRO: tribits_read_subpackage_deps_file_add_to_graph() + +@MACRO: tribits_read_toplevel_package_deps_files_add_to_graph() + @MACRO: tribits_save_off_dependency_vars() + @FUNCTION: tribits_set_dep_packages() + @FUNCTION: tribits_trace_file_processing() + diff --git a/tribits/examples/TribitsExampleProject2/TPLsList.cmake b/tribits/examples/TribitsExampleProject2/TPLsList.cmake index ff4115a0a..3474c5cd5 100644 --- a/tribits/examples/TribitsExampleProject2/TPLsList.cmake +++ b/tribits/examples/TribitsExampleProject2/TPLsList.cmake @@ -4,8 +4,3 @@ tribits_repository_define_tpls( Tpl3 "cmake/tpls/" PT Tpl4 "cmake/tpls/" PT ) - -# Temp hack for setting up TPL dependencies -tribits_external_package_define_dependencies(Tpl2 DEPENDENCIES Tpl1) -tribits_external_package_define_dependencies(Tpl3 DEPENDENCIES Tpl2) -tribits_external_package_define_dependencies(Tpl4 DEPENDENCIES Tpl2 Tpl3) diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake new file mode 100644 index 000000000..074cc9fac --- /dev/null +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake @@ -0,0 +1,2 @@ +tribits_external_package_define_dependencies(Tpl2 + DEPENDENCIES Tpl1) diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake new file mode 100644 index 000000000..9ba617eb3 --- /dev/null +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake @@ -0,0 +1,2 @@ +tribits_external_package_define_dependencies(Tpl3 + DEPENDENCIES Tpl2) diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake new file mode 100644 index 000000000..4181c206e --- /dev/null +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake @@ -0,0 +1,2 @@ +tribits_external_package_define_dependencies(Tpl4 + DEPENDENCIES Tpl2 Tpl3) From dfd53a31e74d593af5b6f42e205eb69a9f37c075 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 14 Jul 2022 19:15:40 -0600 Subject: [PATCH 6/8] Change prefix tribits_external_package_ to tribits_extpkg_ (#63, #299, #494) There was feedback from @KyleFromKitware that this was too long and too hard to see the prefix. --- ...rnalPackageWriteConfigFile_UnitTests.cmake | 202 +++++++++--------- ...TribitsPackageDependencies_UnitTests.cmake | 36 ++-- .../TribitsAdjustPackageEnables.cmake | 2 +- ...TribitsExternalPackageFindTplHelpers.cmake | 10 +- ...ribitsExternalPackageWriteConfigFile.cmake | 84 ++++---- .../TribitsPackageDependencies.cmake | 22 +- .../TribitsProcessEnabledTpl.cmake | 6 +- ...ribitsTplFindIncludeDirsAndLibraries.cmake | 4 +- tribits/doc/guides/TribitsGuidesBody.rst | 16 +- .../TribitsMacroFunctionDocTemplate.rst | 10 +- .../TribitsSystemMacroFunctionDocTemplate.rst | 14 +- .../cmake/tpls/FindTPLTpl1.cmake | 2 +- .../cmake/tpls/FindTPLTpl2.cmake | 2 +- .../cmake/tpls/FindTPLTpl2Dependencies.cmake | 2 +- .../cmake/tpls/FindTPLTpl3.cmake | 2 +- .../cmake/tpls/FindTPLTpl3Dependencies.cmake | 2 +- .../cmake/tpls/FindTPLTpl4.cmake | 2 +- .../cmake/tpls/FindTPLTpl4Dependencies.cmake | 2 +- 18 files changed, 210 insertions(+), 210 deletions(-) diff --git a/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake b/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake index 2bf53e93d..4c5f51ca7 100644 --- a/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake +++ b/test/core/TribitsExternalPackageWriteConfigFile_UnitTests.cmake @@ -61,45 +61,45 @@ include(GlobalNullSet) # -# Tests for tribits_external_package_get_libname_from_full_lib_path() +# Tests for tribits_extpkg_get_libname_from_full_lib_path() # -function(unittest_tribits_external_package_get_libname_from_full_lib_path_linux) +function(unittest_tribits_extpkg_get_libname_from_full_lib_path_linux) message("\n***") - message("*** Testing tribits_external_package_get_libname_from_full_lib_path() for Linux") + message("*** Testing tribits_extpkg_get_libname_from_full_lib_path() for Linux") message("***\n") set(tplName "SomeTpl") set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib1.a" libname) unittest_compare_const( libname "somelib1" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib2.so" libname) unittest_compare_const( libname "somelib2" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib3.so.1.2.3" libname) unittest_compare_const( libname "somelib3" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib4.any.extension" libname) unittest_compare_const( libname "somelib4" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/somelib5.any.extension" libname) unittest_compare_const( libname "" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT @@ -108,37 +108,37 @@ function(unittest_tribits_external_package_get_libname_from_full_lib_path_linux) endfunction() -function(unittest_tribits_external_package_get_libname_from_full_lib_path_win32) +function(unittest_tribits_extpkg_get_libname_from_full_lib_path_win32) message("\n***") - message("*** Testing tribits_external_package_get_libname_from_full_lib_path() for WIN32") + message("*** Testing tribits_extpkg_get_libname_from_full_lib_path() for WIN32") message("***\n") set(WIN32 TRUE) - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/somelib1.a" libname) unittest_compare_const( libname "somelib1" ) - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/somelib2.dll" libname) unittest_compare_const( libname "somelib2" ) - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/somelib3.any-extension" libname) unittest_compare_const( libname "somelib3" ) - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib4.any-extension" libname) unittest_compare_const( libname "libsomelib4" ) endfunction() -function(unittest_tribits_external_package_get_libname_from_full_lib_path_apple) +function(unittest_tribits_extpkg_get_libname_from_full_lib_path_apple) message("\n***") - message("*** Testing tribits_external_package_get_libname_from_full_lib_path() for APPLE") + message("*** Testing tribits_extpkg_get_libname_from_full_lib_path() for APPLE") message("***\n") set(APPLE TRUE) @@ -146,43 +146,43 @@ function(unittest_tribits_external_package_get_libname_from_full_lib_path_apple) set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib1.a" libname) unittest_compare_const( libname "somelib1" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib2.so" libname) unittest_compare_const( libname "somelib2" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib3.tbd" libname) unittest_compare_const( libname "somelib3" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/libsomelib4.any-extension" libname) unittest_compare_const( libname "somelib4" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/Accelerate.framework" libname) unittest_compare_const( libname "Accelerate" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/someNameWithExtraDots.a.b.framework" libname) unittest_compare_const( libname "someNameWithExtraDots" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT "") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_libname_from_full_lib_path( + tribits_extpkg_get_libname_from_full_lib_path( "/some/base/path/SomeBase.any.extension" libname) unittest_compare_const( libname "" ) unittest_compare_const(MESSAGE_WRAPPER_INPUT @@ -192,17 +192,17 @@ endfunction() # -# Tests for tribits_external_package_process_libraries_list_incl() +# Tests for tribits_extpkg_process_libraries_list_incl() # # Testing with no upstream TPL dependencies -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_1) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_1) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib files 1") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib files 1") message("***\n") set(tplName SomeTpl) @@ -210,7 +210,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -238,10 +238,10 @@ set_target_properties(SomeTpl::somelib PROPERTIES endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_2) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_2) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib files 2") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib files 2") message("***\n") set(tplName SomeTpl) @@ -250,7 +250,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -284,10 +284,10 @@ target_link_libraries(SomeTpl::somelib2 endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_3) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_3) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib files 3") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib files 3") message("***\n") set(tplName SomeTpl) @@ -298,7 +298,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -338,10 +338,10 @@ target_link_libraries(SomeTpl::somelib3 endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_1_1) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_1_1) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib opts 1, 1") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib opts 1, 1") message("***\n") set(tplName SomeTpl) @@ -351,7 +351,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -379,10 +379,10 @@ set_target_properties(SomeTpl::lib1 PROPERTIES endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_2_2) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_2_2) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib opts 2, 2") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib opts 2, 2") message("***\n") set(tplName SomeTpl) @@ -393,7 +393,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -427,10 +427,10 @@ target_link_libraries(SomeTpl::lib2 endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_3_3) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_3_3) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib opts 3, 3") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib opts 3, 3") message("***\n") set(tplName SomeTpl) @@ -442,7 +442,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -482,10 +482,10 @@ target_link_libraries(SomeTpl::lib3 endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_link_opt_1) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_link_opt_1) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, link opt 1") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, link opt 1") message("***\n") set(tplName SomeTpl) @@ -496,7 +496,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(MESSAGE_WRAPPER_UNIT_TEST_MODE ON) global_null_set(MESSAGE_WRAPPER_INPUT) - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -524,10 +524,10 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_libname_2) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_libname_2) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, libname 2") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, libname 2") message("***\n") set(tplName SomeTpl) @@ -542,7 +542,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(MESSAGE_WRAPPER_UNIT_TEST_MODE ON) global_null_set(MESSAGE_WRAPPER_INPUT) - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -580,10 +580,10 @@ target_link_libraries(SomeTpl::some1_Longer2-Name3 endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_2_2_lib_files_1) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_2_2_lib_files_1) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib opts 2, 2, lib files 1") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib opts 2, 2, lib files 1") message("***\n") set(tplName SomeTpl) @@ -595,7 +595,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -635,10 +635,10 @@ target_link_libraries(SomeTpl::lib3 endfunction() -function(unittest_tribits_external_package_process_libraries_list_duplicate_libs) +function(unittest_tribits_extpkg_process_libraries_list_duplicate_libs) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): duplicate libs") + message("*** Testing tribits_extpkg_process_libraries_list(): duplicate libs") message("***\n") set(tplName SomeTpl) @@ -652,7 +652,7 @@ function(unittest_tribits_external_package_process_libraries_list_duplicate_libs set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -695,10 +695,10 @@ endfunction() # Testing with upstream TPL dependenices -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_1_deps_3) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_1_deps_3) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib files 1, deps 3") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib files 1, deps 3") message("***\n") set(tplName SomeTpl) @@ -707,7 +707,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -740,10 +740,10 @@ target_link_libraries(SomeTpl::somelib endfunction() -function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_3_deps_3) +function(unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_3_deps_3) message("\n***") - message("*** Testing tribits_external_package_process_libraries_list(): incl dirs 0, lib files 3, deps 3") + message("*** Testing tribits_extpkg_process_libraries_list(): incl dirs 0, lib files 3, deps 3") message("***\n") set(tplName SomeTpl) @@ -755,7 +755,7 @@ function(unittest_tribits_external_package_process_libraries_list_incl_dirs_0_li set(configFileFragStr "#beginning\n\n") - tribits_external_package_process_libraries_list( ${tplName} + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargetsList LIB_LINK_FLAGS_LIST_OUT libLinkFlagsList CONFIG_FILE_STR_INOUT configFileFragStr @@ -801,11 +801,11 @@ endfunction() # -# Tests for tribits_external_package_write_config_file_str() +# Tests for tribits_extpkg_write_config_file_str() # -function(unittest_tribits_external_package_write_config_file_str_incl_dirs_0_lib_files_1) +function(unittest_tribits_extpkg_write_config_file_str_incl_dirs_0_lib_files_1) message("\n***") message("*** Testing the generation of Config.cmake: incl dirs 0, lib files 1") @@ -815,7 +815,7 @@ function(unittest_tribits_external_package_write_config_file_str_incl_dirs_0_lib set(TPL_${tplName}_INCLUDE_DIRS "") set(TPL_${tplName}_LIBRARIES "/some/explicit/path/libsomelib.so") - tribits_external_package_write_config_file_str(${tplName} + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr ) unittest_string_block_compare( tplConfigFileStr @@ -844,7 +844,7 @@ target_link_libraries(SomeTpl::all_libs endfunction() -function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_files_0) +function(unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_files_0) message("\n***") message("*** Testing the generation of Config.cmake: incl dirs 2, lib files 0") @@ -854,7 +854,7 @@ function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib set(TPL_${tplName}_INCLUDE_DIRS "/some/path/to/include/d" "/some/other/path/to/include/e") set(TPL_${tplName}_LIBRARIES "") - tribits_external_package_write_config_file_str(${tplName} + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr ) unittest_string_block_compare( tplConfigFileStr @@ -880,7 +880,7 @@ target_include_directories(SomeTpl::all_libs SYSTEM endfunction() -function(unittest_tribits_external_package_write_config_file_str_incl_dirs_1_lib_files_1) +function(unittest_tribits_extpkg_write_config_file_str_incl_dirs_1_lib_files_1) message("\n***") message("*** Testing the generation of Config.cmake: incl dirs 1, lib files 1") @@ -890,7 +890,7 @@ function(unittest_tribits_external_package_write_config_file_str_incl_dirs_1_lib set(TPL_${tplName}_INCLUDE_DIRS "/some/path/to/include/C") set(TPL_${tplName}_LIBRARIES "/some/explicit/path/libsomelib.so") - tribits_external_package_write_config_file_str(${tplName} + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr ) unittest_string_block_compare( tplConfigFileStr @@ -922,7 +922,7 @@ target_include_directories(SomeTpl::all_libs SYSTEM endfunction() -function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_files_1) +function(unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_files_1) message("\n***") message("*** Testing the generation of Config.cmake: incl dirs 2, lib files 1") @@ -932,7 +932,7 @@ function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib set(TPL_${tplName}_INCLUDE_DIRS "/some/path/to/include/a" "/some/other/path/to/include/b") set(TPL_${tplName}_LIBRARIES "/some/explicit/path/libsomelib.so") - tribits_external_package_write_config_file_str(${tplName} + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr ) unittest_string_block_compare( tplConfigFileStr @@ -965,7 +965,7 @@ target_include_directories(SomeTpl::all_libs SYSTEM endfunction() -function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_opts_2_2) +function(unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_opts_2_2) message("\n***") message("*** Testing the generation of Config.cmake: incl dirs 2, lib opts 2, 2") @@ -980,7 +980,7 @@ function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib -llib1 -L/some/explicit/path1 ) - tribits_external_package_write_config_file_str(${tplName} + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr ) unittest_string_block_compare( tplConfigFileStr @@ -1024,7 +1024,7 @@ target_link_options(SomeTpl::all_libs endfunction() -function(unittest_tribits_external_package_write_config_file_str_incl_dirs_1_bad_lib_args) +function(unittest_tribits_extpkg_write_config_file_str_incl_dirs_1_bad_lib_args) message("\n***") message("*** Testing the generation of Config.cmake: incl dirs 1, bad lib args") @@ -1044,7 +1044,7 @@ function(unittest_tribits_external_package_write_config_file_str_incl_dirs_1_bad set(MESSAGE_WRAPPER_UNIT_TEST_MODE ON) global_null_set(MESSAGE_WRAPPER_INPUT) - tribits_external_package_write_config_file_str(${tplName} + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr ) unittest_compare_const( MESSAGE_WRAPPER_INPUT @@ -1099,7 +1099,7 @@ target_link_options(SomeTpl::all_libs endfunction() -function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_opts_2_2_deps_3) +function(unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_opts_2_2_deps_3) message("\n***") message("*** Testing the generation of Config.cmake: incl dirs 2, lib opts 2, 2, deps 3") @@ -1119,7 +1119,7 @@ function(unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib set(PrivateTpl_DIR "") set(DefaultVisTpl_DIR "") - tribits_external_package_write_config_file_str(${tplName} + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr ) unittest_string_block_compare( tplConfigFileStr @@ -1210,32 +1210,32 @@ unittest_initialize_vars() # Run the unit tests # -unittest_tribits_external_package_get_libname_from_full_lib_path_linux() -unittest_tribits_external_package_get_libname_from_full_lib_path_win32() -unittest_tribits_external_package_get_libname_from_full_lib_path_apple() - -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_1() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_2() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_3() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_1_1() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_2_2() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_3_3() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_opts_2_2_lib_files_1() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_link_opt_1() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_libname_2() -unittest_tribits_external_package_process_libraries_list_duplicate_libs() - -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_1_deps_3() -unittest_tribits_external_package_process_libraries_list_incl_dirs_0_lib_files_3_deps_3() - -unittest_tribits_external_package_write_config_file_str_incl_dirs_0_lib_files_1() -unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_files_0() -unittest_tribits_external_package_write_config_file_str_incl_dirs_1_lib_files_1() -unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_files_1() -unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_opts_2_2() -unittest_tribits_external_package_write_config_file_str_incl_dirs_1_bad_lib_args() - -unittest_tribits_external_package_write_config_file_str_incl_dirs_2_lib_opts_2_2_deps_3() +unittest_tribits_extpkg_get_libname_from_full_lib_path_linux() +unittest_tribits_extpkg_get_libname_from_full_lib_path_win32() +unittest_tribits_extpkg_get_libname_from_full_lib_path_apple() + +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_1() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_2() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_3() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_1_1() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_2_2() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_3_3() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_opts_2_2_lib_files_1() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_link_opt_1() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_libname_2() +unittest_tribits_extpkg_process_libraries_list_duplicate_libs() + +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_1_deps_3() +unittest_tribits_extpkg_process_libraries_list_incl_dirs_0_lib_files_3_deps_3() + +unittest_tribits_extpkg_write_config_file_str_incl_dirs_0_lib_files_1() +unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_files_0() +unittest_tribits_extpkg_write_config_file_str_incl_dirs_1_lib_files_1() +unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_files_1() +unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_opts_2_2() +unittest_tribits_extpkg_write_config_file_str_incl_dirs_1_bad_lib_args() + +unittest_tribits_extpkg_write_config_file_str_incl_dirs_2_lib_opts_2_2_deps_3() # Pass in the number of expected tests that must pass! unittest_final_result(74) diff --git a/test/core/TribitsPackageDependencies_UnitTests.cmake b/test/core/TribitsPackageDependencies_UnitTests.cmake index 11daf2577..b19262282 100644 --- a/test/core/TribitsPackageDependencies_UnitTests.cmake +++ b/test/core/TribitsPackageDependencies_UnitTests.cmake @@ -61,21 +61,21 @@ include(GlobalNullSet) # -# Tests for tribits_external_package_get_dep_name_and_vis() +# Tests for tribits_extpkg_get_dep_name_and_vis() # -function(unittest_tribits_external_package_get_dep_name_and_vis) +function(unittest_tribits_extpkg_get_dep_name_and_vis) message("\n***") - message("*** Testing tribits_external_package_get_dep_name_and_vis()") + message("*** Testing tribits_extpkg_get_dep_name_and_vis()") message("***\n") set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) message("\nTesting default visibility\n") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_dep_name_and_vis( + tribits_extpkg_get_dep_name_and_vis( SomePackage upstreamTplDepNameOut upstreamTplDepVisOut) unittest_compare_const( upstreamTplDepNameOut "SomePackage" ) @@ -85,7 +85,7 @@ function(unittest_tribits_external_package_get_dep_name_and_vis) message("\nTesting PUBLIC\n") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_dep_name_and_vis( + tribits_extpkg_get_dep_name_and_vis( SomePackage:PUBLIC upstreamTplDepNameOut upstreamTplDepVisOut) unittest_compare_const( upstreamTplDepNameOut SomePackage ) @@ -95,7 +95,7 @@ function(unittest_tribits_external_package_get_dep_name_and_vis) message("\nTesting PRIVATE\n") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_dep_name_and_vis( + tribits_extpkg_get_dep_name_and_vis( SomePackage:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut) unittest_compare_const( upstreamTplDepNameOut SomePackage ) @@ -105,14 +105,14 @@ function(unittest_tribits_external_package_get_dep_name_and_vis) message("\nTesting invalid visibility\n") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_dep_name_and_vis( + tribits_extpkg_get_dep_name_and_vis( SomePackage:SPELLEDWRONG upstreamTplDepNameOut upstreamTplDepVisOut) unittest_compare_const(MESSAGE_WRAPPER_INPUT "FATAL_ERROR;ERROR: 'SomePackage:SPELLEDWRONG' has invalid visibility 'SPELLEDWRONG'.; Only 'PUBLIC' or 'PRIVATE' allowed!") message("\nTesting more than two elements splitting on ':'\n") global_set(MESSAGE_WRAPPER_INPUT "") - tribits_external_package_get_dep_name_and_vis( + tribits_extpkg_get_dep_name_and_vis( SomePackage:BadExtraEntry:PRIVATE upstreamTplDepNameOut upstreamTplDepVisOut) unittest_compare_const(MESSAGE_WRAPPER_INPUT "FATAL_ERROR;ERROR: 'SomePackage:BadExtraEntry:PRIVATE' has 2 ':' but only 1 is allowed!") @@ -124,17 +124,17 @@ endfunction() # -# Tests for tribits_external_package_define_dependencies() +# Tests for tribits_extpkg_define_dependencies() # -function(unittest_tribits_external_package_define_dependencies_basic) +function(unittest_tribits_extpkg_define_dependencies_basic) message("\n***") message("*** ${CMAKE_CURRENT_FUNCTION}()") message("***\n") - tribits_external_package_define_dependencies(someExtPkg + tribits_extpkg_define_dependencies(someExtPkg DEPENDENCIES upPkg1 upPkg2:PUBLIC upPkg3:PRIVATE upPkg4) unittest_compare_const( someExtPkg_LIB_ALL_DEPENDENCIES "upPkg1;upPkg2:PUBLIC;upPkg3:PRIVATE;upPkg4" ) @@ -143,22 +143,22 @@ endfunction() # -# Tests for tribits_external_package_setup_enabled_dependencies() +# Tests for tribits_extpkg_setup_enabled_dependencies() # -function(unittest_tribits_external_package_setup_enabled_dependencies) +function(unittest_tribits_extpkg_setup_enabled_dependencies) message("\n***") message("*** ${CMAKE_CURRENT_FUNCTION}()") message("***\n") - tribits_external_package_define_dependencies(someExtPkg + tribits_extpkg_define_dependencies(someExtPkg DEPENDENCIES upPkg1 upPkg2:PUBLIC upPkg3:PRIVATE upPkg4) set(TPL_ENABLE_someExtPkg ON) set(TPL_ENABLE_upPkg1 ON) set(TPL_ENABLE_upPkg3 ON) - tribits_external_package_setup_enabled_dependencies(someExtPkg) + tribits_extpkg_setup_enabled_dependencies(someExtPkg) unittest_compare_const( someExtPkg_LIB_ENABLED_DEPENDENCIES "upPkg1;upPkg3:PRIVATE" ) @@ -177,11 +177,11 @@ unittest_initialize_vars() # Run the unit tests # -unittest_tribits_external_package_get_dep_name_and_vis() +unittest_tribits_extpkg_get_dep_name_and_vis() -unittest_tribits_external_package_define_dependencies_basic() +unittest_tribits_extpkg_define_dependencies_basic() -unittest_tribits_external_package_setup_enabled_dependencies() +unittest_tribits_extpkg_setup_enabled_dependencies() # Pass in the number of expected tests that must pass! unittest_final_result(13) diff --git a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake index 984f91b81..2cd518463 100644 --- a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake +++ b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake @@ -1479,7 +1479,7 @@ macro(tribits_adjust_package_enables) # foreach(externalPkgName ${${PROJECT_NAME}_TPLS}) - tribits_external_package_setup_enabled_dependencies(${externalPkgName}) + tribits_extpkg_setup_enabled_dependencies(${externalPkgName}) # ToDo: Assert that all of the listed dependencies in # ${externalPkgName}_LIB_ENABLED_DEPENDENCIES exist and are upstream from # ${externalPkgName} diff --git a/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake b/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake index a0bf7b129..019911a89 100644 --- a/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake +++ b/tribits/core/package_arch/TribitsExternalPackageFindTplHelpers.cmake @@ -38,7 +38,7 @@ # @HEADER -# @FUNCTION: tribits_external_package_create_imported_all_libs_target_and_config_file() +# @FUNCTION: tribits_extpkg_create_imported_all_libs_target_and_config_file() # # Call from a ``FindTPL.cmake`` module that calls inner # ``find_package()`` for external package that uses modern CMake @@ -46,7 +46,7 @@ # # Usage:: # -# tribits_external_package_create_imported_all_libs_target_and_config_file( +# tribits_extpkg_create_imported_all_libs_target_and_config_file( # # INNER_FIND_PACKAGE_NAME # IMPORTED_TARGETS_FOR_ALL_LIBS ... ) @@ -67,7 +67,7 @@ # For more details, see `Creating FindTPL.cmake using find_package() # with IMPORTED targets`_. # -function(tribits_external_package_create_imported_all_libs_target_and_config_file +function(tribits_extpkg_create_imported_all_libs_target_and_config_file tplName ) @@ -88,7 +88,7 @@ function(tribits_external_package_create_imported_all_libs_target_and_config_fil endforeach() # Create Config.cmake file - tribits_external_package_create_package_config_file_with_imported_targets( + tribits_extpkg_create_package_config_file_with_imported_targets( ${tplName} INNER_FIND_PACKAGE_NAME ${PARSE_INNER_FIND_PACKAGE_NAME} IMPORTED_TARGETS_FOR_ALL_LIBS ${PARSE_IMPORTED_TARGETS_FOR_ALL_LIBS} ) @@ -96,7 +96,7 @@ function(tribits_external_package_create_imported_all_libs_target_and_config_fil endfunction() -function(tribits_external_package_create_package_config_file_with_imported_targets +function(tribits_extpkg_create_package_config_file_with_imported_targets tplName ) diff --git a/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake b/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake index 7766f3246..efc46fdd3 100644 --- a/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake +++ b/tribits/core/package_arch/TribitsExternalPackageWriteConfigFile.cmake @@ -48,7 +48,7 @@ include(MessageWrapper) cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... ) -# @FUNCTION: tribits_external_package_write_config_file() +# @FUNCTION: tribits_extpkg_write_config_file() # # Write out a ``Config.cmake`` file given the list of include # directories and libraries for an external package/TPL. @@ -65,17 +65,17 @@ cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... ) # ````: Full file path for the ``Config.cmake`` # file that will be written out. # -# This function just calls `tribits_external_package_write_config_file_str()`_ +# This function just calls `tribits_extpkg_write_config_file_str()`_ # and writes that text to the file ```` so see that function # for more details. # -function(tribits_external_package_write_config_file tplName tplConfigFile) - tribits_external_package_write_config_file_str(${tplName} tplConfigFileStr) +function(tribits_extpkg_write_config_file tplName tplConfigFile) + tribits_extpkg_write_config_file_str(${tplName} tplConfigFileStr) file(WRITE "${tplConfigFile}" "${tplConfigFileStr}") endfunction() -# @FUNCTION: tribits_external_package_write_config_version_file() +# @FUNCTION: tribits_extpkg_write_config_version_file() # # Write out a ``ConfigVersion.cmake`` file. # @@ -93,7 +93,7 @@ endfunction() # ````: Full file path for the # ``ConfigVersion.cmake`` file that will be written out. # -function(tribits_external_package_write_config_version_file tplName tplConfigVersionFile) +function(tribits_extpkg_write_config_version_file tplName tplConfigVersionFile) set(tplConfigVersionFileStr "") string(APPEND tplConfigVersionFileStr "# Package config file for external package/TPL '${tplName}'\n" @@ -115,7 +115,7 @@ function(tribits_external_package_write_config_version_file tplName tplConfigV endfunction() -# @FUNCTION: tribits_external_package_install_config_file() +# @FUNCTION: tribits_extpkg_install_config_file() # # Install an already-generated ``Config.cmake`` file. # @@ -131,7 +131,7 @@ endfunction() # ````: Full file path for the ``Config.cmake`` # file that will be installed into the correct location. # -function(tribits_external_package_install_config_file tplName tplConfigFile) +function(tribits_extpkg_install_config_file tplName tplConfigFile) install( FILES "${tplConfigFile}" DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}/external_packages/${tplName}" @@ -139,7 +139,7 @@ function(tribits_external_package_install_config_file tplName tplConfigFile) endfunction() -# @FUNCTION: tribits_external_package_install_config_version_file() +# @FUNCTION: tribits_extpkg_install_config_version_file() # # Install an already-generated ``ConfigVersion.cmake`` file. # @@ -156,7 +156,7 @@ endfunction() # ``ConfigVersion.cmake`` file that will be installed into the # correct location ``${${PROJECT_NAME}_INSTALL_LIB_DIR}/external_packages/`` # -function(tribits_external_package_install_config_version_file tplName +function(tribits_extpkg_install_config_version_file tplName tplConfigVersionFile ) install( @@ -166,14 +166,14 @@ function(tribits_external_package_install_config_version_file tplName endfunction() -# @FUNCTION: tribits_external_package_write_config_file_str() +# @FUNCTION: tribits_extpkg_write_config_file_str() # # Create the text string for a ``Config.cmake`` file given the list of # include directories and libraries for an external package/TPL. # # Usage:: # -# tribits_external_package_write_config_file_str( +# tribits_extpkg_write_config_file_str( # ) # # The function arguments are: @@ -250,7 +250,7 @@ endfunction() # ``_LIB_ENABLED_DEPENDENCIES``, a link dependency is created using # ``target_link_library(::all_libs INTERFACE )``. # -function(tribits_external_package_write_config_file_str tplName tplConfigFileStrOut) +function(tribits_extpkg_write_config_file_str tplName tplConfigFileStrOut) # A) Set up beginning of config file text set(configFileStr "") @@ -267,11 +267,11 @@ function(tribits_external_package_write_config_file_str tplName tplConfigFileS ) # B) Call find_dependency() for all direct dependent upstream TPLs - tribits_external_package_add_find_upstream_dependencies_str(${tplName} + tribits_extpkg_add_find_upstream_dependencies_str(${tplName} configFileStr) # C) Create IMPORTED library targets from TPL_${tplName}_LIBRARIES - tribits_external_package_process_libraries_list( + tribits_extpkg_process_libraries_list( ${tplName} LIB_TARGETS_LIST_OUT libTargets LIB_LINK_FLAGS_LIST_OUT libLinkFlags @@ -279,7 +279,7 @@ function(tribits_external_package_write_config_file_str tplName tplConfigFileS ) # D) Create the ::all_libs target - tribits_external_package_create_all_libs_target( + tribits_extpkg_create_all_libs_target( ${tplName} LIB_TARGETS_LIST ${libTargets} LIB_LINK_FLAGS_LIST ${libLinkFlags} @@ -292,20 +292,20 @@ function(tribits_external_package_write_config_file_str tplName tplConfigFileS endfunction() -# @FUNCTION: tribits_external_package_add_find_upstream_dependencies_str() +# @FUNCTION: tribits_extpkg_add_find_upstream_dependencies_str() # # Add code to call find_dependency() for all upstream external packages/TPLs # listed in ``_LIB_ENABLED_DEPENDENCIES``. # # Usage:: # -# tribits_external_package_add_find_upstream_dependencies_str(tplName +# tribits_extpkg_add_find_upstream_dependencies_str(tplName # configFileFragStrInOut) # # NOTE: This also requires that ``_DIR`` be set for each # external package/TPL listed in ``_LIB_ENABLED_DEPENDENCIES``. # -function(tribits_external_package_add_find_upstream_dependencies_str +function(tribits_extpkg_add_find_upstream_dependencies_str tplName configFileFragStrInOut ) if (NOT "${${tplName}_LIB_ENABLED_DEPENDENCIES}" STREQUAL "") @@ -329,7 +329,7 @@ function(tribits_external_package_add_find_upstream_dependencies_str "\n" ) foreach (upstreamTplDepEntry IN LISTS ${tplName}_LIB_ENABLED_DEPENDENCIES) - tribits_external_package_get_dep_name_and_vis( + tribits_extpkg_get_dep_name_and_vis( "${upstreamTplDepEntry}" upstreamTplDepName upstreamTplDepVis) if ("${${upstreamTplDepName}_DIR}" STREQUAL "") message(FATAL_ERROR "ERROR: ${upstreamTplDepName}_DIR is empty!") @@ -367,7 +367,7 @@ endfunction() # search the directory _DIR and no others. That would make -# @FUNCTION: tribits_external_package_process_libraries_list() +# @FUNCTION: tribits_extpkg_process_libraries_list() # # Read the ``TPL__LIBRARIES`` and # ``_LIB_ENABLED_DEPENDENCIES`` list variables and produce the string @@ -376,7 +376,7 @@ endfunction() # # Usage:: # -# tribits_external_package_process_libraries_list( +# tribits_extpkg_process_libraries_list( # # LIB_TARGETS_LIST_OUT # LIB_LINK_FLAGS_LIST_OUT @@ -397,7 +397,7 @@ endfunction() # appended with the IMPORTED library commands for the list of targets given # in ````. # -function(tribits_external_package_process_libraries_list tplName) +function(tribits_extpkg_process_libraries_list tplName) # A) Parse commandline arguments @@ -440,7 +440,7 @@ function(tribits_external_package_process_libraries_list tplName) message_wrapper("-- NOTE: Moving the general link argument '${libentry}' in TPL_${tplName}_LIBRARIES forward on the link line which may change the link and break the link!") list(APPEND libLinkFlagsList "${libentry}") else() - tribits_external_package_process_libraries_list_library_entry( + tribits_extpkg_process_libraries_list_library_entry( ${tplName} "${libentry}" ${libEntryType} libTargets lastLibProcessed configFileStr ) endif() @@ -512,12 +512,12 @@ endfunction() # Function to process a library inside of loop over # ``TPL__LIBRARIES`` in the function -# tribits_external_package_process_libraries_list(). +# tribits_extpkg_process_libraries_list(). # # This also puts in linkages to upstream TPLs ``::all_libs`` listed # in ``_LIB_ENABLED_DEPENDENCIES``. # -function(tribits_external_package_process_libraries_list_library_entry +function(tribits_extpkg_process_libraries_list_library_entry tplName libentry libEntryType libTargetsInOut lastLibProcessedInOut configFileStrInOut ) @@ -526,12 +526,12 @@ function(tribits_external_package_process_libraries_list_library_entry set(lastLibProcessed ${${lastLibProcessedInOut}}) set(configFileStr ${${configFileStrInOut}}) # Get libname - tribits_external_package_get_libname_and_path_from_libentry( + tribits_extpkg_get_libname_and_path_from_libentry( "${libentry}" ${libEntryType} libname libpath) # Create IMPORTED library target set(prefixed_libname "${tplName}::${libname}") if (NOT (prefixed_libname IN_LIST libTargets)) - tribits_external_package_append_add_library_str (${libname} ${prefixed_libname} + tribits_extpkg_append_add_library_str (${libname} ${prefixed_libname} ${libEntryType} "${libpath}" configFileStr) if (lastLibProcessed) string(APPEND configFileStr @@ -539,7 +539,7 @@ function(tribits_external_package_process_libraries_list_library_entry " INTERFACE ${tplName}::${lastLibProcessed})\n" ) else() - tribits_external_package_append_upstream_target_link_libraries_str( ${tplName} + tribits_extpkg_append_upstream_target_link_libraries_str( ${tplName} ${prefixed_libname} configFileStr ) endif() string(APPEND configFileStr @@ -559,14 +559,14 @@ endfunction() # :: which has the needed dependencies. -function(tribits_external_package_get_libname_and_path_from_libentry +function(tribits_extpkg_get_libname_and_path_from_libentry libentry libEntryType libnameOut libpathOut ) if (libEntryType STREQUAL "FULL_LIB_PATH") - tribits_external_package_get_libname_from_full_lib_path("${libentry}" libname) + tribits_extpkg_get_libname_from_full_lib_path("${libentry}" libname) set(libpath "${libentry}") elseif (libEntryType STREQUAL "LIB_NAME_LINK_OPTION") - tribits_external_package_get_libname_from_lib_name_link_option("${libentry}" libname) + tribits_extpkg_get_libname_from_lib_name_link_option("${libentry}" libname) set(libpath "") elseif (libEntryType STREQUAL "LIB_NAME") set(libname "${libentry}") @@ -579,7 +579,7 @@ function(tribits_external_package_get_libname_and_path_from_libentry endfunction() -function(tribits_external_package_append_add_library_str +function(tribits_extpkg_append_add_library_str libname prefix_libname libEntryType libpath configFileStrInOut ) @@ -606,13 +606,13 @@ function(tribits_external_package_append_add_library_str endfunction() -function(tribits_external_package_get_libname_from_full_lib_path full_lib_path +function(tribits_extpkg_get_libname_from_full_lib_path full_lib_path libnameOut ) # Should be an absolute library path get_filename_component(full_libname "${full_lib_path}" NAME_WE) # Begins with 'lib'? - tribits_external_package_libname_begins_with_lib("${full_libname}" beginsWithLib) + tribits_extpkg_libname_begins_with_lib("${full_libname}" beginsWithLib) # Assert is a valid lib name and get lib name set(libname "") string(LENGTH "${full_libname}" full_libname_len) @@ -650,7 +650,7 @@ function(tribits_external_package_get_libname_from_full_lib_path full_lib_path endfunction() -function(tribits_external_package_libname_begins_with_lib full_libname +function(tribits_extpkg_libname_begins_with_lib full_libname libnameBeginsWithLibOut ) string(SUBSTRING "${full_libname}" 0 3 libPart) @@ -663,7 +663,7 @@ function(tribits_external_package_libname_begins_with_lib full_libname endfunction() -function(tribits_external_package_get_libname_from_lib_name_link_option +function(tribits_extpkg_get_libname_from_lib_name_link_option lib_name_link_option libnameOut ) # Assert begging part '-l' @@ -690,7 +690,7 @@ function(tribits_print_invalid_lib_link_option tplName liblinkoption) endfunction() -function(tribits_external_package_append_upstream_target_link_libraries_str +function(tribits_extpkg_append_upstream_target_link_libraries_str tplName prefix_libname configFileStrInOut ) set(configFileStr "${${configFileStrInOut}}") @@ -698,7 +698,7 @@ function(tribits_external_package_append_upstream_target_link_libraries_str string(APPEND configFileStr "target_link_libraries(${prefix_libname}\n") foreach (upstreamTplDepEntry IN LISTS ${tplName}_LIB_ENABLED_DEPENDENCIES) - tribits_external_package_get_dep_name_and_vis( + tribits_extpkg_get_dep_name_and_vis( "${upstreamTplDepEntry}" upstreamTplDepName upstreamTplDepVis) if (upstreamTplDepVis STREQUAL "PUBLIC") string(APPEND configFileStr @@ -726,14 +726,14 @@ endfunction() # libraries being listed on link lines for downstsream library and exec links. -# @FUNCTION: tribits_external_package_create_all_libs_target() +# @FUNCTION: tribits_extpkg_create_all_libs_target() # # Creates the ``::all_libs`` target command text using input info and # from ``TPL__INCLUDE_DIRS``. # # Usage:: # -# tribits_external_package_create_all_libs_target( +# tribits_extpkg_create_all_libs_target( # # LIB_TARGETS_LIST # LIB_LINK_FLAGS_LIST @@ -753,7 +753,7 @@ endfunction() # ````: [out] A string variable that will be # appended with the ``::all_libs`` target statements. # -function(tribits_external_package_create_all_libs_target tplName) +function(tribits_extpkg_create_all_libs_target tplName) # Parse commandline arguments diff --git a/tribits/core/package_arch/TribitsPackageDependencies.cmake b/tribits/core/package_arch/TribitsPackageDependencies.cmake index a949d1109..950d6a434 100644 --- a/tribits/core/package_arch/TribitsPackageDependencies.cmake +++ b/tribits/core/package_arch/TribitsPackageDependencies.cmake @@ -57,14 +57,14 @@ cmake_policy(SET CMP0011 NEW) # include() does policy push and pop cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... ) -# @MACRO: tribits_external_package_define_dependencies() +# @MACRO: tribits_extpkg_define_dependencies() # # Macro called from inside of a `FindTPLDependencies.cmake`_ file to # define the direct upstream dependencies an external package/TPL. # # Usage:: # -# tribits_external_package_define_dependencies( +# tribits_extpkg_define_dependencies( # DEPENDENCIES : ... ) # # The listed upstream dependencies ```` are other external @@ -85,7 +85,7 @@ cmake_policy(SET CMP0057 NEW) # Support if ( ... IN_LIST ... ) # it should list that external package/TPL as a direct dependency and not # expect to get include directories from indirect dependencies.) # -macro(tribits_external_package_define_dependencies +macro(tribits_extpkg_define_dependencies tplName ) @@ -110,11 +110,11 @@ macro(tribits_external_package_define_dependencies endmacro() -# @MACRO: tribits_external_package_setup_enabled_dependencies() +# @MACRO: tribits_extpkg_setup_enabled_dependencies() # # Usage:: # -# tribits_external_package_setup_enabled_dependencies() +# tribits_extpkg_setup_enabled_dependencies() # # Macro that sets up the list of enabled external package/TPL dependencies # @@ -130,13 +130,13 @@ endmacro() # ``_LIB_ENABLED_DEPENDENCIES`` but not in # ``_LIB_ENABLED_DEPENDENCIES``. # -macro(tribits_external_package_setup_enabled_dependencies externalPkgName) +macro(tribits_extpkg_setup_enabled_dependencies externalPkgName) set(libEnabledDependencies "") if (TPL_ENABLE_${externalPkgName}) foreach(upstreamPkgEntry IN LISTS ${externalPkgName}_LIB_ALL_DEPENDENCIES) - tribits_external_package_get_dep_name_and_vis(${upstreamPkgEntry} + tribits_extpkg_get_dep_name_and_vis(${upstreamPkgEntry} upstreamPkgName upstreamPkgVis) if (TPL_ENABLE_${upstreamPkgName}) list(APPEND libEnabledDependencies ${upstreamPkgEntry}) @@ -152,7 +152,7 @@ macro(tribits_external_package_setup_enabled_dependencies externalPkgName) endif() foreach(upstreamPkgEntry IN LISTS ${externalPkgName}_LIB_ENABLED_DEPENDENCIES) - tribits_external_package_get_dep_name_and_vis( ${upstreamPkgEntry} + tribits_extpkg_get_dep_name_and_vis( ${upstreamPkgEntry} upstreamPkgName upstreamPkgVis) set(${externalPkgName}_ENABLE_${upstreamPkgName} ON) endforeach() @@ -160,17 +160,17 @@ macro(tribits_external_package_setup_enabled_dependencies externalPkgName) endmacro() -# @FUNCTION: tribits_external_package_get_dep_name_and_vis() +# @FUNCTION: tribits_extpkg_get_dep_name_and_vis() # # Extract ```` and ```` from ``[:]`` input with # default ```` of ``PRIVATE``. # # Usage:: # -# tribits_external_package_get_dep_name_and_vis( +# tribits_extpkg_get_dep_name_and_vis( # ) # -function(tribits_external_package_get_dep_name_and_vis +function(tribits_extpkg_get_dep_name_and_vis upstreamTplDepEntry upstreamTplDepNameOut upstreamTplDepVisOut ) # Split on ':' to get [:] diff --git a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake index 221e8fb90..c8cbdb4a9 100644 --- a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake +++ b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake @@ -157,10 +157,10 @@ function(tribits_process_enabled_tpl TPL_NAME) "${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake") set(tplConfigVersionFile "${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}ConfigVersion.cmake") - tribits_external_package_write_config_version_file(${TPL_NAME} + tribits_extpkg_write_config_version_file(${TPL_NAME} "${tplConfigVersionFile}") - tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}") - tribits_external_package_install_config_version_file(${TPL_NAME} + tribits_extpkg_install_config_file(${TPL_NAME} "${tplConfigFile}") + tribits_extpkg_install_config_version_file(${TPL_NAME} "${tplConfigVersionFile}") endif() diff --git a/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake b/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake index e690c0d75..987aaf8dd 100644 --- a/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake +++ b/tribits/core/package_arch/TribitsTplFindIncludeDirsAndLibraries.cmake @@ -280,7 +280,7 @@ endfunction() # This fill will also call ``find_dependency()`` to pull in # ``Config.cmake`` files for upstream TPLs that are # listed in ``_LIB_ENABLED_DEPENDENCIES``. (For more -# information, see `tribits_external_package_write_config_file()`_.) +# information, see `tribits_extpkg_write_config_file()`_.) # # Note, if ``TPL_TENTATIVE_ENABLE_=ON``, then if all of the parts of # the TPL can't be found, then ``TPL_ENABLE_`` will be (forced) set @@ -718,7 +718,7 @@ function(tribits_tpl_find_include_dirs_and_libraries TPL_NAME) "${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}") set(tplConfigFileBaseDir "${buildDirExternalPkgsDir}/${TPL_NAME}") set(tplConfigFile "${tplConfigFileBaseDir}/${TPL_NAME}Config.cmake") - tribits_external_package_write_config_file(${TPL_NAME} "${tplConfigFile}") + tribits_extpkg_write_config_file(${TPL_NAME} "${tplConfigFile}") if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) include("${tplConfigFile}") set(${TPL_NAME}_DIR "${tplConfigFileBaseDir}" CACHE INTERNAL diff --git a/tribits/doc/guides/TribitsGuidesBody.rst b/tribits/doc/guides/TribitsGuidesBody.rst index 8a84c1dbf..23b477d86 100644 --- a/tribits/doc/guides/TribitsGuidesBody.rst +++ b/tribits/doc/guides/TribitsGuidesBody.rst @@ -2230,7 +2230,7 @@ call to ``find_package()`` which provides modern IMPORTED CMake targets looks like:: find_package( REQUIRED) - tribits_external_package_create_imported_all_libs_target_and_config_file( + tribits_extpkg_create_imported_all_libs_target_and_config_file( INNER_FIND_PACKAGE_NAME IMPORTED_TARGETS_FOR_ALL_LIBS ... ) @@ -2276,9 +2276,9 @@ about any upstream external packages/TPLs that it may depend on so it can add the dependencies between the created IMPORTED target libraries. The file ``FindTPLDependencies.cmake`` is typically just a single -call to `tribits_external_package_define_dependencies()`_ and takes the form:: +call to `tribits_extpkg_define_dependencies()`_ and takes the form:: - tribits_external_package_define_dependencies( + tribits_extpkg_define_dependencies( DEPENDENCIES ... ) This defines all of the TPLs that ```` could directly depends on but @@ -5671,19 +5671,19 @@ modern (namespaced) IMPORTED targets (but is missing the ``::all_libs`` target or the name ```` and ```` name are different), these ``FindTPL.cmake`` modules can call the function -`tribits_external_package_create_imported_all_libs_target_and_config_file()`_ +`tribits_extpkg_create_imported_all_libs_target_and_config_file()`_ after calling ``find_package()`` to create a very thin wrapper ``FindTPL.cmake`` module. In these cases, such a ``FindTPL.cmake`` module file is nothing more than:: find_package( REQUIRED) - tribits_external_package_create_imported_all_libs_target_and_config_file( + tribits_extpkg_create_imported_all_libs_target_and_config_file( INNER_FIND_PACKAGE_NAME IMPORTED_TARGETS_FOR_ALL_LIBS ... ) The function -`tribits_external_package_create_imported_all_libs_target_and_config_file()`_ +`tribits_extpkg_create_imported_all_libs_target_and_config_file()`_ creates the target ``::all_libs`` and the wrapper file ``Config.cmake`` which is installed by TriBITS. The only unique information required to create this glue module is the name of the external @@ -5717,7 +5717,7 @@ system (such as when upgrading a existing ``FindTPL.cmake`` file), a if (_FOUND) message("-- Found _DIR='${_DIR}'") message("-- Generating ::all_libs and Config.cmake") - tribits_external_package_create_imported_all_libs_target_and_config_file( + tribits_extpkg_create_imported_all_libs_target_and_config_file( INNER_FIND_PACKAGE_NAME IMPORTED_TARGETS_FOR_ALL_LIBS ${IMPORTED_TARGETS_FOR_ALL_LIBS} ) endif() @@ -5742,7 +5742,7 @@ critical since ``find_package()`` defines IMPORTED targets that must be available each time configure is called. Also, if ``find_package()`` is called and ``_FOUND=TRUE``, then the function -`tribits_external_package_create_imported_all_libs_target_and_config_file()`_ +`tribits_extpkg_create_imported_all_libs_target_and_config_file()`_ is called which defines the targets ``::all_libs`` which means that the function ``tribits_tpl_find_include_dirs_and_libraries()`` will **not** be called. diff --git a/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst b/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst index fb8a91838..b87a485d8 100644 --- a/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/TribitsMacroFunctionDocTemplate.rst @@ -20,11 +20,11 @@ @FUNCTION: tribits_determine_if_current_package_needs_rebuilt() + @MACRO: tribits_disable_package_on_platforms() + @MACRO: tribits_exclude_files() + -@MACRO: tribits_external_package_define_dependencies() + -@FUNCTION: tribits_external_package_get_dep_name_and_vis() + -@FUNCTION: tribits_external_package_create_imported_all_libs_target_and_config_file() + -@FUNCTION: tribits_external_package_write_config_file() + -@FUNCTION: tribits_external_package_write_config_file_str() + +@MACRO: tribits_extpkg_define_dependencies() + +@FUNCTION: tribits_extpkg_get_dep_name_and_vis() + +@FUNCTION: tribits_extpkg_create_imported_all_libs_target_and_config_file() + +@FUNCTION: tribits_extpkg_write_config_file() + +@FUNCTION: tribits_extpkg_write_config_file_str() + @FUNCTION: tribits_find_most_recent_binary_file_timestamp() + @FUNCTION: tribits_find_most_recent_file_timestamp() + @FUNCTION: tribits_find_most_recent_source_file_timestamp() + diff --git a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst index 03acd2071..b3f228371 100644 --- a/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/TribitsSystemMacroFunctionDocTemplate.rst @@ -15,13 +15,13 @@ understand the internals of TriBITS. @MACRO: tribits_adjust_package_enables() + @FUNCTION: tribits_append_forward_dep_packages() + @MACRO: tribits_assert_read_dependency_vars() + -@FUNCTION: tribits_external_package_add_find_upstream_dependencies_str() + -@FUNCTION: tribits_external_package_create_all_libs_target() + -@FUNCTION: tribits_external_package_install_config_file() + -@FUNCTION: tribits_external_package_install_config_version_file() + -@FUNCTION: tribits_external_package_process_libraries_list() + -@MACRO: tribits_external_package_setup_enabled_dependencies() + -@FUNCTION: tribits_external_package_write_config_version_file() + +@FUNCTION: tribits_extpkg_add_find_upstream_dependencies_str() + +@FUNCTION: tribits_extpkg_create_all_libs_target() + +@FUNCTION: tribits_extpkg_install_config_file() + +@FUNCTION: tribits_extpkg_install_config_version_file() + +@FUNCTION: tribits_extpkg_process_libraries_list() + +@MACRO: tribits_extpkg_setup_enabled_dependencies() + +@FUNCTION: tribits_extpkg_write_config_version_file() + @FUNCTION: tribits_dump_package_dependencies_info() + @FUNCTION: tribits_print_initial_dependency_info() + @FUNCTION: tribits_print_tentatively_enabled_tpls() + diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl1.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl1.cmake index 146419334..e6fafdbd8 100644 --- a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl1.cmake +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl1.cmake @@ -19,7 +19,7 @@ if (Tpl1_ALLOW_PREFIND) set(TPL_Tpl1_LIBRARIES "${libfile}" CACHE PATH "Libraries for Tpl1") else() message("-- Generating Tpl1::all_libs and Tpl1Config.cmake") - tribits_external_package_create_imported_all_libs_target_and_config_file(Tpl1 + tribits_extpkg_create_imported_all_libs_target_and_config_file(Tpl1 INNER_FIND_PACKAGE_NAME Tpl1 IMPORTED_TARGETS_FOR_ALL_LIBS ${IMPORTED_TARGETS_FOR_ALL_LIBS} ) endif() diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2.cmake index ff4f4f407..ab827bb04 100644 --- a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2.cmake +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2.cmake @@ -10,7 +10,7 @@ if (Tpl2_ALLOW_PREFIND) if (Tpl2_FOUND) message("-- Found Tpl2_DIR='${Tpl2_DIR}'") message("-- Generating Tpl2::all_libs and Tpl2Config.cmake") - tribits_external_package_create_imported_all_libs_target_and_config_file(Tpl2 + tribits_extpkg_create_imported_all_libs_target_and_config_file(Tpl2 INNER_FIND_PACKAGE_NAME Tpl2 IMPORTED_TARGETS_FOR_ALL_LIBS ${IMPORTED_TARGETS_FOR_ALL_LIBS} ) endif() diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake index 074cc9fac..58e5b6744 100644 --- a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl2Dependencies.cmake @@ -1,2 +1,2 @@ -tribits_external_package_define_dependencies(Tpl2 +tribits_extpkg_define_dependencies(Tpl2 DEPENDENCIES Tpl1) diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3.cmake index 8e869f0ed..4f8b2288d 100644 --- a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3.cmake +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3.cmake @@ -10,7 +10,7 @@ if (Tpl3_ALLOW_PREFIND) if (Tpl3_FOUND) message("-- Found Tpl3_DIR='${Tpl3_DIR}'") message("-- Generating Tpl3::all_libs and Tpl3Config.cmake") - tribits_external_package_create_imported_all_libs_target_and_config_file(Tpl3 + tribits_extpkg_create_imported_all_libs_target_and_config_file(Tpl3 INNER_FIND_PACKAGE_NAME Tpl3 IMPORTED_TARGETS_FOR_ALL_LIBS ${IMPORTED_TARGETS_FOR_ALL_LIBS} ) endif() diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake index 9ba617eb3..fb66d7b90 100644 --- a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl3Dependencies.cmake @@ -1,2 +1,2 @@ -tribits_external_package_define_dependencies(Tpl3 +tribits_extpkg_define_dependencies(Tpl3 DEPENDENCIES Tpl2) diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4.cmake index 28f4ae97b..8a5619a8b 100644 --- a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4.cmake +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4.cmake @@ -9,7 +9,7 @@ if (Tpl4_ALLOW_PREFIND) if (Tpl4_FOUND) message("-- Found Tpl4_DIR='${Tpl4_DIR}'") message("-- Generating Tpl4::all_libs and Tpl4Config.cmake") - tribits_external_package_create_imported_all_libs_target_and_config_file(Tpl4 + tribits_extpkg_create_imported_all_libs_target_and_config_file(Tpl4 INNER_FIND_PACKAGE_NAME Tpl4 IMPORTED_TARGETS_FOR_ALL_LIBS ${IMPORTED_TARGETS_FOR_ALL_LIBS} ) endif() diff --git a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake index 4181c206e..705743541 100644 --- a/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject2/cmake/tpls/FindTPLTpl4Dependencies.cmake @@ -1,2 +1,2 @@ -tribits_external_package_define_dependencies(Tpl4 +tribits_extpkg_define_dependencies(Tpl4 DEPENDENCIES Tpl2 Tpl3) From 09eb2426e4330eb29f38f859f7feb7c4c968aae3 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 14 Jul 2022 19:33:11 -0600 Subject: [PATCH 7/8] Added CHANGELOG entry for FindTPLDependencies.cmake (#63, #299, #494) I also reformated the entry noting that TPLs must declare dependencies. --- tribits/CHANGELOG.md | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/tribits/CHANGELOG.md b/tribits/CHANGELOG.md index f851f07ce..20ca6f378 100644 --- a/tribits/CHANGELOG.md +++ b/tribits/CHANGELOG.md @@ -2,19 +2,35 @@ ChangeLog for TriBITS ---------------------------------------- +## 2022-07-14: + +* **Added:** Added support for `FindTPLDependencies.cmake` with new + macro `tribits_extpkg_define_dependencies()` that sets + `_LIB_ALL_DEPENDENCIES`. Now `_LIB_ENABLED_DEPENDENCIES` + is automatically set from `_LIB_ALL_DEPENDENCIES` based on what + TPLs are actaully enabled. This avoids the problem described below from + directly setting `_LIB_ENABLED_DEPENDENCIES` without reguard to + what TPLs are actaully enabled. This maintains backward compatibility for + existing configure scripts where an upstream TPL may not be enabled in some + strange configure scripts (see + [TriBITSPub/TriBITS#494](https://github.com/TriBITSPub/TriBITS/issues/494)). + ## 2022-05-25: -* **Changed:** Dependencies between external packages (TPLs) must - now be specified in order for correct linkage. No longer will listing - the external packages (TPLs) in the correct order in the - `/TPLsList.cmake` file and listing all upstream external packages (TPLs) in - `/cmake/Dependencies.cmake` be sufficient. For now, dependencies - between external packages (TPLs) can be set in the `/TPLsList.cmake` - file by setting the cache var `_LIB_ENABLED_DEPENDENCIES` for each downstream - external package (TPL). (See [`TribitsExampleProject2/TPLsList.cmake`](https://github.com/TriBITSPub/TriBITS/blob/master/tribits/examples/TribitsExampleProject2/TPLsList.cmake) - for an example.) Later, a more scalable approach for setting these vars will - be devised. However, this means it is no longer necessary for a package - to list all of its upstream external packages/TPLs, only its direct dependencies. +* **Changed:** Dependencies between external packages (TPLs) must now be + specified in order for correct linkage. No longer will listing the external + packages (TPLs) in the correct order in the `/TPLsList.cmake` file + and listing all upstream external packages (TPLs) in + `/cmake/Dependencies.cmake` be sufficient. For now, + dependencies between external packages (TPLs) can be set in the + `/TPLsList.cmake` file by setting the cache var + `_LIB_ENABLED_DEPENDENCIES` for each downstream external package + (TPL). (See + [`TribitsExampleProject2/TPLsList.cmake`](https://github.com/TriBITSPub/TriBITS/blob/master/tribits/examples/TribitsExampleProject2/TPLsList.cmake) + for an example.) Later, a more scalable approach for setting these vars + will be devised. However, this means it is no longer necessary for a + package to list all of its upstream external packages/TPLs, only its direct + dependencies. * **Changed:** All compliant external packages (TPLs) must now set the imported target `::all_libs` in their `FindTPL.cmake` From e121d76729c0ebe67a6e09f9e7a6f2cb7c61b5ae Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 14 Jul 2022 19:46:24 -0600 Subject: [PATCH 8/8] Add entry for _LIB_ENABLED_DEPENDENCIES to build ref (#63, #299, #494) --- .../build_ref/TribitsBuildReferenceBody.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst index e1ec3a106..e08d48f23 100644 --- a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst +++ b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst @@ -1767,6 +1767,24 @@ libraries in the right order by configuring with:: (where ``...`` are the rest of the libraries found in order). +Adjusting upstream dependencies for a Third-Party Library (TPL) +--------------------------------------------------------------- + +Some TPLs have dependencies on one or more upstream TPLs. These dependencies +must be specified correctly for the compile and links to work correctly. The + 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:: + + -D _LIB_ENABLED_DEPENDENCIES=";;..." + +If any of the specified TPLs are listed after ```` in the +``TPLsList.cmake`` file or are not enabled, then a configure-time error will +occur. + + Disabling support for a Third-Party Library (TPL) --------------------------------------------------