From 21c919f98927416e89cc2fee52a0ed486983cc10 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 25 May 2022 18:35:27 -0600 Subject: [PATCH 01/43] Fix some typos in comments --- test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 4dbcf5a5b..09ccf5f4b 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -2918,10 +2918,10 @@ tribits_add_advanced_test( TribitsExampleProject_compiler_flags ) # NOTE: The above tests checks the compiler flags that are set by TriBITS for # the various use cases. This is a hard test to make portable because we -# really need to check that the comiler options are set all the way down. To +# really need to check that the compiler options are set all the way down. To # make this more portable, we only do this on Linux systems and only with GCC. # -# We actaully build known targets with 'make VERBOSE=1 ' and then grep +# We actually build known targets with 'make VERBOSE=1 ' and then grep # the output to make sure the compiler flags drill down all the way to the # actual targets. # From a99bf6014fb014e28f0633ca399390ff21852f8c Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 25 May 2022 18:36:06 -0600 Subject: [PATCH 02/43] Fix the comment line for a test block --- test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake index bc51580a0..4d932686a 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake @@ -213,7 +213,7 @@ function(TribitsExampleProject2_find_tpl_parts sharedOrStatic findingTplsMethod) "set[(]Package3_ENABLE_Tpl3 ON[)]" TEST_2 - MESSAGE "Build verbose to check the link line of Package3" + MESSAGE "Build verbose to check the link lines" CMND ${CMAKE_COMMAND} ARGS --build . -v PASS_REGULAR_EXPRESSION_ALL "[-]o packages/package1/src/package1-prg .* ${tplInstallBaseDir}/install_tpl1/lib/libtpl1${libextregex}" From d9646f0229d78adb988631c9b972f6ce63dd15b2 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 3 May 2022 16:19:43 -0600 Subject: [PATCH 03/43] Standardize comments (#299) --- tribits/core/package_arch/TribitsLibraryMacros.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index 360c879b0..58f3356d9 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -56,7 +56,6 @@ include(SetAndIncDirs) ### -# # Macro that configures the package's main config.h file # function(tribits_add_config_define DEFINE) @@ -72,7 +71,6 @@ function(tribits_add_config_define DEFINE) endfunction() -# # @FUNCTION: tribits_configure_file() # # Macro that configures the package's main configured header file (typically @@ -199,7 +197,6 @@ function(tribits_configure_file PACKAGE_NAME_CONFIG_FILE) endfunction() -# # @FUNCTION: tribits_add_library() # # Function used to add a CMake library and target using ``add_library()`` and From a7c2282a1fd9b8d0cf82870aa68f7fa3b083ba0e Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 3 May 2022 16:49:55 -0600 Subject: [PATCH 04/43] Add "" initializers for several vars (#299) I just noticed this while looking over the code. --- tribits/core/package_arch/TribitsGlobalMacros.cmake | 8 ++++---- tribits/core/package_arch/TribitsPackageMacros.cmake | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 741b4f489..775a4d045 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -2087,10 +2087,10 @@ macro(tribits_configure_enabled_packages) # A) Global variable initialization # - global_null_set(${PROJECT_NAME}_INCLUDE_DIRS) - global_null_set(${PROJECT_NAME}_LIBRARY_DIRS) - global_null_set(${PROJECT_NAME}_LIBRARIES) - global_null_set(${PROJECT_NAME}_ETI_PACKAGES) + global_null_set(${PROJECT_NAME}_INCLUDE_DIRS "") + global_null_set(${PROJECT_NAME}_LIBRARY_DIRS "") + global_null_set(${PROJECT_NAME}_LIBRARIES "") + global_null_set(${PROJECT_NAME}_ETI_PACKAGES "") # # B) Define the source and binary directories for all of the packages that diff --git a/tribits/core/package_arch/TribitsPackageMacros.cmake b/tribits/core/package_arch/TribitsPackageMacros.cmake index 48a30c91f..ff2dd7203 100644 --- a/tribits/core/package_arch/TribitsPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsPackageMacros.cmake @@ -77,9 +77,9 @@ include(TribitsReportInvalidTribitsUsage) # they are used. # macro(tribits_define_linkage_vars PACKAGE_NAME_IN) - global_null_set(${PACKAGE_NAME_IN}_INCLUDE_DIRS) - global_null_set(${PACKAGE_NAME_IN}_LIBRARY_DIRS) - global_null_set(${PACKAGE_NAME_IN}_LIBRARIES) + global_null_set(${PACKAGE_NAME_IN}_INCLUDE_DIRS "") + global_null_set(${PACKAGE_NAME_IN}_LIBRARY_DIRS "") + global_null_set(${PACKAGE_NAME_IN}_LIBRARIES "") global_set(${PACKAGE_NAME_IN}_HAS_NATIVE_LIBRARIES_TO_INSTALL FALSE) endmacro() @@ -622,9 +622,9 @@ function(tribits_package_finalize_dependency_vars) # A package with subpackages should get all of its dependency vars from # its enabled subpackages. - set(PARENT_PACKAGE_INCLUDE_DIRS) - set(PARENT_PACKAGE_LIBRARY_DIRS) - set(PARENT_PACKAGE_LIBRARIES) + set(PARENT_PACKAGE_INCLUDE_DIRS "") + set(PARENT_PACKAGE_LIBRARY_DIRS "") + set(PARENT_PACKAGE_LIBRARIES "") set(SUBPACKAGE_IDX 0) foreach(TRIBITS_SUBPACKAGE ${${PARENT_PACKAGE_NAME}_SUBPACKAGES}) From e8bb3d70799c3a531e76fecf85cf0cccebc4d094 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 18 May 2022 16:53:37 -0600 Subject: [PATCH 05/43] Snapshot FindTPLNetcdf.cmake from Trilinos 8c1028df724 with small mods (#299) This was snapshotted from the Trilinos commit: commit 8c1028df724eb0096cd688b381285112bc6f914a Author: Roscoe A. Bartlett Date: Wed May 18 15:08:17 2022 -0600 FindTPLNetcdf.cmake: Lower-case function names (TriBITSPub/TriBITS#274) soon to be merged to Trilinos 'develop' from Trilinos PR #10533. However, this is not an snapshot as I made the following changing before creating this commit: * Kept the spelling fix for 'separated' made in TriBITS 'master' branch from commit c716a74e8419d356fd16552eaf74ece85397eccd; Author: Greg Sjaardema ; Date: Mon Aug 2 16:02:20 2021 -0600; "Spelling fixes" * I removed a few trailing spaces at the end of some lines Why? There really is no value in using a different version of FindTPLNetcdf.cmake in TriBITS that what is used in Trilinos. When testing Trilinos against updated versions of TriBITS, you really want the logic to match. In the case in testing with Trilinos (as part of #299 and testing with trilinos/Trilinos#10533), the old version of FindTPLNetcdf.cmake before this change was not properly setting TPL_Netcdf_PARALLEL which was not allowing the enable of the test SEACASIoss_exodus_fpp_serialize. With this sync, we get the exact same tests. --- tribits/common_tpls/FindTPLNetcdf.cmake | 50 +++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/tribits/common_tpls/FindTPLNetcdf.cmake b/tribits/common_tpls/FindTPLNetcdf.cmake index a5a98ce2c..9ffd66c06 100644 --- a/tribits/common_tpls/FindTPLNetcdf.cmake +++ b/tribits/common_tpls/FindTPLNetcdf.cmake @@ -48,6 +48,10 @@ set(REQUIRED_HEADERS netcdf.h) set(REQUIRED_LIBS_NAMES netcdf) +if (TPL_ENABLE_MPI) + set(REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} pnetcdf) +endif() + # # Second, search for Netcdf components (if allowed) using the standard # find_package(NetCDF ...). @@ -62,7 +66,7 @@ if (Netcdf_ALLOW_PREFIND) "${CMAKE_CURRENT_LIST_DIR}/find_modules" "${CMAKE_CURRENT_LIST_DIR}/utils" ) - + find_package(NetCDF) if (NetCDF_FOUND) @@ -71,7 +75,7 @@ if (Netcdf_ALLOW_PREFIND) "True if netcdf enables netcdf-4") set(TPL_Netcdf_Enables_PNetcdf ${NetCDF_NEEDS_PNetCDF} CACHE BOOL "True if netcdf enables pnetcdf") - set(TPL_Netcdf_PARALLEL ${NetCDF_PARALLEL} CACHE BOOL + set(TPL_Netcdf_PARALLEL ${NetCDF_PARALLEL} CACHE INTERNAL "True if netcdf compiled with parallel enabled") set(TPL_Netcdf_LIBRARY_DIRS ${_hdf5_LIBRARY_SEARCH_DIRS} CACHE PATH "${DOCSTR} library files") @@ -80,7 +84,20 @@ if (Netcdf_ALLOW_PREFIND) set(TPL_Netcdf_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} CACHE PATH "${DOCSTR} header files.") endif() - +else() + # Curl library is only required if DAP is enabled; should detect inside + # FindNetCDF.cmake, but that is not being called... SEMS has DAP enabled; + # many HPC systems don't, but they override these settings... + find_program(NC_CONFIG "nc-config") + if (NC_CONFIG) + execute_process(COMMAND "nc-config --has-dap2" + OUTPUT_VARIABLE NETCDF_HAS_DAP2) + execute_process(COMMAND "nc-config --has-dap4" + OUTPUT_VARIABLE NETCDF_HAS_DAP4) + endif() + if ((NOT NC_CONFIG) OR NETCDF_HAS_DAP2 OR NETCDF_HAS_DAP4) + set(REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} curl) + endif() endif() # @@ -95,3 +112,30 @@ tribits_tpl_find_include_dirs_and_libraries( Netcdf # variables TPL_Netcdf_INCLUDE_DIRS and TPL_Netcdf_LIBRARIES and then print # them out (and set some other standard variables as well). This is the final # "hook" into the TriBITS TPL system. + +# If the `find_package(NetCDF)` is not run, then this may not be set +# Need to determine how this is set in the library that is being used... + +if ("${TPL_Netcdf_PARALLEL}" STREQUAL "") + assert_defined(TPL_Netcdf_INCLUDE_DIRS) + find_path(meta_path + NAMES "netcdf_meta.h" + HINTS ${TPL_Netcdf_INCLUDE_DIRS} + NO_DEFAULT_PATH) + + if (meta_path) + # Search meta for NC_HAS_PARALLEL setting... + # Note that there is both NC_HAS_PARALLEL and NC_HAS_PARALLEL4, only want first... + file(STRINGS "${meta_path}/netcdf_meta.h" netcdf_par_string REGEX "NC_HAS_PARALLEL ") + string(REGEX MATCH "[01]" netcdf_par_val "${netcdf_par_string}") + if (netcdf_par_val EQUAL 1) + set(TPL_Netcdf_PARALLEL True CACHE INTERNAL + "True if netcdf compiled with parallel enabled") + endif() + endif() + if ("${TPL_Netcdf_PARALLEL}" STREQUAL "") + set(TPL_Netcdf_PARALLEL False CACHE INTERNAL + "True if netcdf compiled with parallel enabled") + endif() +endif() +message(STATUS "TPL_Netcdf_PARALLEL is ${TPL_Netcdf_PARALLEL}") From bed095ec443e70f1fc08cdf8f99f1db5eb09ac25 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 4 May 2022 15:47:50 -0600 Subject: [PATCH 06/43] Switch to relying on TRIBITS_TESTONLY_LIB property only (#299) This gets rid of logic that was looking for _INCLUDE_DIRS. With modern CMake, the include dirs are carried along with the library target object itself so there is no need for this var (but we don't remove the var yet, that comes in later commit). As part of this, I created a new module TribitsLibIsTestOnly.cmake with functions to reduce duplication. --- .../package_arch/TribitsAddExecutable.cmake | 13 +++- .../package_arch/TribitsLibIsTestOnly.cmake | 77 +++++++++++++++++++ .../package_arch/TribitsLibraryMacros.cmake | 25 +++--- .../package_arch/TribitsPackageMacros.cmake | 3 +- 4 files changed, 99 insertions(+), 19 deletions(-) create mode 100644 tribits/core/package_arch/TribitsLibIsTestOnly.cmake diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index aa0f100de..42f37cdad 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -42,6 +42,7 @@ include(TribitsAddExecutableTestHelpers) include(TribitsCommonArgsHelpers) include(TribitsAddTestHelpers) include(TribitsGeneralMacros) +include(TribitsLibIsTestOnly) include(TribitsReportInvalidTribitsUsage) include(PrintVar) @@ -473,7 +474,8 @@ function(tribits_add_executable EXE_NAME) # Assert that TESTONLYLIBS only contains TESTONLY libs! foreach(TESTONLYLIB ${PARSE_TESTONLYLIBS}) set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${TESTONLYLIB}") - if (NOT ${PREFIXED_LIB}_INCLUDE_DIRS) + tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + if (NOT libIsTestOnlyLib) message(FATAL_ERROR "ERROR: '${TESTONLYLIB}' in TESTONLYLIBS not a TESTONLY lib!" " If this a regular library in this SE package or in an dependent upstream SE" " package then TriBITS will link automatically to it. If you remove this and it" @@ -493,7 +495,8 @@ function(tribits_add_executable EXE_NAME) # libs! foreach(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") - if (${PREFIXED_LIB}_INCLUDE_DIRS) + tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + if (libIsTestOnly) message(FATAL_ERROR "ERROR: Lib '${IMPORTEDLIB}' being passed through" " IMPORTEDLIBS is not allowed to be a TESTONLY lib!" @@ -523,7 +526,8 @@ function(tribits_add_executable EXE_NAME) # Convert from old DEPLIBS to TESTONLYLIBS and IMPORTEDLIBS foreach(DEPLIB ${PARSE_DEPLIBS}) set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${DEPLIB}") - if (${PREFIXED_LIB}_INCLUDE_DIRS) + tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + if (libIsTestOnlyLib) message(WARNING "WARNING: Passing TESTONLY lib '${DEPLIB}' through DEPLIBS" " is deprecated! Instead, please pass through TESTONLYLIBS instead!" " DEPLIBS is deprecated!") @@ -550,7 +554,8 @@ function(tribits_add_executable EXE_NAME) foreach(TESTONLYLIB_IN ${PARSE_TESTONLYLIBS}) set(TESTONLYLIB "${LIBRARY_NAME_PREFIX}${TESTONLYLIB_IN}") - if (${TESTONLYLIB}_INCLUDE_DIRS) + tribits_lib_is_testonly(${TESTONLYLIB} libIsTestOnlyLib) + if (libIsTestOnlyLib) if (${PROJECT_NAME}_VERBOSE_CONFIGURE) message(STATUS "Adding include directories ${TESTONLYLIB}_INCLUDE_DIRS ...") endif() diff --git a/tribits/core/package_arch/TribitsLibIsTestOnly.cmake b/tribits/core/package_arch/TribitsLibIsTestOnly.cmake new file mode 100644 index 000000000..1120b2704 --- /dev/null +++ b/tribits/core/package_arch/TribitsLibIsTestOnly.cmake @@ -0,0 +1,77 @@ +# @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 + +include_guard() + + +# @FUNCTION: tribits_set_lib_is_testonly() +# +# See if a library is a TESTONLY library +# +# Usage:: +# +# tribits_set_lib_is_testonly() +# +# This sets the ``TRIBITS_TESTONLY_LIB`` on the library target ````. +# +function(tribits_set_lib_is_testonly libName) + set_target_properties(${libName} PROPERTIES TRIBITS_TESTONLY_LIB TRUE) +endfunction() + + +# @FUNCTION: tribits_lib_is_testonly() +# +# See if a library is a TESTONLY library +# +# Usage:: +# +# tribits_lib_is_testonly( ) +# +# This will only return ``TRUE`` in `` `` if ```` +# is a target and the target property ``TRIBITS_TESTONLY_LIB`` is set to +# ``TRUE``. +# +function(tribits_lib_is_testonly libName libIsTestOnlyOut) + if (TARGET ${libName}) + get_target_property(libIsTestOnly ${libName} TRIBITS_TESTONLY_LIB) + else() + set(libIsTestOnly FALSE) + endif() + set(${libIsTestOnlyOut} ${libIsTestOnly} PARENT_SCOPE) +endfunction() diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index 58f3356d9..9d0b6a0b1 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -38,6 +38,7 @@ # @HEADER include(TribitsCreateClientTemplateHeaders) +include(TribitsLibIsTestOnly) include(CMakeParseArguments) include(GlobalSet) include(AppendSet) @@ -636,27 +637,23 @@ function(tribits_add_library LIBRARY_NAME_IN) set(LIB_IN_SE_PKG FALSE) endif() - # PREFIXED_LIB_IS_TESTONLY? - if (${PREFIXED_LIB}_INCLUDE_DIRS) - set(LIB_TESTONLY TRUE) - else() - set(LIB_TESTONLY FALSE) - endif() + # ${PREFIXED_LIB" is TESTONLY? + tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) # Check for valid usage (sorted by most common to least common) - if (LIB_IN_SE_PKG AND NOT LIB_TESTONLY) #PARSE_TESTONLY=TRUE/FASLE + if (LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) #PARSE_TESTONLY=TRUE/FASLE # The library being created here is a library dependent on a regular # (non-TESTONLY) lib in this SE package. This is valid usage of # DEPLIBS. There is no need to link this new lib to the SE package's # upstream dependent SE package and TPL libraries because thse are # already linked into the lib ${LIB}. set(ADD_DEP_PACKAGE_AND_TPL_LIBS FALSE) - elseif (PARSE_TESTONLY AND LIB_IN_SE_PKG AND NOT LIB_TESTONLY) + elseif (PARSE_TESTONLY AND LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) # The library being created here is TESTONLY library and is # dependent on a regular (non-TESTONLY) lib. This is valid usage of # DEPLIBS. In the case of test-only libraries, we always link in # the upstream libs. - elseif (PARSE_TESTONLY AND LIB_TESTONLY) # LIB_IN_SE_PKG=TRUE/FASLE + elseif (PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE # The library being created here is TESTONLY library and is dependent # on another TESTONLY library. This is valid usage of DEPLIBS. In # this case we just hope that this SE package correctly specified a @@ -667,7 +664,7 @@ function(tribits_add_library LIBRARY_NAME_IN) "Adding include directories for TESTONLY ${PREFIXED_LIB}_INCLUDE_DIRS ...") endif() include_directories(${${PREFIXED_LIB}_INCLUDE_DIRS}) - elseif (NOT PARSE_TESTONLY AND LIB_TESTONLY) # LIB_IN_SE_PKG=TRUE/FASLE + elseif (NOT PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE message(WARNING "WARNING: '${LIB}' in DEPLIBS is a TESTONLY lib" " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." " Such usage is deprecated (and this warning will soon become an error)!" @@ -698,7 +695,7 @@ function(tribits_add_library LIBRARY_NAME_IN) " through a proper TriBITS TPL is the C math library 'm'.") else() message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY}," - " LIB_IN_SE_PKG=${LIB_IN_SE_PKG}, LIB_TESTONLY=${LIB_TESTONLY}, has" + " LIB_IN_SE_PKG=${LIB_IN_SE_PKG}, libIsTestOnlyLib=${libIsTestOnlyLib}, has" " not yet been handled!") endif() @@ -716,7 +713,8 @@ function(tribits_add_library LIBRARY_NAME_IN) set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX) - if (${PREFIXED_LIB}_INCLUDE_DIRS) + tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + if (libIsTestOnlyLib) message(WARNING "WARNING: '${IMPORTEDLIB}' in IMPORTEDLIBS is a TESTONLY lib" " and it is illegal to pass in through IMPORTEDLIBS!" " Such usage is deprecated (and this warning will soon become an error)!" @@ -842,8 +840,7 @@ function(tribits_add_library LIBRARY_NAME_IN) endif() if (PARSE_TESTONLY) - set_target_properties(${LIBRARY_NAME} PROPERTIES - TRIBITS_TESTONLY_LIB TRUE) + tribits_set_lib_is_testonly(${LIBRARY_NAME}) endif() set_property( diff --git a/tribits/core/package_arch/TribitsPackageMacros.cmake b/tribits/core/package_arch/TribitsPackageMacros.cmake index ff2dd7203..42889656c 100644 --- a/tribits/core/package_arch/TribitsPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsPackageMacros.cmake @@ -40,6 +40,7 @@ include(TribitsPackageSetupCompilerFlags) include(TribitsWriteClientExportFiles) include(TribitsGeneralMacros) +include(TribitsLibIsTestOnly) include(CMakeParseArguments) include(GlobalNullSet) @@ -723,7 +724,7 @@ macro(tribits_package_create_all_libs_interface_library) #print_var(allPackageBuildableLibTargetsList) set(packageLibsInAllLibsList) foreach (libTarget IN LISTS allPackageBuildableLibTargetsList) - get_target_property(isTestOnlyLib ${libTarget} TRIBITS_TESTONLY_LIB) + tribits_lib_is_testonly(${libTarget} isTestOnlyLib) #print_var(isTestOnlyLib) if (NOT isTestOnlyLib) list(APPEND packageLibsInAllLibsList ${libTarget}) From ca3f5e32243a23995e72adcafee76a8b4637fd9b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 3 May 2022 09:50:00 -0600 Subject: [PATCH 07/43] Switch to linking against ::all_libs (#299) This seems to pass all of the tests. This could use some cleanup of the link lines to avoid listing the same library more than once on the link line. But we can do that latter with some fine-tuning. --- .../package_arch/TribitsAddExecutable.cmake | 22 ++++++++++++- .../package_arch/TribitsLibraryMacros.cmake | 31 ++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index 42f37cdad..ac38e5571 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -652,7 +652,27 @@ function(tribits_add_executable EXE_NAME) message("-- ${EXE_NAME}:LINK_LIBS='${LINK_LIBS}'") endif() - target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${LINK_LIBS}) + # + # Link ${EXE_BINARY_NAME} to direct upstream libraries + # + + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) + foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + foreach(testOnlyLib ${PARSE_TESTONLYLIBS}) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC + "${LIBRARY_NAME_PREFIX}${testOnlyLib}") + endforeach() + + #target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${LINK_LIBS}) assert_defined(${PROJECT_NAME}_LINK_SEARCH_START_STATIC) if (${PROJECT_NAME}_LINK_SEARCH_START_STATIC) diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index 9d0b6a0b1..bf1afad03 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -867,7 +867,36 @@ function(tribits_add_library LIBRARY_NAME_IN) message("-- ${LIBRARY_NAME_IN}:LINK_LIBS='${LINK_LIBS}'") endif() - target_link_libraries(${LIBRARY_NAME} PUBLIC ${LINK_LIBS}) + # + # Link ${LIBRARY_NAME} to direct upstream libraries + # + + # DEPLIBS + foreach(depLib ${PARSE_DEPLIBS}) + target_link_libraries(${LIBRARY_NAME} PUBLIC "${LIBRARY_NAME_PREFIX}${depLib}") + endforeach() + # ${PACKAGE_NAME}_LIBRARIES + target_link_libraries(${LIBRARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) + # ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES + foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + # ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES + foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + # IMPORTEDLIBS + foreach(importedLib ${PARSE_IMPORTEDLIBS}) + target_link_libraries(${LIBRARY_NAME} PUBLIC "${importedLib}") + endforeach() + + # ToDo: #63: Above, allow for other link visibilities other than 'PUBLIC'! + + #target_link_libraries(${LIBRARY_NAME} PUBLIC ${LINK_LIBS}) if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) target_compile_features(${LIBRARY_NAME} PUBLIC "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") From 969abad05eae50652efafb2337e7c33bbdd6053b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 3 May 2022 17:22:15 -0600 Subject: [PATCH 08/43] WIP: Comment out old TriBITS manual manipulation of includes and libs (#299) Here, I just commented out everything that I don't need. I really need to just remove it once I get there. I also changed _TPL_LIBRARIES and _TPL_LIBRARIES to list ::all_libs instead of library files and list these in generated Config.cmake and Config.cmake files. I don't think downsteam customers need this list but it is there if they want to use them for some reason I can't imagine. --- .../TribitsExampleProject_Tests.cmake | 76 ++---- .../TribitsHelloWorld_Tests.cmake | 4 +- ...bitsWriteClientExportFiles_UnitTests.cmake | 48 ++-- .../TribitsExampleProject/CMakeLists.txt | 4 +- .../TribitsPackageConfigTemplate.cmake.in | 8 +- .../TribitsProjectConfigTemplate.cmake.in | 53 ++-- .../package_arch/TribitsAddExecutable.cmake | 40 ++-- .../package_arch/TribitsGeneralMacros.cmake | 226 +++++++++--------- .../package_arch/TribitsGlobalMacros.cmake | 12 +- .../package_arch/TribitsLibraryMacros.cmake | 89 ++++--- .../package_arch/TribitsPackageMacros.cmake | 58 ++--- .../TribitsWriteClientExportFiles.cmake | 106 ++++---- .../packages/wrap_external/CMakeLists.txt | 2 +- 13 files changed, 343 insertions(+), 383 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 09ccf5f4b..cfd5cab9f 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -236,12 +236,12 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran "WithSubpackages_LINKER = '.+'" "WithSubpackages_AR = '.+'" "WithSubpackages_INSTALL_DIR = .*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install" - "WithSubpackages_INCLUDE_DIRS = .+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/b/src;.+/TribitsExampleProject/packages/with_subpackages/b/src;.+/TribitsExampleProject/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/simple_cxx/src;.+/TribitsExampleProject/packages/simple_cxx/src;.+/tpls/HeaderOnlyTpl;.+/TribitsExampleProject/packages/with_subpackages/c" - "WithSubpackages_LIBRARY_DIRS = '.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/simple_cxx/src;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/c'" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/tribits/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_TPL_LIBRARY_DIRS = ''" - "WithSubpackages_TPL_LIBRARIES = ''" + "WithSubpackages_TPL_LIBRARIES = 'HeaderOnlyTpl::all_libs'" "WithSubpackages_MPI_LIBRARIES = ''" "WithSubpackages_MPI_LIBRARY_DIRS = ''" "WithSubpackages_MPI_INCLUDE_DIRS = ''" @@ -314,12 +314,12 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran "WithSubpackages_LINKER = '.+'" "WithSubpackages_AR = '.+'" "WithSubpackages_INSTALL_DIR = '.+/install'" - "WithSubpackages_INCLUDE_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../include'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_TPL_LIBRARY_DIRS = ''" - "WithSubpackages_TPL_LIBRARIES = ''" + "WithSubpackages_TPL_LIBRARIES = 'HeaderOnlyTpl::all_libs'" "WithSubpackages_MPI_LIBRARIES = ''" "WithSubpackages_MPI_LIBRARY_DIRS = ''" "WithSubpackages_MPI_INCLUDE_DIRS = ''" @@ -368,12 +368,12 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran "TribitsExProj_LINKER = '.*'" "TribitsExProj_AR = '.*'" "TribitsExProj_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install'" - "TribitsExProj_INCLUDE_DIRS = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install/include'" - "TribitsExProj_LIBRARY_DIRS = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install/lib'" + "TribitsExProj_INCLUDE_DIRS = ''" + "TribitsExProj_LIBRARY_DIRS = ''" "TribitsExProj_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "TribitsExProj_TPL_INCLUDE_DIRS = '.*/examples/tpls/HeaderOnlyTpl" + "TribitsExProj_TPL_INCLUDE_DIRS = ''" "TribitsExProj_TPL_LIBRARY_DIRS = ''" - "TribitsExProj_TPL_LIBRARIES = ''" + "TribitsExProj_TPL_LIBRARIES = 'HeaderOnlyTpl::all_libs'" "TribitsExProj_MPI_LIBRARIES = ''" "TribitsExProj_MPI_LIBRARY_DIRS = ''" "TribitsExProj_MPI_INCLUDE_DIRS = ''" @@ -1038,7 +1038,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja/install'" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/tribits/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1062,9 +1062,9 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja MESSAGE "Create and configure a dummy project that includes WithSubpackagesConfig.cmake" PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja/install'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1162,7 +1162,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefiles/install'" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/tribits/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1186,9 +1186,9 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile MESSAGE "Create and configure a dummy project that includes WithSubpackagesConfig.cmake" PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefiles/install'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1357,8 +1357,8 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_PT_NoFortran MESSAGE "Create and configure a dummy project that includes WithSubpackagesConfig.cmake" PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.+/install'" - "WithSubpackages_INCLUDE_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../include'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesA.SimpleCxx'" ) @@ -2183,30 +2183,16 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_NoFortran_WrapExternal_Verb "HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" "-- TPL_HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" - "SimpleCxx_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "SimpleCxx_LIBRARY_DIRS='.+/packages/simple_cxx/src'" "SimpleCxx_LIBRARIES='SimpleCxx::simplecxx'" - "WithSubpackagesA_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "WithSubpackagesA_LIBRARY_DIRS='.+/packages/with_subpackages/a[;].+/packages/simple_cxx/src'" "WithSubpackagesA_LIBRARIES='WithSubpackagesA::pws_a'" - "b_test_utils_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl[;].+/TribitsExampleProject/packages/with_subpackages/b/tests/testlib'" - - "WithSubpackagesB_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "WithSubpackagesB_LIBRARY_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src'" "WithSubpackagesB_LIBRARIES='WithSubpackagesB::pws_b'" - "WithSubpackagesC_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl[;].+/TribitsExampleProject/packages/with_subpackages/c'" - "WithSubpackagesC_LIBRARY_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/c'" "WithSubpackagesC_LIBRARIES='WithSubpackagesC::pws_c'" - "WithSubpackages_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl[;].+/TribitsExampleProject/packages/with_subpackages/c'" - "WithSubpackages_LIBRARY_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/c'" "WithSubpackages_LIBRARIES='WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a'" - "WrapExternal_INCLUDE_DIRS='.+/packages/wrap_external/external_func'" - "WrapExternal_LIBRARY_DIRS=''" "WrapExternal_LIBRARIES='external_func[;]pws_a'" "pws_b_TARGET_NAME='pws_b'" @@ -2214,17 +2200,6 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_NoFortran_WrapExternal_Verb "test_of_b_TEST_NAME='WithSubpackagesB_test_of_b'" "c_util_TEST_NAME='WithSubpackagesC_test_of_c_util${TEST_MPI_1_SUFFIX}'" - "-- simplecxx:LINK_LIBS=''" - "-- HelloWorldTests:LINK_LIBS='SimpleCxx::simplecxx'" - "-- pws_a:LINK_LIBS='SimpleCxx::simplecxx'" - "-- a_test:LINK_LIBS='WithSubpackagesA::pws_a'" - "-- pws_b:LINK_LIBS='WithSubpackagesA::pws_a;SimpleCxx::simplecxx'" - "-- b_test:LINK_LIBS='WithSubpackagesB::pws_b'" - "-- c_util:LINK_LIBS='WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a'" - "-- pws_c:LINK_LIBS='WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a'" - "-- c_test:LINK_LIBS='WithSubpackagesC::pws_c'" - "-- run_external_func:LINK_LIBS='external_func[;]pws_a'" - ) @@ -2282,23 +2257,12 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_NoFortran_OverridePackageSo "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a/CMakeLists[.]txt" "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a/tests/CMakeLists[.]txt" - "-- WithSubpackagesA_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/CMakeLists[.]txt" "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/tests/CMakeLists[.]txt" - "-- WithSubpackagesB_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "-- WithSubpackagesB_LIBRARY_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src'" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c/CMakeLists[.]txt" "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c/tests/CMakeLists[.]txt" - "-- WithSubpackagesC_INCLUDE_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c'" - "-- WithSubpackagesC_LIBRARY_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/c'" - - "-- WithSubpackages_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src;.+/examples/tpls/HeaderOnlyTpl;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c'" - "-- WithSubpackages_LIBRARY_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/c'" - TEST_4 CMND make ARGS ${CTEST_BUILD_FLAGS} PASS_REGULAR_EXPRESSION_ALL diff --git a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake index 4d1787bd7..62eac2a00 100644 --- a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake @@ -767,8 +767,8 @@ tribits_add_advanced_test( TribitsHelloWorld_install_config_dummy_proj "TribitsHelloWorld_LINKER = '.*'" "TribitsHelloWorld_AR = '.*'" "TribitsHelloWorld_INSTALL_DIR = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install'" - "TribitsHelloWorld_INCLUDE_DIRS = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install/include'" - "TribitsHelloWorld_LIBRARY_DIRS = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install/lib'" + "TribitsHelloWorld_INCLUDE_DIRS = ''" + "TribitsHelloWorld_LIBRARY_DIRS = ''" "TribitsHelloWorld_LIBRARIES = 'HelloWorld::hello_world_lib'" "TribitsHelloWorld_TPL_INCLUDE_DIRS = '" "TribitsHelloWorld_TPL_LIBRARY_DIRS = ''" diff --git a/test/core/TribitsWriteClientExportFiles_UnitTests.cmake b/test/core/TribitsWriteClientExportFiles_UnitTests.cmake index 607c104fb..e565d171f 100644 --- a/test/core/TribitsWriteClientExportFiles_UnitTests.cmake +++ b/test/core/TribitsWriteClientExportFiles_UnitTests.cmake @@ -135,14 +135,14 @@ function(unittest_write_specialized_package_export_makefile_rtop_before_libs) unittest_file_regex("${GENERATED_EXPORT_CONFIG_FOR_BUILD}" REGEX_STRINGS "set[(]RTOp1_CMAKE_BUILD_TYPE .DEBUG." - "set[(]RTOp1_INCLUDE_DIRS .teuchos/core/include.teuchos/numeric/include.." - "set[(]RTOp1_LIBRARY_DIRS .teuchos/core/src.teuchos/numeric/src.." - "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.." - "set[(]RTOp1_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.." - "set[(]RTOp1_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.." - "set[(]RTOp1_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.." - "set[(]RTOp1_PACKAGE_LIST .Teuchos.." - "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.." + "set[(]RTOp1_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.[)]" + "set[(]RTOp1_TPL_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARIES .LAPACK::all_libs[;]BLAS::all_libs.[)]" + "set[(]RTOp1_PACKAGE_LIST .Teuchos.[)]" + "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.[)]" "set[(]RTOp1_ENABLE_Teuchos ON[)]" ) @@ -150,14 +150,14 @@ function(unittest_write_specialized_package_export_makefile_rtop_before_libs) unittest_file_regex("${GENERATED_EXPORT_CONFIG_FOR_INSTALL}" REGEX_STRINGS "set[(]RTOp1_CMAKE_BUILD_TYPE .DEBUG." - "set[(]RTOp1_INCLUDE_DIRS .*/dummy_install_include_dir" - "set[(]RTOp1_LIBRARY_DIRS .*/dummy_install_lib_dir" - "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.." - "set[(]RTOp1_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.." - "set[(]RTOp1_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.." - "set[(]RTOp1_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.." - "set[(]RTOp1_PACKAGE_LIST .Teuchos.." - "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.." + "set[(]RTOp1_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.[)]" + "set[(]RTOp1_TPL_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARIES .LAPACK::all_libs[;]BLAS::all_libs.[)]" + "set[(]RTOp1_PACKAGE_LIST .Teuchos.[)]" + "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.[)]" "set[(]RTOp1_ENABLE_Teuchos ON[)]" ) @@ -225,14 +225,14 @@ function(unittest_write_specialized_package_export_makefile_rtop_after_libs) unittest_file_regex("${GENERATED_EXPORT_CONFIG_FOR_BUILD}" REGEX_STRINGS "set[(]RTOp2_CMAKE_BUILD_TYPE .RELEASE." - "set[(]RTOp2_INCLUDE_DIRS .rtop/include.teuchos/core/include.teuchos/numeric/include.." - "set[(]RTOp2_LIBRARY_DIRS .rtop/src.teuchos/core/src.teuchos/numeric/src.." - "set[(]RTOp2_LIBRARIES .rtop.teuchoscore.teuchosnumeric.." - "set[(]RTOp2_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.." - "set[(]RTOp2_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.." - "set[(]RTOp2_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.." - "set[(]RTOp2_PACKAGE_LIST .RTOp.Teuchos.." - "set[(]RTOp2_TPL_LIST .LAPACK.BLAS.." + "set[(]RTOp2_INCLUDE_DIRS ..[)]" + "set[(]RTOp2_LIBRARY_DIRS ..[)]" + "set[(]RTOp2_LIBRARIES .rtop.teuchoscore.teuchosnumeric.[)]" + "set[(]RTOp2_TPL_INCLUDE_DIRS ..[)]" + "set[(]RTOp2_TPL_LIBRARY_DIRS ..[)]" + "set[(]RTOp2_TPL_LIBRARIES .LAPACK::all_libs[;]BLAS::all_libs.[)]" + "set[(]RTOp2_PACKAGE_LIST .RTOp.Teuchos.[)]" + "set[(]RTOp2_TPL_LIST .LAPACK.BLAS.[)]" "set[(]RTOp2_ENABLE_Teuchos ON[)]" ) diff --git a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt index cb9402d6f..c2ec213ae 100644 --- a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt @@ -2477,7 +2477,7 @@ function(generate_aao_tests) "EXPORT_CONFIG_FILE = '../BUILD/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" "TribitsExProj_FIND_COMPONENTS = 'SimpleCxx[;]WithSubpackagesA[;]WrapExternal'" "TribitsExProj_LIBRARIES = 'WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "TribitsExProj_TPL_INCLUDE_DIRS = '.*/examples/tpls/HeaderOnlyTpl'" + "TribitsExProj_TPL_INCLUDE_DIRS = ''" "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]MixedLang[;]SimpleCxx'" "TribitsExProj_TPL_LIST = 'HeaderOnlyTpl'" "TribitsExProj_WithSubpackages_FOUND = ''" @@ -2595,7 +2595,7 @@ function(generate_aao_tests) "EXPORT_CONFIG_FILE = '../BUILD/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" "TribitsExProj_FIND_COMPONENTS = 'SimpleCxx[;]WithSubpackagesA'" "TribitsExProj_LIBRARIES = 'WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "TribitsExProj_TPL_INCLUDE_DIRS = '.*/examples/tpls/HeaderOnlyTpl'" + "TribitsExProj_TPL_INCLUDE_DIRS = ''" "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]MixedLang[;]SimpleCxx'" "TribitsExProj_TPL_LIST = 'HeaderOnlyTpl'" "TribitsExProj_WithSubpackages_FOUND = ''" diff --git a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in index f92d40c80..15025561c 100644 --- a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in @@ -93,19 +93,19 @@ set(${EXPORT_FILE_VAR_PREFIX}_AR ${CMAKE_AR}) set(${EXPORT_FILE_VAR_PREFIX}_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@") ## List of package include dirs -set(${EXPORT_FILE_VAR_PREFIX}_INCLUDE_DIRS "${FULL_INCLUDE_DIRS_SET}") +set(${EXPORT_FILE_VAR_PREFIX}_INCLUDE_DIRS "") ## List of package library paths -set(${EXPORT_FILE_VAR_PREFIX}_LIBRARY_DIRS "${FULL_LIBRARY_DIRS_SET}") +set(${EXPORT_FILE_VAR_PREFIX}_LIBRARY_DIRS "") ## List of package libraries set(${EXPORT_FILE_VAR_PREFIX}_LIBRARIES "${FULL_LIBRARY_SET}") ## Specification of directories for TPL headers -set(${EXPORT_FILE_VAR_PREFIX}_TPL_INCLUDE_DIRS "${${PACKAGE_NAME}_TPL_INCLUDE_DIRS}") +set(${EXPORT_FILE_VAR_PREFIX}_TPL_INCLUDE_DIRS "") ## Specification of directories for TPL libraries -set(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARY_DIRS "${${PACKAGE_NAME}_TPL_LIBRARY_DIRS}") +set(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARY_DIRS "") ## List of required TPLs set(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARIES "${${PACKAGE_NAME}_TPL_LIBRARIES}") diff --git a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in index 8cf75679d..b15c327ca 100644 --- a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in @@ -113,11 +113,11 @@ foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST}) # Include the package file. include(${PDOLLAR}{INCLUDE_FILE}) # Add variables to lists. - list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_INCLUDE_DIRS}) - list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARY_DIRS}) + #list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_INCLUDE_DIRS}) + #list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARIES}) - list(APPEND ${PROJECT_NAME}_TPL_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_INCLUDE_DIRS}) - list(APPEND ${PROJECT_NAME}_TPL_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARY_DIRS}) + #list(APPEND ${PROJECT_NAME}_TPL_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_INCLUDE_DIRS}) + #list(APPEND ${PROJECT_NAME}_TPL_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_TPL_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARIES}) else() set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND FALSE) @@ -132,35 +132,36 @@ endforeach() # Resolve absolute paths and remove duplicate paths # for LIBRARY_DIRS and INCLUDE_DIRS # This reduces stress on regular expressions later -set(short_dirs) -foreach(dir ${PDOLLAR}{${PROJECT_NAME}_INCLUDE_DIRS}) - get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) - list(APPEND short_dirs ${PDOLLAR}{dir_abs}) -endforeach() -list(REMOVE_DUPLICATES short_dirs) -set(${PROJECT_NAME}_INCLUDE_DIRS ${PDOLLAR}{short_dirs}) - -set(short_dirs) -foreach(dir ${PDOLLAR}{${PROJECT_NAME}_LIBRARY_DIRS}) - get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) - list(APPEND short_dirs ${PDOLLAR}{dir_abs}) -endforeach() -list(REMOVE_DUPLICATES short_dirs) -set(${PROJECT_NAME}_LIBRARY_DIRS ${PDOLLAR}{short_dirs}) +#set(short_dirs) +#foreach(dir ${PDOLLAR}{${PROJECT_NAME}_INCLUDE_DIRS}) +# get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) +# list(APPEND short_dirs ${PDOLLAR}{dir_abs}) +#endforeach() +#list(REMOVE_DUPLICATES short_dirs) +set(${PROJECT_NAME}_INCLUDE_DIRS "") + +#set(short_dirs) +#foreach(dir ${PDOLLAR}{${PROJECT_NAME}_LIBRARY_DIRS}) +# get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) +# list(APPEND short_dirs ${PDOLLAR}{dir_abs}) +#endforeach() +#list(REMOVE_DUPLICATES short_dirs) +set(${PROJECT_NAME}_LIBRARY_DIRS "") # Remove duplicates in ${PROJECT_NAME}_LIBRARIES list(REVERSE ${PROJECT_NAME}_LIBRARIES) list(REMOVE_DUPLICATES ${PROJECT_NAME}_LIBRARIES) list(REVERSE ${PROJECT_NAME}_LIBRARIES) -# Remove duplicates in ${PROJECT_NAME}_TPL_INCLUDE_DIRS -if (${PROJECT_NAME}_TPL_INCLUDE_DIRS) - list(REMOVE_DUPLICATES ${PROJECT_NAME}_TPL_INCLUDE_DIRS) -endif() +## Remove duplicates in ${PROJECT_NAME}_TPL_INCLUDE_DIRS +#if (${PROJECT_NAME}_TPL_INCLUDE_DIRS) +# list(REMOVE_DUPLICATES ${PROJECT_NAME}_TPL_INCLUDE_DIRS) +#endif() -# NOTE: It is *NOT* safe to try to remove duplicate in -# ${PROJECT_NAME}_TPL_LIBRARIES because these can be specified as -L, -l, etc. -# Actually, we should think about that. +# Remove duplicates in ${PROJECT_NAME}_TPL_LIBRARIES +list(REVERSE ${PROJECT_NAME}_TPL_LIBRARIES) +list(REMOVE_DUPLICATES ${PROJECT_NAME}_TPL_LIBRARIES) +list(REVERSE ${PROJECT_NAME}_TPL_LIBRARIES) ## --------------------------------------------------------------------------- ## MPI specific variables diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index ac38e5571..2319d6fd1 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -427,8 +427,8 @@ function(tribits_add_executable EXE_NAME) set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") if (NOT TRIBITS_ADD_EXECUTABLE_UNIT_TESTING) - tribits_include_directories(REQUIRED_DURING_INSTALLATION_TESTING - ${${PACKAGE_NAME}_INCLUDE_DIRS}) + #tribits_include_directories(REQUIRED_DURING_INSTALLATION_TESTING + # ${${PACKAGE_NAME}_INCLUDE_DIRS}) # set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS # ${${PACKAGE_NAME}_LIBRARY_DIRS}) endif() @@ -556,10 +556,10 @@ function(tribits_add_executable EXE_NAME) set(TESTONLYLIB "${LIBRARY_NAME_PREFIX}${TESTONLYLIB_IN}") tribits_lib_is_testonly(${TESTONLYLIB} libIsTestOnlyLib) if (libIsTestOnlyLib) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message(STATUS "Adding include directories ${TESTONLYLIB}_INCLUDE_DIRS ...") - endif() - include_directories(${${TESTONLYLIB}_INCLUDE_DIRS}) + #if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + # message(STATUS "Adding include directories ${TESTONLYLIB}_INCLUDE_DIRS ...") + #endif() + #include_directories(${${TESTONLYLIB}_INCLUDE_DIRS}) endif() endforeach() @@ -622,23 +622,23 @@ function(tribits_add_executable EXE_NAME) # dependent Packages and TPLs and accumulate the list of libraries that will # need to be linked to. - if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING - AND NOT ${PACKAGE_NAME}_INCLUDE_DIRS - ) - # No libraries have been added for this package so - # add the upstream package and TPL includes and libraries - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - endif() +# if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING +# AND NOT ${PACKAGE_NAME}_INCLUDE_DIRS +# ) +# # No libraries have been added for this package so +# # add the upstream package and TPL includes and libraries +# #tribits_sort_and_append_package_include_and_link_dirs_and_libs( +# # ${PACKAGE_NAME} LIB LINK_LIBS) +# #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( +# # ${PACKAGE_NAME} LIB LINK_LIBS) +# endif() - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) + #tribits_sort_and_append_package_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} TEST LINK_LIBS) if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) + #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} TEST LINK_LIBS) else() list(APPEND LINK_LIBS ${${PACKAGE_NAME}_INSTALLATION_TPL_LIBRARIES}) endif() diff --git a/tribits/core/package_arch/TribitsGeneralMacros.cmake b/tribits/core/package_arch/TribitsGeneralMacros.cmake index 16471366e..534a358b9 100644 --- a/tribits/core/package_arch/TribitsGeneralMacros.cmake +++ b/tribits/core/package_arch/TribitsGeneralMacros.cmake @@ -384,136 +384,136 @@ endfunction() # NOTE: Because this function may be called in cases where a package's # required subpackages are not actually enabled (e.g. SEACAS subpackages) # -function( tribits_append_include_and_link_dirs TPL_OR_PACKAGE PREFIX - LIST EXTRA_DEP_LIBS_INOUT - ) - if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) - message("\nTRIBITS_APPEND_INCLUDE_AND_LINK_DIRS: '${TPL_OR_PACKAGE}'" - " '${PREFIX}' '${LIST}' '${EXTRA_DEP_LIBS_INOUT}'") - endif() - set(EXTRA_DEP_LIBS_INOUT_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - cmake_policy(SET CMP0054 NEW) - if ( - "${TPL_OR_PACKAGE}" STREQUAL "TPL" - AND - ( - ${PROJECT_NAME}_TPL_SYSTEM_INCLUDE_DIRS - AND NOT - (${PARENT_PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS - OR ${PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS) - ) - ) - set(SYSTEM_ARG "SYSTEM") - else() - set(SYSTEM_ARG) - endif() - foreach(ITEM ${LIST}) - if (${PREFIX}${ITEM}_LIBRARIES) - append_set(EXTRA_DEP_LIBS_ARG_TMP ${${PREFIX}${ITEM}_LIBRARIES}) - endif() - if (${PREFIX}${ITEM}_INCLUDE_DIRS) - if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) - message("-- " "include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS})") - endif() - include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS}) - endif() - if (${PREFIX}${ITEM}_LIBRARY_DIRS) - if (PREFIX) - # TODO: Is there a better way to know if we need this? - # We want LINK_DIRECTORIES for TPLs but not packages. - link_directories(${${PREFIX}${ITEM}_LIBRARY_DIRS}) - endif() - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${${PREFIX}${ITEM}_LIBRARY_DIRS}) - endif() - if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) - print_var(${PREFIX}${ITEM}_LIBRARIES) - print_var(${PREFIX}${ITEM}_INCLUDE_DIRS) - print_var(${PREFIX}${ITEM}_LIBRARY_DIRS) - endif() - endforeach() - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) -endfunction() +#function( tribits_append_include_and_link_dirs TPL_OR_PACKAGE PREFIX +# LIST EXTRA_DEP_LIBS_INOUT +# ) +# if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) +# message("\nTRIBITS_APPEND_INCLUDE_AND_LINK_DIRS: '${TPL_OR_PACKAGE}'" +# " '${PREFIX}' '${LIST}' '${EXTRA_DEP_LIBS_INOUT}'") +# endif() +# set(EXTRA_DEP_LIBS_INOUT_TMP ${${EXTRA_DEP_LIBS_INOUT}}) +# cmake_policy(SET CMP0054 NEW) +# if ( +# "${TPL_OR_PACKAGE}" STREQUAL "TPL" +# AND +# ( +# ${PROJECT_NAME}_TPL_SYSTEM_INCLUDE_DIRS +# AND NOT +# (${PARENT_PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS +# OR ${PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS) +# ) +# ) +# set(SYSTEM_ARG "SYSTEM") +# else() +# set(SYSTEM_ARG) +# endif() +# foreach(ITEM ${LIST}) +# if (${PREFIX}${ITEM}_LIBRARIES) +# append_set(EXTRA_DEP_LIBS_ARG_TMP ${${PREFIX}${ITEM}_LIBRARIES}) +# endif() +# if (${PREFIX}${ITEM}_INCLUDE_DIRS) +# if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) +# message("-- " "include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS})") +# endif() +# include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS}) +# endif() +# if (${PREFIX}${ITEM}_LIBRARY_DIRS) +# if (PREFIX) +# # TODO: Is there a better way to know if we need this? +# # We want LINK_DIRECTORIES for TPLs but not packages. +# link_directories(${${PREFIX}${ITEM}_LIBRARY_DIRS}) +# endif() +# set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS +# ${${PREFIX}${ITEM}_LIBRARY_DIRS}) +# endif() +# if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) +# print_var(${PREFIX}${ITEM}_LIBRARIES) +# print_var(${PREFIX}${ITEM}_INCLUDE_DIRS) +# print_var(${PREFIX}${ITEM}_LIBRARY_DIRS) +# endif() +# endforeach() +# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) +#endfunction() # Function that sorts and appends all the items in a dependency list for # packages or TPLs. # -function( tribits_sort_and_append_include_and_link_dirs_and_libs - TPL_OR_PACKAGE MASTER_SORT_LIST LIST PREFIX - EXTRA_DEP_LIBS_INOUT - ) - - if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) - message("TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS:") - print_var(MASTER_SORT_LIST) - print_var(LIST) - print_var(PREFIX) - print_var(EXTRA_DEP_LIBS_INOUT) - endif() - - set(LOCAL_LIST ${LIST}) - if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) - print_var(LOCAL_LIST) - endif() - - if (LOCAL_LIST) - - tribits_sort_list_according_to_master_list("${MASTER_SORT_LIST}" LOCAL_LIST) - if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) - print_var(LOCAL_LIST) - endif() - - set(EXTRA_DEP_LIBS_ARG_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - tribits_append_include_and_link_dirs("${TPL_OR_PACKAGE}" "${PREFIX}" - "${LOCAL_LIST}" EXTRA_DEP_LIBS_ARG_TMP) - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) - - endif() - -endfunction() +#function( tribits_sort_and_append_include_and_link_dirs_and_libs +# TPL_OR_PACKAGE MASTER_SORT_LIST LIST PREFIX +# EXTRA_DEP_LIBS_INOUT +# ) +# +# if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) +# message("TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS:") +# print_var(MASTER_SORT_LIST) +# print_var(LIST) +# print_var(PREFIX) +# print_var(EXTRA_DEP_LIBS_INOUT) +# endif() +# +# set(LOCAL_LIST ${LIST}) +# if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) +# print_var(LOCAL_LIST) +# endif() +# +# if (LOCAL_LIST) +# +# tribits_sort_list_according_to_master_list("${MASTER_SORT_LIST}" LOCAL_LIST) +# if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) +# print_var(LOCAL_LIST) +# endif() +# +# set(EXTRA_DEP_LIBS_ARG_TMP ${${EXTRA_DEP_LIBS_INOUT}}) +# tribits_append_include_and_link_dirs("${TPL_OR_PACKAGE}" "${PREFIX}" +# "${LOCAL_LIST}" EXTRA_DEP_LIBS_ARG_TMP) +# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) +# +# endif() +# +#endfunction() # Fully process the include and link directories and list of libraries for a # package's list of dependent packages for use in creating a library or an # executable # -function( tribits_sort_and_append_package_include_and_link_dirs_and_libs - PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT - ) - - tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} - PACKAGES ALL_DEP_PACKAGES) - - set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - tribits_sort_and_append_include_and_link_dirs_and_libs( - "PACKAGE" - "${${PROJECT_NAME}_REVERSE_ENABLED_SE_PACKAGES}" - "${ALL_DEP_PACKAGES}" "" EXTRA_DEP_LIBS_TMP) - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) - -endfunction() +#function( tribits_sort_and_append_package_include_and_link_dirs_and_libs +# PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT +# ) +# +# tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} +# PACKAGES ALL_DEP_PACKAGES) +# +# set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) +# tribits_sort_and_append_include_and_link_dirs_and_libs( +# "PACKAGE" +# "${${PROJECT_NAME}_REVERSE_ENABLED_SE_PACKAGES}" +# "${ALL_DEP_PACKAGES}" "" EXTRA_DEP_LIBS_TMP) +# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) +# +#endfunction() # Fully process the include and link directories and list of libraries for a # package's list of dependent TPLs for use in creating a library or an # executable # -function( tribits_sort_and_append_tpl_include_and_link_dirs_and_libs - PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT - ) - - tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} - TPLS ALL_TPLS) - - set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - tribits_sort_and_append_include_and_link_dirs_and_libs( - "TPL" - "${${PROJECT_NAME}_REVERSE_ENABLED_TPLS}" - "${ALL_TPLS}" TPL_ EXTRA_DEP_LIBS_TMP) - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) - -endfunction() +#function( tribits_sort_and_append_tpl_include_and_link_dirs_and_libs +# PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT +# ) +# +# tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} +# TPLS ALL_TPLS) +# +# set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) +# tribits_sort_and_append_include_and_link_dirs_and_libs( +# "TPL" +# "${${PROJECT_NAME}_REVERSE_ENABLED_TPLS}" +# "${ALL_TPLS}" TPL_ EXTRA_DEP_LIBS_TMP) +# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) +# +#endfunction() # Print trace of file processing diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 775a4d045..cd72c618f 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -2087,8 +2087,8 @@ macro(tribits_configure_enabled_packages) # A) Global variable initialization # - global_null_set(${PROJECT_NAME}_INCLUDE_DIRS "") - global_null_set(${PROJECT_NAME}_LIBRARY_DIRS "") + #global_null_set(${PROJECT_NAME}_INCLUDE_DIRS "") + #global_null_set(${PROJECT_NAME}_LIBRARY_DIRS "") global_null_set(${PROJECT_NAME}_LIBRARIES "") global_null_set(${PROJECT_NAME}_ETI_PACKAGES "") @@ -2192,8 +2192,8 @@ macro(tribits_configure_enabled_packages) endif() list(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}_libs) - list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) - list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) + #list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) + #list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_LIBRARIES ${${TRIBITS_PACKAGE}_LIBRARIES}) tribits_package_config_code_stop_timer(PROCESS_THIS_PACKAGE_TIME_START_SECONDS @@ -2272,8 +2272,8 @@ macro(tribits_configure_enabled_packages) if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY) - remove_global_duplicates(${PROJECT_NAME}_INCLUDE_DIRS) - remove_global_duplicates(${PROJECT_NAME}_LIBRARY_DIRS) + #remove_global_duplicates(${PROJECT_NAME}_INCLUDE_DIRS) + #remove_global_duplicates(${PROJECT_NAME}_LIBRARY_DIRS) remove_global_duplicates(${PROJECT_NAME}_LIBRARIES) # Add global 'libs' target diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index bf1afad03..eee78720d 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -527,8 +527,8 @@ function(tribits_add_library LIBRARY_NAME_IN) endif() if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - print_var(${PACKAGE_NAME}_LIBRARY_DIRS) + #print_var(${PACKAGE_NAME}_INCLUDE_DIRS) + #print_var(${PACKAGE_NAME}_LIBRARY_DIRS) print_var(${PACKAGE_NAME}_LIBRARIES) endif() @@ -568,8 +568,8 @@ function(tribits_add_library LIBRARY_NAME_IN) # Add the link directory for this library. - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${CMAKE_CURRENT_BINARY_DIR}) + #set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS + # ${CMAKE_CURRENT_BINARY_DIR}) # NOTE: Above, this link path not really used here for anything. # Instead it is just added to the other set link library directories @@ -583,8 +583,8 @@ function(tribits_add_library LIBRARY_NAME_IN) # Add whatever link directories have been added so far - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${${PACKAGE_NAME}_LIBRARY_DIRS}) + #set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS + # ${${PACKAGE_NAME}_LIBRARY_DIRS}) # Local variable to hold all of the libraries that will be directly linked # to this library. @@ -659,11 +659,11 @@ function(tribits_add_library LIBRARY_NAME_IN) # this case we just hope that this SE package correctly specified a # TEST dependency on the upstream SE package that owns this upstream # TESTONLY library. - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " - "Adding include directories for TESTONLY ${PREFIXED_LIB}_INCLUDE_DIRS ...") - endif() - include_directories(${${PREFIXED_LIB}_INCLUDE_DIRS}) + #if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + # message("-- " + # "Adding include directories for TESTONLY ${PREFIXED_LIB}_INCLUDE_DIRS ...") + #endif() + #include_directories(${${PREFIXED_LIB}_INCLUDE_DIRS}) elseif (NOT PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE message(WARNING "WARNING: '${LIB}' in DEPLIBS is a TESTONLY lib" " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." @@ -754,11 +754,11 @@ function(tribits_add_library LIBRARY_NAME_IN) " for TEST dependencies ...") endif() - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) - - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) + #tribits_sort_and_append_package_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} TEST LINK_LIBS) + # + #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} TEST LINK_LIBS) endif() @@ -787,11 +787,11 @@ function(tribits_add_library LIBRARY_NAME_IN) # property and set on ${PACKAGE_NAME}_INCLUDE_DIRS # - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) + #tribits_sort_and_append_package_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} LIB LINK_LIBS) + # + #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} LIB LINK_LIBS) endif() @@ -966,16 +966,16 @@ function(tribits_add_library LIBRARY_NAME_IN) # Append the new include dirs, library dirs, and libraries to this package's lists get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) + #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) if (APPEND_LIB_AND_HEADERS_TO_PACKAGE) - prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) + #prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) + #prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${PACKAGE_NAME}::${LIBRARY_NAME}) - remove_global_duplicates(${PACKAGE_NAME}_INCLUDE_DIRS) - remove_global_duplicates(${PACKAGE_NAME}_LIBRARY_DIRS) + #remove_global_duplicates(${PACKAGE_NAME}_INCLUDE_DIRS) + #remove_global_duplicates(${PACKAGE_NAME}_LIBRARY_DIRS) remove_global_duplicates(${PACKAGE_NAME}_LIBRARIES) if (INSTALL_LIB) @@ -990,26 +990,21 @@ function(tribits_add_library LIBRARY_NAME_IN) endif() list(REMOVE_DUPLICATES INCLUDE_DIRS_CURRENT) - global_set(${LIBRARY_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) + #global_set(${LIBRARY_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${LIBRARY_NAME}_INCLUDE_DIRS) - endif() + #if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + # print_var(${LIBRARY_NAME}_INCLUDE_DIRS) + #endif() endif() # Set INTERFACE_INCLUDE_DIRECTOIRES property for added library and must # only do for the build interface (not the install interface). set(buildInterfaceIncludeDirs) - foreach (includeDir IN LISTS ${PACKAGE_NAME}_INCLUDE_DIRS) + foreach (includeDir IN LISTS INCLUDE_DIRS_CURRENT) list(APPEND buildInterfaceIncludeDirs "$") endforeach() target_include_directories( ${LIBRARY_NAME} PUBLIC ${buildInterfaceIncludeDirs} ) - # ToDo: #299: In the final refactoring, the list of include directories - # for this library should be extracted from the directory property - # INCLUDE_DIRECTORIES and then set INTERFACE instead of PUBLIC above. The - # rest of the include directories from upstream packages should come from - # the targets that have their INTERFACE_INCLUDE_DIRECTORIES property set. # Add ALIAS library :: add_library(${PACKAGE_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME}) @@ -1035,17 +1030,17 @@ function(tribits_add_library LIBRARY_NAME_IN) " Please disable package ${PACKAGE_NAME} or install it.") endif() - include_directories(REQUIRED_DURING_INSTALLATION_TESTING BEFORE - ${${PACKAGE_NAME}_INSTALLATION_INCLUDE_DIRS} - ${${TRIBITS_PACKAGE}_INSTALLATION_TPL_INCLUDE_DIRS}) - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${${PACKAGE_NAME}_INSTALLATION_LIBRARY_DIRS}) + #include_directories(REQUIRED_DURING_INSTALLATION_TESTING BEFORE + # ${${PACKAGE_NAME}_INSTALLATION_INCLUDE_DIRS} + # ${${TRIBITS_PACKAGE}_INSTALLATION_TPL_INCLUDE_DIRS}) + #set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS + # ${${PACKAGE_NAME}_INSTALLATION_LIBRARY_DIRS}) - get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) + #get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) + #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) + #global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) + #global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) endif() #installation testing mode @@ -1055,8 +1050,8 @@ function(tribits_add_library LIBRARY_NAME_IN) # if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - print_var(${PACKAGE_NAME}_LIBRARY_DIRS) + #print_var(${PACKAGE_NAME}_INCLUDE_DIRS) + #print_var(${PACKAGE_NAME}_LIBRARY_DIRS) print_var(${PACKAGE_NAME}_LIBRARIES) endif() diff --git a/tribits/core/package_arch/TribitsPackageMacros.cmake b/tribits/core/package_arch/TribitsPackageMacros.cmake index 42889656c..f6a5ec02b 100644 --- a/tribits/core/package_arch/TribitsPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsPackageMacros.cmake @@ -78,8 +78,8 @@ include(TribitsReportInvalidTribitsUsage) # they are used. # macro(tribits_define_linkage_vars PACKAGE_NAME_IN) - global_null_set(${PACKAGE_NAME_IN}_INCLUDE_DIRS "") - global_null_set(${PACKAGE_NAME_IN}_LIBRARY_DIRS "") + #global_null_set(${PACKAGE_NAME_IN}_INCLUDE_DIRS "") + #global_null_set(${PACKAGE_NAME_IN}_LIBRARY_DIRS "") global_null_set(${PACKAGE_NAME_IN}_LIBRARIES "") global_set(${PACKAGE_NAME_IN}_HAS_NATIVE_LIBRARIES_TO_INSTALL FALSE) endmacro() @@ -623,8 +623,8 @@ function(tribits_package_finalize_dependency_vars) # A package with subpackages should get all of its dependency vars from # its enabled subpackages. - set(PARENT_PACKAGE_INCLUDE_DIRS "") - set(PARENT_PACKAGE_LIBRARY_DIRS "") + #set(PARENT_PACKAGE_INCLUDE_DIRS "") + #set(PARENT_PACKAGE_LIBRARY_DIRS "") set(PARENT_PACKAGE_LIBRARIES "") set(SUBPACKAGE_IDX 0) @@ -634,10 +634,10 @@ function(tribits_package_finalize_dependency_vars) set(SUBPACKAGE_FULLNAME ${PARENT_PACKAGE_NAME}${TRIBITS_SUBPACKAGE}) if (${PROJECT_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}) - prepend_set(PARENT_PACKAGE_INCLUDE_DIRS - ${${SUBPACKAGE_FULLNAME}_INCLUDE_DIRS}) - prepend_set(PARENT_PACKAGE_LIBRARY_DIRS - ${${SUBPACKAGE_FULLNAME}_LIBRARY_DIRS}) + #prepend_set(PARENT_PACKAGE_INCLUDE_DIRS + # ${${SUBPACKAGE_FULLNAME}_INCLUDE_DIRS}) + #prepend_set(PARENT_PACKAGE_LIBRARY_DIRS + # ${${SUBPACKAGE_FULLNAME}_LIBRARY_DIRS}) prepend_set(PARENT_PACKAGE_LIBRARIES ${${SUBPACKAGE_FULLNAME}_LIBRARIES}) endif() @@ -646,12 +646,12 @@ function(tribits_package_finalize_dependency_vars) endforeach() - if (PARENT_PACKAGE_INCLUDE_DIRS) - list(REMOVE_DUPLICATES PARENT_PACKAGE_INCLUDE_DIRS) - endif() - if (PARENT_PACKAGE_LIBRARY_DIRS) - list(REMOVE_DUPLICATES PARENT_PACKAGE_LIBRARY_DIRS) - endif() + #if (PARENT_PACKAGE_INCLUDE_DIRS) + # list(REMOVE_DUPLICATES PARENT_PACKAGE_INCLUDE_DIRS) + #endif() + #if (PARENT_PACKAGE_LIBRARY_DIRS) + # list(REMOVE_DUPLICATES PARENT_PACKAGE_LIBRARY_DIRS) + #endif() # NOTE: Above, in the rare case that none of the subpackages contain any # libraries or any include directories, we need to not call # list(REMOVE_DUPLICATES ...). @@ -659,27 +659,27 @@ function(tribits_package_finalize_dependency_vars) # NOTE: There can't be any duplicate libraries in PARENT_PACKAGE_LIBRARIES # so no need to remove them. - global_set(${PACKAGE_NAME}_INCLUDE_DIRS "${PARENT_PACKAGE_INCLUDE_DIRS}") - global_set(${PACKAGE_NAME}_LIBRARY_DIRS "${PARENT_PACKAGE_LIBRARY_DIRS}") + #global_set(${PACKAGE_NAME}_INCLUDE_DIRS "${PARENT_PACKAGE_INCLUDE_DIRS}") + #global_set(${PACKAGE_NAME}_LIBRARY_DIRS "${PARENT_PACKAGE_LIBRARY_DIRS}") global_set(${PACKAGE_NAME}_LIBRARIES "${PARENT_PACKAGE_LIBRARIES}") - elseif(NOT ${PACKAGE_NAME}_INCLUDE_DIRS) +# elseif(NOT ${PACKAGE_NAME}_INCLUDE_DIRS) # No libraries have been defined for this package so we are going to set # them based on this package's dependencies. - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) + #tribits_sort_and_append_package_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} LIB LINK_LIBS) + # + #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( + # ${PACKAGE_NAME} LIB LINK_LIBS) - get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) + #get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) + #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) - prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${LINK_LIBS}) + #prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) + #prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) + #prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${LINK_LIBS}) endif() @@ -692,8 +692,8 @@ macro(tribits_package_postprocess_common) if (${PROJECT_NAME}_VERBOSE_CONFIGURE) message("\nTRIBITS_PACKAGE_POSTPROCESS_COMMON: ${PACKAGE_NAME}") - print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - print_var(${PACKAGE_NAME}_LIBRARY_DIRS) + #print_var(${PACKAGE_NAME}_INCLUDE_DIRS) + #print_var(${PACKAGE_NAME}_LIBRARY_DIRS) print_var(${PACKAGE_NAME}_LIBRARIES) endif() diff --git a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake index 44cfd8a00..5e26cdad7 100644 --- a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake +++ b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake @@ -186,14 +186,14 @@ function(tribits_write_flexible_package_client_export_files) set(FULL_LIBRARY_SET "") set(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM TRUE) - if (${PACKAGE_NAME}_INCLUDE_DIRS) - set(FULL_INCLUDE_DIRS_SET ${${PACKAGE_NAME}_INCLUDE_DIRS}) - set(FULL_LIBRARY_DIRS_SET ${${PACKAGE_NAME}_LIBRARY_DIRS}) - set(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM FALSE) - else() - set(FULL_INCLUDE_DIRS_SET "") - set(FULL_LIBRARY_DIRS_SET "") - endif() +# if (${PACKAGE_NAME}_INCLUDE_DIRS) +# set(FULL_INCLUDE_DIRS_SET ${${PACKAGE_NAME}_INCLUDE_DIRS}) +# set(FULL_LIBRARY_DIRS_SET ${${PACKAGE_NAME}_LIBRARY_DIRS}) +# set(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM FALSE) +# else() +# set(FULL_INCLUDE_DIRS_SET "") +# set(FULL_LIBRARY_DIRS_SET "") +# endif() if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) print_var(${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES) @@ -219,10 +219,10 @@ function(tribits_write_flexible_package_client_export_files) list(APPEND FULL_PACKAGE_SET ${TRIBITS_PACKAGE}) if (APPEND_THE_PACKAGE_LIBS) append_set(FULL_LIBRARY_SET ${${TRIBITS_PACKAGE}_LIBRARIES}) - if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) - append_set(FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) - append_set(FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) - endif() +# if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) +# append_set(FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) +# append_set(FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) +# endif() else() if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) message("-- " "Skipping adding the package libs!") @@ -237,10 +237,10 @@ function(tribits_write_flexible_package_client_export_files) if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) print_var(FULL_PACKAGE_SET) print_var(FULL_LIBRARY_SET) - if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) - print_var(FULL_INCLUDE_DIRS_SET) - print_var(FULL_LIBRARY_DIRS_SET) - endif() +# if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) +# print_var(FULL_INCLUDE_DIRS_SET) +# print_var(FULL_LIBRARY_DIRS_SET) +# endif() endif() endforeach() @@ -256,21 +256,21 @@ function(tribits_write_flexible_package_client_export_files) prepend_set(FULL_LIBRARY_SET ${${PACKAGE_NAME}_LIBRARIES}) endif() - if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) - if (FULL_INCLUDE_DIRS_SET) - list(REMOVE_DUPLICATES FULL_INCLUDE_DIRS_SET) - endif() - if (FULL_LIBRARY_DIRS_SET) - list(REMOVE_DUPLICATES FULL_LIBRARY_DIRS_SET) - endif() - endif() +# if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) +# if (FULL_INCLUDE_DIRS_SET) +# list(REMOVE_DUPLICATES FULL_INCLUDE_DIRS_SET) +# endif() +# if (FULL_LIBRARY_DIRS_SET) +# list(REMOVE_DUPLICATES FULL_LIBRARY_DIRS_SET) +# endif() +# endif() if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) message("-- " "*** Final sets of packages, libs, include dirs, and lib dirs:") print_var(FULL_PACKAGE_SET) print_var(FULL_LIBRARY_SET) - print_var(FULL_INCLUDE_DIRS_SET) - print_var(FULL_LIBRARY_DIRS_SET) +# print_var(FULL_INCLUDE_DIRS_SET) +# print_var(FULL_LIBRARY_DIRS_SET) endif() # @@ -315,12 +315,12 @@ function(tribits_write_flexible_package_client_export_files) # set(${PACKAGE_NAME}_TPL_LIBRARIES "") - set(${PACKAGE_NAME}_TPL_INCLUDE_DIRS "") - set(${PACKAGE_NAME}_TPL_LIBRARY_DIRS "") +# set(${PACKAGE_NAME}_TPL_INCLUDE_DIRS "") +# set(${PACKAGE_NAME}_TPL_LIBRARY_DIRS "") foreach(TPL ${ORDERED_FULL_TPL_SET}) - list(APPEND ${PACKAGE_NAME}_TPL_LIBRARIES ${TPL_${TPL}_LIBRARIES}) - list(APPEND ${PACKAGE_NAME}_TPL_INCLUDE_DIRS ${TPL_${TPL}_INCLUDE_DIRS}) - list(APPEND ${PACKAGE_NAME}_TPL_LIBRARY_DIRS ${TPL_${TPL}_LIBRARY_DIRS}) + list(APPEND ${PACKAGE_NAME}_TPL_LIBRARIES ${TPL}::all_libs) + #list(APPEND ${PACKAGE_NAME}_TPL_INCLUDE_DIRS ${TPL_${TPL}_INCLUDE_DIRS}) + #list(APPEND ${PACKAGE_NAME}_TPL_LIBRARY_DIRS ${TPL_${TPL}_LIBRARY_DIRS}) endforeach() # Generate a note discouraging editing of the Config.cmake file @@ -512,10 +512,10 @@ function(tribits_generate_package_config_file_for_install_tree packageName) foreach(PATH ${PATH_LIST}) set(RELATIVE_PATH "${RELATIVE_PATH}/..") endforeach() - set(FULL_LIBRARY_DIRS_SET - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") - set(FULL_INCLUDE_DIRS_SET - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") +# set(FULL_LIBRARY_DIRS_SET +# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") +# set(FULL_INCLUDE_DIRS_SET +# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") # Custom code in configuration file. set(PACKAGE_CONFIG_CODE "") @@ -778,14 +778,14 @@ function(tribits_write_project_client_export_files) # of all their libraries/includes in the proper order for linking set(FULL_PACKAGE_SET "") set(FULL_LIBRARY_SET "") - set(FULL_INCLUDE_DIRS_SET "") - set(FULL_LIBRARY_DIRS_SET "") +# set(FULL_INCLUDE_DIRS_SET "") +# set(FULL_LIBRARY_DIRS_SET "") foreach(TRIBITS_PACKAGE ${PACKAGE_LIST}) if(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}) list(APPEND FULL_PACKAGE_SET ${TRIBITS_PACKAGE}) list(APPEND FULL_LIBRARY_SET ${${TRIBITS_PACKAGE}_LIBRARIES}) - list(APPEND FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) - list(APPEND FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) +# list(APPEND FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) +# list(APPEND FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) endif() endforeach() @@ -802,14 +802,14 @@ function(tribits_write_project_client_export_files) # of all their libraries/includes in the proper order for linking set(FULL_TPL_SET "") set(FULL_TPL_LIBRARY_SET "") - set(FULL_TPL_INCLUDE_DIRS_SET "") - set(FULL_TPL_LIBRARY_DIRS_SET "") +# set(FULL_TPL_INCLUDE_DIRS_SET "") +# set(FULL_TPL_LIBRARY_DIRS_SET "") foreach(TPL ${TPL_LIST}) if(TPL_ENABLE_${TPL}) list(APPEND FULL_TPL_SET ${TPL}) list(APPEND FULL_TPL_LIBRARY_SET ${TPL_${TPL}_LIBRARIES}) - list(APPEND FULL_TPL_INCLUDE_DIRS_SET ${TPL_${TPL}_INCLUDE_DIRS}) - list(APPEND FULL_TPL_LIBRARY_DIRS_SET ${TPL_${TPL}_LIBRARY_DIRS}) +# list(APPEND FULL_TPL_INCLUDE_DIRS_SET ${TPL_${TPL}_INCLUDE_DIRS}) +# list(APPEND FULL_TPL_LIBRARY_DIRS_SET ${TPL_${TPL}_LIBRARY_DIRS}) endif() endforeach() @@ -818,11 +818,11 @@ function(tribits_write_project_client_export_files) # any duplicates. This shouldn't affect which include or library is # found since the first instance of any path will be the one that is # kept. - list(REMOVE_DUPLICATES FULL_TPL_INCLUDE_DIRS_SET) - list(REMOVE_DUPLICATES FULL_TPL_LIBRARY_DIRS_SET) +# list(REMOVE_DUPLICATES FULL_TPL_INCLUDE_DIRS_SET) +# list(REMOVE_DUPLICATES FULL_TPL_LIBRARY_DIRS_SET) - set(${PROJECT_NAME}_CONFIG_TPL_INCLUDE_DIRS ${FULL_TPL_INCLUDE_DIRS_SET}) - set(${PROJECT_NAME}_CONFIG_TPL_LIBRARY_DIRS ${FULL_TPL_LIBRARY_DIRS_SET}) +# set(${PROJECT_NAME}_CONFIG_TPL_INCLUDE_DIRS ${FULL_TPL_INCLUDE_DIRS_SET}) +# set(${PROJECT_NAME}_CONFIG_TPL_LIBRARY_DIRS ${FULL_TPL_LIBRARY_DIRS_SET}) set(${PROJECT_NAME}_CONFIG_TPL_LIBRARIES ${FULL_TPL_LIBRARY_SET}) # @@ -835,8 +835,8 @@ function(tribits_write_project_client_export_files) # Config file for setting variables and finding include/library paths from # the build directory - set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS ${FULL_INCLUDE_DIRS_SET}) - set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS ${FULL_LIBRARY_DIRS_SET}) +# set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS ${FULL_INCLUDE_DIRS_SET}) +# set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS ${FULL_LIBRARY_DIRS_SET}) # Write the specification of the rpath if necessary. This is only needed if # we're building shared libraries. @@ -920,10 +920,10 @@ include(\"${${TRIBITS_PACKAGE}_BINARY_DIR}/${TRIBITS_PACKAGE}Config.cmake\")") foreach(PATH ${PATH_LIST}) set(RELATIVE_PATH "${RELATIVE_PATH}/..") endforeach() - set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") - set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") +# set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS +# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") +# set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS +# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") # Write the specification of the rpath if necessary. This is only needed if # we're building shared libraries. diff --git a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt index c24397019..90e061312 100644 --- a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt @@ -144,7 +144,7 @@ add_dependencies(build_external_func pws_a) # E.3) Update the TriBITS variables append_set(${PACKAGE_NAME}_LIB_TARGETS external_func) global_set(${PACKAGE_NAME}_LIBRARIES external_func pws_a) -global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${EXTERNAL_FUNC_SOURCE_DIR}) +#global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${EXTERNAL_FUNC_SOURCE_DIR}) global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES ON) include_directories(${EXTERNAL_FUNC_SOURCE_DIR}) # NOTE: Above, you have to add the upstream dependent libraries to the current From 2e51918f76db754b1e46e160a56dc2f9cabc1330 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 5 May 2022 11:13:43 -0600 Subject: [PATCH 09/43] Factor out new module TribitsConfigureFile.cmake (#63, #299) This should be broken out. We will break out TribitsAddLibrary.cmake later, after stripping all of the old commented-out support code for INCLUDE_DIRS, LIBRARY_DIRS and manual library sorting and ordering. --- .../package_arch/TribitsConfigureFile.cmake | 180 ++++++++++++++++++ .../package_arch/TribitsLibraryMacros.cmake | 143 +------------- 2 files changed, 182 insertions(+), 141 deletions(-) create mode 100644 tribits/core/package_arch/TribitsConfigureFile.cmake diff --git a/tribits/core/package_arch/TribitsConfigureFile.cmake b/tribits/core/package_arch/TribitsConfigureFile.cmake new file mode 100644 index 000000000..55ac9123c --- /dev/null +++ b/tribits/core/package_arch/TribitsConfigureFile.cmake @@ -0,0 +1,180 @@ +# @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 + + + +# Macro that configures the package's main config.h file +# +function(tribits_add_config_define DEFINE) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Package ${PARENT_PACKAGE_NAME}: adding compiler" + " define to config file: ${DEFINE}") + endif() + global_set(${PARENT_PACKAGE_NAME}_CONFIG_DEFINES + "${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}\n#define ${DEFINE}") + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- ${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}") + endif() +endfunction() + + +# @FUNCTION: tribits_configure_file() +# +# Macro that configures the package's main configured header file (typically +# called ``${PACKAGE_NAME}_config.h`` but any name can be used). +# +# Usage:: +# +# tribits_configure_file() +# +# This function requires the file:: +# +# ${PACKAGE_SOURCE_DIR}/cmake/.in +# +# exists and it creates the file:: +# +# ${CMAKE_CURRENT_BINARY_DIR}/ +# +# by calling the built-in ``configure_file()`` command:: +# +# configure_file( +# ${PACKAGE_SOURCE_DIR}/cmake/.in +# ${CMAKE_CURRENT_BINARY_DIR}/ +# ) +# +# which does basic substitution of CMake variables (see documentation for +# built-in CMake `configure_file()`_ command for rules on how it performs +# substitutions). This command is typically used to configure the package's +# main `/cmake/_config.h.in`_ file. +# +# In addition to just calling ``configure_file()``, this function also aids in +# creating configured header files adding macros for deprecating code as +# described below. +# +# **Deprecated Code Macros** +# +# If ``${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS`` is ``TRUE`` (see +# `tribits_add_show_deprecated_warnings_option()`_), then the local CMake +# variable ``${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS`` is set which +# adds a define ``_DEPRECATED`` (where +# ```` is the package name in all upper-case letters) +# which adds a compiler-specific deprecated warning for an entity. To take +# advantage of this, just add the line:: +# +# @_DEPRECATED_DECLARATIONS@ +# +# to the ``.in`` file and it will be expanded at configure +# time. +# +# Then C/C++ code can use this macro to deprecate functions, variables, +# classes, etc., for example, using:: +# +# _DEPRECATED class SomeDepreatedClass { ... }. +# +# If the particular compiler does not support deprecated warnings, then this +# macro is defined to be empty. See `Regulated Backward Compatibility and +# Deprecated Code`_ for more details. +# +function(tribits_configure_file PACKAGE_NAME_CONFIG_FILE) + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("\nPACKAGE_CONFIGURE_FILE: ${PACKAGE_NAME_CONFIG_FILE}") + endif() + + # Set up the deprecated attribute if showing deprecated warnings + if (${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS) + multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS + "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" + "# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED __attribute__((__deprecated__))\n" + "# else\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" + "# endif\n" + "#endif\n" + "\n" + "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG\n" + "# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__ (#MSG) ))\n" + "# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__))\n" + "# else\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" + "# endif\n" + "#endif\n" + ) + else() + multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS + "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" + "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" + ) + endif() + + if (${PARENT_PACKAGE_NAME}_HIDE_DEPRECATED_CODE) + string(APPEND ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS + "\n#define ${PARENT_PACKAGE_NAME_UC}_HIDE_DEPRECATED_CODE") + endif() + + # Set up the macro to create the define for time monitor + set(TIME_MONITOR_DEFINE_NAME ${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR) + set(FUNC_TIME_MONITOR_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR) + set(FUNC_TIME_MONITOR_DIFF_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR_DIFF) + if (${PARENT_PACKAGE_NAME}_ENABLE_TEUCHOS_TIME_MONITOR) + multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS + "#ifndef ${FUNC_TIME_MONITOR_MACRO_NAME}\n" + "# define ${TIME_MONITOR_DEFINE_NAME}\n" + "# define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME) \\\n" + " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, ${PARENT_PACKAGE_NAME_UC})\n" + "# define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF) \\\n" + " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, DIFF)\n" + "#endif\n" + ) + else() + multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS + "#define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME)\n" + "#define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF)\n" + ) + endif() + + # Configure the file + configure_file( + ${PACKAGE_SOURCE_DIR}/cmake/${PACKAGE_NAME_CONFIG_FILE}.in + ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_CONFIG_FILE} + ) + +endfunction() diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index eee78720d..30b039b36 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -38,6 +38,7 @@ # @HEADER include(TribitsCreateClientTemplateHeaders) +include(TribitsConfigureFile) include(TribitsLibIsTestOnly) include(CMakeParseArguments) include(GlobalSet) @@ -51,153 +52,13 @@ include(TribitsGeneralMacros) include(TribitsReportInvalidTribitsUsage) include(SetAndIncDirs) + ### ### WARNING: See "NOTES TO DEVELOPERS" at the bottom of the file ### TribitsPackageMacros.cmake! ### -# Macro that configures the package's main config.h file -# -function(tribits_add_config_define DEFINE) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Package ${PARENT_PACKAGE_NAME}: adding compiler" - " define to config file: ${DEFINE}") - endif() - global_set(${PARENT_PACKAGE_NAME}_CONFIG_DEFINES - "${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}\n#define ${DEFINE}") - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- ${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}") - endif() -endfunction() - - -# @FUNCTION: tribits_configure_file() -# -# Macro that configures the package's main configured header file (typically -# called ``${PACKAGE_NAME}_config.h`` but any name can be used). -# -# Usage:: -# -# tribits_configure_file() -# -# This function requires the file:: -# -# ${PACKAGE_SOURCE_DIR}/cmake/.in -# -# exists and it creates the file:: -# -# ${CMAKE_CURRENT_BINARY_DIR}/ -# -# by calling the built-in ``configure_file()`` command:: -# -# configure_file( -# ${PACKAGE_SOURCE_DIR}/cmake/.in -# ${CMAKE_CURRENT_BINARY_DIR}/ -# ) -# -# which does basic substitution of CMake variables (see documentation for -# built-in CMake `configure_file()`_ command for rules on how it performs -# substitutions). This command is typically used to configure the package's -# main `/cmake/_config.h.in`_ file. -# -# In addition to just calling ``configure_file()``, this function also aids in -# creating configured header files adding macros for deprecating code as -# described below. -# -# **Deprecated Code Macros** -# -# If ``${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS`` is ``TRUE`` (see -# `tribits_add_show_deprecated_warnings_option()`_), then the local CMake -# variable ``${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS`` is set which -# adds a define ``_DEPRECATED`` (where -# ```` is the package name in all upper-case letters) -# which adds a compiler-specific deprecated warning for an entity. To take -# advantage of this, just add the line:: -# -# @_DEPRECATED_DECLARATIONS@ -# -# to the ``.in`` file and it will be expanded at configure -# time. -# -# Then C/C++ code can use this macro to deprecate functions, variables, -# classes, etc., for example, using:: -# -# _DEPRECATED class SomeDepreatedClass { ... }. -# -# If the particular compiler does not support deprecated warnings, then this -# macro is defined to be empty. See `Regulated Backward Compatibility and -# Deprecated Code`_ for more details. -# -function(tribits_configure_file PACKAGE_NAME_CONFIG_FILE) - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("\nPACKAGE_CONFIGURE_FILE: ${PACKAGE_NAME_CONFIG_FILE}") - endif() - - # Set up the deprecated attribute if showing deprecated warnings - if (${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS) - multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS - "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" - "# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED __attribute__((__deprecated__))\n" - "# else\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" - "# endif\n" - "#endif\n" - "\n" - "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG\n" - "# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__ (#MSG) ))\n" - "# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__))\n" - "# else\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" - "# endif\n" - "#endif\n" - ) - else() - multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS - "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" - "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" - ) - endif() - - if (${PARENT_PACKAGE_NAME}_HIDE_DEPRECATED_CODE) - string(APPEND ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS - "\n#define ${PARENT_PACKAGE_NAME_UC}_HIDE_DEPRECATED_CODE") - endif() - - # Set up the macro to create the define for time monitor - set(TIME_MONITOR_DEFINE_NAME ${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR) - set(FUNC_TIME_MONITOR_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR) - set(FUNC_TIME_MONITOR_DIFF_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR_DIFF) - if (${PARENT_PACKAGE_NAME}_ENABLE_TEUCHOS_TIME_MONITOR) - multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS - "#ifndef ${FUNC_TIME_MONITOR_MACRO_NAME}\n" - "# define ${TIME_MONITOR_DEFINE_NAME}\n" - "# define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME) \\\n" - " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, ${PARENT_PACKAGE_NAME_UC})\n" - "# define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF) \\\n" - " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, DIFF)\n" - "#endif\n" - ) - else() - multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS - "#define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME)\n" - "#define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF)\n" - ) - endif() - - # Configure the file - configure_file( - ${PACKAGE_SOURCE_DIR}/cmake/${PACKAGE_NAME_CONFIG_FILE}.in - ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_CONFIG_FILE} - ) - -endfunction() - - # @FUNCTION: tribits_add_library() # # Function used to add a CMake library and target using ``add_library()`` and From 31fbaea94ea662e8639b5f8361302f958d8cb4ce Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 5 May 2022 12:24:25 -0600 Subject: [PATCH 10/43] WIP: Remove old TriBITS manual manipulation of includes and libs (#299) There is still a lot of work to clean up all of the junk that is being done in TribitsWriteClientExportFiles.cmake. But this is a good start. NOTE: This does **not** handle the extra link flags/libraries given in _EXTRA_LINK_FLAGS that is collected into the library target 'last_lib'. That is an open problem that I am going to have to solve in some way :-( --- .../TribitsProjectConfigTemplate.cmake.in | 26 +--- .../package_arch/TribitsAddExecutable.cmake | 93 ----------- .../package_arch/TribitsGeneralMacros.cmake | 144 ------------------ .../package_arch/TribitsGlobalMacros.cmake | 6 - .../package_arch/TribitsLibraryMacros.cmake | 143 +---------------- .../package_arch/TribitsPackageMacros.cmake | 41 ----- .../TribitsWriteClientExportFiles.cmake | 63 -------- .../packages/wrap_external/CMakeLists.txt | 1 - 8 files changed, 5 insertions(+), 512 deletions(-) diff --git a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in index b15c327ca..8aa7f6f46 100644 --- a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in @@ -113,11 +113,7 @@ foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST}) # Include the package file. include(${PDOLLAR}{INCLUDE_FILE}) # Add variables to lists. - #list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_INCLUDE_DIRS}) - #list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARIES}) - #list(APPEND ${PROJECT_NAME}_TPL_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_INCLUDE_DIRS}) - #list(APPEND ${PROJECT_NAME}_TPL_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_TPL_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARIES}) else() set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND FALSE) @@ -129,23 +125,10 @@ foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST}) endif() endforeach() -# Resolve absolute paths and remove duplicate paths -# for LIBRARY_DIRS and INCLUDE_DIRS -# This reduces stress on regular expressions later -#set(short_dirs) -#foreach(dir ${PDOLLAR}{${PROJECT_NAME}_INCLUDE_DIRS}) -# get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) -# list(APPEND short_dirs ${PDOLLAR}{dir_abs}) -#endforeach() -#list(REMOVE_DUPLICATES short_dirs) +# Deprecated (see #299)! set(${PROJECT_NAME}_INCLUDE_DIRS "") -#set(short_dirs) -#foreach(dir ${PDOLLAR}{${PROJECT_NAME}_LIBRARY_DIRS}) -# get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) -# list(APPEND short_dirs ${PDOLLAR}{dir_abs}) -#endforeach() -#list(REMOVE_DUPLICATES short_dirs) +# Deprecated (see #299)! set(${PROJECT_NAME}_LIBRARY_DIRS "") # Remove duplicates in ${PROJECT_NAME}_LIBRARIES @@ -153,11 +136,6 @@ list(REVERSE ${PROJECT_NAME}_LIBRARIES) list(REMOVE_DUPLICATES ${PROJECT_NAME}_LIBRARIES) list(REVERSE ${PROJECT_NAME}_LIBRARIES) -## Remove duplicates in ${PROJECT_NAME}_TPL_INCLUDE_DIRS -#if (${PROJECT_NAME}_TPL_INCLUDE_DIRS) -# list(REMOVE_DUPLICATES ${PROJECT_NAME}_TPL_INCLUDE_DIRS) -#endif() - # Remove duplicates in ${PROJECT_NAME}_TPL_LIBRARIES list(REVERSE ${PROJECT_NAME}_TPL_LIBRARIES) list(REMOVE_DUPLICATES ${PROJECT_NAME}_TPL_LIBRARIES) diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index 2319d6fd1..f51c374d8 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -426,13 +426,6 @@ function(tribits_add_executable EXE_NAME) set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") - if (NOT TRIBITS_ADD_EXECUTABLE_UNIT_TESTING) - #tribits_include_directories(REQUIRED_DURING_INSTALLATION_TESTING - # ${${PACKAGE_NAME}_INCLUDE_DIRS}) -# set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS -# ${${PACKAGE_NAME}_LIBRARY_DIRS}) - endif() - set (EXE_SOURCES) set(EXE_BINARY_NAME ${EXE_NAME}) @@ -552,17 +545,6 @@ function(tribits_add_executable EXE_NAME) endif() endforeach() - foreach(TESTONLYLIB_IN ${PARSE_TESTONLYLIBS}) - set(TESTONLYLIB "${LIBRARY_NAME_PREFIX}${TESTONLYLIB_IN}") - tribits_lib_is_testonly(${TESTONLYLIB} libIsTestOnlyLib) - if (libIsTestOnlyLib) - #if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - # message(STATUS "Adding include directories ${TESTONLYLIB}_INCLUDE_DIRS ...") - #endif() - #include_directories(${${TESTONLYLIB}_INCLUDE_DIRS}) - endif() - endforeach() - if (PARSE_DEFINES) message(WARNING "WARNING: Passing extra defines through 'DEFINES' ${PARSE_DEFINES}" " is deprecated. Instead, pass them through 'TARGET_DEFINES'. The 'DEFINES'" @@ -597,61 +579,6 @@ function(tribits_add_executable EXE_NAME) tribits_set_linker_language_from_arg( ${EXE_BINARY_NAME} "${PARSE_LINKER_LANGUAGE}" ) - set(LINK_LIBS) - - # First, add in the passed in TESTONLY dependent libraries - if (PARSE_TESTONLYLIBS) - foreach(LIB ${PARSE_TESTONLYLIBS}) - list(APPEND LINK_LIBS "${LIBRARY_NAME_PREFIX}${LIB}") - endforeach() - endif() - - # Second, add the package's own regular libraries - if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - list(APPEND LINK_LIBS ${${PACKAGE_NAME}_LIBRARIES}) - else() - list(APPEND LINK_LIBS ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) - endif() - - # Third, add the IMPORTEDLIBS - if (PARSE_IMPORTEDLIBS) - list(APPEND LINK_LIBS ${PARSE_IMPORTEDLIBS}) - endif() - - # Call include_directories() and link_directories(...) for upstream - # dependent Packages and TPLs and accumulate the list of libraries that will - # need to be linked to. - -# if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING -# AND NOT ${PACKAGE_NAME}_INCLUDE_DIRS -# ) -# # No libraries have been added for this package so -# # add the upstream package and TPL includes and libraries -# #tribits_sort_and_append_package_include_and_link_dirs_and_libs( -# # ${PACKAGE_NAME} LIB LINK_LIBS) -# #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( -# # ${PACKAGE_NAME} LIB LINK_LIBS) -# endif() - - #tribits_sort_and_append_package_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} TEST LINK_LIBS) - - if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} TEST LINK_LIBS) - else() - list(APPEND LINK_LIBS ${${PACKAGE_NAME}_INSTALLATION_TPL_LIBRARIES}) - endif() - - # Last, add last_lib to get extra link options on the link line - if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) - list(APPEND LINK_LIBS last_lib) - endif() - - if (${PROJECT_NAME}_DUMP_LINK_LIBS) - message("-- ${EXE_NAME}:LINK_LIBS='${LINK_LIBS}'") - endif() - # # Link ${EXE_BINARY_NAME} to direct upstream libraries # @@ -672,8 +599,6 @@ function(tribits_add_executable EXE_NAME) "${LIBRARY_NAME_PREFIX}${testOnlyLib}") endforeach() - #target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${LINK_LIBS}) - assert_defined(${PROJECT_NAME}_LINK_SEARCH_START_STATIC) if (${PROJECT_NAME}_LINK_SEARCH_START_STATIC) #message("${EXE_BINARY_NAME}: Adding property LINK_SEARCH_START_STATIC") @@ -697,21 +622,3 @@ function(tribits_add_executable EXE_NAME) ) endif() endfunction() - - -# -# Setup include directories and library dependencies -# - -#if (${PROJECT_NAME}_VERBOSE_CONFIGURE) -# message("TribitsAddExecutable.cmake") -# print_var(${PACKAGE_NAME}_INCLUDE_DIRS) -# print_var(${PACKAGE_NAME}_LIBRARY_DIRS) -#endif() -# -#if (NOT TRIBITS_ADD_EXECUTABLE_UNIT_TESTING) -# include_directories(REQUIRED_DURING_INSTALLATION_TESTING -# ${${PACKAGE_NAME}_INCLUDE_DIRS}) -# set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS -# ${${PACKAGE_NAME}_LIBRARY_DIRS}) -#endif() diff --git a/tribits/core/package_arch/TribitsGeneralMacros.cmake b/tribits/core/package_arch/TribitsGeneralMacros.cmake index 534a358b9..df170daee 100644 --- a/tribits/core/package_arch/TribitsGeneralMacros.cmake +++ b/tribits/core/package_arch/TribitsGeneralMacros.cmake @@ -372,150 +372,6 @@ function( tribits_gather_enabled_items PACKAGE_NAME LISTTYPE_PREFIX endfunction() -# Function that appends the Package/TPL include and library paths for given -# list of enabled Packages/TPLs -# -# As a side effect of calling this function, include_directories(...) to set -# all of the include directories for a given set of enabled Packages/TPLs. -# -# NOTE: The Packages/TPLs should be sorted in descending dependency order -# before calling this function. -# -# NOTE: Because this function may be called in cases where a package's -# required subpackages are not actually enabled (e.g. SEACAS subpackages) -# -#function( tribits_append_include_and_link_dirs TPL_OR_PACKAGE PREFIX -# LIST EXTRA_DEP_LIBS_INOUT -# ) -# if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) -# message("\nTRIBITS_APPEND_INCLUDE_AND_LINK_DIRS: '${TPL_OR_PACKAGE}'" -# " '${PREFIX}' '${LIST}' '${EXTRA_DEP_LIBS_INOUT}'") -# endif() -# set(EXTRA_DEP_LIBS_INOUT_TMP ${${EXTRA_DEP_LIBS_INOUT}}) -# cmake_policy(SET CMP0054 NEW) -# if ( -# "${TPL_OR_PACKAGE}" STREQUAL "TPL" -# AND -# ( -# ${PROJECT_NAME}_TPL_SYSTEM_INCLUDE_DIRS -# AND NOT -# (${PARENT_PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS -# OR ${PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS) -# ) -# ) -# set(SYSTEM_ARG "SYSTEM") -# else() -# set(SYSTEM_ARG) -# endif() -# foreach(ITEM ${LIST}) -# if (${PREFIX}${ITEM}_LIBRARIES) -# append_set(EXTRA_DEP_LIBS_ARG_TMP ${${PREFIX}${ITEM}_LIBRARIES}) -# endif() -# if (${PREFIX}${ITEM}_INCLUDE_DIRS) -# if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) -# message("-- " "include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS})") -# endif() -# include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS}) -# endif() -# if (${PREFIX}${ITEM}_LIBRARY_DIRS) -# if (PREFIX) -# # TODO: Is there a better way to know if we need this? -# # We want LINK_DIRECTORIES for TPLs but not packages. -# link_directories(${${PREFIX}${ITEM}_LIBRARY_DIRS}) -# endif() -# set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS -# ${${PREFIX}${ITEM}_LIBRARY_DIRS}) -# endif() -# if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) -# print_var(${PREFIX}${ITEM}_LIBRARIES) -# print_var(${PREFIX}${ITEM}_INCLUDE_DIRS) -# print_var(${PREFIX}${ITEM}_LIBRARY_DIRS) -# endif() -# endforeach() -# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) -#endfunction() - - -# Function that sorts and appends all the items in a dependency list for -# packages or TPLs. -# -#function( tribits_sort_and_append_include_and_link_dirs_and_libs -# TPL_OR_PACKAGE MASTER_SORT_LIST LIST PREFIX -# EXTRA_DEP_LIBS_INOUT -# ) -# -# if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) -# message("TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS:") -# print_var(MASTER_SORT_LIST) -# print_var(LIST) -# print_var(PREFIX) -# print_var(EXTRA_DEP_LIBS_INOUT) -# endif() -# -# set(LOCAL_LIST ${LIST}) -# if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) -# print_var(LOCAL_LIST) -# endif() -# -# if (LOCAL_LIST) -# -# tribits_sort_list_according_to_master_list("${MASTER_SORT_LIST}" LOCAL_LIST) -# if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) -# print_var(LOCAL_LIST) -# endif() -# -# set(EXTRA_DEP_LIBS_ARG_TMP ${${EXTRA_DEP_LIBS_INOUT}}) -# tribits_append_include_and_link_dirs("${TPL_OR_PACKAGE}" "${PREFIX}" -# "${LOCAL_LIST}" EXTRA_DEP_LIBS_ARG_TMP) -# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) -# -# endif() -# -#endfunction() - - -# Fully process the include and link directories and list of libraries for a -# package's list of dependent packages for use in creating a library or an -# executable -# -#function( tribits_sort_and_append_package_include_and_link_dirs_and_libs -# PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT -# ) -# -# tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} -# PACKAGES ALL_DEP_PACKAGES) -# -# set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) -# tribits_sort_and_append_include_and_link_dirs_and_libs( -# "PACKAGE" -# "${${PROJECT_NAME}_REVERSE_ENABLED_SE_PACKAGES}" -# "${ALL_DEP_PACKAGES}" "" EXTRA_DEP_LIBS_TMP) -# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) -# -#endfunction() - - -# Fully process the include and link directories and list of libraries for a -# package's list of dependent TPLs for use in creating a library or an -# executable -# -#function( tribits_sort_and_append_tpl_include_and_link_dirs_and_libs -# PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT -# ) -# -# tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} -# TPLS ALL_TPLS) -# -# set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) -# tribits_sort_and_append_include_and_link_dirs_and_libs( -# "TPL" -# "${${PROJECT_NAME}_REVERSE_ENABLED_TPLS}" -# "${ALL_TPLS}" TPL_ EXTRA_DEP_LIBS_TMP) -# set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) -# -#endfunction() - - # Print trace of file processing # function(tribits_trace_file_processing TYPE_IN PROCESSING_TYPE_IN FILE_PATH) diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index cd72c618f..2ae4211b6 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -2087,8 +2087,6 @@ macro(tribits_configure_enabled_packages) # A) Global variable initialization # - #global_null_set(${PROJECT_NAME}_INCLUDE_DIRS "") - #global_null_set(${PROJECT_NAME}_LIBRARY_DIRS "") global_null_set(${PROJECT_NAME}_LIBRARIES "") global_null_set(${PROJECT_NAME}_ETI_PACKAGES "") @@ -2192,8 +2190,6 @@ macro(tribits_configure_enabled_packages) endif() list(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}_libs) - #list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) - #list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_LIBRARIES ${${TRIBITS_PACKAGE}_LIBRARIES}) tribits_package_config_code_stop_timer(PROCESS_THIS_PACKAGE_TIME_START_SECONDS @@ -2272,8 +2268,6 @@ macro(tribits_configure_enabled_packages) if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY) - #remove_global_duplicates(${PROJECT_NAME}_INCLUDE_DIRS) - #remove_global_duplicates(${PROJECT_NAME}_LIBRARY_DIRS) remove_global_duplicates(${PROJECT_NAME}_LIBRARIES) # Add global 'libs' target diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index 30b039b36..ddeaec788 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -388,8 +388,6 @@ function(tribits_add_library LIBRARY_NAME_IN) endif() if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - #print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - #print_var(${PACKAGE_NAME}_LIBRARY_DIRS) print_var(${PACKAGE_NAME}_LIBRARIES) endif() @@ -427,30 +425,6 @@ function(tribits_add_library LIBRARY_NAME_IN) if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING OR PARSE_TESTONLY) - # Add the link directory for this library. - - #set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - # ${CMAKE_CURRENT_BINARY_DIR}) - - # NOTE: Above, this link path not really used here for anything. - # Instead it is just added to the other set link library directories - # that are already set. These link directories are then extracted - # and stored into stored in ${PACKAGE_NAME}_LIBRARY_DIRS. - - # Add whatever include directories have been defined so far - - #include_directories(AFTER ${${PACKAGE_NAME}_INCLUDE_DIRS}) - # ToDo: #299: Remove the above once final cleanup is performed for #299. - - # Add whatever link directories have been added so far - - #set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - # ${${PACKAGE_NAME}_LIBRARY_DIRS}) - - # Local variable to hold all of the libraries that will be directly linked - # to this library. - set(LINK_LIBS) - # Add dependent libraries passed directly in if (PARSE_DEPLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) @@ -461,16 +435,7 @@ function(tribits_add_library LIBRARY_NAME_IN) endif() # - # Add the DEPLIBS to the LINK_LIBS, assert correct usage of DEPLIBS, and - # see if we need to link in the upstream SE package and TPL libs. - # - # We only want to link to the upstream dependent SE package and TPL - # libraries if needed. We only need to link to these upstream dependent - # libraries when this is the first library being created for this SE - # package or if this library does not depend on other libraries created - # for this package. Otherwise, we don't need to add the include - # directories or link libraries because a dependent lib specified in - # PARSE_DEPLIBS already has everything that we need. + # Loop over and assert DEPLIBS # # We also need to make special considerations for test libraries since # things need to be handled a little bit differently (but not much). In the @@ -482,8 +447,6 @@ function(tribits_add_library LIBRARY_NAME_IN) # give enough time for people to clean up their codes. # - set(ADD_DEP_PACKAGE_AND_TPL_LIBS TRUE) - set(PREFIXED_DEPLIBS) foreach(LIB ${PARSE_DEPLIBS}) @@ -508,7 +471,6 @@ function(tribits_add_library LIBRARY_NAME_IN) # DEPLIBS. There is no need to link this new lib to the SE package's # upstream dependent SE package and TPL libraries because thse are # already linked into the lib ${LIB}. - set(ADD_DEP_PACKAGE_AND_TPL_LIBS FALSE) elseif (PARSE_TESTONLY AND LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) # The library being created here is TESTONLY library and is # dependent on a regular (non-TESTONLY) lib. This is valid usage of @@ -520,11 +482,6 @@ function(tribits_add_library LIBRARY_NAME_IN) # this case we just hope that this SE package correctly specified a # TEST dependency on the upstream SE package that owns this upstream # TESTONLY library. - #if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - # message("-- " - # "Adding include directories for TESTONLY ${PREFIXED_LIB}_INCLUDE_DIRS ...") - #endif() - #include_directories(${${PREFIXED_LIB}_INCLUDE_DIRS}) elseif (NOT PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE message(WARNING "WARNING: '${LIB}' in DEPLIBS is a TESTONLY lib" " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." @@ -564,8 +521,6 @@ function(tribits_add_library LIBRARY_NAME_IN) endforeach() - append_set(LINK_LIBS ${PREFIXED_DEPLIBS}) - # # Check IMPORTEDLIBS # @@ -596,70 +551,8 @@ function(tribits_add_library LIBRARY_NAME_IN) " in this SE package's dependencies file: " " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") endif() - # ToDo: Assert that this is not a test-only lib - list(APPEND LINK_LIBS ${IMPORTEDLIB}) endforeach() - # - # Link in the upstream TEST SE package and TPL libs - # - # We link these before those in the LIB SE package and TPL libs because - # the TEST dependencies tend to be higher in the dependency tree. It - # should not really matter but it looks better on the link line. - # - - if (PARSE_TESTONLY) - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Pulling in header and libraries dependencies" - " for TEST dependencies ...") - endif() - - #tribits_sort_and_append_package_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} TEST LINK_LIBS) - # - #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} TEST LINK_LIBS) - - endif() - - # - # Add the dependent LIB SE package and TPL libs - # - - if (ADD_DEP_PACKAGE_AND_TPL_LIBS) - - # If there are no dependent libs passed in, then this library can not - # possibly depend on the package's other libraries so we must link to - # the dependent libraries in dependent libraries and TPLs. - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Pulling in header and libraries dependencies" - " for LIB dependencies ...") - endif() - - # - # Call include_directories() and link_directories(...) for all upstream - # dependent Packages and TPLs and accumulate the libraries to link against. - # - # NOTE: Adding these directories serves two purposes. First, so that the includes - # get added the the sources that get built for this library. Second, so - # that list full list of include directories can be extracted as a - # property and set on ${PACKAGE_NAME}_INCLUDE_DIRS - # - - #tribits_sort_and_append_package_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} LIB LINK_LIBS) - # - #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} LIB LINK_LIBS) - - endif() - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(LINK_LIBS) - endif() - # Add the library and all the dependencies if (PARSE_DEFINES) @@ -724,10 +617,6 @@ function(tribits_add_library LIBRARY_NAME_IN) prepend_global_set(${PARENT_PACKAGE_NAME}_LIB_TARGETS ${LIBRARY_NAME}) prepend_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${LIBRARY_NAME}) - if (${PROJECT_NAME}_DUMP_LINK_LIBS) - message("-- ${LIBRARY_NAME_IN}:LINK_LIBS='${LINK_LIBS}'") - endif() - # # Link ${LIBRARY_NAME} to direct upstream libraries # @@ -757,8 +646,6 @@ function(tribits_add_library LIBRARY_NAME_IN) # ToDo: #63: Above, allow for other link visibilities other than 'PUBLIC'! - #target_link_libraries(${LIBRARY_NAME} PUBLIC ${LINK_LIBS}) - if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) target_compile_features(${LIBRARY_NAME} PUBLIC "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") ENDIF () @@ -831,12 +718,8 @@ function(tribits_add_library LIBRARY_NAME_IN) if (APPEND_LIB_AND_HEADERS_TO_PACKAGE) - #prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - #prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${PACKAGE_NAME}::${LIBRARY_NAME}) - #remove_global_duplicates(${PACKAGE_NAME}_INCLUDE_DIRS) - #remove_global_duplicates(${PACKAGE_NAME}_LIBRARY_DIRS) remove_global_duplicates(${PACKAGE_NAME}_LIBRARIES) if (INSTALL_LIB) @@ -850,13 +733,6 @@ function(tribits_add_library LIBRARY_NAME_IN) " directories and libraries! ...") endif() - list(REMOVE_DUPLICATES INCLUDE_DIRS_CURRENT) - #global_set(${LIBRARY_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - - #if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - # print_var(${LIBRARY_NAME}_INCLUDE_DIRS) - #endif() - endif() # Set INTERFACE_INCLUDE_DIRECTOIRES property for added library and must @@ -891,28 +767,15 @@ function(tribits_add_library LIBRARY_NAME_IN) " Please disable package ${PACKAGE_NAME} or install it.") endif() - #include_directories(REQUIRED_DURING_INSTALLATION_TESTING BEFORE - # ${${PACKAGE_NAME}_INSTALLATION_INCLUDE_DIRS} - # ${${TRIBITS_PACKAGE}_INSTALLATION_TPL_INCLUDE_DIRS}) - #set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - # ${${PACKAGE_NAME}_INSTALLATION_LIBRARY_DIRS}) - - #get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) + global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) - #global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - #global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) - global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) - - endif() #installation testing mode + endif() # # Print the updates to the linkage variables # if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - #print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - #print_var(${PACKAGE_NAME}_LIBRARY_DIRS) print_var(${PACKAGE_NAME}_LIBRARIES) endif() diff --git a/tribits/core/package_arch/TribitsPackageMacros.cmake b/tribits/core/package_arch/TribitsPackageMacros.cmake index f6a5ec02b..977f91d0d 100644 --- a/tribits/core/package_arch/TribitsPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsPackageMacros.cmake @@ -78,8 +78,6 @@ include(TribitsReportInvalidTribitsUsage) # they are used. # macro(tribits_define_linkage_vars PACKAGE_NAME_IN) - #global_null_set(${PACKAGE_NAME_IN}_INCLUDE_DIRS "") - #global_null_set(${PACKAGE_NAME_IN}_LIBRARY_DIRS "") global_null_set(${PACKAGE_NAME_IN}_LIBRARIES "") global_set(${PACKAGE_NAME_IN}_HAS_NATIVE_LIBRARIES_TO_INSTALL FALSE) endmacro() @@ -623,8 +621,6 @@ function(tribits_package_finalize_dependency_vars) # A package with subpackages should get all of its dependency vars from # its enabled subpackages. - #set(PARENT_PACKAGE_INCLUDE_DIRS "") - #set(PARENT_PACKAGE_LIBRARY_DIRS "") set(PARENT_PACKAGE_LIBRARIES "") set(SUBPACKAGE_IDX 0) @@ -634,10 +630,6 @@ function(tribits_package_finalize_dependency_vars) set(SUBPACKAGE_FULLNAME ${PARENT_PACKAGE_NAME}${TRIBITS_SUBPACKAGE}) if (${PROJECT_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}) - #prepend_set(PARENT_PACKAGE_INCLUDE_DIRS - # ${${SUBPACKAGE_FULLNAME}_INCLUDE_DIRS}) - #prepend_set(PARENT_PACKAGE_LIBRARY_DIRS - # ${${SUBPACKAGE_FULLNAME}_LIBRARY_DIRS}) prepend_set(PARENT_PACKAGE_LIBRARIES ${${SUBPACKAGE_FULLNAME}_LIBRARIES}) endif() @@ -646,41 +638,10 @@ function(tribits_package_finalize_dependency_vars) endforeach() - #if (PARENT_PACKAGE_INCLUDE_DIRS) - # list(REMOVE_DUPLICATES PARENT_PACKAGE_INCLUDE_DIRS) - #endif() - #if (PARENT_PACKAGE_LIBRARY_DIRS) - # list(REMOVE_DUPLICATES PARENT_PACKAGE_LIBRARY_DIRS) - #endif() - # NOTE: Above, in the rare case that none of the subpackages contain any - # libraries or any include directories, we need to not call - # list(REMOVE_DUPLICATES ...). - # NOTE: There can't be any duplicate libraries in PARENT_PACKAGE_LIBRARIES # so no need to remove them. - - #global_set(${PACKAGE_NAME}_INCLUDE_DIRS "${PARENT_PACKAGE_INCLUDE_DIRS}") - #global_set(${PACKAGE_NAME}_LIBRARY_DIRS "${PARENT_PACKAGE_LIBRARY_DIRS}") global_set(${PACKAGE_NAME}_LIBRARIES "${PARENT_PACKAGE_LIBRARIES}") -# elseif(NOT ${PACKAGE_NAME}_INCLUDE_DIRS) - - # No libraries have been defined for this package so we are going to set - # them based on this package's dependencies. - - #tribits_sort_and_append_package_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} LIB LINK_LIBS) - # - #tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - # ${PACKAGE_NAME} LIB LINK_LIBS) - - #get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - - #prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - #prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) - #prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${LINK_LIBS}) - endif() endfunction() @@ -692,8 +653,6 @@ macro(tribits_package_postprocess_common) if (${PROJECT_NAME}_VERBOSE_CONFIGURE) message("\nTRIBITS_PACKAGE_POSTPROCESS_COMMON: ${PACKAGE_NAME}") - #print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - #print_var(${PACKAGE_NAME}_LIBRARY_DIRS) print_var(${PACKAGE_NAME}_LIBRARIES) endif() diff --git a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake index 5e26cdad7..146ffb507 100644 --- a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake +++ b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake @@ -185,15 +185,6 @@ function(tribits_write_flexible_package_client_export_files) set(FULL_PACKAGE_SET "") set(FULL_LIBRARY_SET "") - set(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM TRUE) -# if (${PACKAGE_NAME}_INCLUDE_DIRS) -# set(FULL_INCLUDE_DIRS_SET ${${PACKAGE_NAME}_INCLUDE_DIRS}) -# set(FULL_LIBRARY_DIRS_SET ${${PACKAGE_NAME}_LIBRARY_DIRS}) -# set(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM FALSE) -# else() -# set(FULL_INCLUDE_DIRS_SET "") -# set(FULL_LIBRARY_DIRS_SET "") -# endif() if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) print_var(${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES) @@ -219,10 +210,6 @@ function(tribits_write_flexible_package_client_export_files) list(APPEND FULL_PACKAGE_SET ${TRIBITS_PACKAGE}) if (APPEND_THE_PACKAGE_LIBS) append_set(FULL_LIBRARY_SET ${${TRIBITS_PACKAGE}_LIBRARIES}) -# if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) -# append_set(FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) -# append_set(FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) -# endif() else() if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) message("-- " "Skipping adding the package libs!") @@ -237,10 +224,6 @@ function(tribits_write_flexible_package_client_export_files) if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) print_var(FULL_PACKAGE_SET) print_var(FULL_LIBRARY_SET) -# if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) -# print_var(FULL_INCLUDE_DIRS_SET) -# print_var(FULL_LIBRARY_DIRS_SET) -# endif() endif() endforeach() @@ -256,21 +239,10 @@ function(tribits_write_flexible_package_client_export_files) prepend_set(FULL_LIBRARY_SET ${${PACKAGE_NAME}_LIBRARIES}) endif() -# if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) -# if (FULL_INCLUDE_DIRS_SET) -# list(REMOVE_DUPLICATES FULL_INCLUDE_DIRS_SET) -# endif() -# if (FULL_LIBRARY_DIRS_SET) -# list(REMOVE_DUPLICATES FULL_LIBRARY_DIRS_SET) -# endif() -# endif() - if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) message("-- " "*** Final sets of packages, libs, include dirs, and lib dirs:") print_var(FULL_PACKAGE_SET) print_var(FULL_LIBRARY_SET) -# print_var(FULL_INCLUDE_DIRS_SET) -# print_var(FULL_LIBRARY_DIRS_SET) endif() # @@ -315,12 +287,8 @@ function(tribits_write_flexible_package_client_export_files) # set(${PACKAGE_NAME}_TPL_LIBRARIES "") -# set(${PACKAGE_NAME}_TPL_INCLUDE_DIRS "") -# set(${PACKAGE_NAME}_TPL_LIBRARY_DIRS "") foreach(TPL ${ORDERED_FULL_TPL_SET}) list(APPEND ${PACKAGE_NAME}_TPL_LIBRARIES ${TPL}::all_libs) - #list(APPEND ${PACKAGE_NAME}_TPL_INCLUDE_DIRS ${TPL_${TPL}_INCLUDE_DIRS}) - #list(APPEND ${PACKAGE_NAME}_TPL_LIBRARY_DIRS ${TPL_${TPL}_LIBRARY_DIRS}) endforeach() # Generate a note discouraging editing of the Config.cmake file @@ -512,10 +480,6 @@ function(tribits_generate_package_config_file_for_install_tree packageName) foreach(PATH ${PATH_LIST}) set(RELATIVE_PATH "${RELATIVE_PATH}/..") endforeach() -# set(FULL_LIBRARY_DIRS_SET -# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") -# set(FULL_INCLUDE_DIRS_SET -# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") # Custom code in configuration file. set(PACKAGE_CONFIG_CODE "") @@ -778,14 +742,10 @@ function(tribits_write_project_client_export_files) # of all their libraries/includes in the proper order for linking set(FULL_PACKAGE_SET "") set(FULL_LIBRARY_SET "") -# set(FULL_INCLUDE_DIRS_SET "") -# set(FULL_LIBRARY_DIRS_SET "") foreach(TRIBITS_PACKAGE ${PACKAGE_LIST}) if(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}) list(APPEND FULL_PACKAGE_SET ${TRIBITS_PACKAGE}) list(APPEND FULL_LIBRARY_SET ${${TRIBITS_PACKAGE}_LIBRARIES}) -# list(APPEND FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) -# list(APPEND FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) endif() endforeach() @@ -802,27 +762,13 @@ function(tribits_write_project_client_export_files) # of all their libraries/includes in the proper order for linking set(FULL_TPL_SET "") set(FULL_TPL_LIBRARY_SET "") -# set(FULL_TPL_INCLUDE_DIRS_SET "") -# set(FULL_TPL_LIBRARY_DIRS_SET "") foreach(TPL ${TPL_LIST}) if(TPL_ENABLE_${TPL}) list(APPEND FULL_TPL_SET ${TPL}) list(APPEND FULL_TPL_LIBRARY_SET ${TPL_${TPL}_LIBRARIES}) -# list(APPEND FULL_TPL_INCLUDE_DIRS_SET ${TPL_${TPL}_INCLUDE_DIRS}) -# list(APPEND FULL_TPL_LIBRARY_DIRS_SET ${TPL_${TPL}_LIBRARY_DIRS}) endif() endforeach() - # it is possible that tpls are in the same directory, to keep from - # having a very long include path or library path we will strip out - # any duplicates. This shouldn't affect which include or library is - # found since the first instance of any path will be the one that is - # kept. -# list(REMOVE_DUPLICATES FULL_TPL_INCLUDE_DIRS_SET) -# list(REMOVE_DUPLICATES FULL_TPL_LIBRARY_DIRS_SET) - -# set(${PROJECT_NAME}_CONFIG_TPL_INCLUDE_DIRS ${FULL_TPL_INCLUDE_DIRS_SET}) -# set(${PROJECT_NAME}_CONFIG_TPL_LIBRARY_DIRS ${FULL_TPL_LIBRARY_DIRS_SET}) set(${PROJECT_NAME}_CONFIG_TPL_LIBRARIES ${FULL_TPL_LIBRARY_SET}) # @@ -833,11 +779,6 @@ function(tribits_write_project_client_export_files) # Generate a note discouraging editing of the Config.cmake file set(DISCOURAGE_EDITING "Do not edit: This file was generated automatically by CMake.") - # Config file for setting variables and finding include/library paths from - # the build directory -# set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS ${FULL_INCLUDE_DIRS_SET}) -# set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS ${FULL_LIBRARY_DIRS_SET}) - # Write the specification of the rpath if necessary. This is only needed if # we're building shared libraries. if(BUILD_SHARED_LIBS) @@ -920,10 +861,6 @@ include(\"${${TRIBITS_PACKAGE}_BINARY_DIR}/${TRIBITS_PACKAGE}Config.cmake\")") foreach(PATH ${PATH_LIST}) set(RELATIVE_PATH "${RELATIVE_PATH}/..") endforeach() -# set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS -# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") -# set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS -# "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") # Write the specification of the rpath if necessary. This is only needed if # we're building shared libraries. diff --git a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt index 90e061312..3adfc2cdb 100644 --- a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt @@ -144,7 +144,6 @@ add_dependencies(build_external_func pws_a) # E.3) Update the TriBITS variables append_set(${PACKAGE_NAME}_LIB_TARGETS external_func) global_set(${PACKAGE_NAME}_LIBRARIES external_func pws_a) -#global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${EXTERNAL_FUNC_SOURCE_DIR}) global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES ON) include_directories(${EXTERNAL_FUNC_SOURCE_DIR}) # NOTE: Above, you have to add the upstream dependent libraries to the current From ed1597c7a71c29f9bb147c696fcbb31dcbcbdd8c Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 5 May 2022 12:29:07 -0600 Subject: [PATCH 11/43] Factor out TribitsAddLibrary.cmake for tribits_add_library() (#299) It just makes sense for the function tribits_add_library() and its support code to have its own file. --- .../core/package_arch/TribitsAddLibrary.cmake | 780 ++++++++++++++++++ .../package_arch/TribitsLibraryMacros.cmake | 742 +---------------- 2 files changed, 781 insertions(+), 741 deletions(-) create mode 100644 tribits/core/package_arch/TribitsAddLibrary.cmake diff --git a/tribits/core/package_arch/TribitsAddLibrary.cmake b/tribits/core/package_arch/TribitsAddLibrary.cmake new file mode 100644 index 000000000..422d05aa3 --- /dev/null +++ b/tribits/core/package_arch/TribitsAddLibrary.cmake @@ -0,0 +1,780 @@ +# @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 + +include(TribitsLibIsTestOnly) +include(CMakeParseArguments) +include(GlobalSet) +include(AppendSet) +include(AppendGlob) +include(AppendGlobalSet) +include(AppendStringVar) +include(PrependGlobalSet) +include(RemoveGlobalDuplicates) +include(TribitsGeneralMacros) +include(TribitsReportInvalidTribitsUsage) +include(SetAndIncDirs) + + +### +### WARNING: See "NOTES TO DEVELOPERS" at the bottom of the file +### TribitsPackageMacros.cmake! +### + + +# @FUNCTION: tribits_add_library() +# +# Function used to add a CMake library and target using ``add_library()`` and +# also the ALIAS target ``${PACKAGE_NAME}::`` (where ```` is +# the full CMake target name as returned from ``${}``). +# +# Usage:: +# +# tribits_add_library( +# +# [HEADERS

...] +# [HEADERS_INSTALL_SUBDIR ] +# [NOINSTALLHEADERS ...] +# [SOURCES ...] +# [DEPLIBS ...] +# [IMPORTEDLIBS ...] +# [STATIC|SHARED] +# [TESTONLY] +# [NO_INSTALL_LIB_OR_HEADERS] +# [CUDALIBRARY] +# [ADDED_LIB_TARGET_NAME_OUT ] +# ) +# +# *Sections:* +# +# * `Formal Arguments (tribits_add_library())`_ +# * `Include Directories (tribits_add_library())`_ +# * `Install Targets (tribits_add_library())`_ +# * `Additional Library and Source File Properties (tribits_add_library())`_ +# * `Miscellaneous Notes (tribits_add_library())`_ +# +# .. _Formal Arguments (tribits_add_library()): +# +# **Formal Arguments (tribits_add_library())** +# +# ```` +# +# Required base name of the library. The name of the actual library name +# will be prefixed by ``${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}`` to +# produce:: +# +# = ${${PROJECT_NAME}_LIBRARY_NAME_PREFIX} +# +# This is the name passed to ``add_library( ...)``. The +# name is *not* prefixed by the package name. CMake will of course add +# any standard prefix or post-fix to the library file name appropriate for +# the platform and if this is a static or shared library build (e.g. on +# Linux prefix = ``'lib'``, postfix = ``'.so'`` for shared lib and postfix +# = ``'.a'`` static lib) (see documentation for the built-in CMake command +# ``add_library()``. +# +# ``HEADERS

...`` +# +# List of public header files for using this library. By default, these +# header files are assumed to be in the current source directory. They +# can also contain the relative path or absolute path to the files if they +# are not in the current source directory. This list of headers is passed +# into ``add_library(...)`` as well (which is not strictly needed but is +# helpful for some build tools, like MS Visual Studio). By default, these +# headers will be installed (see `Install Targets +# (tribits_add_library())`_). +# +# ``HEADERS_INSTALL_SUBDIR `` +# +# Optional subdirectory that the headers will be installed under the +# standard installation directory. If ``!=""``, then the +# headers will be installed under +# ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. Otherwise, +# they will be installed under ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. +# `Install Targets (tribits_add_library())`_. +# +# ``NOINSTALLHEADERS ...`` +# +# List of private header files which are used by this library. These +# headers are not installed and do not needed to be passed in for any +# purpose other than to pass them into ``add_library()`` as some build +# tools like to have these listed (e.g. MS Visual Studio). +# +# ``SOURCES ...`` +# +# List of source files passed into ``add_library()`` that are compiled +# into header files and included in the library. The compiler used to +# compile the files is determined automatically based on the file +# extension (see CMake documentation for ``add_library()``). +# +# ``DEPLIBS ...`` +# +# List of dependent libraries that are built in the current SE package +# that this library is dependent on. These libraries are passed into +# ``target_link_libraries( ...)`` so that CMake knows about +# the dependency structure of the libraries within this SE package. +# **NOTE:** One must **not** list libraries in other upstream `TriBITS SE +# Packages`_ or libraries built externally from this TriBITS CMake project +# in ``DEPLIBS``. The TriBITS system automatically handles linking to +# libraries in upstream TriBITS SE packages. External libraries need to +# be listed in the ``IMPORTEDLIBS`` argument instead if they are not +# already specified automatically using a `TriBITS TPL`_. +# +# ``IMPORTEDLIBS ...`` +# +# List of dependent libraries built externally from this TriBITS CMake +# project. These libraries are passed into +# ``target_link_libraries( ...)`` so that CMake knows about +# the dependency. However, note that external libraries are often better +# handled as `TriBITS TPLs`_. A well constructed TriBITS package and +# library should never have to use this option! So far, the only case +# where ``IMPORTEDLIBS`` has been shown to be necessary is to pass in the +# standard C math library ``m``. In every other case, a TriBITS TPL +# should be used instead. +# +# ``STATIC`` or ``SHARED`` +# +# If ``STATIC`` is passed in, then a static library will be created +# independent of the value of ``BUILD_SHARED_LIBS``. If ``SHARED`` is +# passed in, then a shared library will be created independent of the +# value of ``BUILD_SHARED_LIBS``. If neither ``STATIC`` or ``SHARED`` are +# passed in, then a shared library will be created if +# ``BUILD_SHARED_LIBS`` evaluates to true, otherwise and a static library +# will be created. If both ``STATIC`` and ``SHARED`` are passed in (which +# is obviously a mistake), then a shared library will be created. +# WARNING: Once you mark a library with ``STATIC``, then all of the +# downstream libraries in the current SE package and all downstream SE +# packages must also be also be marked with ``STATIC``. That is because, +# generally, one can not link a link a static lib against a downstream +# shared lib since that is not portable (but can be done on some platforms +# if, for example, ``-fPIC`` is specified). So be careful to use +# ``STATIC`` in all downstream libraries! +# +# ``TESTONLY`` +# +# If passed in, then ```` will **not** be added to +# ``${PACKAGE_NAME}_LIBRARIES`` and an install target for the library will +# not be added. In this case, the current include directories will be set +# in the global variable ``_INCLUDE_DIR`` which will be +# used in `tribits_add_executable()`_ when a test-only library is linked +# in through its ``DEPLIBS`` argument. Also, the custom property +# ``TRIBITS_TESTONLY_LIB`` will be set to ``TRUE`` which will ensure that +# this library will not be added to the ``${PACKAGE_NAME}::all_libs`` +# target. +# +# ``NO_INSTALL_LIB_OR_HEADERS`` +# +# If specified, then no install targets will be added for the library +# ```` or the header files listed in ``HEADERS``. +# +# ``CUDALIBRARY`` +# +# If specified then ``cuda_add_library()`` is used instead of +# ``add_library()`` where ``cuda_add_library()`` is assumed to be defined +# by the standard ``FindCUDA.cmake`` module as processed using the +# standard TriBITS ``FindTPLCUDA.cmake`` file (see `Standard TriBITS +# TPLs`_). For this option to work, this SE package must have an enabled +# direct or indirect dependency on the TriBITS CUDA TPL or a +# configure-time error may occur about not knowing about +# ``cuda_all_library()``. +# +# ``ADDED_LIB_TARGET_NAME_OUT `` +# +# If specified, then on output the variable ```` will be +# set with the name of the library passed to ``add_library()``. Having +# this name allows the calling ``CMakeLists.txt`` file access and set +# additional target properties (see `Additional Library and Source File +# Properties (tribits_add_library())`_). +# +# .. _Include Directories (tribits_add_library()): +# +# **Include Directories (tribits_add_library())** +# +# Any base directories for the header files listed in the arguments +# ``HEADERS`` or ``NOINSTALLHEADERS`` should be passed into the standard CMake +# command ``include_directories()`` **before** calling this function. For +# example, a CMakeLists.txt file will look like:: +# +# ... +# +# tribits_configure_file(${PACKAGE_NAME}_config.h) +# configure_file(...) +# +# ... +# +# include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +# include_directories(${CMAKE_CURRENT_BINARY_DIR}) +# +# ... +# +# tribits_add_library( +# SOURCES +# .c +# /.cpp +# /.F90 +# ... +# HEADERS +# .h +# /.hpp +# ... +# NONINSTALLHEADERS .hpp .hpp ... +# ... +# ) +# +# The include of ``${CMAKE_CURRENT_BINARY_DIR}`` is needed for any generated +# header files (e.g. using raw ``configure_file()`` or +# `tribits_configure_file()`_) or any generated Fortran ``*.mod`` module files +# generated as a byproduct of compiling F90+ source files (that contain one or +# more Fortran module declarations). +# +# The function ``tribits_add_library()`` will grab the list of all of the +# include directories in scope from prior calls to ``include_directories()`` +# and will append these to the variable ``${PACKAGE_NAME}_INCLUDE_DIRS``. +# This list of include directories is exported to downstream SE packages so +# they appear on the compile lines of all downstream object file compiles. +# This is a critical part of the "glue" that allows TriBITS packages to link +# up automatically (just by clearing dependencies in +# `/cmake/Dependencies.cmake`_ files). +# +# .. _Install Targets (tribits_add_library()): +# +# **Install Targets (tribits_add_library())** +# +# By default, an install target for the library is created using +# ``install(TARGETS ...)`` to install into the directory +# ``${CMAKE_INSTALL_PREFIX}/lib/`` (actual install directory is given by +# ``${PROJECT}_INSTALL_LIB_DIR``, see `Setting the install prefix`_). +# However, this install target will not get created if +# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE`` and +# ``BUILD_SHARD_LIBS=OFF``. But when ``BUILD_SHARD_LIBS=ON``, the install +# target will get added. Also, this install target will *not* get added if +# ``TESTONLY`` or ``NO_INSTALL_LIB_OR_HEADERS`` are passed in. +# +# By default, an install target for the headers listed in ``HEADERS`` will get +# added using ``install(FILES

...)``, but only if ``TESTONLY`` and +# ``NO_INSTALL_LIB_OR_HEADERS`` are not passed in as well. Also, the install +# target for the headers will not get added if +# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE``. If this +# install target is added, then the headers get installed into the flat +# directory ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/`` (default is +# ``${CMAKE_INSTALL_PREFIX}/include/``, see `Setting the install prefix`_). +# If ``HEADERS_INSTALL_SUBDIR`` is set, then the headers will be installed +# under ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}//``. +# +# Note that an install target will *not* get created for the headers listed in +# ``NOINSTALLHEADERS``. +# +# .. _Additional Library and Source File Properties (tribits_add_library()): +# +# **Additional Library and Source File Properties (tribits_add_library())** +# +# Once ``add_library( ... ...)`` is called, one +# can set and change properties on the ```` library target +# using the built-in CMake command ``set_target_properties()`` as well as set +# and change properties on any of the source files listed in ``SOURCES`` using +# the built-in CMake command ``set_source_file_properties()`` just like in any +# CMake project. For example:: +# +# tribits_add_library( somelib ... +# ADDED_LIB_TARGET_NAME_OUT somelib_TARGET_NAME ) +# +# set_target_properties( ${somelib_TARGET_NAME} +# PROPERTIES LINKER_LANGUAGE CXX ) +# +# .. _Miscellaneous Notes (tribits_add_library()): +# +# **Miscellaneous Notes (tribits_add_library())** +# +# When the file ``Version.cmake`` exists and the CMake variables +# ``${PROJECT_NAME}_VERSION`` and ``${PROJECT_NAME}_MAJOR_VERSION`` are +# defined, then produced shared libraries will be given the standard SOVERSION +# symlinks (see `/Version.cmake`_). +# +# **WARNING:** Do **NOT** use the built-in CMake command ``add_definitions()`` +# to add defines ``-D`` to the compile command line that will +# affect any of the header files in the package! These CMake-added defines +# are only set locally in this directory and child directories. These defines +# will **NOT** be set when code in peer directories (e.g. a downstream TriBITS +# packages) compiles that may include these header files. To add defines that +# affect header files, please use a configured header file (see +# `tribits_configure_file()`_). +# +function(tribits_add_library LIBRARY_NAME_IN) + + # + # Confirm that package and subpackage macros/functions have been called in the correct order + # + + if (CURRENTLY_PROCESSING_SUBPACKAGE) + + # This is a subpackage being processed + + if(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_subpackage() before tribits_add_library()" + " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + endif() + + if(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_add_library() before " + " tribits_subpackage_postprocess() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + endif() + + else() + + # This is a package being processed + + if(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_package() or tribits_package_decl() before" + " tribits_add_library() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") + endif() + + if(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_add_library() before " + " tribits_package_postprocess() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") + endif() + + endif() + + set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") + set(LIBRARY_NAME ${LIBRARY_NAME_PREFIX}${LIBRARY_NAME_IN}) + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("\nTRIBITS_ADD_LIBRARY: ${LIBRARY_NAME}") + if(${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) + message("\n${PACKAGE_NAME}_LIBRARIES In installation testing mode," + " libraries will be found instead of created.") + endif() + endif() + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + print_var(${PACKAGE_NAME}_LIBRARIES) + endif() + + cmake_parse_arguments( + #prefix + PARSE + #Options + "STATIC;SHARED;TESTONLY;NO_INSTALL_LIB_OR_HEADERS;CUDALIBRARY" + #one_value_keywords + "" + #mulit_value_keywords + "HEADERS;HEADERS_INSTALL_SUBDIR;NOINSTALLHEADERS;SOURCES;DEPLIBS;IMPORTEDLIBS;DEFINES;ADDED_LIB_TARGET_NAME_OUT" + ${ARGN} + ) + + tribits_check_for_unparsed_arguments() + + # ToDo: Assert that HEADERS_INSTALL_SUBDIR has 0 or 1 entries! + # ToDo: Assert that ADDED_LIB_TARGET_NAME_OUT as 0 or 1 entries! + + if(PARSE_HEADERS) + list(REMOVE_DUPLICATES PARSE_HEADERS) + endif() + if(PARSE_SOURCES) + list(REMOVE_DUPLICATES PARSE_SOURCES) + endif() + + if(PARSE_ADDED_LIB_TARGET_NAME_OUT) + set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} PARENT_SCOPE) + endif() + + # ToDo: Deprecate and remove the usage of DEFINES! People should be putting + # defines into configured header files, not adding -D to the + # compile lines! + + if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING OR PARSE_TESTONLY) + + # Add dependent libraries passed directly in + + if (PARSE_DEPLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "DEPLIBS = ${PARSE_DEPLIBS}") + endif() + if (PARSE_IMPORTEDLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "IMPORTEDLIBS = ${PARSE_IMPORTEDLIBS}") + endif() + + # + # Loop over and assert DEPLIBS + # + # We also need to make special considerations for test libraries since + # things need to be handled a little bit differently (but not much). In the + # case of test libraries, we need to also pull the test-only dependencies. + # In this case, we will always assume that we will add in the test + # libraries. + # + # ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we + # give enough time for people to clean up their codes. + # + + set(PREFIXED_DEPLIBS) + + foreach(LIB ${PARSE_DEPLIBS}) + + set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${LIB}") + + # LIB_IN_SE_PKG? + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" FOUND_IDX) + if (FOUND_IDX GREATER -1) + set(LIB_IN_SE_PKG TRUE) + else() + set(LIB_IN_SE_PKG FALSE) + endif() + + # ${PREFIXED_LIB" is TESTONLY? + tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + + # Check for valid usage (sorted by most common to least common) + if (LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) #PARSE_TESTONLY=TRUE/FASLE + # The library being created here is a library dependent on a regular + # (non-TESTONLY) lib in this SE package. This is valid usage of + # DEPLIBS. There is no need to link this new lib to the SE package's + # upstream dependent SE package and TPL libraries because thse are + # already linked into the lib ${LIB}. + elseif (PARSE_TESTONLY AND LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) + # The library being created here is TESTONLY library and is + # dependent on a regular (non-TESTONLY) lib. This is valid usage of + # DEPLIBS. In the case of test-only libraries, we always link in + # the upstream libs. + elseif (PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE + # The library being created here is TESTONLY library and is dependent + # on another TESTONLY library. This is valid usage of DEPLIBS. In + # this case we just hope that this SE package correctly specified a + # TEST dependency on the upstream SE package that owns this upstream + # TESTONLY library. + elseif (NOT PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE + message(WARNING "WARNING: '${LIB}' in DEPLIBS is a TESTONLY lib" + " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." + " Such usage is deprecated (and this warning will soon become an error)!" + " If this is a regular library in this SE package or in an dependent upstream SE" + " package then TriBITS will link automatically to it. If you remove this and it" + " does not link, then you need to add a new SE package dependency to" + " this SE package's dependencies file" + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code + elseif (NOT LIB_IN_SE_PKG AND TARGET ${PREFIXED_LIB} ) # PARSE_TESTONLY=TRUE/FALSE + message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" + " a lib in this SE package but is a library defined in the current" + " cmake project! Such usage is deprecated (and" + " will result in a configure error soon). If this is a library in" + " a dependent upstream SE package, then simply remove it from this list." + " TriBITS automatically links in libraries in upstream SE packages." + " If you remove '${LIB}' from DEPLIBS and your code does" + " not link, then you need to add a new SE package dependency to" + " this SE package's dependencies file" + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + elseif (NOT LIB_IN_SE_PKG AND NOT TARGET ${PREFIXED_LIB} ) + message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" + " a lib defined in the current cmake project! Such usage is deprecated (and" + " will result in a configure error soon). If this is an external" + " lib you are trying to link in, it should likely be handled as a TriBITS" + " TPL. Otherwise, it should be passed in through IMPORTEDLIBS. However," + " the only case we have found where IMPORTEDLIBS had to be used instead of" + " through a proper TriBITS TPL is the C math library 'm'.") + else() + message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY}," + " LIB_IN_SE_PKG=${LIB_IN_SE_PKG}, libIsTestOnlyLib=${libIsTestOnlyLib}, has" + " not yet been handled!") + endif() + + list(APPEND PREFIXED_DEPLIBS "${LIBRARY_NAME_PREFIX}${LIB}") + + endforeach() + + # + # Check IMPORTEDLIBS + # + + foreach(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) + set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" + FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX) + tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + if (libIsTestOnlyLib) + message(WARNING "WARNING: '${IMPORTEDLIB}' in IMPORTEDLIBS is a TESTONLY lib" + " and it is illegal to pass in through IMPORTEDLIBS!" + " Such usage is deprecated (and this warning will soon become an error)!" + " Should '${IMPORTEDLIB}' instead be passed through DEPLIBS?") + # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code + elseif (FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX GREATER -1) + message(WARNING "WARNING: Lib '${IMPORTEDLIB}' in IMPORTEDLIBS is in" + " this SE package and is *not* an external lib!" + " TriBITS takes care of linking against libs the current" + " SE package automatically. Please remove it from IMPORTEDLIBS!") + elseif (TARGET ${PREFIXED_LIB}) + message(WARNING "WARNING: Lib '${IMPORTEDLIB}' being passed through" + " IMPORTEDLIBS is *not* an external library but instead is a library" + " defined in this CMake project!" + " TriBITS takes care of linking against libraries in dependent upstream" + " SE packages. If you want to link to a library in an upstream SE" + " package then add the SE package name to the appropriate category" + " in this SE package's dependencies file: " + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + endif() + endforeach() + + # Add the library and all the dependencies + + if (PARSE_DEFINES) + add_definitions(${PARSE_DEFINES}) + endif() + + if (PARSE_STATIC) + set(STATIC_KEYWORD "STATIC") + else() + set(STATIC_KEYWORD) + endif() + + if (PARSE_SHARED) + set(SHARED_KEYWORD "SHARED") + else() + set(SHARED_KEYWORD) + endif() + + if (NOT PARSE_CUDALIBRARY) + add_library( + ${LIBRARY_NAME} + ${STATIC_KEYWORD} + ${SHARED_KEYWORD} + ${PARSE_HEADERS} + ${PARSE_NOINSTALLHEADERS} + ${PARSE_SOURCES} + ) + else() + cuda_add_library( + ${LIBRARY_NAME} + ${PARSE_HEADERS} + ${PARSE_NOINSTALLHEADERS} + ${PARSE_SOURCES} + ) + endif() + + if(PARSE_ADDED_LIB_TARGET_NAME_OUT) + set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} ${LIBRARY_NAME} PARENT_SCOPE) + endif() + + if (PARSE_TESTONLY) + tribits_set_lib_is_testonly(${LIBRARY_NAME}) + endif() + + set_property( + TARGET ${LIBRARY_NAME} + APPEND PROPERTY + LABELS ${PACKAGE_NAME}Libs ${PARENT_PACKAGE_NAME}Libs + ) + + if (NOT "${${PROJECT_NAME}_VERSION}" STREQUAL "" AND + NOT "${${PROJECT_NAME}_MAJOR_VERSION}" STREQUAL "" + ) + set_target_properties( + ${LIBRARY_NAME} + PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} + SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION} + ) + endif() + + prepend_global_set(${PARENT_PACKAGE_NAME}_LIB_TARGETS ${LIBRARY_NAME}) + prepend_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${LIBRARY_NAME}) + + # + # Link ${LIBRARY_NAME} to direct upstream libraries + # + + # DEPLIBS + foreach(depLib ${PARSE_DEPLIBS}) + target_link_libraries(${LIBRARY_NAME} PUBLIC "${LIBRARY_NAME_PREFIX}${depLib}") + endforeach() + # ${PACKAGE_NAME}_LIBRARIES + target_link_libraries(${LIBRARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) + # ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES + foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + # ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES + foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + # IMPORTEDLIBS + foreach(importedLib ${PARSE_IMPORTEDLIBS}) + target_link_libraries(${LIBRARY_NAME} PUBLIC "${importedLib}") + endforeach() + + # ToDo: #63: Above, allow for other link visibilities other than 'PUBLIC'! + + if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) + target_compile_features(${LIBRARY_NAME} PUBLIC "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") + ENDIF () + + # Add to the install target + + set(INSTALL_LIB ON) + set(INSTALL_HEADERS ON) + set(APPEND_LIB_AND_HEADERS_TO_PACKAGE ON) + + if (PARSE_TESTONLY) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation hooks for this library" + " because 'TESTONLY' was passed in ...") + endif() + set(INSTALL_LIB OFF) + set(INSTALL_HEADERS OFF) + set(APPEND_LIB_AND_HEADERS_TO_PACKAGE OFF) + elseif (PARSE_NO_INSTALL_LIB_OR_HEADERS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation hooks for this library" + " because 'NO_INSTALL_LIB_OR_HEADERS' was passed in ...") + endif() + set(INSTALL_LIB OFF) + set(INSTALL_HEADERS OFF) + elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND NOT BUILD_SHARED_LIBS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation of headers and libraries" + " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=FALSE ...") + endif() + set(INSTALL_LIB OFF) + set(INSTALL_HEADERS OFF) + elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND BUILD_SHARED_LIBS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation of headers but installing libraries" + " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=TRUE ...") + endif() + set(INSTALL_HEADERS OFF) + endif() + + if (INSTALL_LIB OR INSTALL_HEADERS) + set_property(GLOBAL PROPERTY ${PROJECT_NAME}_HAS_INSTALL_TARGETS ON) + set_property(GLOBAL PROPERTY ${PACKAGE_NAME}_HAS_INSTALL_TARGETS ON) + endif() + + if (INSTALL_LIB) + install( + TARGETS ${LIBRARY_NAME} + EXPORT ${PACKAGE_NAME} + INCLUDES DESTINATION "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}" + RUNTIME DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_DIR}" + LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" + COMPONENT ${PACKAGE_NAME} + ) + endif() + + if (INSTALL_HEADERS) + tribits_install_headers( + HEADERS ${PARSE_HEADERS} + INSTALL_SUBDIR ${PARSE_HEADERS_INSTALL_SUBDIR} + COMPONENT ${PACKAGE_NAME} + ) + endif() + + # Append the new include dirs, library dirs, and libraries to this package's lists + + get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) + #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) + + if (APPEND_LIB_AND_HEADERS_TO_PACKAGE) + + prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${PACKAGE_NAME}::${LIBRARY_NAME}) + + remove_global_duplicates(${PACKAGE_NAME}_LIBRARIES) + + if (INSTALL_LIB) + global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES_TO_INSTALL TRUE) + endif() + + else() + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping augmentation of package's lists of include" + " directories and libraries! ...") + endif() + + endif() + + # Set INTERFACE_INCLUDE_DIRECTOIRES property for added library and must + # only do for the build interface (not the install interface). + set(buildInterfaceIncludeDirs) + foreach (includeDir IN LISTS INCLUDE_DIRS_CURRENT) + list(APPEND buildInterfaceIncludeDirs "$") + endforeach() + target_include_directories( ${LIBRARY_NAME} PUBLIC ${buildInterfaceIncludeDirs} ) + + # Add ALIAS library :: + add_library(${PACKAGE_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME}) + + # Optionally Set IMPORTED_NO_SYSTEM + if (${PROJECT_NAME}_IMPORTED_NO_SYSTEM) + set_target_properties(${LIBRARY_NAME} PROPERTIES IMPORTED_NO_SYSTEM TRUE) + endif() + + endif() #if not in installation testing mode + + # + # Adjust for installation testing + # + + if (${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) + + list(FIND ${PROJECT_NAME}_INSTALLATION_PACKAGE_LIST ${PACKAGE_NAME} + ${PACKAGE_NAME}_WAS_INSTALLED) + if(${${PACKAGE_NAME}_WAS_INSTALLED} EQUAL -1) + message(FATAL_ERROR + "The package ${PACKAGE_NAME} was not installed with ${PROJECT_NAME}!" + " Please disable package ${PACKAGE_NAME} or install it.") + endif() + + global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) + + endif() + + # + # Print the updates to the linkage variables + # + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + print_var(${PACKAGE_NAME}_LIBRARIES) + endif() + +endfunction() diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index ddeaec788..27fdfc952 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -39,744 +39,4 @@ include(TribitsCreateClientTemplateHeaders) include(TribitsConfigureFile) -include(TribitsLibIsTestOnly) -include(CMakeParseArguments) -include(GlobalSet) -include(AppendSet) -include(AppendGlob) -include(AppendGlobalSet) -include(AppendStringVar) -include(PrependGlobalSet) -include(RemoveGlobalDuplicates) -include(TribitsGeneralMacros) -include(TribitsReportInvalidTribitsUsage) -include(SetAndIncDirs) - - -### -### WARNING: See "NOTES TO DEVELOPERS" at the bottom of the file -### TribitsPackageMacros.cmake! -### - - -# @FUNCTION: tribits_add_library() -# -# Function used to add a CMake library and target using ``add_library()`` and -# also the ALIAS target ``${PACKAGE_NAME}::`` (where ```` is -# the full CMake target name as returned from ``${}``). -# -# Usage:: -# -# tribits_add_library( -# -# [HEADERS

...] -# [HEADERS_INSTALL_SUBDIR ] -# [NOINSTALLHEADERS ...] -# [SOURCES ...] -# [DEPLIBS ...] -# [IMPORTEDLIBS ...] -# [STATIC|SHARED] -# [TESTONLY] -# [NO_INSTALL_LIB_OR_HEADERS] -# [CUDALIBRARY] -# [ADDED_LIB_TARGET_NAME_OUT ] -# ) -# -# *Sections:* -# -# * `Formal Arguments (tribits_add_library())`_ -# * `Include Directories (tribits_add_library())`_ -# * `Install Targets (tribits_add_library())`_ -# * `Additional Library and Source File Properties (tribits_add_library())`_ -# * `Miscellaneous Notes (tribits_add_library())`_ -# -# .. _Formal Arguments (tribits_add_library()): -# -# **Formal Arguments (tribits_add_library())** -# -# ```` -# -# Required base name of the library. The name of the actual library name -# will be prefixed by ``${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}`` to -# produce:: -# -# = ${${PROJECT_NAME}_LIBRARY_NAME_PREFIX} -# -# This is the name passed to ``add_library( ...)``. The -# name is *not* prefixed by the package name. CMake will of course add -# any standard prefix or post-fix to the library file name appropriate for -# the platform and if this is a static or shared library build (e.g. on -# Linux prefix = ``'lib'``, postfix = ``'.so'`` for shared lib and postfix -# = ``'.a'`` static lib) (see documentation for the built-in CMake command -# ``add_library()``. -# -# ``HEADERS

...`` -# -# List of public header files for using this library. By default, these -# header files are assumed to be in the current source directory. They -# can also contain the relative path or absolute path to the files if they -# are not in the current source directory. This list of headers is passed -# into ``add_library(...)`` as well (which is not strictly needed but is -# helpful for some build tools, like MS Visual Studio). By default, these -# headers will be installed (see `Install Targets -# (tribits_add_library())`_). -# -# ``HEADERS_INSTALL_SUBDIR `` -# -# Optional subdirectory that the headers will be installed under the -# standard installation directory. If ``!=""``, then the -# headers will be installed under -# ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. Otherwise, -# they will be installed under ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. -# `Install Targets (tribits_add_library())`_. -# -# ``NOINSTALLHEADERS ...`` -# -# List of private header files which are used by this library. These -# headers are not installed and do not needed to be passed in for any -# purpose other than to pass them into ``add_library()`` as some build -# tools like to have these listed (e.g. MS Visual Studio). -# -# ``SOURCES ...`` -# -# List of source files passed into ``add_library()`` that are compiled -# into header files and included in the library. The compiler used to -# compile the files is determined automatically based on the file -# extension (see CMake documentation for ``add_library()``). -# -# ``DEPLIBS ...`` -# -# List of dependent libraries that are built in the current SE package -# that this library is dependent on. These libraries are passed into -# ``target_link_libraries( ...)`` so that CMake knows about -# the dependency structure of the libraries within this SE package. -# **NOTE:** One must **not** list libraries in other upstream `TriBITS SE -# Packages`_ or libraries built externally from this TriBITS CMake project -# in ``DEPLIBS``. The TriBITS system automatically handles linking to -# libraries in upstream TriBITS SE packages. External libraries need to -# be listed in the ``IMPORTEDLIBS`` argument instead if they are not -# already specified automatically using a `TriBITS TPL`_. -# -# ``IMPORTEDLIBS ...`` -# -# List of dependent libraries built externally from this TriBITS CMake -# project. These libraries are passed into -# ``target_link_libraries( ...)`` so that CMake knows about -# the dependency. However, note that external libraries are often better -# handled as `TriBITS TPLs`_. A well constructed TriBITS package and -# library should never have to use this option! So far, the only case -# where ``IMPORTEDLIBS`` has been shown to be necessary is to pass in the -# standard C math library ``m``. In every other case, a TriBITS TPL -# should be used instead. -# -# ``STATIC`` or ``SHARED`` -# -# If ``STATIC`` is passed in, then a static library will be created -# independent of the value of ``BUILD_SHARED_LIBS``. If ``SHARED`` is -# passed in, then a shared library will be created independent of the -# value of ``BUILD_SHARED_LIBS``. If neither ``STATIC`` or ``SHARED`` are -# passed in, then a shared library will be created if -# ``BUILD_SHARED_LIBS`` evaluates to true, otherwise and a static library -# will be created. If both ``STATIC`` and ``SHARED`` are passed in (which -# is obviously a mistake), then a shared library will be created. -# WARNING: Once you mark a library with ``STATIC``, then all of the -# downstream libraries in the current SE package and all downstream SE -# packages must also be also be marked with ``STATIC``. That is because, -# generally, one can not link a link a static lib against a downstream -# shared lib since that is not portable (but can be done on some platforms -# if, for example, ``-fPIC`` is specified). So be careful to use -# ``STATIC`` in all downstream libraries! -# -# ``TESTONLY`` -# -# If passed in, then ```` will **not** be added to -# ``${PACKAGE_NAME}_LIBRARIES`` and an install target for the library will -# not be added. In this case, the current include directories will be set -# in the global variable ``_INCLUDE_DIR`` which will be -# used in `tribits_add_executable()`_ when a test-only library is linked -# in through its ``DEPLIBS`` argument. Also, the custom property -# ``TRIBITS_TESTONLY_LIB`` will be set to ``TRUE`` which will ensure that -# this library will not be added to the ``${PACKAGE_NAME}::all_libs`` -# target. -# -# ``NO_INSTALL_LIB_OR_HEADERS`` -# -# If specified, then no install targets will be added for the library -# ```` or the header files listed in ``HEADERS``. -# -# ``CUDALIBRARY`` -# -# If specified then ``cuda_add_library()`` is used instead of -# ``add_library()`` where ``cuda_add_library()`` is assumed to be defined -# by the standard ``FindCUDA.cmake`` module as processed using the -# standard TriBITS ``FindTPLCUDA.cmake`` file (see `Standard TriBITS -# TPLs`_). For this option to work, this SE package must have an enabled -# direct or indirect dependency on the TriBITS CUDA TPL or a -# configure-time error may occur about not knowing about -# ``cuda_all_library()``. -# -# ``ADDED_LIB_TARGET_NAME_OUT `` -# -# If specified, then on output the variable ```` will be -# set with the name of the library passed to ``add_library()``. Having -# this name allows the calling ``CMakeLists.txt`` file access and set -# additional target properties (see `Additional Library and Source File -# Properties (tribits_add_library())`_). -# -# .. _Include Directories (tribits_add_library()): -# -# **Include Directories (tribits_add_library())** -# -# Any base directories for the header files listed in the arguments -# ``HEADERS`` or ``NOINSTALLHEADERS`` should be passed into the standard CMake -# command ``include_directories()`` **before** calling this function. For -# example, a CMakeLists.txt file will look like:: -# -# ... -# -# tribits_configure_file(${PACKAGE_NAME}_config.h) -# configure_file(...) -# -# ... -# -# include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -# include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# -# ... -# -# tribits_add_library( -# SOURCES -# .c -# /.cpp -# /.F90 -# ... -# HEADERS -# .h -# /.hpp -# ... -# NONINSTALLHEADERS .hpp .hpp ... -# ... -# ) -# -# The include of ``${CMAKE_CURRENT_BINARY_DIR}`` is needed for any generated -# header files (e.g. using raw ``configure_file()`` or -# `tribits_configure_file()`_) or any generated Fortran ``*.mod`` module files -# generated as a byproduct of compiling F90+ source files (that contain one or -# more Fortran module declarations). -# -# The function ``tribits_add_library()`` will grab the list of all of the -# include directories in scope from prior calls to ``include_directories()`` -# and will append these to the variable ``${PACKAGE_NAME}_INCLUDE_DIRS``. -# This list of include directories is exported to downstream SE packages so -# they appear on the compile lines of all downstream object file compiles. -# This is a critical part of the "glue" that allows TriBITS packages to link -# up automatically (just by clearing dependencies in -# `/cmake/Dependencies.cmake`_ files). -# -# .. _Install Targets (tribits_add_library()): -# -# **Install Targets (tribits_add_library())** -# -# By default, an install target for the library is created using -# ``install(TARGETS ...)`` to install into the directory -# ``${CMAKE_INSTALL_PREFIX}/lib/`` (actual install directory is given by -# ``${PROJECT}_INSTALL_LIB_DIR``, see `Setting the install prefix`_). -# However, this install target will not get created if -# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE`` and -# ``BUILD_SHARD_LIBS=OFF``. But when ``BUILD_SHARD_LIBS=ON``, the install -# target will get added. Also, this install target will *not* get added if -# ``TESTONLY`` or ``NO_INSTALL_LIB_OR_HEADERS`` are passed in. -# -# By default, an install target for the headers listed in ``HEADERS`` will get -# added using ``install(FILES

...)``, but only if ``TESTONLY`` and -# ``NO_INSTALL_LIB_OR_HEADERS`` are not passed in as well. Also, the install -# target for the headers will not get added if -# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE``. If this -# install target is added, then the headers get installed into the flat -# directory ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/`` (default is -# ``${CMAKE_INSTALL_PREFIX}/include/``, see `Setting the install prefix`_). -# If ``HEADERS_INSTALL_SUBDIR`` is set, then the headers will be installed -# under ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}//``. -# -# Note that an install target will *not* get created for the headers listed in -# ``NOINSTALLHEADERS``. -# -# .. _Additional Library and Source File Properties (tribits_add_library()): -# -# **Additional Library and Source File Properties (tribits_add_library())** -# -# Once ``add_library( ... ...)`` is called, one -# can set and change properties on the ```` library target -# using the built-in CMake command ``set_target_properties()`` as well as set -# and change properties on any of the source files listed in ``SOURCES`` using -# the built-in CMake command ``set_source_file_properties()`` just like in any -# CMake project. For example:: -# -# tribits_add_library( somelib ... -# ADDED_LIB_TARGET_NAME_OUT somelib_TARGET_NAME ) -# -# set_target_properties( ${somelib_TARGET_NAME} -# PROPERTIES LINKER_LANGUAGE CXX ) -# -# .. _Miscellaneous Notes (tribits_add_library()): -# -# **Miscellaneous Notes (tribits_add_library())** -# -# When the file ``Version.cmake`` exists and the CMake variables -# ``${PROJECT_NAME}_VERSION`` and ``${PROJECT_NAME}_MAJOR_VERSION`` are -# defined, then produced shared libraries will be given the standard SOVERSION -# symlinks (see `/Version.cmake`_). -# -# **WARNING:** Do **NOT** use the built-in CMake command ``add_definitions()`` -# to add defines ``-D`` to the compile command line that will -# affect any of the header files in the package! These CMake-added defines -# are only set locally in this directory and child directories. These defines -# will **NOT** be set when code in peer directories (e.g. a downstream TriBITS -# packages) compiles that may include these header files. To add defines that -# affect header files, please use a configured header file (see -# `tribits_configure_file()`_). -# -function(tribits_add_library LIBRARY_NAME_IN) - - # - # Confirm that package and subpackage macros/functions have been called in the correct order - # - - if (CURRENTLY_PROCESSING_SUBPACKAGE) - - # This is a subpackage being processed - - if(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_subpackage() before tribits_add_library()" - " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") - endif() - - if(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_add_library() before " - " tribits_subpackage_postprocess() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") - endif() - - else() - - # This is a package being processed - - if(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_package() or tribits_package_decl() before" - " tribits_add_library() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") - endif() - - if(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_add_library() before " - " tribits_package_postprocess() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") - endif() - - endif() - - set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") - set(LIBRARY_NAME ${LIBRARY_NAME_PREFIX}${LIBRARY_NAME_IN}) - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("\nTRIBITS_ADD_LIBRARY: ${LIBRARY_NAME}") - if(${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - message("\n${PACKAGE_NAME}_LIBRARIES In installation testing mode," - " libraries will be found instead of created.") - endif() - endif() - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${PACKAGE_NAME}_LIBRARIES) - endif() - - cmake_parse_arguments( - #prefix - PARSE - #Options - "STATIC;SHARED;TESTONLY;NO_INSTALL_LIB_OR_HEADERS;CUDALIBRARY" - #one_value_keywords - "" - #mulit_value_keywords - "HEADERS;HEADERS_INSTALL_SUBDIR;NOINSTALLHEADERS;SOURCES;DEPLIBS;IMPORTEDLIBS;DEFINES;ADDED_LIB_TARGET_NAME_OUT" - ${ARGN} - ) - - tribits_check_for_unparsed_arguments() - - # ToDo: Assert that HEADERS_INSTALL_SUBDIR has 0 or 1 entries! - # ToDo: Assert that ADDED_LIB_TARGET_NAME_OUT as 0 or 1 entries! - - if(PARSE_HEADERS) - list(REMOVE_DUPLICATES PARSE_HEADERS) - endif() - if(PARSE_SOURCES) - list(REMOVE_DUPLICATES PARSE_SOURCES) - endif() - - if(PARSE_ADDED_LIB_TARGET_NAME_OUT) - set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} PARENT_SCOPE) - endif() - - # ToDo: Deprecate and remove the usage of DEFINES! People should be putting - # defines into configured header files, not adding -D to the - # compile lines! - - if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING OR PARSE_TESTONLY) - - # Add dependent libraries passed directly in - - if (PARSE_DEPLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "DEPLIBS = ${PARSE_DEPLIBS}") - endif() - if (PARSE_IMPORTEDLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "IMPORTEDLIBS = ${PARSE_IMPORTEDLIBS}") - endif() - - # - # Loop over and assert DEPLIBS - # - # We also need to make special considerations for test libraries since - # things need to be handled a little bit differently (but not much). In the - # case of test libraries, we need to also pull the test-only dependencies. - # In this case, we will always assume that we will add in the test - # libraries. - # - # ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we - # give enough time for people to clean up their codes. - # - - set(PREFIXED_DEPLIBS) - - foreach(LIB ${PARSE_DEPLIBS}) - - set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${LIB}") - - # LIB_IN_SE_PKG? - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" FOUND_IDX) - if (FOUND_IDX GREATER -1) - set(LIB_IN_SE_PKG TRUE) - else() - set(LIB_IN_SE_PKG FALSE) - endif() - - # ${PREFIXED_LIB" is TESTONLY? - tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) - - # Check for valid usage (sorted by most common to least common) - if (LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) #PARSE_TESTONLY=TRUE/FASLE - # The library being created here is a library dependent on a regular - # (non-TESTONLY) lib in this SE package. This is valid usage of - # DEPLIBS. There is no need to link this new lib to the SE package's - # upstream dependent SE package and TPL libraries because thse are - # already linked into the lib ${LIB}. - elseif (PARSE_TESTONLY AND LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) - # The library being created here is TESTONLY library and is - # dependent on a regular (non-TESTONLY) lib. This is valid usage of - # DEPLIBS. In the case of test-only libraries, we always link in - # the upstream libs. - elseif (PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE - # The library being created here is TESTONLY library and is dependent - # on another TESTONLY library. This is valid usage of DEPLIBS. In - # this case we just hope that this SE package correctly specified a - # TEST dependency on the upstream SE package that owns this upstream - # TESTONLY library. - elseif (NOT PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE - message(WARNING "WARNING: '${LIB}' in DEPLIBS is a TESTONLY lib" - " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." - " Such usage is deprecated (and this warning will soon become an error)!" - " If this is a regular library in this SE package or in an dependent upstream SE" - " package then TriBITS will link automatically to it. If you remove this and it" - " does not link, then you need to add a new SE package dependency to" - " this SE package's dependencies file" - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code - elseif (NOT LIB_IN_SE_PKG AND TARGET ${PREFIXED_LIB} ) # PARSE_TESTONLY=TRUE/FALSE - message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" - " a lib in this SE package but is a library defined in the current" - " cmake project! Such usage is deprecated (and" - " will result in a configure error soon). If this is a library in" - " a dependent upstream SE package, then simply remove it from this list." - " TriBITS automatically links in libraries in upstream SE packages." - " If you remove '${LIB}' from DEPLIBS and your code does" - " not link, then you need to add a new SE package dependency to" - " this SE package's dependencies file" - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - elseif (NOT LIB_IN_SE_PKG AND NOT TARGET ${PREFIXED_LIB} ) - message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" - " a lib defined in the current cmake project! Such usage is deprecated (and" - " will result in a configure error soon). If this is an external" - " lib you are trying to link in, it should likely be handled as a TriBITS" - " TPL. Otherwise, it should be passed in through IMPORTEDLIBS. However," - " the only case we have found where IMPORTEDLIBS had to be used instead of" - " through a proper TriBITS TPL is the C math library 'm'.") - else() - message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY}," - " LIB_IN_SE_PKG=${LIB_IN_SE_PKG}, libIsTestOnlyLib=${libIsTestOnlyLib}, has" - " not yet been handled!") - endif() - - list(APPEND PREFIXED_DEPLIBS "${LIBRARY_NAME_PREFIX}${LIB}") - - endforeach() - - # - # Check IMPORTEDLIBS - # - - foreach(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) - set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" - FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX) - tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) - if (libIsTestOnlyLib) - message(WARNING "WARNING: '${IMPORTEDLIB}' in IMPORTEDLIBS is a TESTONLY lib" - " and it is illegal to pass in through IMPORTEDLIBS!" - " Such usage is deprecated (and this warning will soon become an error)!" - " Should '${IMPORTEDLIB}' instead be passed through DEPLIBS?") - # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code - elseif (FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX GREATER -1) - message(WARNING "WARNING: Lib '${IMPORTEDLIB}' in IMPORTEDLIBS is in" - " this SE package and is *not* an external lib!" - " TriBITS takes care of linking against libs the current" - " SE package automatically. Please remove it from IMPORTEDLIBS!") - elseif (TARGET ${PREFIXED_LIB}) - message(WARNING "WARNING: Lib '${IMPORTEDLIB}' being passed through" - " IMPORTEDLIBS is *not* an external library but instead is a library" - " defined in this CMake project!" - " TriBITS takes care of linking against libraries in dependent upstream" - " SE packages. If you want to link to a library in an upstream SE" - " package then add the SE package name to the appropriate category" - " in this SE package's dependencies file: " - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - endif() - endforeach() - - # Add the library and all the dependencies - - if (PARSE_DEFINES) - add_definitions(${PARSE_DEFINES}) - endif() - - if (PARSE_STATIC) - set(STATIC_KEYWORD "STATIC") - else() - set(STATIC_KEYWORD) - endif() - - if (PARSE_SHARED) - set(SHARED_KEYWORD "SHARED") - else() - set(SHARED_KEYWORD) - endif() - - if (NOT PARSE_CUDALIBRARY) - add_library( - ${LIBRARY_NAME} - ${STATIC_KEYWORD} - ${SHARED_KEYWORD} - ${PARSE_HEADERS} - ${PARSE_NOINSTALLHEADERS} - ${PARSE_SOURCES} - ) - else() - cuda_add_library( - ${LIBRARY_NAME} - ${PARSE_HEADERS} - ${PARSE_NOINSTALLHEADERS} - ${PARSE_SOURCES} - ) - endif() - - if(PARSE_ADDED_LIB_TARGET_NAME_OUT) - set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} ${LIBRARY_NAME} PARENT_SCOPE) - endif() - - if (PARSE_TESTONLY) - tribits_set_lib_is_testonly(${LIBRARY_NAME}) - endif() - - set_property( - TARGET ${LIBRARY_NAME} - APPEND PROPERTY - LABELS ${PACKAGE_NAME}Libs ${PARENT_PACKAGE_NAME}Libs - ) - - if (NOT "${${PROJECT_NAME}_VERSION}" STREQUAL "" AND - NOT "${${PROJECT_NAME}_MAJOR_VERSION}" STREQUAL "" - ) - set_target_properties( - ${LIBRARY_NAME} - PROPERTIES - VERSION ${${PROJECT_NAME}_VERSION} - SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION} - ) - endif() - - prepend_global_set(${PARENT_PACKAGE_NAME}_LIB_TARGETS ${LIBRARY_NAME}) - prepend_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${LIBRARY_NAME}) - - # - # Link ${LIBRARY_NAME} to direct upstream libraries - # - - # DEPLIBS - foreach(depLib ${PARSE_DEPLIBS}) - target_link_libraries(${LIBRARY_NAME} PUBLIC "${LIBRARY_NAME_PREFIX}${depLib}") - endforeach() - # ${PACKAGE_NAME}_LIBRARIES - target_link_libraries(${LIBRARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) - # ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES - foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() - endforeach() - # ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES - foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() - endforeach() - # IMPORTEDLIBS - foreach(importedLib ${PARSE_IMPORTEDLIBS}) - target_link_libraries(${LIBRARY_NAME} PUBLIC "${importedLib}") - endforeach() - - # ToDo: #63: Above, allow for other link visibilities other than 'PUBLIC'! - - if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) - target_compile_features(${LIBRARY_NAME} PUBLIC "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") - ENDIF () - - # Add to the install target - - set(INSTALL_LIB ON) - set(INSTALL_HEADERS ON) - set(APPEND_LIB_AND_HEADERS_TO_PACKAGE ON) - - if (PARSE_TESTONLY) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation hooks for this library" - " because 'TESTONLY' was passed in ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - set(APPEND_LIB_AND_HEADERS_TO_PACKAGE OFF) - elseif (PARSE_NO_INSTALL_LIB_OR_HEADERS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation hooks for this library" - " because 'NO_INSTALL_LIB_OR_HEADERS' was passed in ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND NOT BUILD_SHARED_LIBS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation of headers and libraries" - " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=FALSE ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND BUILD_SHARED_LIBS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation of headers but installing libraries" - " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=TRUE ...") - endif() - set(INSTALL_HEADERS OFF) - endif() - - if (INSTALL_LIB OR INSTALL_HEADERS) - set_property(GLOBAL PROPERTY ${PROJECT_NAME}_HAS_INSTALL_TARGETS ON) - set_property(GLOBAL PROPERTY ${PACKAGE_NAME}_HAS_INSTALL_TARGETS ON) - endif() - - if (INSTALL_LIB) - install( - TARGETS ${LIBRARY_NAME} - EXPORT ${PACKAGE_NAME} - INCLUDES DESTINATION "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}" - RUNTIME DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_DIR}" - LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" - ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" - COMPONENT ${PACKAGE_NAME} - ) - endif() - - if (INSTALL_HEADERS) - tribits_install_headers( - HEADERS ${PARSE_HEADERS} - INSTALL_SUBDIR ${PARSE_HEADERS_INSTALL_SUBDIR} - COMPONENT ${PACKAGE_NAME} - ) - endif() - - # Append the new include dirs, library dirs, and libraries to this package's lists - - get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - - if (APPEND_LIB_AND_HEADERS_TO_PACKAGE) - - prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${PACKAGE_NAME}::${LIBRARY_NAME}) - - remove_global_duplicates(${PACKAGE_NAME}_LIBRARIES) - - if (INSTALL_LIB) - global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES_TO_INSTALL TRUE) - endif() - - else() - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping augmentation of package's lists of include" - " directories and libraries! ...") - endif() - - endif() - - # Set INTERFACE_INCLUDE_DIRECTOIRES property for added library and must - # only do for the build interface (not the install interface). - set(buildInterfaceIncludeDirs) - foreach (includeDir IN LISTS INCLUDE_DIRS_CURRENT) - list(APPEND buildInterfaceIncludeDirs "$") - endforeach() - target_include_directories( ${LIBRARY_NAME} PUBLIC ${buildInterfaceIncludeDirs} ) - - # Add ALIAS library :: - add_library(${PACKAGE_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME}) - - # Optionally Set IMPORTED_NO_SYSTEM - if (${PROJECT_NAME}_IMPORTED_NO_SYSTEM) - set_target_properties(${LIBRARY_NAME} PROPERTIES IMPORTED_NO_SYSTEM TRUE) - endif() - - endif() #if not in installation testing mode - - # - # Adjust for installation testing - # - - if (${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - - list(FIND ${PROJECT_NAME}_INSTALLATION_PACKAGE_LIST ${PACKAGE_NAME} - ${PACKAGE_NAME}_WAS_INSTALLED) - if(${${PACKAGE_NAME}_WAS_INSTALLED} EQUAL -1) - message(FATAL_ERROR - "The package ${PACKAGE_NAME} was not installed with ${PROJECT_NAME}!" - " Please disable package ${PACKAGE_NAME} or install it.") - endif() - - global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) - - endif() - - # - # Print the updates to the linkage variables - # - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${PACKAGE_NAME}_LIBRARIES) - endif() - -endfunction() +include(TribitsAddLibrary) From 5011e8bbfd8eefbd98e8cd44f172e75e73075f41 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 6 May 2022 07:04:30 -0600 Subject: [PATCH 12/43] tribits_add_library(): Factor out functions and some cleanup (#299) * Factor out tribits_add_library_assert_deplibs() * Factor out tribits_add_library_assert_importedlibs() * Factor out tribits_add_library_determine_install_lib_and_or_headers() * Improve names of some vars * Remove 'SE' from warning messages * Various other cleanup --- .../TribitsExampleProject_Tests.cmake | 24 +- .../core/package_arch/TribitsAddLibrary.cmake | 485 ++++++++++-------- 2 files changed, 272 insertions(+), 237 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index cfd5cab9f..0ba33a199 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -1512,31 +1512,31 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage # TEST_1 - MESSAGE "Show deprecated warning when trying to link lib from upstream SE package." + MESSAGE "Show deprecated warning when trying to link lib from upstream package." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR=ON . PASS_REGULAR_EXPRESSION_ALL - "WARNING: 'simplecxx' in DEPLIBS is not a lib in this SE package" + "WARNING: 'simplecxx' in DEPLIBS is not a lib in this package" "packages/with_subpackages/b/src/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage" TEST_2 - MESSAGE "Show deprecated warning when passing a lib from this SE package through IMPORTEDLIBS." + MESSAGE "Show deprecated warning when passing a lib from this package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR= . PASS_REGULAR_EXPRESSION_ALL - "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this SE package " + "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this package " "packages/with_subpackages/b/tests/testlib/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage" TEST_3 MESSAGE "Show deprecated warning when passing a lib from upstream" - " SE package through IMPORTEDLIBS." + " package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR= @@ -1612,7 +1612,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage "Configuring incomplete, errors occurred!" TEST_9 - MESSAGE "Show error when trying to link SE package lib using TESTONLYLIBS" + MESSAGE "Show error when trying to link package lib using TESTONLYLIBS" CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_IMPORTED_LIBS_THIS_PKG_ERROR=ON -DSPKB_SHOW_NON_TESTONLY_LIB_ERROR= @@ -1696,31 +1696,31 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage_LibPrefix # TEST_1 - MESSAGE "Show deprecated warning when trying to link lib from upstream SE package." + MESSAGE "Show deprecated warning when trying to link lib from upstream package." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR=ON . PASS_REGULAR_EXPRESSION_ALL - "WARNING: 'simplecxx' in DEPLIBS is not a lib in this SE package" + "WARNING: 'simplecxx' in DEPLIBS is not a lib in this package" "packages/with_subpackages/b/src/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage_LibPrefix" TEST_2 - MESSAGE "Show deprecated warning when passing a lib from this SE package through IMPORTEDLIBS." + MESSAGE "Show deprecated warning when passing a lib from this package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR= . PASS_REGULAR_EXPRESSION_ALL - "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this SE package " + "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this package " "packages/with_subpackages/b/tests/testlib/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage_LibPrefix" TEST_3 MESSAGE "Show deprecated warning when passing a lib from upstream" - " SE package through IMPORTEDLIBS." + " package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR= @@ -1796,7 +1796,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage_LibPrefix "Configuring incomplete, errors occurred!" TEST_9 - MESSAGE "Show error when trying to link SE package lib using TESTONLYLIBS" + MESSAGE "Show error when trying to link package lib using TESTONLYLIBS" CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_IMPORTED_LIBS_THIS_PKG_ERROR=ON -DSPKB_SHOW_NON_TESTONLY_LIB_ERROR= diff --git a/tribits/core/package_arch/TribitsAddLibrary.cmake b/tribits/core/package_arch/TribitsAddLibrary.cmake index 422d05aa3..ede40b0bf 100644 --- a/tribits/core/package_arch/TribitsAddLibrary.cmake +++ b/tribits/core/package_arch/TribitsAddLibrary.cmake @@ -334,45 +334,11 @@ include(SetAndIncDirs) # affect header files, please use a configured header file (see # `tribits_configure_file()`_). # -function(tribits_add_library LIBRARY_NAME_IN) +function(tribits_add_library LIBRARY_NAME_IN) - # - # Confirm that package and subpackage macros/functions have been called in the correct order - # - - if (CURRENTLY_PROCESSING_SUBPACKAGE) - - # This is a subpackage being processed - - if(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_subpackage() before tribits_add_library()" - " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") - endif() - - if(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_add_library() before " - " tribits_subpackage_postprocess() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") - endif() - - else() - - # This is a package being processed + tribits_add_library_assert_correct_call_context() - if(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_package() or tribits_package_decl() before" - " tribits_add_library() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") - endif() - - if(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_add_library() before " - " tribits_package_postprocess() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") - endif() - - endif() + # Set library prefix and name set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") set(LIBRARY_NAME ${LIBRARY_NAME_PREFIX}${LIBRARY_NAME_IN}) @@ -383,12 +349,11 @@ function(tribits_add_library LIBRARY_NAME_IN) message("\n${PACKAGE_NAME}_LIBRARIES In installation testing mode," " libraries will be found instead of created.") endif() - endif() - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) print_var(${PACKAGE_NAME}_LIBRARIES) endif() + # Parse input args + cmake_parse_arguments( #prefix PARSE @@ -413,18 +378,18 @@ function(tribits_add_library LIBRARY_NAME_IN) list(REMOVE_DUPLICATES PARSE_SOURCES) endif() + # Library not added by default if(PARSE_ADDED_LIB_TARGET_NAME_OUT) - set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} PARENT_SCOPE) + set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} "" PARENT_SCOPE) endif() - # ToDo: Deprecate and remove the usage of DEFINES! People should be putting - # defines into configured header files, not adding -D to the - # compile lines! + # + # Create library target if not doing installation testing or if this is a + # TESTONLY library. + # if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING OR PARSE_TESTONLY) - # Add dependent libraries passed directly in - if (PARSE_DEPLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) message("-- " "DEPLIBS = ${PARSE_DEPLIBS}") endif() @@ -432,124 +397,10 @@ function(tribits_add_library LIBRARY_NAME_IN) message("-- " "IMPORTEDLIBS = ${PARSE_IMPORTEDLIBS}") endif() - # - # Loop over and assert DEPLIBS - # - # We also need to make special considerations for test libraries since - # things need to be handled a little bit differently (but not much). In the - # case of test libraries, we need to also pull the test-only dependencies. - # In this case, we will always assume that we will add in the test - # libraries. - # - # ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we - # give enough time for people to clean up their codes. - # - - set(PREFIXED_DEPLIBS) - - foreach(LIB ${PARSE_DEPLIBS}) - - set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${LIB}") - - # LIB_IN_SE_PKG? - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" FOUND_IDX) - if (FOUND_IDX GREATER -1) - set(LIB_IN_SE_PKG TRUE) - else() - set(LIB_IN_SE_PKG FALSE) - endif() - - # ${PREFIXED_LIB" is TESTONLY? - tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) - - # Check for valid usage (sorted by most common to least common) - if (LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) #PARSE_TESTONLY=TRUE/FASLE - # The library being created here is a library dependent on a regular - # (non-TESTONLY) lib in this SE package. This is valid usage of - # DEPLIBS. There is no need to link this new lib to the SE package's - # upstream dependent SE package and TPL libraries because thse are - # already linked into the lib ${LIB}. - elseif (PARSE_TESTONLY AND LIB_IN_SE_PKG AND NOT libIsTestOnlyLib) - # The library being created here is TESTONLY library and is - # dependent on a regular (non-TESTONLY) lib. This is valid usage of - # DEPLIBS. In the case of test-only libraries, we always link in - # the upstream libs. - elseif (PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE - # The library being created here is TESTONLY library and is dependent - # on another TESTONLY library. This is valid usage of DEPLIBS. In - # this case we just hope that this SE package correctly specified a - # TEST dependency on the upstream SE package that owns this upstream - # TESTONLY library. - elseif (NOT PARSE_TESTONLY AND libIsTestOnlyLib) # LIB_IN_SE_PKG=TRUE/FASLE - message(WARNING "WARNING: '${LIB}' in DEPLIBS is a TESTONLY lib" - " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." - " Such usage is deprecated (and this warning will soon become an error)!" - " If this is a regular library in this SE package or in an dependent upstream SE" - " package then TriBITS will link automatically to it. If you remove this and it" - " does not link, then you need to add a new SE package dependency to" - " this SE package's dependencies file" - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code - elseif (NOT LIB_IN_SE_PKG AND TARGET ${PREFIXED_LIB} ) # PARSE_TESTONLY=TRUE/FALSE - message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" - " a lib in this SE package but is a library defined in the current" - " cmake project! Such usage is deprecated (and" - " will result in a configure error soon). If this is a library in" - " a dependent upstream SE package, then simply remove it from this list." - " TriBITS automatically links in libraries in upstream SE packages." - " If you remove '${LIB}' from DEPLIBS and your code does" - " not link, then you need to add a new SE package dependency to" - " this SE package's dependencies file" - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - elseif (NOT LIB_IN_SE_PKG AND NOT TARGET ${PREFIXED_LIB} ) - message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" - " a lib defined in the current cmake project! Such usage is deprecated (and" - " will result in a configure error soon). If this is an external" - " lib you are trying to link in, it should likely be handled as a TriBITS" - " TPL. Otherwise, it should be passed in through IMPORTEDLIBS. However," - " the only case we have found where IMPORTEDLIBS had to be used instead of" - " through a proper TriBITS TPL is the C math library 'm'.") - else() - message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY}," - " LIB_IN_SE_PKG=${LIB_IN_SE_PKG}, libIsTestOnlyLib=${libIsTestOnlyLib}, has" - " not yet been handled!") - endif() + # Assert DEPLIBS and IMPORTEDLIBS - list(APPEND PREFIXED_DEPLIBS "${LIBRARY_NAME_PREFIX}${LIB}") - - endforeach() - - # - # Check IMPORTEDLIBS - # - - foreach(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) - set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" - FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX) - tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) - if (libIsTestOnlyLib) - message(WARNING "WARNING: '${IMPORTEDLIB}' in IMPORTEDLIBS is a TESTONLY lib" - " and it is illegal to pass in through IMPORTEDLIBS!" - " Such usage is deprecated (and this warning will soon become an error)!" - " Should '${IMPORTEDLIB}' instead be passed through DEPLIBS?") - # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code - elseif (FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX GREATER -1) - message(WARNING "WARNING: Lib '${IMPORTEDLIB}' in IMPORTEDLIBS is in" - " this SE package and is *not* an external lib!" - " TriBITS takes care of linking against libs the current" - " SE package automatically. Please remove it from IMPORTEDLIBS!") - elseif (TARGET ${PREFIXED_LIB}) - message(WARNING "WARNING: Lib '${IMPORTEDLIB}' being passed through" - " IMPORTEDLIBS is *not* an external library but instead is a library" - " defined in this CMake project!" - " TriBITS takes care of linking against libraries in dependent upstream" - " SE packages. If you want to link to a library in an upstream SE" - " package then add the SE package name to the appropriate category" - " in this SE package's dependencies file: " - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - endif() - endforeach() + tribits_add_library_assert_deplibs() + tribits_add_library_assert_importedlibs() # Add the library and all the dependencies @@ -560,13 +411,13 @@ function(tribits_add_library LIBRARY_NAME_IN) if (PARSE_STATIC) set(STATIC_KEYWORD "STATIC") else() - set(STATIC_KEYWORD) + set(STATIC_KEYWORD "") endif() if (PARSE_SHARED) set(SHARED_KEYWORD "SHARED") else() - set(SHARED_KEYWORD) + set(SHARED_KEYWORD "") endif() if (NOT PARSE_CUDALIBRARY) @@ -642,54 +493,25 @@ function(tribits_add_library LIBRARY_NAME_IN) target_link_libraries(${LIBRARY_NAME} PUBLIC "${importedLib}") endforeach() + # ToDo: #299: Above, Handle 'last_lib' from ${PROJECT_NAME}_EXTRA_LINK_FLAGS! # ToDo: #63: Above, allow for other link visibilities other than 'PUBLIC'! if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) - target_compile_features(${LIBRARY_NAME} PUBLIC "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") - ENDIF () + target_compile_features(${LIBRARY_NAME} PUBLIC + "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") + endif() # Add to the install target - set(INSTALL_LIB ON) - set(INSTALL_HEADERS ON) - set(APPEND_LIB_AND_HEADERS_TO_PACKAGE ON) + tribits_add_library_determine_install_lib_and_or_headers( + installLib installHeaders appendLibAndHeadersToPackageVars) - if (PARSE_TESTONLY) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation hooks for this library" - " because 'TESTONLY' was passed in ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - set(APPEND_LIB_AND_HEADERS_TO_PACKAGE OFF) - elseif (PARSE_NO_INSTALL_LIB_OR_HEADERS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation hooks for this library" - " because 'NO_INSTALL_LIB_OR_HEADERS' was passed in ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND NOT BUILD_SHARED_LIBS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation of headers and libraries" - " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=FALSE ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND BUILD_SHARED_LIBS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation of headers but installing libraries" - " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=TRUE ...") - endif() - set(INSTALL_HEADERS OFF) - endif() - - if (INSTALL_LIB OR INSTALL_HEADERS) + if (installLib OR installHeaders) set_property(GLOBAL PROPERTY ${PROJECT_NAME}_HAS_INSTALL_TARGETS ON) set_property(GLOBAL PROPERTY ${PACKAGE_NAME}_HAS_INSTALL_TARGETS ON) endif() - if (INSTALL_LIB) + if (installLib) install( TARGETS ${LIBRARY_NAME} EXPORT ${PACKAGE_NAME} @@ -701,7 +523,7 @@ function(tribits_add_library LIBRARY_NAME_IN) ) endif() - if (INSTALL_HEADERS) + if (installHeaders) tribits_install_headers( HEADERS ${PARSE_HEADERS} INSTALL_SUBDIR ${PARSE_HEADERS_INSTALL_SUBDIR} @@ -709,32 +531,23 @@ function(tribits_add_library LIBRARY_NAME_IN) ) endif() - # Append the new include dirs, library dirs, and libraries to this package's lists - - get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - #get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - - if (APPEND_LIB_AND_HEADERS_TO_PACKAGE) + # Append the new libraries to this package's lists + if (appendLibAndHeadersToPackageVars) prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${PACKAGE_NAME}::${LIBRARY_NAME}) - remove_global_duplicates(${PACKAGE_NAME}_LIBRARIES) - - if (INSTALL_LIB) + if (installLib) global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES_TO_INSTALL TRUE) endif() - else() - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping augmentation of package's lists of include" - " directories and libraries! ...") + message("-- " "Skipping augmentation of package's lists of libraries! ...") endif() - endif() - # Set INTERFACE_INCLUDE_DIRECTOIRES property for added library and must + # Set INTERFACE_INCLUDE_DIRECTORIES property for added library and must # only do for the build interface (not the install interface). + get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) set(buildInterfaceIncludeDirs) foreach (includeDir IN LISTS INCLUDE_DIRS_CURRENT) list(APPEND buildInterfaceIncludeDirs "$") @@ -751,12 +564,9 @@ function(tribits_add_library LIBRARY_NAME_IN) endif() #if not in installation testing mode - # # Adjust for installation testing - # if (${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - list(FIND ${PROJECT_NAME}_INSTALLATION_PACKAGE_LIST ${PACKAGE_NAME} ${PACKAGE_NAME}_WAS_INSTALLED) if(${${PACKAGE_NAME}_WAS_INSTALLED} EQUAL -1) @@ -764,17 +574,242 @@ function(tribits_add_library LIBRARY_NAME_IN) "The package ${PACKAGE_NAME} was not installed with ${PROJECT_NAME}!" " Please disable package ${PACKAGE_NAME} or install it.") endif() - global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) - endif() - # # Print the updates to the linkage variables - # if (${PROJECT_NAME}_VERBOSE_CONFIGURE) print_var(${PACKAGE_NAME}_LIBRARIES) endif() endfunction() +# +# ToDo:, above Deprecate and remove the usage of DEFINES! People should be +# putting defines into configured header files, not adding -D to +# the compile lines! + + +# Function that asserts that tribits_add_library() is called in the correct +# context +# +function(tribits_add_library_assert_correct_call_context) + + if (CURRENTLY_PROCESSING_SUBPACKAGE) + + # This is a subpackage being processed + + if(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_subpackage() before tribits_add_library()" + " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + endif() + + if(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_add_library() before " + " tribits_subpackage_postprocess() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + endif() + + else() + + # This is a package being processed + + if(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_package() or tribits_package_decl() before" + " tribits_add_library() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") + endif() + + if(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_add_library() before " + " tribits_package_postprocess() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") + endif() + + endif() + +endfunction() + + +# Assert correct DEPSLIB passed to tribits_add_library() +# +# NOTE: This accesses vars from the enclosed calling function +# tribits_add_library() but does not set any variables in that scope! +# +# We also need to make special considerations for test libraries since +# things need to be handled a little bit differently (but not much). In the +# case of test libraries, we need to also pull the test-only dependencies. +# In this case, we will always assume that we will add in the test +# libraries. +# +# ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we +# give enough time for people to clean up their codes. +# +function(tribits_add_library_assert_deplibs) + + foreach(depLib ${PARSE_DEPLIBS}) + + set(prefixedDepLib "${LIBRARY_NAME_PREFIX}${depLib}") + + # Is this lib already listed in ${PACKAGE_NAME}_LIBS? + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${prefixedDepLib}" FOUND_IDX) + if (FOUND_IDX GREATER -1) + set(depLibAlreadyInPkgLibs TRUE) + else() + set(depLibAlreadyInPkgLibs FALSE) + endif() + + # ${PREFIXED_LIB" is TESTONLY? + tribits_lib_is_testonly(${prefixedDepLib} depLibIsTestOnlyLib) + + # Check for valid usage (sorted by most common to least common) + if (depLibAlreadyInPkgLibs AND NOT depLibIsTestOnlyLib) # PARSE_TESTONLY=any + # The library being created here is a (regular or testonly) library + # dependent on a regular (non-TESTONLY) lib in this package. This is + # valid usage of DEPLIBS. There is no need to link this new lib to + # the package's upstream dependent package and TPL libraries because + # these are already linked into one of the of the package's own + # upstream libs. + elseif (PARSE_TESTONLY AND depLibAlreadyInPkgLibs AND NOT depLibIsTestOnlyLib) + # The library being created here is TESTONLY library and is + # dependent on a regular (non-TESTONLY) lib. This is valid usage of + # DEPLIBS. In the case of test-only libraries, we always link in + # the upstream libs. + elseif (PARSE_TESTONLY AND depLibIsTestOnlyLib) # any depLibAlreadyInPkgLibs + # The library being created here is TESTONLY library and is dependent + # on another TESTONLY library. This is valid usage of DEPLIBS. In + # this case we just hope that this package correctly specified a TEST + # dependency on the upstream package that owns this upstream TESTONLY + # library if it comes from an upstream package. + elseif (NOT PARSE_TESTONLY AND depLibIsTestOnlyLib) # any depLibAlreadyInPkgLibs + message(WARNING "WARNING: '${depLib}' in DEPLIBS is a TESTONLY lib" + " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." + " Such usage is deprecated (and this warning will soon become an error)!" + " If this is a regular library in this package or in an dependent upstream" + " package then TriBITS will link automatically to it. If you remove this and it" + " does not link, then you need to add a new package dependency to" + " this package's dependencies file" + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code + elseif (NOT depLibAlreadyInPkgLibs AND TARGET ${prefixedDepLib}) # any PARSE_TESTONLY + message(WARNING "WARNING: '${depLib}' in DEPLIBS is not" + " a lib in this package but is a library defined in the current" + " cmake project! Such usage is deprecated (and" + " will result in a configure error soon). If this is a library in" + " a dependent upstream package, then simply remove '${depLib}' from this list." + " TriBITS automatically links in libraries in upstream packages." + " If you remove '${depLib}' from DEPLIBS and your code does" + " not link, then you need to add a new package dependency to" + " this package's dependencies file" + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake.") + elseif (NOT depLibAlreadyInPkgLibs AND NOT TARGET ${prefixedDepLib} ) + message(WARNING "WARNING: '${depLib}' in DEPLIBS is not" + " a lib defined in the current cmake project! Such usage is deprecated (and" + " will result in a configure error soon). If this is an external" + " lib you are trying to link in, it should likely be handled as a TriBITS" + " TPL. Otherwise, it should be passed in through IMPORTEDLIBS. However," + " the only case we have found where IMPORTEDLIBS had to be used instead of" + " through a proper TriBITS TPL is the C math library 'm'.") + else() + message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY}," + " depLibAlreadyInPkgLibs=${depLibAlreadyInPkgLibs}," + " depLibIsTestOnlyLib=${depLibIsTestOnlyLib}, has" + " not yet been handled!") + endif() + + endforeach() + +endfunction() + + +# Assert correct IMPORTEDLIBS passed to tribits_add_library() +# +# NOTE: This accesses vars from the enclosed calling function +# tribits_add_library() but does not set any variables in that scope! +# +# ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we +# give enough time for people to clean up their codes. +# +function(tribits_add_library_assert_importedlibs) + foreach(importedLib ${PARSE_IMPORTEDLIBS}) + set(prefixedImportedLib "${LIBRARY_NAME_PREFIX}${importedLib}") + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${prefixedImportedLib}" + FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX) + tribits_lib_is_testonly(${prefixedImportedLib} importedLibIsTestOnlyLib) + if (importedLibIsTestOnlyLib) + message(WARNING "WARNING: '${importedLib}' in IMPORTEDLIBS is a TESTONLY lib" + " and it is illegal to pass in through IMPORTEDLIBS!" + " Such usage is deprecated (and this warning will soon become an error)!" + " Should '${importedLib}' instead be passed through DEPLIBS?") + # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code + elseif (FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX GREATER -1) + message(WARNING "WARNING: Lib '${importedLib}' in IMPORTEDLIBS is in" + " this package and is *not* an external lib!" + " Please move '${importedLib}' from the list IMPORTEDLIBS to DEPLIBS.") + elseif (TARGET ${prefixedImportedLib}) + message(WARNING "WARNING: Lib '${importedLib}' being passed through" + " IMPORTEDLIBS is *not* an external library but instead is a library" + " defined in this CMake project!" + " TriBITS takes care of linking against libraries in dependent upstream" + " packages. If you want to link to a library in an upstream" + " package then add the package name to the appropriate category" + " in this package's dependencies file: " + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake.") + endif() + endforeach() +endfunction() + + +# Determine lib and/or headers should be installed and if the package vars +# should be updated +# +# NOTE: This reads the parsed arguments (prefixed with ``PARSE_``) from the +# calling tribits_add_library() function from the enclosing scope. +# +function(tribits_add_library_determine_install_lib_and_or_headers + installLibOut installHeadersOut appendLibAndHeadersToPackageVarsOut + ) + + set(installLib ON) + set(installHeaders ON) + set(appendLibAndHeadersToPackageVars ON) + + if (PARSE_TESTONLY) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation hooks for this library" + " because 'TESTONLY' was passed in ...") + endif() + set(installLib OFF) + set(installHeaders OFF) + set(appendLibAndHeadersToPackageVars OFF) + elseif (PARSE_NO_INSTALL_LIB_OR_HEADERS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation hooks for this library" + " because 'NO_INSTALL_LIB_OR_HEADERS' was passed in ...") + endif() + set(installLib OFF) + set(installHeaders OFF) + elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND NOT BUILD_SHARED_LIBS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation of headers and libraries" + " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and" + " BUILD_SHARED_LIBS=FALSE ...") + endif() + set(installLib OFF) + set(installHeaders OFF) + elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND BUILD_SHARED_LIBS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation of headers but installing libraries" + " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and" + " BUILD_SHARED_LIBS=TRUE ...") + endif() + set(installHeaders OFF) + endif() + + set(${installLibOut} ${installLib} PARENT_SCOPE) + set(${installHeadersOut} ${installHeaders} PARENT_SCOPE) + set(${appendLibAndHeadersToPackageVarsOut} ${appendLibAndHeadersToPackageVars} + PARENT_SCOPE) + +endfunction() From 81f7f4456626e9507b1e7ccd09188954e8b827f4 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 13 May 2022 11:47:40 -0600 Subject: [PATCH 13/43] Add test for ADD_DIR_TO_NAME (#299) This also indirectly tests tribits_create_name_from_current_source_directory(), sort of. --- test/core/CMakeLists.txt | 2 +- .../core/TestingFunctionMacro_UnitTests.cmake | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 87446c066..659f59324 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -49,7 +49,7 @@ tribits_add_advanced_test( TestingFunctionMacro_UnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/TestingFunctionMacro_UnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 695" + "Final UnitTests Result: num_run = 696" "Final UnitTests Result: PASSED" ) diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index b22067f7a..8c5058b17 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -1304,6 +1304,23 @@ function(unittest_tribits_add_test_basic) "NAME;${PACKEXEN};COMMAND;/some/abs/path/${PACKEXEN}.exe;arg1" ) + + # + # ADD_DIR_TO_NAME + # + + message("Add a test with ADD_DIR_TO_NAME") + set(PACKAGE_SOURCE_DIR "/base/project/package/mypackage") + set(CMAKE_CURRENT_SOURCE_DIR "/base/project/package/mypackage/tests/unit-tests/test1") + global_set(TRIBITS_ADD_TEST_ADD_TEST_INPUT) + tribits_add_test( ${EXEN} ADD_DIR_TO_NAME ARGS arg1 ) + unittest_compare_const( + TRIBITS_ADD_TEST_ADD_TEST_INPUT + "NAME;${PACKAGE_NAME}_tests_unit-tests_test1_${EXEN};COMMAND;${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_tests_unit-tests_test1_${EXEN}.exe;arg1" + ) + unset(PACKAGE_SOURCE_DIR) + unset(CMAKE_CURRENT_SOURCE_DIR) + # # _EXTRA_ARGS # @@ -4555,4 +4572,4 @@ message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(695) +unittest_final_result(696) From f4752b3b4e36241a01bf00c1d73c8938f5a40a9e Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 13 May 2022 11:50:09 -0600 Subject: [PATCH 14/43] Rename local var to test tribits_create_name_from_current_source_directory() (#299) This will help catch the defect in tribits_create_name_from_current_source_directory() (to be fixed next). --- tribits/core/package_arch/TribitsAddTest.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tribits/core/package_arch/TribitsAddTest.cmake b/tribits/core/package_arch/TribitsAddTest.cmake index df5f25daf..1c355e30c 100644 --- a/tribits/core/package_arch/TribitsAddTest.cmake +++ b/tribits/core/package_arch/TribitsAddTest.cmake @@ -877,20 +877,20 @@ function(tribits_add_test EXE_NAME) # If requested create a modifier for the name that will be inserted between # the package name and the given name or exe_name for the test - set(DIRECTORY_NAME "") - if(PARSE_ADD_DIR_TO_NAME) - tribits_create_name_from_current_source_directory(DIRECTORY_NAME) - set(DIRECTORY_NAME "${DIRECTORY_NAME}_") + set(directoryName "") + if (PARSE_ADD_DIR_TO_NAME) + tribits_create_name_from_current_source_directory(directoryName) + set(directoryName "${directoryName}_") endif() #message("TRIBITS_ADD_TEST: ${EXE_NAME}: EXE_BINARY_NAME = ${EXE_BINARY_NAME}") if (PARSE_NAME) - set(TEST_NAME "${DIRECTORY_NAME}${PARSE_NAME}") + set(TEST_NAME "${directoryName}${PARSE_NAME}") elseif (PARSE_NAME_POSTFIX) - set(TEST_NAME "${DIRECTORY_NAME}${EXE_NAME}_${PARSE_NAME_POSTFIX}") + set(TEST_NAME "${directoryName}${EXE_NAME}_${PARSE_NAME_POSTFIX}") else() - set(TEST_NAME "${DIRECTORY_NAME}${EXE_NAME}") + set(TEST_NAME "${directoryName}${EXE_NAME}") endif() set(TEST_NAME "${PACKAGE_NAME}_${TEST_NAME}") From d7a81de6b0c4601ad5e635844e34ee4ef13f35f4 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 13 May 2022 11:16:17 -0600 Subject: [PATCH 15/43] Fix return arg in tribits_create_name_from_current_source_directory() (#299) Wen I did the refactoring of tribits_add_executable() to break out some subfunctions, it exposed a defect from the following commit 13 years ago: 654a4ef8843 " SUMMARY: Cmakify Intrepid" Author: Brent M. Perschbacher Date: Thu Apr 2 15:54:30 2009 +0000 (13 years ago) The problem was an incorrect setting of an output function argument: FUNCTION( PACKAGE_CREATE_NAME_FROM_CURRENT_SOURCE_DIRECTORY DIRECTORY_NAME ) SET(DIRECTORY_NAME "") ... SET(DIRECTORY_NAME ${DIRECTORY_NAME} PARENT_SCOPE) ENDFUNCTION() When I renamed the variable `DIRECTORY_NAME` in the parent scope, it broke this function (because DIRECTORY_NAME was no longer being used). (If you are going to just set a var in the parent scope unconditionally, why bother passing in some name in the function? Just another example of where inexperienced developers have problems with the strange CMake language.) NOTE: That function got renamed and moved around but I was able to track it along the CMake history. --- .../package_arch/TribitsAddExecutableTestHelpers.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake b/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake index 1121de2f3..81cfec436 100644 --- a/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake +++ b/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake @@ -96,8 +96,9 @@ function( tribits_process_comm_args ADD_SERIAL_FEATURE_OUT ADD_MPI_FEATURE_OUT endfunction() -function( tribits_create_name_from_current_source_directory DIRECTORY_NAME ) - set(DIRECTORY_NAME "") +function(tribits_create_name_from_current_source_directory directoryNameOut) + set(directoryName "") + #Get the unique part of the path for this test directory string(REGEX REPLACE ${PACKAGE_SOURCE_DIR} "" unique_dir_path ${CMAKE_CURRENT_SOURCE_DIR}) @@ -111,8 +112,7 @@ function( tribits_create_name_from_current_source_directory DIRECTORY_NAME ) # compatible with windows since they use a "\" instead of a "/" for # directory delimiters. I'm not sure how this will react if we encounter a # directory name with a space in it. - string(REGEX REPLACE "/" "_" DIRECTORY_NAME ${unique_dir_path}) + string(REGEX REPLACE "/" "_" directoryName "${unique_dir_path}") - #print_var(DIRECTORY_NAME) - set(DIRECTORY_NAME ${DIRECTORY_NAME} PARENT_SCOPE) + set(${directoryNameOut} "${directoryName}" PARENT_SCOPE) endfunction() From 24a2a8ed04364e0c5f328d4f28049ecc34b5cc1a Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 6 May 2022 16:34:20 -0600 Subject: [PATCH 16/43] tribits_add_executable(): Factor out functions and cleanup (#299) * Propertly set initial value of ${PARSE_ADDED_EXE_TARGET_NAME_OUT} at beginning * Factor out tribits_add_executable_assert_correct_call_context() * Factor out tribits_add_executable_is_skipped() * Factor out tribits_add_executable_adjust_exe_name() * Factor out tribits_add_executable_get_adjusted_sources_list() * Factor out tribits_add_executable_assert_testonlylibs() * Factor out tribits_add_executable_assert_importedlibs() * Factor out tribits_add_executable_convert_from_deplibs() * Other cleanup: - Rename some local vars - Move blocks of code around to group them locally - Add/improve some comments --- .../package_arch/TribitsAddExecutable.cmake | 408 +++++++++++------- .../TribitsCommonArgsHelpers.cmake | 5 +- 2 files changed, 250 insertions(+), 163 deletions(-) diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index f51c374d8..623f65a1e 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -335,11 +335,143 @@ function(tribits_add_executable EXE_NAME) message("") message("TRIBITS_ADD_EXECUTABLE: ${EXE_NAME} ${ARGN}") endif() - + + tribits_add_executable_assert_correct_call_context() + + # + # A) Parse the input arguments + # + + cmake_parse_arguments( + #prefix + PARSE + #options + "NOEXEPREFIX;NOEXESUFFIX;ADD_DIR_TO_NAME;INSTALLABLE" + #one_value_keywords + "" + #multi_value_keywords + "SOURCES;CATEGORIES;HOST;XHOST;HOSTTYPE;XHOSTTYPE;EXCLUDE_IF_NOT_TRUE;DIRECTORY;TESTONLYLIBS;IMPORTEDLIBS;DEPLIBS;COMM;LINKER_LANGUAGE;TARGET_DEFINES;DEFINES;ADDED_EXE_TARGET_NAME_OUT" + ${ARGN} + ) + + tribits_check_for_unparsed_arguments() + + # Executable not added by default! + if(PARSE_ADDED_EXE_TARGET_NAME_OUT) + set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} "" PARENT_SCOPE) + endif() + + set(EXE_BINARY_NAME ${EXE_NAME}) + tribits_add_executable_adjust_exe_name(EXE_BINARY_NAME) + + tribits_add_executable_is_skipped(skipAddExecutable) + if (skipAddExecutable) + return() + endif() + + tribits_add_executable_get_adjusted_sources_list(EXE_SOURCES) + + tribits_add_executable_assert_testonlylibs() + + tribits_add_executable_assert_importedlibs() + + tribits_add_executable_convert_from_deplibs() + + # + # B) Add the executable and set its properties + # + + if(${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("TRIBITS_ADD_EXECUTABLE: add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES})") + endif() + add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES}) + append_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${EXE_BINARY_NAME}) + + if(PARSE_ADDED_EXE_TARGET_NAME_OUT) + set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} ${EXE_BINARY_NAME} PARENT_SCOPE) + endif() + + if (PARSE_DEFINES) + message(WARNING "WARNING: Passing extra defines through 'DEFINES' ${PARSE_DEFINES}" + " is deprecated. Instead, pass them through 'TARGET_DEFINES'. The 'DEFINES'" + " argument was incorrectly implemented by calling add_definitions() which has" + " directory scope and not function scope as was documented. This resulted in" + " confusing behavior. If one wishes to set defines at the directly level," + " just call add_definitions() directly.") + add_definitions(${PARSE_DEFINES}) + endif() + + if (PARSE_TARGET_DEFINES) + target_compile_definitions(${EXE_BINARY_NAME} PUBLIC ${PARSE_TARGET_DEFINES}) + endif() + + if(PARSE_NOEXESUFFIX AND NOT WIN32) + set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX "") + else() + set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX + ${${PROJECT_NAME}_CMAKE_EXECUTABLE_SUFFIX}) + endif() + + tribits_set_linker_language_from_arg( ${EXE_BINARY_NAME} + "${PARSE_LINKER_LANGUAGE}" ) + + assert_defined(${PROJECT_NAME}_LINK_SEARCH_START_STATIC) + if (${PROJECT_NAME}_LINK_SEARCH_START_STATIC) + #message("${EXE_BINARY_NAME}: Adding property LINK_SEARCH_START_STATIC") + set_property(TARGET ${EXE_BINARY_NAME} PROPERTY LINK_SEARCH_START_STATIC 1) + endif() + + if(PARSE_DIRECTORY) + set_target_properties( ${EXE_BINARY_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${PARSE_DIRECTORY} ) + endif() + + set_property(TARGET ${EXE_BINARY_NAME} APPEND PROPERTY + LABELS ${PACKAGE_NAME}Exes ${PARENT_PACKAGE_NAME}Exes) + # - # Confirm that package and subpackage macros/functions have been called inteh correct order + # C) Link ${EXE_BINARY_NAME} to direct upstream libraries # - + + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) + foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) + if (TARGET ${depPkg}::all_libs) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) + endif() + endforeach() + foreach(testOnlyLib ${PARSE_TESTONLYLIBS}) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC + "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${testOnlyLib}") + endforeach() + + # + # D) Install if asked + # + + if(${PROJECT_NAME}_INSTALL_EXECUTABLES AND PARSE_INSTALLABLE) + install( + TARGETS ${EXE_BINARY_NAME} + EXPORT ${PROJECT_NAME} + DESTINATION ${${PROJECT_NAME}_INSTALL_RUNTIME_DIR} + COMPONENT ${PACKAGE_NAME} + ) + endif() + +endfunction() + + +# Assert tribits_add_executable() is called in the correct context +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_assert_correct_call_context) + if (CURRENTLY_PROCESSING_SUBPACKAGE) # This is a subpackage being processed @@ -374,138 +506,155 @@ function(tribits_add_executable EXE_NAME) endif() +endfunction() - # - # A) Parse the input arguments - # - cmake_parse_arguments( - #prefix - PARSE - #options - "NOEXEPREFIX;NOEXESUFFIX;ADD_DIR_TO_NAME;INSTALLABLE" - #one_value_keywords - "" - #multi_value_keywords - "SOURCES;CATEGORIES;HOST;XHOST;HOSTTYPE;XHOSTTYPE;EXCLUDE_IF_NOT_TRUE;DIRECTORY;TESTONLYLIBS;IMPORTEDLIBS;DEPLIBS;COMM;LINKER_LANGUAGE;TARGET_DEFINES;DEFINES;ADDED_EXE_TARGET_NAME_OUT" - ${ARGN} - ) +# Modify EXE_BINARY_NAME based in passed-in args +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_adjust_exe_name exeBinaryNameInOut) - tribits_check_for_unparsed_arguments() + set(exeBinaryName ${${exeBinaryNameInOut}}) + if (PARSE_ADD_DIR_TO_NAME) + set(dirName "") + tribits_create_name_from_current_source_directory(dirName) + set(exeBinaryName ${dirName}_${exeBinaryName}) + endif() - if(PARSE_ADDED_EXE_TARGET_NAME_OUT) - set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} PARENT_SCOPE) + if (DEFINED PACKAGE_NAME AND NOT PARSE_NOEXEPREFIX) + set(exeBinaryName ${PACKAGE_NAME}_${exeBinaryName}) endif() + set(${exeBinaryNameInOut} ${exeBinaryName} PARENT_SCOPE) - # - # B) Exclude building the test executable based on some criteria - # +endfunction() + + +# Check if to skip adding the executable based on different criteria +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_is_skipped skipAddExecutableOut) + + set(skipAddExecutable FALSE) set(ADD_THE_TEST FALSE) set(TEST_NAME ${EXE_NAME}) # For error message tribits_add_test_process_categories(ADD_THE_TEST) if (NOT ADD_THE_TEST) - return() + set(skipAddExecutable TRUE) endif() - set(TEST_NAME) + set(TEST_NAME "") set(ADD_THE_TEST FALSE) tribits_add_test_process_host_hosttype(ADD_THE_TEST) if (NOT ADD_THE_TEST) - return() + set(skipAddExecutable TRUE) endif() tribits_process_comm_args(ADD_SERIAL_EXE ADD_MPI_EXE ${PARSE_COMM}) if (NOT ADD_SERIAL_EXE AND NOT ADD_MPI_EXE) - return() - endif() - - # - # C) Add the executable - # - - set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") - - set (EXE_SOURCES) - set(EXE_BINARY_NAME ${EXE_NAME}) - - # If requested create a modifier for the name that will be inserted between - # the package name and the given name or exe_name for the test - if(PARSE_ADD_DIR_TO_NAME) - set(DIRECTORY_NAME "") - tribits_create_name_from_current_source_directory(DIRECTORY_NAME) - set(EXE_BINARY_NAME ${DIRECTORY_NAME}_${EXE_BINARY_NAME}) - endif() - - if(DEFINED PACKAGE_NAME AND NOT PARSE_NOEXEPREFIX) - set(EXE_BINARY_NAME ${PACKAGE_NAME}_${EXE_BINARY_NAME}) + set(skipAddExecutable TRUE) endif() - # Exclude the build if requested if (${EXE_BINARY_NAME}_EXE_DISABLE) message("-- " "${EXE_BINARY_NAME} EXE NOT being built due to ${EXE_BINARY_NAME}_EXE_DISABLE=" "'${${EXE_BINARY_NAME}_EXE_DISABLE}'") - return() + set(skipAddExecutable TRUE) endif() - # If exe is in subdirectory prepend that dir name to the source files + set(${skipAddExecutableOut} ${skipAddExecutable} PARENT_SCOPE) + +endfunction() + + +# Get adjusted list of source files +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_get_adjusted_sources_list exeSourcesOut) + + set(exeSources "") if(PARSE_DIRECTORY ) - foreach( SOURCE_FILE ${PARSE_SOURCES} ) - if(IS_ABSOLUTE ${SOURCE_FILE}) - set (EXE_SOURCES ${EXE_SOURCES} ${SOURCE_FILE}) + foreach( srcFile ${PARSE_SOURCES} ) + if(IS_ABSOLUTE ${srcFile}) + list(APPEND exeSources "${srcFile}") else() - set (EXE_SOURCES ${EXE_SOURCES} ${PARSE_DIRECTORY}/${SOURCE_FILE}) + list(APPEND exeSources "${PARSE_DIRECTORY}/${srcFile}") endif() endforeach( ) else() - foreach( SOURCE_FILE ${PARSE_SOURCES} ) - set (EXE_SOURCES ${EXE_SOURCES} ${SOURCE_FILE}) + foreach( srcFile ${PARSE_SOURCES} ) + list(APPEND exeSources "${srcFile}") endforeach( ) endif() + set(${exeSourcesOut} ${exeSources} PARENT_SCOPE) + +endfunction() + + +# Assert tribits_add_executable() TESTONLYLIBS +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_assert_testonlylibs) # Assert that TESTONLYLIBS only contains TESTONLY libs! - foreach(TESTONLYLIB ${PARSE_TESTONLYLIBS}) - set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${TESTONLYLIB}") - tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + foreach(testOnlyLib ${PARSE_TESTONLYLIBS}) + set(prefixedTestOnlyLib "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${testOnlyLib}") + tribits_lib_is_testonly(${prefixedTestOnlyLib} libIsTestOnlyLib) if (NOT libIsTestOnlyLib) - message(FATAL_ERROR "ERROR: '${TESTONLYLIB}' in TESTONLYLIBS not a TESTONLY lib!" + message(FATAL_ERROR "ERROR: '${testOnlyLib}' in TESTONLYLIBS not a TESTONLY lib!" " If this a regular library in this SE package or in an dependent upstream SE" " package then TriBITS will link automatically to it. If you remove this and it" " does not link, then you need to add a new SE package dependency to" " this SE package's dependencies file" " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") elseif(PARSE_INSTALLABLE) - message(FATAL_ERROR "ERROR: TESTONLY lib '${TESTONLYLIB}' not allowed with" + message(FATAL_ERROR "ERROR: TESTONLY lib '${testOnlyLib}' not allowed with" " INSTALLABLE executable! An INSTALLABLE executable can only depend on" " non-TESTONLY libraries! Otherwise, when shared libs are used, and" " TESTONLY library would not be installed and the installed executable" " would be unusable!" ) endif() endforeach() +endfunction() + + +# Assert tribits_add_executable() IMPORTEDLIBS +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_assert_importedlibs) # Assert that IMPORTEDLIBS are not TESTONLY libs are not regular package # libs! - foreach(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) - set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") - tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) + foreach(importedLib ${PARSE_IMPORTEDLIBS}) + set(prefixedImportedLib "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${importedLib}") + tribits_lib_is_testonly(${prefixedImportedLib} importedLibIsTestOnlyLib) if (libIsTestOnly) message(FATAL_ERROR - "ERROR: Lib '${IMPORTEDLIB}' being passed through" + "ERROR: Lib '${importedLib}' being passed through" " IMPORTEDLIBS is not allowed to be a TESTONLY lib!" " Use TESTONLYLIBS instead!" ) endif() - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" - FOUND_PREFIXED_LIB_IN_PKG_LIBRARIES_IDX) - if (NOT FOUND_PREFIXED_LIB_IN_PKG_LIBRARIES_IDX EQUAL -1) + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${prefixedImportedLib}" + foundPrefixedImportedLibInPkgLibs_idx) + if (NOT foundPrefixedImportedLibInPkgLibs_idx EQUAL -1) message(FATAL_ERROR - "ERROR: Lib '${IMPORTEDLIB}' in IMPORTEDLIBS is in" + "ERROR: Lib '${importedLib}' in IMPORTEDLIBS is in" " this SE package and is *not* an external lib!" " TriBITS takes care of linking against libs the current" - " SE package automatically. Please remove '${IMPORTEDLIB}' from IMPORTEDLIBS!") - elseif (TARGET ${PREFIXED_LIB}) + " SE package automatically. Please remove '${importedLib}' from IMPORTEDLIBS!") + elseif (TARGET ${prefixedImportedLib}) message(FATAL_ERROR - "ERROR: Lib '${IMPORTEDLIB}' being passed through" + "ERROR: Lib '${importedLib}' being passed through" " IMPORTEDLIBS is *not* an external library but instead is a library" " defined in this CMake project!" " TriBITS takes care of linking against libraries in dependent upstream" @@ -516,109 +665,44 @@ function(tribits_add_executable EXE_NAME) endif() endforeach() +endfunction() + + +# Convert from tribits_add_executable() DEPLIBS to IMPORTEDLIBS and TESTONLYLIBS +# +# NOTE: This is a macro as it updates local variables in the +# tribits_add_executable() scope! +# +macro(tribits_add_executable_convert_from_deplibs) + # Convert from old DEPLIBS to TESTONLYLIBS and IMPORTEDLIBS - foreach(DEPLIB ${PARSE_DEPLIBS}) - set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${DEPLIB}") - tribits_lib_is_testonly(${PREFIXED_LIB} libIsTestOnlyLib) - if (libIsTestOnlyLib) - message(WARNING "WARNING: Passing TESTONLY lib '${DEPLIB}' through DEPLIBS" + foreach(depLib ${PARSE_DEPLIBS}) + set(prefixedDepLib "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${depLib}") + tribits_lib_is_testonly(${prefixedDepLib} depLibIsTestOnlyLib) + if (depLibIsTestOnlyLib) + message(WARNING "WARNING: Passing TESTONLY lib '${depLib}' through DEPLIBS" " is deprecated! Instead, please pass through TESTONLYLIBS instead!" " DEPLIBS is deprecated!") - list(APPEND PARSE_TESTONLYLIBS ${DEPLIB}) - elseif (TARGET ${PREFIXED_LIB}) - message(WARNING "WARNING: Passing non-TESTONLY lib '${DEPLIB}' through DEPLIBS" - " is deprecated! The library '${DEPLIB}' appears to be a" + list(APPEND PARSE_TESTONLYLIBS ${depLib}) + elseif (TARGET ${prefixedDepLib}) + message(WARNING "WARNING: Passing non-TESTONLY lib '${depLib}' through DEPLIBS" + " is deprecated! The library '${depLib}' appears to be a" " library defined in this CMake project." " TriBITS takes care of linking against libraries in dependent upstream" - " SE packages. Therefore, please remove '${DEPLIB}' from this list." + " SE packages. Therefore, please remove '${depLib}' from this list." " If you want to link to a library from an upstream SE" " package, then add the SE package name to the appropriate category" " in this SE package's dependencies file: " " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + # ToDo: Convert the above 'WARNING' to 'SEND_ERROR' else() - message(WARNING "WARNING: Passing external lib '${DEPLIB}' through" + message(WARNING "WARNING: Passing external lib '${depLib}' through" " DEPLIBS is deprecated! Instead, pass through IMPORTEDLIBS!" " DEPLIBS is deprecated!" " Please note that only external libs are allowed to be passed through" " IMPORTEDLIBS.") - list(APPEND PARSE_IMPORTEDLIBS ${DEPLIB}) + list(APPEND PARSE_IMPORTEDLIBS ${depLib}) endif() endforeach() - if (PARSE_DEFINES) - message(WARNING "WARNING: Passing extra defines through 'DEFINES' ${PARSE_DEFINES}" - " is deprecated. Instead, pass them through 'TARGET_DEFINES'. The 'DEFINES'" - " argument was incorrectly implemented by calling add_definitions() which has" - " directory scope and not function scope as was documented. This resulted in" - " confusing behavior. If one wishes to set defines at the directly level," - " just call add_definitions() directly.") - add_definitions(${PARSE_DEFINES}) - endif() - - if(${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("TRIBITS_ADD_EXECUTABLE: add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES})") - endif() - add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES}) - append_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${EXE_BINARY_NAME}) - - if(PARSE_ADDED_EXE_TARGET_NAME_OUT) - set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} ${EXE_BINARY_NAME} PARENT_SCOPE) - endif() - - if (PARSE_TARGET_DEFINES) - target_compile_definitions(${EXE_BINARY_NAME} PUBLIC ${PARSE_TARGET_DEFINES}) - endif() - - if(PARSE_NOEXESUFFIX AND NOT WIN32) - set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX "") - else() - set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX - ${${PROJECT_NAME}_CMAKE_EXECUTABLE_SUFFIX}) - endif() - - tribits_set_linker_language_from_arg( ${EXE_BINARY_NAME} - "${PARSE_LINKER_LANGUAGE}" ) - - # - # Link ${EXE_BINARY_NAME} to direct upstream libraries - # - - target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) - foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() - endforeach() - foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() - endforeach() - foreach(testOnlyLib ${PARSE_TESTONLYLIBS}) - target_link_libraries(${EXE_BINARY_NAME} PUBLIC - "${LIBRARY_NAME_PREFIX}${testOnlyLib}") - endforeach() - - assert_defined(${PROJECT_NAME}_LINK_SEARCH_START_STATIC) - if (${PROJECT_NAME}_LINK_SEARCH_START_STATIC) - #message("${EXE_BINARY_NAME}: Adding property LINK_SEARCH_START_STATIC") - set_property(TARGET ${EXE_BINARY_NAME} PROPERTY LINK_SEARCH_START_STATIC 1) - endif() - - if(PARSE_DIRECTORY) - set_target_properties( ${EXE_BINARY_NAME} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${PARSE_DIRECTORY} ) - endif() - - set_property(TARGET ${EXE_BINARY_NAME} APPEND PROPERTY - LABELS ${PACKAGE_NAME}Exes ${PARENT_PACKAGE_NAME}Exes) - - if(${PROJECT_NAME}_INSTALL_EXECUTABLES AND PARSE_INSTALLABLE) - install( - TARGETS ${EXE_BINARY_NAME} - EXPORT ${PROJECT_NAME} - DESTINATION ${${PROJECT_NAME}_INSTALL_RUNTIME_DIR} - COMPONENT ${PACKAGE_NAME} - ) - endif() -endfunction() +endmacro() diff --git a/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake b/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake index a6370f153..9aaffca98 100644 --- a/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake +++ b/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake @@ -55,7 +55,9 @@ function(tribits_set_linker_language_from_arg TARGET_NAME_IN LINKER_LANGUAGE_I if (LINKER_LANGUAGE) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE OR TRIBITS_SET_LINKER_LANGUAGE_FROM_ARG_DEBUG_DUMP) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE + OR TRIBITS_SET_LINKER_LANGUAGE_FROM_ARG_DEBUG_DUMP + ) message("-- Setting linker language for target '${TARGET_NAME_IN}' to '${LINKER_LANGUAGE}'") endif() @@ -63,6 +65,7 @@ function(tribits_set_linker_language_from_arg TARGET_NAME_IN LINKER_LANGUAGE_I TARGET ${TARGET_NAME_IN} APPEND PROPERTY LINKER_LANGUAGE ${LINKER_LANGUAGE} ) + endif() endfunction() From dcb616f6f1d639ec82a1db50367fac277a9b0f6f Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 6 May 2022 19:16:13 -0600 Subject: [PATCH 17/43] Remove comments about being hard to maintain (#299) With the switch to modern CMake, this is much simpler --- .../package_arch/TribitsAddExecutable.cmake | 6 ----- .../core/package_arch/TribitsAddLibrary.cmake | 6 ----- .../package_arch/TribitsPackageMacros.cmake | 27 ------------------- 3 files changed, 39 deletions(-) diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index 623f65a1e..fdeff3a26 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -49,13 +49,7 @@ include(PrintVar) include(AppendSet) include(CMakeParseArguments) -### -### WARNING: See "NOTES TO DEVELOPERS" at the bottom of the file -### TribitsPackageMacros.cmake before trying to change anything in this file! -### - -# # @FUNCTION: tribits_add_executable() # # Function used to create an executable (typically for a test or example), diff --git a/tribits/core/package_arch/TribitsAddLibrary.cmake b/tribits/core/package_arch/TribitsAddLibrary.cmake index ede40b0bf..bfb313aa7 100644 --- a/tribits/core/package_arch/TribitsAddLibrary.cmake +++ b/tribits/core/package_arch/TribitsAddLibrary.cmake @@ -51,12 +51,6 @@ include(TribitsReportInvalidTribitsUsage) include(SetAndIncDirs) -### -### WARNING: See "NOTES TO DEVELOPERS" at the bottom of the file -### TribitsPackageMacros.cmake! -### - - # @FUNCTION: tribits_add_library() # # Function used to add a CMake library and target using ``add_library()`` and diff --git a/tribits/core/package_arch/TribitsPackageMacros.cmake b/tribits/core/package_arch/TribitsPackageMacros.cmake index 977f91d0d..cee06a2d8 100644 --- a/tribits/core/package_arch/TribitsPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsPackageMacros.cmake @@ -61,11 +61,6 @@ include(TribitsCopyFilesToBinaryDir) include(TribitsReportInvalidTribitsUsage) -### -### WARNING: See "NOTES TO DEVELOPERS" at the bottom of file! -### - - # # Utility macros # @@ -926,25 +921,3 @@ macro(tribits_process_subpackages) set(${PACKAGE_NAME}_TRIBITS_PROCESS_SUBPACKAGES_CALLED TRUE) endmacro() - - -################################################################## -# -# NOTES TO DEVELOPERS -# -# Don't even attempt to touch the logic that goes into setting up and -# modifying the variables: -# -# ${PACKAGE_NAME}_INCLUDE_DIRS -# ${PACKAGE_NAME}_LIBRARY_DIRS -# ${PACKAGE_NAME}_LIBRARIES -# ${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES_TO_INSTALL -# ${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES -# ${PARENT_PACKAGE_NAME}_LIB_TARGETS -# ${PARENT_PACKAGE_NAME}_ALL_TARGETS -# -# without carefully studying the documentation in README.DEPENDENCIES and then -# carefully studying all of the code and issues that modify these variables! -# -# ToDo: Write some good unit tests that pin down the behavior of all of this! -# From cb6bdbd0c762af5f22ea02b41d83ad80b3503292 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 6 May 2022 20:52:59 -0600 Subject: [PATCH 18/43] Remove all obsolete doc references to include dirs and lib dirs (#299) I also removed a few more code references to these vars as they should not be needed anymore. --- .../package_arch/TribitsAddExecutable.cmake | 14 +---------- .../core/package_arch/TribitsAddLibrary.cmake | 8 ++----- .../TribitsProcessEnabledTpl.cmake | 12 ---------- ...itsSystemDataStructuresMacrosFunctions.rst | 23 ------------------- tribits/doc/guides/TribitsGuidesBody.rst | 20 ++++++++-------- 5 files changed, 12 insertions(+), 65 deletions(-) diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index fdeff3a26..312558cbe 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -175,19 +175,7 @@ include(CMakeParseArguments) # package or any upstream SE packages can *NOT* be listed! TriBITS # automatically links non ``TESTONLY`` libraries in this package and # upstream packages to the executable. The only libraries that should be -# listed in this argument are either ``TESTONLY`` libraries. The include -# directories for each test-only library will automatically be added -# using:: -# -# include_directories(${_INCLUDE_DIRS}) -# -# where ``_INCLUDE_DIRS`` was set by:: -# -# tribits_add_library( ... TESTONLY ...) -# -# Therefore, to link to a defined ``TESTONLY`` library in any upstream -# enabled package, one just needs to pass in the library name through -# ``TESTONLYLIBS ... ...`` and that is it! +# listed in this argument are either ``TESTONLY`` libraries. # # ``IMPORTEDLIBS ...`` # diff --git a/tribits/core/package_arch/TribitsAddLibrary.cmake b/tribits/core/package_arch/TribitsAddLibrary.cmake index bfb313aa7..531307a31 100644 --- a/tribits/core/package_arch/TribitsAddLibrary.cmake +++ b/tribits/core/package_arch/TribitsAddLibrary.cmake @@ -258,12 +258,8 @@ include(SetAndIncDirs) # # The function ``tribits_add_library()`` will grab the list of all of the # include directories in scope from prior calls to ``include_directories()`` -# and will append these to the variable ``${PACKAGE_NAME}_INCLUDE_DIRS``. -# This list of include directories is exported to downstream SE packages so -# they appear on the compile lines of all downstream object file compiles. -# This is a critical part of the "glue" that allows TriBITS packages to link -# up automatically (just by clearing dependencies in -# `/cmake/Dependencies.cmake`_ files). +# and will add this to the generated library target using +# ``target_link_libraries()`` so that they get propagated downstream as well. # # .. _Install Targets (tribits_add_library()): # diff --git a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake index 71429910b..d90ae1563 100644 --- a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake +++ b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake @@ -76,22 +76,14 @@ function(tribits_process_enabled_tpl TPL_NAME) if (${PROJECT_NAME}_VERBOSE_CONFIGURE) print_var(${TPL_NAME}_FINDMOD) endif() - #print_var(${TPL_NAME}_FINDMOD) if (${TPL_NAME}_FINDMOD STREQUAL "TRIBITS_PKG") set(TPL_${TPL_NAME}_PARTS_ALREADY_SET FALSE) # ToDo: Take out? if (NOT TPL_${TPL_NAME}_PARTS_ALREADY_SET) find_package(${TPL_NAME} CONFIG REQUIRED) - #print_var(${TPL_NAME}_INCLUDE_DIRS) - #print_var(${TPL_NAME}_LIBRARIES) - tribits_standardize_abs_paths(THIS_TPL_INCLUDE_DIRS - ${${TPL_NAME}_INCLUDE_DIRS} ${${TPL_NAME}_TPL_INCLUDE_DIRS}) - global_set(TPL_${TPL_NAME}_INCLUDE_DIRS ${THIS_TPL_INCLUDE_DIRS}) global_set(TPL_${TPL_NAME}_LIBRARIES "${${TPL_NAME}_LIBRARIES}" "${${TPL_NAME}_TPL_LIBRARIES}") global_set(TPL_${TPL_NAME}_PARTS_ALREADY_SET TRUE) endif() - #print_var(TPL_${TPL_NAME}_INCLUDE_DIRS) - #print_var(TPL_${TPL_NAME}_LIBRARIES) return() elseif (IS_ABSOLUTE ${${TPL_NAME}_FINDMOD}) #message("${${TPL_NAME}_FINDMOD} is absolute!") @@ -158,11 +150,7 @@ function(tribits_process_enabled_tpl TPL_NAME) endif() # Assert that the TPL correctly defined all of these variables - assert_defined(TPL_${TPL_NAME}_INCLUDE_DIRS) assert_defined(TPL_${TPL_NAME}_LIBRARIES) - assert_defined(TPL_${TPL_NAME}_LIBRARY_DIRS) - # ToDo: Make TPL_${TPL_NAME}_LIBRARY_DIRS go away. It is not needed for - # anything. # Generate the ConfigVersion.cmake file if it has not been # created yet and add install targets for Config[Version].cmake diff --git a/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst b/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst index f553f0e6e..e3183fd22 100644 --- a/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst +++ b/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst @@ -389,29 +389,6 @@ targets as part of #299. The following global internal cache variables are used to communicate the required header directory paths and libraries needed to build and link against a given package's capabilities: - - ``${PACKAGE_NAME}_INCLUDE_DIRS`` - - Defines a list of include paths needed to find all of the headers needed - to compile client code against this (sub)packages sources and it's - upstream packages and TPL sources. This variable is used whenever - building downstream code including downstream libraries or executables in - the same package, or libraries or executables in downstream packages. It - is also used to list out in ${PACKAGE_NAME}Config.cmake files. - - ToDo: Look to eliminate this variable and just add it to the package's - library targets with target_include_directories(). - - ToDo: Split off ${PACKAGE_NAME}_TPL_INCLUDE_DIRS - - ``${PACKAGE_NAME}_LIBRARY_DIRS`` - - Defines as list of the link directories needed to find all of the - libraries for this packages and it's upstream packages and TPLs. Adding - these library directories to the CMake link line is unnecessary and would - cause link-line too long errors on some systems. Instead, this list of - library directories is used when creating ${PACKAGE_NAME}Config.cmake - files. ``${PACKAGE_NAME}_LIBRARIES`` diff --git a/tribits/doc/guides/TribitsGuidesBody.rst b/tribits/doc/guides/TribitsGuidesBody.rst index 6a6e62faa..fd4094662 100644 --- a/tribits/doc/guides/TribitsGuidesBody.rst +++ b/tribits/doc/guides/TribitsGuidesBody.rst @@ -2185,12 +2185,11 @@ downstream dependencies`_). For each TPL referenced in a `/TPLsList.cmake`_ file using the macro `tribits_repository_define_tpls()`_, there must exist a file, typically called -``FindTPL${TPL_NAME}.cmake``, that once processed, produces the variables -``TPL_${TPL_NAME}_LIBRARIES`` and ``TPL_${TPL_NAME}_INCLUDE_DIRS``. Most -``FindTPL${TPL_NAME}.cmake`` files just use the function -`tribits_tpl_find_include_dirs_and_libraries()`_ the define the TriBITS TPL. -A simple example of such a file is the common TriBITS ``FindTPLPETSC.cmake`` -module which is currently: +``FindTPL${TPL_NAME}.cmake``, that once processed, produces the target +```${TPL_NAME}::all_libs``. Most ``FindTPL${TPL_NAME}.cmake`` files just use +the function `tribits_tpl_find_include_dirs_and_libraries()`_ to define the +TriBITS TPL. A simple example of such a file is the common TriBITS +``FindTPLPETSC.cmake`` module which is currently: .. include:: ../../common_tpls/FindTPLPETSC.cmake :literal: @@ -2253,11 +2252,10 @@ override and specialize how a TPL's include directories and libraries are determined. However, note that the TriBITS system does not require the usage of the function ``tribits_tpl_find_include_dirs_and_libraries()`` and does not even care about the TPL module name ``FindTPL${TPL_NAME}.cmake``. All that is -required is that some CMake file fragment exist that once included, will -define the variables ``${TPL_NAME}_LIBRARIES`` and -``${TPL_NAME}_INCLUDE_DIRS``. However, to be user friendly, such a CMake file -should respond to the same variables as accepted by the standard -``tribits_tpl_find_include_dirs_and_libraries()`` function. +required is that some CMake file fragment exist such that, once included, will +define the target ``${TPL_NAME}::all_libs``. However, to be user friendly, +such a CMake file should respond to the same variables as accepted by the +standard ``tribits_tpl_find_include_dirs_and_libraries()`` function. The core variables related to an enabled TPL are ``${TPL_NAME}_LIBRARIES``, ``${TPL_NAME}_INCLUDE_DIRS``, and ``${TPL_NAME}_TESTGROUP`` as defined in From d4303762cc2be6a35606826b5d8875606e652cc5 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 13 May 2022 07:54:47 -0600 Subject: [PATCH 19/43] TribitsExampleProject2: Remove hacked dependencies on indirect TPLs (#63, #299) This shows that the new TPL dependencies actually work to bring in indirect TPL dependencies and create the proper link lines. If you comment out the `set(_LIB_ENABLED_DEPENDENCIES ...)` statements in `TribitsExampleProject2/TPLsList.cmake`, you will see failing tests. --- .../ExamplesUnitTests/TribitsExampleProject2_Tests.cmake | 8 -------- .../packages/package2/cmake/Dependencies.cmake | 1 - .../packages/package3/cmake/Dependencies.cmake | 2 -- 3 files changed, 11 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake index 4d932686a..e51c87a7c 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake @@ -208,9 +208,7 @@ function(TribitsExampleProject2_find_tpl_parts sharedOrStatic findingTplsMethod) "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 ON[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 ON[)]" - "set[(]Package3_ENABLE_Tpl3 ON[)]" TEST_2 MESSAGE "Build verbose to check the link lines" @@ -253,9 +251,7 @@ function(TribitsExampleProject2_find_tpl_parts sharedOrStatic findingTplsMethod) "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 ON[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 ON[)]" - "set[(]Package3_ENABLE_Tpl3 ON[)]" ${ENV_PATH_HACK_FOR_TPL1_${sharedOrStatic}_ARG} @@ -345,9 +341,7 @@ function(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls sharedO "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 OFF[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 OFF[)]" - "set[(]Package3_ENABLE_Tpl3 OFF[)]" TEST_2 MESSAGE "Build verbose to check the link line of Package3" @@ -378,9 +372,7 @@ function(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls sharedO "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 OFF[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 OFF[)]" - "set[(]Package3_ENABLE_Tpl3 OFF[)]" ADDED_TEST_NAME_OUT ${testNameBase}_NAME ) diff --git a/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake b/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake index 7351d3a19..46c260a26 100644 --- a/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake @@ -1,5 +1,4 @@ tribits_package_define_dependencies( LIB_REQUIRED_PACKAGES Package1 LIB_OPTIONAL_TPLS Tpl3 - Tpl2 Tpl1 # ToDo: Remove this line once TPL dependencies are implemented! (#299) ) diff --git a/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake b/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake index bde6d5305..6e9a0e1e4 100644 --- a/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake @@ -2,7 +2,5 @@ tribits_package_define_dependencies( LIB_REQUIRED_PACKAGES Package1 LIB_OPTIONAL_PACKAGES Package2 LIB_REQUIRED_TPLS Tpl2 - Tpl1 # ToDo: Remove this line once TPL dependencies are implemented! (#299) LIB_OPTIONAL_TPLS Tpl4 - Tpl3 # ToDo: Remove this line once TPL dependencies are implemented! (#299) ) From 7ef19a19e0870e28f4d705636313ce100fc4bf94 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 13 May 2022 07:42:42 -0600 Subject: [PATCH 20/43] Update changelog for final switch to modern CMake targets (#299) --- tribits/CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tribits/CHANGELOG.md b/tribits/CHANGELOG.md index 27e339c0f..0235119ea 100644 --- a/tribits/CHANGELOG.md +++ b/tribits/CHANGELOG.md @@ -4,6 +4,25 @@ ChangeLog for TriBITS ## 2022-05-16: +* **Changed:** All compliant external packages (TPLs) must now set the + imported target `::all_libs` in their `FindTPL.cmake` + files instead of the variables `TPL__INCLUDE` and + `TPL__LIBRARIES`. + +* **Changed:** The project-level variables `_INCLUDE_DIRS`, + `_TPL_INCLUDE_DIRS`, `_LIBRARY_DIRS` and + `_TPL_LIBRARY_DIRS` from the file `Config.cmake` and + package-level variables `_INCLUDE_DIRS`, + `_TPL_INCLUDE_DIRS`, `_LIBRARY_DIRS` and + `_TPL_LIBRARY_DIRS` from the installed files + `Config.cmake` are now set to empty. Downstream CMake projects + will need to link against the exported project-level target + `::all_libs` or `::all_selected_libs` or the package-level + targets `::all_libs` in order to get the list of include + directories that are propagated through those targets by CMake. + +## 2022-05-16: + * **Added:** The function `tribits_add_advanced_test(`) now correctly accepts a list of regexes for `PASS_REGULAR_EXPRESSION` and `FAIL_REGULAR_EXPRESSION` and behave the same as the raw CTest properties of From 6ddc67ab17e88ba3da94da5f3e4b0740e150e2a6 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 17 May 2022 09:47:28 -0600 Subject: [PATCH 21/43] Add changelog note about no longer setting dir property INCLUDE_DIRECTORIES (#299) --- tribits/CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tribits/CHANGELOG.md b/tribits/CHANGELOG.md index 0235119ea..5533079be 100644 --- a/tribits/CHANGELOG.md +++ b/tribits/CHANGELOG.md @@ -21,6 +21,16 @@ ChangeLog for TriBITS targets `::all_libs` in order to get the list of include directories that are propagated through those targets by CMake. +* **Changed:** The function `tribits_add_library()` no longer sets the + directory property `INCLUDE_DIRECTORIES` and instead passes include + directory information between targets directly using the + `INTERFACE_INCLUDE_DIRECTORIES` target property. This may result in + situations where include directories were getting set through the directory + property `INCLUDE_DIRECTORIES` and getting picked up in the builds of + targets that lacked the proper library dependencies. Therefore, this is + technically a break in backward compatibility, but not for well-formed + TriBITS projects. + ## 2022-05-16: * **Added:** The function `tribits_add_advanced_test(`) now correctly accepts From a9cdb796666d28d58fafb4fa50d4e500d695453c Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 17 May 2022 10:50:26 -0600 Subject: [PATCH 22/43] Add changelog note for setting _ENABLE_ for required deps (#63, #299) --- tribits/CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tribits/CHANGELOG.md b/tribits/CHANGELOG.md index 5533079be..63761777b 100644 --- a/tribits/CHANGELOG.md +++ b/tribits/CHANGELOG.md @@ -31,6 +31,18 @@ ChangeLog for TriBITS technically a break in backward compatibility, but not for well-formed TriBITS projects. +* **Changed:** Variables `${PACKAGE_NAME}_ENABLE_` are now set to + `TRUE` for required upstream internal and external packages/TPLs `` + (in order to simplify internal TriBITS logic). However, a side-effect of + this change is that CMake code that was ifed out with an `if + (${PACKAGE_NAME}_ENABLE_)` statement (because that variable was not + defined and therefore defaults to `FLASE`) for a required upstream + dependency `` will now be enabled. (This mistake can happen when an + optional dependency `` is changed to a required dependency but the + `if()` statements based on `${PACKAGE_NAME}_ENABLE_` are not + removed. Well-formed TriBITS projects and packages should not experience + this problem or notice any change.) + ## 2022-05-16: * **Added:** The function `tribits_add_advanced_test(`) now correctly accepts From b1895f74bb85a801545c94eb4bf21e72798156c0 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 25 May 2022 19:10:45 -0600 Subject: [PATCH 23/43] Handle _EXTRA_LINK_FLAGS as extra TPL that everything depends on (#299) It was amazing how little code this required. I added a pretty decent test to show this puts the libraries at the end of every link link. This also removes the last remnants of the 'last_lib' library. --- .../TribitsExampleProject_Tests.cmake | 59 ++++++++++++++++++ .../common_tpls/FindTPLProjectLastLib.cmake | 9 +++ .../core/package_arch/TribitsAddLibrary.cmake | 1 - .../package_arch/TribitsGlobalMacros.cmake | 61 +++++++++++++------ 4 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 tribits/common_tpls/FindTPLProjectLastLib.cmake diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 0ba33a199..1bcb33cf0 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -2895,3 +2895,62 @@ tribits_add_advanced_test( TribitsExampleProject_compiler_flags # NOTE: Above, we had to switch to Ninja and 'cmake --build . -v [--target # ] in order to get verbose output when run inside of a cmake -S # script with CMake 3.23-rc2. Not sure why this is but this is better anyway. + + +################################################################################### + + +tribits_add_advanced_test( TribitsExampleProject_extra_link_flags + OVERALL_WORKING_DIRECTORY TEST_NAME + OVERALL_NUM_MPI_PROCS 1 + EXCLUDE_IF_NOT_TRUE IS_REAL_LINUX_SYSTEM ${PROJECT_NAME}_ENABLE_Fortran + NINJA_EXE + + TEST_0 + MESSAGE "Configure by setting _EXTRA_LINK_FLAGS" + CMND ${CMAKE_COMMAND} + ARGS + -GNinja + -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DTribitsExProj_ENABLE_Fortran=ON + -DTribitsExProj_ENABLE_TESTS=ON + -DTribitsExProj_ENABLE_ALL_PACKAGES=ON + -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON + -DTPL_ENABLE_SimpleTpl=ON + -DSimpleTpl_INCLUDE_DIRS=${SimpleTpl_install_STATIC_DIR}/install/include + -DSimpleTpl_LIBRARY_DIRS=${SimpleTpl_install_STATIC_DIR}/install/lib + -DTribitsExProj_EXTRA_LINK_FLAGS="-lgfortran -ldl" + ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject + PASS_REGULAR_EXPRESSION_ALL + "Processing enabled TPL: TribitsExProjTribitsLastLib" + "TPL_TribitsExProjTribitsLastLib_LIBRARIES='-lgfortran[;]-ldl'" + ALWAYS_FAIL_ON_NONZERO_RETURN + # NOTE: Above, we use two libraries to ensure that the logic in TriBITS can + # handle these correctly. + + TEST_1 + MESSAGE "Build verbose to check the link lines" + CMND ${CMAKE_COMMAND} ARGS --build . -v + PASS_REGULAR_EXPRESSION_ALL + "-o packages/simple_cxx/src/simplecxx-helloworld .* packages/simple_cxx/src/libsimplecxx.a +${SimpleTpl_install_STATIC_DIR}/install/lib/libsimpletpl.a +-lgfortran +-ldl" + "-o packages/mixed_lang/test/MixedLang_RayTracerTests.exe packages/mixed_lang/src/libmixedlang.a +-lgfortran +-ldl" + "-o packages/with_subpackages/c/c_util +packages/with_subpackages/b/src/libpws_b.a +packages/with_subpackages/a/libpws_a.a +packages/simple_cxx/src/libsimplecxx.a +${SimpleTpl_install_STATIC_DIR}/install/lib/libsimpletpl.a + packages/mixed_lang/src/libmixedlang.a +-lgfortran +-ldl" + ALWAYS_FAIL_ON_NONZERO_RETURN + + ADDED_TEST_NAME_OUT TribitsExampleProject_extra_link_flags_NAME + ) + # NOTE: The above test ensures that _EXTRA_LINK_FLAGS is handled + # correctly. Note that the package MixedLang has no TPL dependencies so + # that fact that the extra libs gets tacked on to the end proves that they + # get sets even for packages without TPLs. The package SimpleCxx that + # depends on SimpleTPL proves that the extra libs get tacked on after the + # TPL's libs. Also, the fact that the extra libs are tacked on at the very + # end of the link lik for the 'c_util' exec shows that CMake is respecting + # the dependency of libmixedlang.a on these extra libs. This test also + # shows that TriBITS and CMake do a good job of not listing the same libs + # more than once. + +if (TribitsExampleProject_extra_link_flags_NAME) + set_tests_properties(${TribitsExampleProject_extra_link_flags_NAME} + PROPERTIES DEPENDS ${SimpleTpl_install_STATIC_NAME} ) +endif() diff --git a/tribits/common_tpls/FindTPLProjectLastLib.cmake b/tribits/common_tpls/FindTPLProjectLastLib.cmake new file mode 100644 index 000000000..97d052978 --- /dev/null +++ b/tribits/common_tpls/FindTPLProjectLastLib.cmake @@ -0,0 +1,9 @@ +# This is a hack to handle the ${PROJECT_NAME}_EXTRA_LINK_FLAGS options as a +# TPL that every downstream TPL and package will depend on. + +separate_arguments(TPL_${PROJECT_NAME}TribitsLastLib_LIBRARIES NATIVE_COMMAND + "${${PROJECT_NAME}_EXTRA_LINK_FLAGS}") + +tribits_tpl_find_include_dirs_and_libraries( ${PROJECT_NAME}TribitsLastLib + REQUIRED_LIBS_NAMES NEVER_USED + ) diff --git a/tribits/core/package_arch/TribitsAddLibrary.cmake b/tribits/core/package_arch/TribitsAddLibrary.cmake index 531307a31..018638e73 100644 --- a/tribits/core/package_arch/TribitsAddLibrary.cmake +++ b/tribits/core/package_arch/TribitsAddLibrary.cmake @@ -483,7 +483,6 @@ function(tribits_add_library LIBRARY_NAME_IN) target_link_libraries(${LIBRARY_NAME} PUBLIC "${importedLib}") endforeach() - # ToDo: #299: Above, Handle 'last_lib' from ${PROJECT_NAME}_EXTRA_LINK_FLAGS! # ToDo: #63: Above, allow for other link visibilities other than 'PUBLIC'! if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 2ae4211b6..860e75c65 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -1454,12 +1454,54 @@ macro(tribits_adjust_and_print_package_dependencies) tribits_print_enables_before_adjust_package_enables() tribits_adjust_package_enables() tribits_print_enables_after_adjust_package_enables() + tribits_handle_project_extra_link_flags_as_a_tpl() tribits_set_up_enabled_only_dependencies() tribits_config_code_stop_timer(ADJUST_PACKAGE_DEPS_TIME_START_SECONDS "\nTotal time to adjust package and TPL enables") endmacro() +# Tack on ${PROJECT_NAME}_EXTRA_LINK_LIBS as a TPL that every downstream +# external and internal package depends on +# +macro(tribits_handle_project_extra_link_flags_as_a_tpl) + + if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) + + set(lastLibTplName ${PROJECT_NAME}TribitsLastLib) + + # Define the TPL ${PROJECT_NAME}TribitsLastLib and its find module + set(${lastLibTplName}_FINDMOD + "${${PROJECT_NAME}_TRIBITS_DIR}/common_tpls/FindTPLProjectLastLib.cmake") + + # Tack on ${PROJECT_NAME}TribitsLastLib as a dependency to all enabled + # external packages/TPLs + foreach(TPL_NAME ${${PROJECT_NAME}_TPLS}) + list(APPEND ${TPL_NAME}_LIB_ALL_DEPENDENCIES ${lastLibTplName}) + if (TPL_ENABLE_${TPL_NAME}) + list(APPEND ${TPL_NAME}_LIB_ENABLED_DEPENDENCIES ${lastLibTplName}) + endif() + endforeach() + + # Prepend ${PROJECT_NAME}TribitsLastLib to the list of external packages/TPLs + list(PREPEND ${PROJECT_NAME}_TPLS ${lastLibTplName}) + set(TPL_ENABLE_${lastLibTplName} ON) + set(${lastLibTplName}_PACKAGE_BUILD_STATUS EXTERNAL) + + # Tack on ${PROJECT_NAME}TribitsLastLib as a dependency to all enabled + # internal packages + foreach(PACKAGE_NAME ${${PROJECT_NAME}_PACKAGES}) + list(APPEND ${PACKAGE_NAME}_LIB_ALL_DEPENDENCIES ${lastLibTplName}) + if (${PROJECT_NAME}_ENABLE_${PACKAGE_NAME}) + list(APPEND ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES ${lastLibTplName}) + endif() + endforeach() + + endif() + +endmacro() + + # Gather information from enabled TPLs # macro(tribits_process_enabled_tpls) @@ -1739,21 +1781,6 @@ macro(tribits_setup_env) # enable/disable the graphical dependency graphs in doxygen Doxyfiles. include(FindDoxygen) - # Set the hack library to get link options on - - if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) - if (TRIBITS_SETUP_ENV_DEBUG) - message(STATUS "Creating dummy last_lib for appending the link flags: " - "${${PROJECT_NAME}_EXTRA_LINK_FLAGS}") - endif() - if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/last_lib_dummy.c) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/last_lib_dummy.c - "typedef int last_lib_dummy_t;\n") - endif() - add_library(last_lib STATIC ${CMAKE_CURRENT_BINARY_DIR}/last_lib_dummy.c) - target_link_libraries(last_lib ${${PROJECT_NAME}_EXTRA_LINK_FLAGS}) - endif() - # You have to override the configuration types for MSVS after the compiler # checks! set(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPE} @@ -2274,10 +2301,6 @@ macro(tribits_configure_enabled_packages) if(ENABLED_PACKAGE_LIBS_TARGETS) list(REVERSE ENABLED_PACKAGE_LIBS_TARGETS) # Make it so when no packages are enabled it is not a cmake error - if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) - append_set(ENABLED_PACKAGE_LIBS_TARGETS last_lib) - endif() - #print_var(ENABLED_PACKAGE_LIBS_TARGETS) if (NOT TARGET ${PROJECT_NAME}_libs) add_custom_target(${PROJECT_NAME}_libs) add_dependencies(${PROJECT_NAME}_libs ${ENABLED_PACKAGE_LIBS_TARGETS}) From a168af139838adb0d9583718c9ea9ac8b76b6ccd Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 26 May 2022 19:00:21 -0600 Subject: [PATCH 24/43] Add back include_guard(GLOBAL) (#299) When you have a lot of packages, you have to avoid including their Config.cmake file more than once during a find_packge() call. Without these include guards, it took like 24 minutes to configure Albany. When I put them in, the configure time for Albany went down to just 7 sec! --- tribits/core/installation/TribitsPackageConfigTemplate.cmake.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in index 15025561c..1b11675c7 100644 --- a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in @@ -45,6 +45,8 @@ # ############################################################################## +include_guard(GLOBAL) + ## --------------------------------------------------------------------------- ## Compilers used by ${PROJECT_NAME}/${PACKAGE_NAME} build ## --------------------------------------------------------------------------- From 618284aa58caab7e2f00a84de963054ff6638157 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 26 May 2022 18:08:21 -0600 Subject: [PATCH 25/43] WIP: Set _INCLUDE_DIRS in Config.cmake for the install tree (#299) Turns out that Albany explicitly looks for files under ${Trilinos_INCLUDE_DIRS}. Also, Albany was looking for files like "${Trilinos_INCLUDE_DIRS}/Kokkos_config.h" so it basically requires Trilinos_INCLUDE_DIRS to be just a single directory! Therefore, to avoid having to change Albany, I have set _INCLUDE_DIRS in the installed Config.cmake file. This was easy to do for this case. But note that _INCLUDE_DIRS in Config.cmake in the build dir still will be set to empty because there is no easy way to set it in that case. This is a stop-gap measure to allow APPs like Albany to keep working during this initial transition to modern CMake. But we really should remove this var from the Config.cmake file entirely at some point. NOTE: I have not fixed all of the TriBITS tests for this change yet. That is why this is a 'WIP' commit. I will fix the tests in a later commit. --- test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake | 2 +- .../installation/TribitsProjectConfigTemplate.cmake.in | 2 +- .../core/package_arch/TribitsWriteClientExportFiles.cmake | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake index 62eac2a00..fa53aebb5 100644 --- a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake @@ -767,7 +767,7 @@ tribits_add_advanced_test( TribitsHelloWorld_install_config_dummy_proj "TribitsHelloWorld_LINKER = '.*'" "TribitsHelloWorld_AR = '.*'" "TribitsHelloWorld_INSTALL_DIR = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install'" - "TribitsHelloWorld_INCLUDE_DIRS = ''" + "TribitsHelloWorld_INCLUDE_DIRS = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install/include'" "TribitsHelloWorld_LIBRARY_DIRS = ''" "TribitsHelloWorld_LIBRARIES = 'HelloWorld::hello_world_lib'" "TribitsHelloWorld_TPL_INCLUDE_DIRS = '" diff --git a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in index 8aa7f6f46..38a27dedf 100644 --- a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in @@ -126,7 +126,7 @@ foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST}) endforeach() # Deprecated (see #299)! -set(${PROJECT_NAME}_INCLUDE_DIRS "") +set(${PROJECT_NAME}_INCLUDE_DIRS "${TRIBITS_PROJECT_INSTALL_INCLUDE_DIR}") # Deprecated (see #299)! set(${PROJECT_NAME}_LIBRARY_DIRS "") diff --git a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake index 146ffb507..0572e6a5d 100644 --- a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake +++ b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake @@ -831,6 +831,7 @@ include(\"${${TRIBITS_PACKAGE}_BINARY_DIR}/${TRIBITS_PACKAGE}Config.cmake\")") set(PDOLLAR "$") set(tribitsInstallationDir "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}") + set(TRIBITS_PROJECT_INSTALL_INCLUDE_DIR "") configure_file( "${tribitsInstallationDir}/TribitsProjectConfigTemplate.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" ) @@ -879,6 +880,13 @@ include(\"${${TRIBITS_PACKAGE}_BINARY_DIR}/${TRIBITS_PACKAGE}Config.cmake\")") set(PDOLLAR "$") # Hack used in configure file below + if (IS_ABSOLUTE "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") + set(TRIBITS_PROJECT_INSTALL_INCLUDE_DIR "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") + else() + set(TRIBITS_PROJECT_INSTALL_INCLUDE_DIR + "${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") + endif() + configure_file( "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}/TribitsProjectConfigTemplate.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake" From ebe89e3639cb367454b7f2d8b3888bc9390d4f90 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 27 May 2022 17:27:16 -0600 Subject: [PATCH 26/43] Add test for TribitsExampleApp with MPI enabled (#299) I was trying too reproduce failure I saw testing with Albany where it was trying to link against MPI::all_libs. But this did not do it. But it is nice to have a test case where the MPI TPL is enabled and propgated to a downstream APP. --- .../TribitsExampleApp_Tests.cmake | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake index ab26db95d..37ddd7c47 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake @@ -526,7 +526,7 @@ TribitsExampleApp_EnableSingleSubpackage(FULL STATIC) ################################################################################ -function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) +function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic serialOrMpi) if (byProjectOrPackage STREQUAL "ByProject") set(findByProjectOrPackageArg -DTribitsExApp_FIND_INDIVIDUAL_PACKAGES=OFF) @@ -535,12 +535,21 @@ function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) set(findByProjectOrPackageArg -DTribitsExApp_FIND_INDIVIDUAL_PACKAGES=ON) set(foundProjectOrPackageStr "Found SimpleCxx") else() - message(FATAL_ERROR "Invalid value for findByProjectOrPackageArg='${findByProjectOrPackageArg}'!") + message(FATAL_ERROR + "Invalid value findByProjectOrPackageArg='${findByProjectOrPackageArg}'!") endif() TribitsExampleApp_process_sharedOrStatic_arg() - set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${byProjectOrPackage}_${sharedOrStatic}) + if (serialOrMpi STREQUAL "SERIAL") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=OFF) + elseif (serialOrMpi STREQUAL "MPI") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=ON) + else() + message(FATAL_ERROR "Invalid value tplEnableMpiArg='${tplEnableMpiArg}'!") + endif() + + set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${byProjectOrPackage}_${sharedOrStatic}_${serialOrMpi}) set(testName ${PACKAGE_NAME}_${testBaseName}) set(testDir ${CMAKE_CURRENT_BINARY_DIR}/${testName}) @@ -577,6 +586,7 @@ function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) -DSimpleTpl_INCLUDE_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/include -DSimpleTpl_LIBRARY_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/lib ${buildSharedLibsArg} + ${tplEnableMpiArg} -DCMAKE_INSTALL_PREFIX=${testDir}/install ${testDir}/TribitsExampleProject @@ -641,10 +651,10 @@ function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) endfunction() -TribitsExampleApp_ALL_ST(ByProject STATIC) -TribitsExampleApp_ALL_ST(ByProject SHARED) -TribitsExampleApp_ALL_ST(ByPackage STATIC) -TribitsExampleApp_ALL_ST(ByPackage SHARED) +TribitsExampleApp_ALL_ST(ByProject STATIC SERIAL) +TribitsExampleApp_ALL_ST(ByProject SHARED MPI) +TribitsExampleApp_ALL_ST(ByPackage STATIC MPI) +TribitsExampleApp_ALL_ST(ByPackage SHARED SERIAL) ################################################################################ From e2dbc6696da143640b729391c3e75e0e721862c0 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 27 May 2022 18:00:19 -0600 Subject: [PATCH 27/43] WIP: Make SimpleCxx package dependent on MPI (#299) This will help to expose a defect in TriBITS and provides better TriBITS testing realted to the TriBITS MPI TPL. --- .../packages/simple_cxx/cmake/Dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake b/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake index 957707d9b..13461825a 100644 --- a/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake @@ -1,5 +1,5 @@ tribits_package_define_dependencies( LIB_REQUIRED_TPLS HeaderOnlyTpl - LIB_OPTIONAL_TPLS SimpleTpl + LIB_OPTIONAL_TPLS SimpleTpl MPI REGRESSION_EMAIL_LIST simplecxx-regressions@someurl.none ) From a831472fcab8f34e6ce4590250df7b179a0ae741 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 27 May 2022 20:13:54 -0600 Subject: [PATCH 28/43] Fix tests for adding MPI to SimpleCxx and adding back install include dir (#299) --- .../TribitsExampleProject_Tests.cmake | 766 ++++++++++-------- 1 file changed, 409 insertions(+), 357 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 1bcb33cf0..51b57fef4 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -66,369 +66,419 @@ set(LabelsForSubprojects_REGEX ######################################################################## -tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran - OVERALL_WORKING_DIRECTORY TEST_NAME - OVERALL_NUM_MPI_PROCS 1 - XHOSTTYPE Darwin - - TEST_0 - MESSAGE "Do the initial configure (and test a lot of things at once)" - CMND ${CMAKE_COMMAND} - ARGS - ${TribitsExampleProject_COMMON_CONFIG_ARGS} - -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} - -DTribitsExProj_ENABLE_Fortran=OFF - -DTribitsExProj_ENABLE_ALL_PACKAGES=ON - -DTribitsExProj_ENABLE_TESTS=ON - -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON - -DTribitsExProj_TRACE_FILE_PROCESSING=ON - -DTribitsExProj_ENABLE_CPACK_PACKAGING=ON - -DTribitsExProj_DUMP_CPACK_SOURCE_IGNORE_FILES=ON - -DTribitsExProj_DUMP_PACKAGE_DEPENDENCIES=ON - -DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=ON - -DCMAKE_CXX_FLAGS=-DSIMPLECXX_SHOW_DEPRECATED_WARNINGS=1 - -DCMAKE_INSTALL_PREFIX=install - ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject - PASS_REGULAR_EXPRESSION_ALL - "Configuring TribitsExProj build directory" - "-- PROJECT_SOURCE_DIR=" - "-- PROJECT_BINARY_DIR=" - "-- TribitsExProj_TRIBITS_DIR=" - "-- TriBITS_VERSION_STRING=" - "-- CMAKE_VERSION=" - "-- CMAKE_HOST_SYSTEM_NAME=" - "-- TribitsExProj_HOSTNAME=" - - "NOTE: Setting TribitsExProj_ENABLE_WrapExternal=OFF because TribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES='ON'" - "NOTE: Setting TribitsExProj_ENABLE_MixedLang=OFF because TribitsExProj_ENABLE_Fortran" - "Printing package dependencies ..." - "-- TribitsExProj_PACKAGES: SimpleCxx MixedLang WithSubpackages WrapExternal" - "-- TribitsExProj_SE_PACKAGES: SimpleCxx MixedLang WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages WrapExternal" - - "-- SimpleCxx_LIB_REQUIRED_DEP_TPLS: HeaderOnlyTpl" - "-- MixedLang: No dependencies!" - "-- WithSubpackagesA_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" - "-- WithSubpackagesB_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" - "-- WithSubpackagesB_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesA" - "-- WithSubpackagesB_TEST_OPTIONAL_DEP_PACKAGES: MixedLang" - "-- WithSubpackagesC_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA WithSubpackagesB" - "-- WithSubpackages_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" - "-- WithSubpackages_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesB WithSubpackagesC" - "-- WrapExternal_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" - "-- WrapExternal_LIB_OPTIONAL_DEP_PACKAGES: MixedLang" - "-- SimpleCxx: No library dependencies!" - "-- WithSubpackagesA_FULL_ENABLED_DEP_PACKAGES: SimpleCxx" - "-- WithSubpackagesB_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesA SimpleCxx" - "-- WithSubpackagesC_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesB WithSubpackagesA SimpleCxx" - "-- WithSubpackages_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesC WithSubpackagesB WithSubpackagesA SimpleCxx" - "Explicitly enabled packages on input .by user.: 0" - "Explicitly disabled packages on input .by user or by default.: MixedLang WrapExternal 2" - "Enabling all SE packages that are not currently disabled because of TribitsExProj_ENABLE_ALL_PACKAGES=ON " - "Setting TribitsExProj_ENABLE_SimpleCxx=ON" - "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 ..." - "-- SimpleCxx_LIB_ENABLED_DEPENDENCIES: HeaderOnlyTpl" - "-- SimpleCxx_LIB_ALL_DEPENDENCIES: HeaderOnlyTpl SimpleTpl" - "-- MixedLang_LIB_ALL_DEPENDENCIES: " - "-- WithSubpackagesA_LIB_ENABLED_DEPENDENCIES: SimpleCxx" - "-- WithSubpackagesA_LIB_ALL_DEPENDENCIES: SimpleCxx" - "-- WithSubpackagesB_LIB_ENABLED_DEPENDENCIES: SimpleCxx WithSubpackagesA" - "-- WithSubpackagesB_LIB_ALL_DEPENDENCIES: SimpleCxx WithSubpackagesA" - "-- WithSubpackagesB_TEST_ALL_DEPENDENCIES: MixedLang" - "-- WithSubpackagesC_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" - "-- WithSubpackagesC_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" - "-- WithSubpackages_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" - "-- WithSubpackages_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" - "-- WrapExternal_LIB_ALL_DEPENDENCIES: WithSubpackagesA MixedLang" - "Final set of enabled packages: SimpleCxx WithSubpackages 2" - "Final set of enabled SE packages: SimpleCxx WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages 5" - "Final set of enabled TPLs: ${FINAL_ENABLED_TPLS}" - "Final set of non-enabled packages: MixedLang WrapExternal 2" - "Processing enabled TPL: HeaderOnlyTpl" - "-- File Trace: TPL INCLUDE .+/TribitsExampleProject/cmake/tpls/FindTPLHeaderOnlyTpl.cmake" - "-- TPL_HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" - "Performing Test HAVE_SIMPLECXX___INT64" - "Configuring done" - "Generating done" - "Build files have been written to: .*ExamplesUnitTests/TriBITS_TribitsExampleProject_ALL_ST_NoFortran" - "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/Version.cmake" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/PackagesList.cmake" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/TPLsList.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/mixed_lang/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/a/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/b/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/c/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/wrap_external/cmake/Dependencies.cmake" - "-- File Trace: PROJECT CONFIGURE .*/TribitsExampleProject/cmake/ctest/CTestCustom.cmake.in" - "-- File Trace: REPOSITORY READ .*/TribitsExampleProject/Copyright.txt" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/Version.cmake" - "${TPL_MPI_FILE_TRACE}" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/test/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/tests/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/tests/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/tests/CMakeLists.txt" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineRepositoryPackaging.cmake" - "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineProjectPackaging.cmake" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_1 - MESSAGE "Make sure that 'LabelsForSubprojects' is set to list of packages" - CMND ${LabelsForSubprojects_CMND_AND_ARGS} - PASS_REGULAR_EXPRESSION "${LabelsForSubprojects_REGEX}" - - TEST_2 - MESSAGE "Build the default 'all' target using raw 'make'" - CMND make ARGS ${CTEST_BUILD_FLAGS} - PASS_REGULAR_EXPRESSION_ALL - "Built target simplecxx" - "${DEPRECATED_WARNING_1_STR}" - "${DEPRECATED_WARNING_2_STR}" - "Built target pws_a" - "Built target pws_b" - "Built target pws_c" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_3 - MESSAGE "Run all the tests with raw 'ctest'" - CMND ${CMAKE_CTEST_COMMAND} ARGS -VV - PASS_REGULAR_EXPRESSION_ALL - "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" - "WithSubpackagesA_test_of_a .* Passed" - "WithSubpackagesB_test_of_b .* Passed" - "WithSubpackagesC_test_of_c .* Passed" - "WithSubpackagesC_test_of_c_util.* Passed" - "100% tests passed, 0 tests failed out of 6" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_4 - MESSAGE "Create and configure a dummy project that includes" - " WithSubpackagesConfig.cmake from the build tree" - CMND ${CMAKE_COMMAND} - ARGS - -DDUMMY_PROJECT_NAME=DummyProject - -DDUMMY_PROJECT_DIR=dummy_client_of_build_WithSubpackages - -DEXPORT_VAR_PREFIX=WithSubpackages - -DEXPORT_CONFIG_FILE=../cmake_packages/WithSubpackages/WithSubpackagesConfig.cmake - -DCMAKE_COMMAND=${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake - PASS_REGULAR_EXPRESSION_ALL - "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" - "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" - "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" - "WithSubpackages_Fortran_COMPILER = ''" - "WithSubpackages_FORTRAN_COMPILER = ''" - "WithSubpackages_CXX_FLAGS = '.*'" - "WithSubpackages_C_FLAGS = '.*'" - "WithSubpackages_Fortran_FLAGS = '.*'" - "WithSubpackages_EXTRA_LD_FLAGS = '.*'" - "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" - "WithSubpackages_BUILD_SHARED_LIBS = '.*'" - "WithSubpackages_LINKER = '.+'" - "WithSubpackages_AR = '.+'" - "WithSubpackages_INSTALL_DIR = .*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install" - "WithSubpackages_INCLUDE_DIRS = ''" - "WithSubpackages_LIBRARY_DIRS = ''" - "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = ''" - "WithSubpackages_TPL_LIBRARY_DIRS = ''" - "WithSubpackages_TPL_LIBRARIES = 'HeaderOnlyTpl::all_libs'" - "WithSubpackages_MPI_LIBRARIES = ''" - "WithSubpackages_MPI_LIBRARY_DIRS = ''" - "WithSubpackages_MPI_INCLUDE_DIRS = ''" - "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" - "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" - "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" - "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" - "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" - "-- Configuring done" - "-- Generating done" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_5 - MESSAGE "Build 'install' target using raw 'make'" - CMND make ARGS install ${CTEST_BUILD_FLAGS} - PASS_REGULAR_EXPRESSION_ALL - "Install configuration: .RELEASE." - "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfig.cmake" - "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfigVersion.cmake" - "Installing: .+/install/include/TribitsExProj_version.h" - "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake" - "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfigVersion.cmake" - "Installing: .+/install/include/TribitsExProjConfig.cmake" - "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxConfig.cmake" - "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets.cmake" - "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets-release.cmake" - "Installing: .+/install/lib/libsimplecxx.a" - "Installing: .+/install/include/SimpleCxx_HelloWorld.hpp" - "Installing: .+/install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake" - "Installing: .+/install/lib/libpws_a.a" - "Installing: .+/install/include/A.hpp" - "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesAConfig.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets-release.cmake" - "Installing: .+/install/lib/libpws_b.a" - "Installing: .+/install/include/B.hpp" - "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBConfig.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets-release.cmake" - "Installing: .+/install/lib/libpws_c.a" - "Installing: .+/install/include/wsp_c/C.hpp" - "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCConfig.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets-release.cmake" - ALWAYS_FAIL_ON_NONZERO_RETURN +function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi) - TEST_6 - MESSAGE "Create and configure a dummy project that includes" - " WithSubpackagesConfig.cmake from the install tree" - CMND ${CMAKE_COMMAND} - ARGS - -DDUMMY_PROJECT_NAME=DummyProject - -DDUMMY_PROJECT_DIR=dummy_client_of_WithSubpackages - -DEXPORT_VAR_PREFIX=WithSubpackages - -DEXPORT_CONFIG_FILE=../install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake - -DCMAKE_COMMAND=${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake - PASS_REGULAR_EXPRESSION_ALL - "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" - "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" - "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" - "WithSubpackages_Fortran_COMPILER = ''" - "WithSubpackages_FORTRAN_COMPILER = ''" - "WithSubpackages_CXX_FLAGS = '.*'" - "WithSubpackages_C_FLAGS = '.*'" - "WithSubpackages_Fortran_FLAGS = '.*'" - "WithSubpackages_EXTRA_LD_FLAGS = '.*'" - "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" - "WithSubpackages_BUILD_SHARED_LIBS = '.*'" - "WithSubpackages_LINKER = '.+'" - "WithSubpackages_AR = '.+'" - "WithSubpackages_INSTALL_DIR = '.+/install'" - "WithSubpackages_INCLUDE_DIRS = ''" - "WithSubpackages_LIBRARY_DIRS = ''" - "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = ''" - "WithSubpackages_TPL_LIBRARY_DIRS = ''" - "WithSubpackages_TPL_LIBRARIES = 'HeaderOnlyTpl::all_libs'" - "WithSubpackages_MPI_LIBRARIES = ''" - "WithSubpackages_MPI_LIBRARY_DIRS = ''" - "WithSubpackages_MPI_INCLUDE_DIRS = ''" - "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" - "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" - "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" - "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" - "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" - ALWAYS_FAIL_ON_NONZERO_RETURN + set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}_${serialOrMpi}) + set(testName ${PACKAGE_NAME}_${testBaseName}) - TEST_7 - MESSAGE "Create and configure a dummy project that includes" - " TribitsExProjConfig.cmake from the install tree" - CMND ${CMAKE_COMMAND} - ARGS - -DDUMMY_PROJECT_NAME=DummyProject - -DDUMMY_PROJECT_DIR=dummy_client_of_TribitsExProj - -DEXPORT_VAR_PREFIX=TribitsExProj - -DEXPORT_CONFIG_FILE=../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake - -DCMAKE_COMMAND=${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake - PASS_REGULAR_EXPRESSION_ALL - "DUMMY_PROJECT_NAME = 'DummyProject'" - "DUMMY_PROJECT_DIR = 'dummy_client_of_TribitsExProj'" - "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" - "EXPORT_VAR_PREFIX = 'TribitsExProj'" - "CMAKE_COMMAND = '${CMAKE_COMMAND}" - "Create the dummy client directory ..." - "Create dummy dummy_client_of_TribitsExProj/CMakeLists.txt file ..." - "Configure the dummy project to print the variables in .*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/dummy_client_of_TribitsExProj ..." - "DUMMY_PROJECT_NAME = 'DummyProject'" - "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" - "EXPORT_VAR_PREFIX = 'TribitsExProj'" - "Including file '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/dummy_client_of_TribitsExProj/../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" - "TribitsExProj_CMAKE_BUILD_TYPE = 'RELEASE'" - "TribitsExProj_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" - "TribitsExProj_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" - "TribitsExProj_Fortran_COMPILER = ''" - "TribitsExProj_FORTRAN_COMPILER = ''" - "TribitsExProj_CXX_FLAGS = ''" - "TribitsExProj_C_FLAGS = ''" - "TribitsExProj_Fortran_FLAGS = ''" - "TribitsExProj_EXTRA_LD_FLAGS = ''" - "TribitsExProj_SHARED_LIB_RPATH_COMMAND = ''" - "TribitsExProj_BUILD_SHARED_LIBS = 'FALSE'" - "TribitsExProj_LINKER = '.*'" - "TribitsExProj_AR = '.*'" - "TribitsExProj_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install'" - "TribitsExProj_INCLUDE_DIRS = ''" - "TribitsExProj_LIBRARY_DIRS = ''" - "TribitsExProj_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "TribitsExProj_TPL_INCLUDE_DIRS = ''" - "TribitsExProj_TPL_LIBRARY_DIRS = ''" - "TribitsExProj_TPL_LIBRARIES = 'HeaderOnlyTpl::all_libs'" - "TribitsExProj_MPI_LIBRARIES = ''" - "TribitsExProj_MPI_LIBRARY_DIRS = ''" - "TribitsExProj_MPI_INCLUDE_DIRS = ''" - "TribitsExProj_MPI_EXEC = '.*'" - "TribitsExProj_MPI_EXEC_MAX_NUMPROCS = '[1-9]*'" # Is null for an MPI build - "TribitsExProj_MPI_EXEC_NUMPROCS_FLAG = '.*'" - "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]SimpleCxx'" - "TribitsExProj_TPL_LIST = 'HeaderOnlyTpl" # Must work for no MPI too - "-- Configuring done" - "-- Generating done" - ALWAYS_FAIL_ON_NONZERO_RETURN + if (sharedOrStatic STREQUAL "SHARED") + set(BUILD_SHARED_LIBS_VAL ON) + set(libExtRegex "[.]so[.].*") + elseif (sharedOrStatic STREQUAL "STATIC") + set(BUILD_SHARED_LIBS_VAL OFF) + set(libExtRegex "[.]a") + else() + message(FATAL_ERROR "Invalid value sharedOrStatic='${sharedOrStatic}'!") + endif() - # ToDo: Add test for the components parts of Config.cmake ... + if (serialOrMpi STREQUAL "SERIAL") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=OFF) + set(TPL_MPI_FILE_TRACE "") + set(FINAL_ENABLED_TPLS "HeaderOnlyTpl 1") + set(TEST_MPI_1_SUFFIX "") + set(WithSubpackages_TPL_LIBRARIES HeaderOnlyTpl::all_libs) + set(WithSubpackages_TPL_LIST HeaderOnlyTpl) + set(TribitsExProj_TPL_LIBRARIES HeaderOnlyTpl::all_libs) + set(TribitsExProj_TPL_LIST HeaderOnlyTpl) + set(TribitsExProj_SHARED_LIB_RPATH_COMMAND_REGEX "") + elseif (serialOrMpi STREQUAL "MPI") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=ON) + set(TPL_MPI_FILE_TRACE + "-- File Trace: TPL INCLUDE .*/core/std_tpls/FindTPLMPI.cmake") + set(FINAL_ENABLED_TPLS "MPI HeaderOnlyTpl 2") + set(TEST_MPI_1_SUFFIX "_MPI_1") + set(WithSubpackages_TPL_LIBRARIES "HeaderOnlyTpl::all_libs;MPI::all_libs") + set(WithSubpackages_TPL_LIST "HeaderOnlyTpl;MPI") + set(TribitsExProj_TPL_LIBRARIES "HeaderOnlyTpl::all_libs;MPI::all_libs") + set(TribitsExProj_TPL_LIST "HeaderOnlyTpl;MPI") + set(TribitsExProj_SHARED_LIB_RPATH_COMMAND_REGEX + "-Wl,-rpath,.*/${testName}/install/lib") + else() + message(FATAL_ERROR "Invalid value tplEnableMpiArg='${tplEnableMpiArg}'!") + endif() - # ToDo: Add test that actually builds a C++ project and links to these libs - # to make sure this works! + tribits_add_advanced_test( ${testBaseName} + OVERALL_WORKING_DIRECTORY TEST_NAME + OVERALL_NUM_MPI_PROCS 1 + XHOSTTYPE Darwin - TEST_8 - MESSAGE "Create the tarball" - CMND make ARGS package_source - PASS_REGULAR_EXPRESSION_ALL - "Run CPack packaging tool for source..." - "CPack: Create package using TGZ" - "CPack: Install projects" - "CPack: - Install directory: .*/examples/TribitsExampleProject" - "CPack: Create package" - "CPack: - package: .*/ExamplesUnitTests/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/tribitsexproj-1.1-Source.tar.gz generated." - "CPack: Create package using TBZ2" - "CPack: Install projects" - "CPack: - Install directory: .*/examples/TribitsExampleProject" - "CPack: Create package" - "CPack: - package: .*/ExamplesUnitTests/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/tribitsexproj-1.1-Source.tar.bz2 generated." - ALWAYS_FAIL_ON_NONZERO_RETURN + TEST_0 + MESSAGE "Do the initial configure (and test a lot of things at once)" + CMND ${CMAKE_COMMAND} + ARGS + ${TribitsExampleProject_COMMON_CONFIG_ARGS} + -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS_VAL} + ${tplEnableMpiArg} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DTribitsExProj_ENABLE_Fortran=OFF + -DTribitsExProj_ENABLE_ALL_PACKAGES=ON + -DTribitsExProj_ENABLE_TESTS=ON + -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON + -DTribitsExProj_TRACE_FILE_PROCESSING=ON + -DTribitsExProj_ENABLE_CPACK_PACKAGING=ON + -DTribitsExProj_DUMP_CPACK_SOURCE_IGNORE_FILES=ON + -DTribitsExProj_DUMP_PACKAGE_DEPENDENCIES=ON + -DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=ON + -DCMAKE_CXX_FLAGS=-DSIMPLECXX_SHOW_DEPRECATED_WARNINGS=1 + -DCMAKE_INSTALL_PREFIX=install + ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject + PASS_REGULAR_EXPRESSION_ALL + "Configuring TribitsExProj build directory" + "-- PROJECT_SOURCE_DIR=" + "-- PROJECT_BINARY_DIR=" + "-- TribitsExProj_TRIBITS_DIR=" + "-- TriBITS_VERSION_STRING=" + "-- CMAKE_VERSION=" + "-- CMAKE_HOST_SYSTEM_NAME=" + "-- TribitsExProj_HOSTNAME=" + + "NOTE: Setting TribitsExProj_ENABLE_WrapExternal=OFF because TribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES='ON'" + "NOTE: Setting TribitsExProj_ENABLE_MixedLang=OFF because TribitsExProj_ENABLE_Fortran" + "Printing package dependencies ..." + "-- TribitsExProj_PACKAGES: SimpleCxx MixedLang WithSubpackages WrapExternal" + "-- TribitsExProj_SE_PACKAGES: SimpleCxx MixedLang WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages WrapExternal" + + "-- SimpleCxx_LIB_REQUIRED_DEP_TPLS: HeaderOnlyTpl" + "-- MixedLang: No dependencies!" + "-- WithSubpackagesA_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" + "-- WithSubpackagesB_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" + "-- WithSubpackagesB_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesA" + "-- WithSubpackagesB_TEST_OPTIONAL_DEP_PACKAGES: MixedLang" + "-- WithSubpackagesC_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA WithSubpackagesB" + "-- WithSubpackages_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" + "-- WithSubpackages_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesB WithSubpackagesC" + "-- WrapExternal_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" + "-- WrapExternal_LIB_OPTIONAL_DEP_PACKAGES: MixedLang" + "-- SimpleCxx: No library dependencies!" + "-- WithSubpackagesA_FULL_ENABLED_DEP_PACKAGES: SimpleCxx" + "-- WithSubpackagesB_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesA SimpleCxx" + "-- WithSubpackagesC_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesB WithSubpackagesA SimpleCxx" + "-- WithSubpackages_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesC WithSubpackagesB WithSubpackagesA SimpleCxx" + "Explicitly enabled packages on input .by user.: 0" + "Explicitly disabled packages on input .by user or by default.: MixedLang WrapExternal 2" + "Enabling all SE packages that are not currently disabled because of TribitsExProj_ENABLE_ALL_PACKAGES=ON " + "Setting TribitsExProj_ENABLE_SimpleCxx=ON" + "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 ..." + "-- SimpleCxx_LIB_ENABLED_DEPENDENCIES: HeaderOnlyTpl" + "-- SimpleCxx_LIB_ALL_DEPENDENCIES: HeaderOnlyTpl SimpleTpl" + "-- MixedLang_LIB_ALL_DEPENDENCIES: " + "-- WithSubpackagesA_LIB_ENABLED_DEPENDENCIES: SimpleCxx" + "-- WithSubpackagesA_LIB_ALL_DEPENDENCIES: SimpleCxx" + "-- WithSubpackagesB_LIB_ENABLED_DEPENDENCIES: SimpleCxx WithSubpackagesA" + "-- WithSubpackagesB_LIB_ALL_DEPENDENCIES: SimpleCxx WithSubpackagesA" + "-- WithSubpackagesB_TEST_ALL_DEPENDENCIES: MixedLang" + "-- WithSubpackagesC_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" + "-- WithSubpackagesC_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" + "-- WithSubpackages_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" + "-- WithSubpackages_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" + "-- WrapExternal_LIB_ALL_DEPENDENCIES: WithSubpackagesA MixedLang" + "Final set of enabled packages: SimpleCxx WithSubpackages 2" + "Final set of enabled SE packages: SimpleCxx WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages 5" + "Final set of enabled TPLs: ${FINAL_ENABLED_TPLS}" + "Final set of non-enabled packages: MixedLang WrapExternal 2" + "Processing enabled TPL: HeaderOnlyTpl" + "-- File Trace: TPL INCLUDE .+/TribitsExampleProject/cmake/tpls/FindTPLHeaderOnlyTpl.cmake" + "-- TPL_HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" + "Performing Test HAVE_SIMPLECXX___INT64" + "Configuring done" + "Generating done" + "Build files have been written to: .*ExamplesUnitTests/${testName}" + "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/Version.cmake" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/PackagesList.cmake" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/TPLsList.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/mixed_lang/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/a/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/b/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/c/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/wrap_external/cmake/Dependencies.cmake" + "-- File Trace: PROJECT CONFIGURE .*/TribitsExampleProject/cmake/ctest/CTestCustom.cmake.in" + "-- File Trace: REPOSITORY READ .*/TribitsExampleProject/Copyright.txt" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/Version.cmake" + "${TPL_MPI_FILE_TRACE}" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/test/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/tests/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/tests/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/tests/CMakeLists.txt" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineRepositoryPackaging.cmake" + "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineProjectPackaging.cmake" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_1 + MESSAGE "Make sure that 'LabelsForSubprojects' is set to list of packages" + CMND ${LabelsForSubprojects_CMND_AND_ARGS} + PASS_REGULAR_EXPRESSION "${LabelsForSubprojects_REGEX}" + + TEST_2 + MESSAGE "Build the default 'all' target using raw 'make'" + CMND make ARGS ${CTEST_BUILD_FLAGS} + PASS_REGULAR_EXPRESSION_ALL + "Built target simplecxx" + "${DEPRECATED_WARNING_1_STR}" + "${DEPRECATED_WARNING_2_STR}" + "Built target pws_a" + "Built target pws_b" + "Built target pws_c" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_3 + MESSAGE "Run all the tests with raw 'ctest'" + CMND ${CMAKE_CTEST_COMMAND} ARGS -VV + PASS_REGULAR_EXPRESSION_ALL + "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" + "WithSubpackagesA_test_of_a .* Passed" + "WithSubpackagesB_test_of_b .* Passed" + "WithSubpackagesC_test_of_c .* Passed" + "WithSubpackagesC_test_of_c_util.* Passed" + "100% tests passed, 0 tests failed out of 6" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_4 + MESSAGE "Create and configure a dummy project that includes" + " WithSubpackagesConfig.cmake from the build tree" + CMND ${CMAKE_COMMAND} + ARGS + -DDUMMY_PROJECT_NAME=DummyProject + -DDUMMY_PROJECT_DIR=dummy_client_of_build_WithSubpackages + -DEXPORT_VAR_PREFIX=WithSubpackages + -DEXPORT_CONFIG_FILE=../cmake_packages/WithSubpackages/WithSubpackagesConfig.cmake + -DCMAKE_COMMAND=${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake + PASS_REGULAR_EXPRESSION_ALL + "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" + "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" + "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" + "WithSubpackages_Fortran_COMPILER = ''" + "WithSubpackages_FORTRAN_COMPILER = ''" + "WithSubpackages_CXX_FLAGS = '.*'" + "WithSubpackages_C_FLAGS = '.*'" + "WithSubpackages_Fortran_FLAGS = '.*'" + "WithSubpackages_EXTRA_LD_FLAGS = '.*'" + "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" + "WithSubpackages_BUILD_SHARED_LIBS = '.*'" + "WithSubpackages_LINKER = '.+'" + "WithSubpackages_AR = '.+'" + "WithSubpackages_INSTALL_DIR = .*/${testName}/install" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" + "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" + "WithSubpackages_TPL_LIBRARY_DIRS = ''" + "WithSubpackages_TPL_LIBRARIES = '${WithSubpackages_TPL_LIBRARIES}'" + "WithSubpackages_MPI_LIBRARIES = ''" + "WithSubpackages_MPI_LIBRARY_DIRS = ''" + "WithSubpackages_MPI_INCLUDE_DIRS = ''" + "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" + "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" + "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" + "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" + "WithSubpackages_TPL_LIST = '${WithSubpackages_TPL_LIST}'" + "-- Configuring done" + "-- Generating done" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_5 + MESSAGE "Build 'install' target using raw 'make'" + CMND make ARGS install ${CTEST_BUILD_FLAGS} + PASS_REGULAR_EXPRESSION_ALL + "Install configuration: .RELEASE." + "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfig.cmake" + "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfigVersion.cmake" + "Installing: .+/install/include/TribitsExProj_version.h" + "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake" + "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfigVersion.cmake" + "Installing: .+/install/include/TribitsExProjConfig.cmake" + "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxConfig.cmake" + "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets.cmake" + "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets-release.cmake" + "Installing: .+/install/lib/libsimplecxx${libExtRegex}" + "Installing: .+/install/include/SimpleCxx_HelloWorld.hpp" + "Installing: .+/install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake" + "Installing: .+/install/lib/libpws_a${libExtRegex}" + "Installing: .+/install/include/A.hpp" + "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesAConfig.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets-release.cmake" + "Installing: .+/install/lib/libpws_b${libExtRegex}" + "Installing: .+/install/include/B.hpp" + "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBConfig.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets-release.cmake" + "Installing: .+/install/lib/libpws_c${libExtRegex}" + "Installing: .+/install/include/wsp_c/C.hpp" + "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCConfig.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets-release.cmake" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_6 + MESSAGE "Create and configure a dummy project that includes" + " WithSubpackagesConfig.cmake from the install tree" + CMND ${CMAKE_COMMAND} + ARGS + -DDUMMY_PROJECT_NAME=DummyProject + -DDUMMY_PROJECT_DIR=dummy_client_of_WithSubpackages + -DEXPORT_VAR_PREFIX=WithSubpackages + -DEXPORT_CONFIG_FILE=../install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake + -DCMAKE_COMMAND=${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake + PASS_REGULAR_EXPRESSION_ALL + "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" + "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" + "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" + "WithSubpackages_Fortran_COMPILER = ''" + "WithSubpackages_FORTRAN_COMPILER = ''" + "WithSubpackages_CXX_FLAGS = '.*'" + "WithSubpackages_C_FLAGS = '.*'" + "WithSubpackages_Fortran_FLAGS = '.*'" + "WithSubpackages_EXTRA_LD_FLAGS = '.*'" + "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" + "WithSubpackages_BUILD_SHARED_LIBS = '.*'" + "WithSubpackages_LINKER = '.+'" + "WithSubpackages_AR = '.+'" + "WithSubpackages_INSTALL_DIR = '.+/install'" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" + "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" + "WithSubpackages_TPL_LIBRARY_DIRS = ''" + "WithSubpackages_TPL_LIBRARIES = '${WithSubpackages_TPL_LIBRARIES}'" + "WithSubpackages_MPI_LIBRARIES = ''" + "WithSubpackages_MPI_LIBRARY_DIRS = ''" + "WithSubpackages_MPI_INCLUDE_DIRS = ''" + "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" + "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" + "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" + "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" + "WithSubpackages_TPL_LIST = '${WithSubpackages_TPL_LIST}'" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_7 + MESSAGE "Create and configure a dummy project that includes" + " TribitsExProjConfig.cmake from the install tree" + CMND ${CMAKE_COMMAND} + ARGS + -DDUMMY_PROJECT_NAME=DummyProject + -DDUMMY_PROJECT_DIR=dummy_client_of_TribitsExProj + -DEXPORT_VAR_PREFIX=TribitsExProj + -DEXPORT_CONFIG_FILE=../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake + -DCMAKE_COMMAND=${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake + PASS_REGULAR_EXPRESSION_ALL + "DUMMY_PROJECT_NAME = 'DummyProject'" + "DUMMY_PROJECT_DIR = 'dummy_client_of_TribitsExProj'" + "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" + "EXPORT_VAR_PREFIX = 'TribitsExProj'" + "CMAKE_COMMAND = '${CMAKE_COMMAND}" + "Create the dummy client directory ..." + "Create dummy dummy_client_of_TribitsExProj/CMakeLists.txt file ..." + "Configure the dummy project to print the variables in .*/${testName}/dummy_client_of_TribitsExProj ..." + "DUMMY_PROJECT_NAME = 'DummyProject'" + "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" + "EXPORT_VAR_PREFIX = 'TribitsExProj'" + "Including file '.*/${testName}/dummy_client_of_TribitsExProj/../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" + "TribitsExProj_CMAKE_BUILD_TYPE = 'RELEASE'" + "TribitsExProj_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" + "TribitsExProj_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" + "TribitsExProj_Fortran_COMPILER = ''" + "TribitsExProj_FORTRAN_COMPILER = ''" + "TribitsExProj_CXX_FLAGS = ''" + "TribitsExProj_C_FLAGS = ''" + "TribitsExProj_Fortran_FLAGS = ''" + "TribitsExProj_EXTRA_LD_FLAGS = ''" + "TribitsExProj_SHARED_LIB_RPATH_COMMAND = '${TribitsExProj_SHARED_LIB_RPATH_COMMAND_REGEX}'" + "TribitsExProj_BUILD_SHARED_LIBS = '${BUILD_SHARED_LIBS_VAL}'" + "TribitsExProj_LINKER = '.*'" + "TribitsExProj_AR = '.*'" + "TribitsExProj_INSTALL_DIR = '.*/${testName}/install'" + "TribitsExProj_INCLUDE_DIRS = '.*/${testName}/install/include'" + "TribitsExProj_LIBRARY_DIRS = ''" + "TribitsExProj_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" + "TribitsExProj_TPL_INCLUDE_DIRS = ''" + "TribitsExProj_TPL_LIBRARY_DIRS = ''" + "TribitsExProj_TPL_LIBRARIES = '${TribitsExProj_TPL_LIBRARIES}'" + "TribitsExProj_MPI_LIBRARIES = ''" + "TribitsExProj_MPI_LIBRARY_DIRS = ''" + "TribitsExProj_MPI_INCLUDE_DIRS = ''" + "TribitsExProj_MPI_EXEC = '.*'" + "TribitsExProj_MPI_EXEC_MAX_NUMPROCS = '[1-9]*'" # Is null for an MPI build + "TribitsExProj_MPI_EXEC_NUMPROCS_FLAG = '.*'" + "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]SimpleCxx'" + "TribitsExProj_TPL_LIST = '${TribitsExProj_TPL_LIST}'" + "-- Configuring done" + "-- Generating done" + ALWAYS_FAIL_ON_NONZERO_RETURN + + # ToDo: Add test for the components parts of Config.cmake ... + + # ToDo: Add test that actually builds a C++ project and links to these libs + # to make sure this works! + + TEST_8 + MESSAGE "Create the tarball" + CMND make ARGS package_source + PASS_REGULAR_EXPRESSION_ALL + "Run CPack packaging tool for source..." + "CPack: Create package using TGZ" + "CPack: Install projects" + "CPack: - Install directory: .*/examples/TribitsExampleProject" + "CPack: Create package" + "CPack: - package: .*/ExamplesUnitTests/${testName}/tribitsexproj-1.1-Source.tar.gz generated." + "CPack: Create package using TBZ2" + "CPack: Install projects" + "CPack: - Install directory: .*/examples/TribitsExampleProject" + "CPack: Create package" + "CPack: - package: .*/ExamplesUnitTests/${testName}/tribitsexproj-1.1-Source.tar.bz2 generated." + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_9 + MESSAGE "Untar the tarball" + CMND tar ARGS -xzf tribitsexproj-1.1-Source.tar.gz + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_10 + MESSAGE "Make sure right directoires are excluced" + CMND diff + ARGS -qr + ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject + tribitsexproj-1.1-Source + PASS_REGULAR_EXPRESSION_ALL + "Only in .*/TribitsExampleProject/cmake: ctest" + ${REGEX_FOR_GITIGNORE} + "Only in .*/TribitsExampleProject/packages: mixed_lang" + "Only in .*/TribitsExampleProject/packages: wrap_external" + "Only in .*/TribitsExampleProject/packages/with_subpackages/b: ExcludeFromRelease.txt" + "Only in .*/TribitsExampleProject/packages/with_subpackages/b/src: AlsoExcludeFromTarball.txt" + # NOTE: We don't check return code because diff returns nonzero - TEST_9 - MESSAGE "Untar the tarball" - CMND tar ARGS -xzf tribitsexproj-1.1-Source.tar.gz - ALWAYS_FAIL_ON_NONZERO_RETURN + ) - TEST_10 - MESSAGE "Make sure right directoires are excluced" - CMND diff - ARGS -qr - ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject - tribitsexproj-1.1-Source - PASS_REGULAR_EXPRESSION_ALL - "Only in .*/TribitsExampleProject/cmake: ctest" - ${REGEX_FOR_GITIGNORE} - "Only in .*/TribitsExampleProject/packages: mixed_lang" - "Only in .*/TribitsExampleProject/packages: wrap_external" - "Only in .*/TribitsExampleProject/packages/with_subpackages/b: ExcludeFromRelease.txt" - "Only in .*/TribitsExampleProject/packages/with_subpackages/b/src: AlsoExcludeFromTarball.txt" - # NOTE: We don't check return code because diff returns nonzero +endfunction() - ) +TribitsExampleProject_ALL_ST_NoFortran(STATIC SERIAL) +TribitsExampleProject_ALL_ST_NoFortran(SHARED MPI) ######################################################################## @@ -972,6 +1022,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja -DTribitsExProj_WRITE_NINJA_MAKEFILES=OFF ${TribitsExampleProject_COMMON_CONFIG_ARGS} -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DTPL_ENABLE_MPI=OFF -DTribitsExProj_ENABLE_Fortran=OFF -DTribitsExProj_ENABLE_ALL_PACKAGES=ON -DTribitsExProj_ENABLE_TESTS=ON @@ -1017,7 +1068,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja TEST_4 CMND ${CMAKE_CTEST_COMMAND} ARGS -VV MESSAGE "Run all the tests with raw 'ctest'" PASS_REGULAR_EXPRESSION_ALL - "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" + "SimpleCxx_HelloWorldTests .* Passed" "WithSubpackagesA_test_of_a .* Passed" "WithSubpackagesB_test_of_b .* Passed" "WithSubpackagesC_test_of_c .* Passed" @@ -1112,6 +1163,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile -GNinja ${TribitsExampleProject_COMMON_CONFIG_ARGS} -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DTPL_ENABLE_MPI=OFF -DTribitsExProj_ENABLE_Fortran=OFF -DTribitsExProj_ENABLE_ALL_PACKAGES=ON -DTribitsExProj_ENABLE_TESTS=ON @@ -1141,7 +1193,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile TEST_2 CMND ${CMAKE_CTEST_COMMAND} ARGS -VV MESSAGE "Run all the tests with raw 'ctest'" PASS_REGULAR_EXPRESSION_ALL - "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" + "SimpleCxx_HelloWorldTests .* Passed" "WithSubpackagesA_test_of_a .* Passed" "WithSubpackagesB_test_of_b .* Passed" "WithSubpackagesC_test_of_c .* Passed" From 40518477ceab48c36fa961f0d84f6a095150a1d7 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 27 May 2022 18:05:19 -0600 Subject: [PATCH 29/43] WIP: Add test to expose defect with MPI::all_libs (#299) This produces the same error I saw when testing Albany against Trilinos and updated TriBITS: CMake Error at CMakeLists.txt:??? (add_executable): Target "app" links to target "MPI::all_libs" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? To generate this error, I add to add linking against ${TribitsExProj_TPL_LIBRARIES} which is what Albany currently does as well. I think this is a common usage of old-style TriBITS so it is important to test this case. --- .../TribitsOldSimpleExampleApp_Tests.cmake | 23 ++++++++++++++----- .../TribitsOldSimpleExampleApp/CMakeLists.txt | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake b/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake index e298c22ac..c48c15584 100644 --- a/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake @@ -52,7 +52,7 @@ set_default_and_from_env( # TribitsOldSimpleExampleApp. -function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) +function(TribitsOldSimpleExampleApp sharedOrStatic serialOrMpi useDeprecatedTargets) set(appConfigurePassRegexAll "") @@ -61,7 +61,15 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) elseif (sharedOrStatic STREQUAL "STATIC") set(buildSharedLibsArg -DBUILD_SHARED_LIBS=OFF) else() - message(FATAL_ERROR "Invalid value for sharedOrStatic='${sharedOrStatic}'!") + message(FATAL_ERROR "Invalid value sharedOrStatic='${sharedOrStatic}'!") + endif() + + if (serialOrMpi STREQUAL "SERIAL") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=OFF) + elseif (serialOrMpi STREQUAL "MPI") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=ON) + else() + message(FATAL_ERROR "Invalid value tplEnableMpiArg='${tplEnableMpiArg}'!") endif() if (useDeprecatedTargets STREQUAL "USE_DEPRECATED_TARGETS") @@ -82,10 +90,11 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) elseif (useDeprecatedTargets STREQUAL "USE_NEW_TARGETS") set(useDeprecatedTargetsArg "") else() - message(FATAL_ERROR "Invalid value for useDeprecatedTargets='${useDeprecatedTargets}'!") + message(FATAL_ERROR "Invalid value useDeprecatedTargets='${useDeprecatedTargets}'!") endif() - set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}_${useDeprecatedTargets}) + set(testBaseName + ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}_${serialOrMpi}_${useDeprecatedTargets}) set(testName ${PACKAGE_NAME}_${testBaseName}) set(testDir ${CMAKE_CURRENT_BINARY_DIR}/${testName}) @@ -109,6 +118,7 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) -DSimpleTpl_INCLUDE_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/include -DSimpleTpl_LIBRARY_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/lib ${buildSharedLibsArg} + ${tplEnableMpiArg} -DCMAKE_INSTALL_PREFIX=${testDir}/install ${TribitsOldSimpleExampleApp_TribitsExampleProject_TRIBITS_DIR}/examples/TribitsExampleProject @@ -169,5 +179,6 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) endfunction() -TribitsOldSimpleExampleApp(STATIC USE_DEPRECATED_TARGETS) -TribitsOldSimpleExampleApp(SHARED USE_NEW_TARGETS) +TribitsOldSimpleExampleApp(STATIC MPI USE_DEPRECATED_TARGETS) +TribitsOldSimpleExampleApp(STATIC SERIAL USE_DEPRECATED_TARGETS) +TribitsOldSimpleExampleApp(SHARED SERIAL USE_NEW_TARGETS) diff --git a/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt b/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt index 0b8d334d5..34302ee7b 100644 --- a/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt +++ b/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt @@ -44,7 +44,7 @@ target_include_directories(util # Build the APP and link to libraries from TribitsExProj packages add_executable(app app.cpp) target_link_libraries(app - PRIVATE ${TribitsExProj_LIBRARIES}) + PRIVATE ${TribitsExProj_LIBRARIES} ${TribitsExProj_TPL_LIBRARIES}) target_include_directories(app PRIVATE ${TribitsExProj_INCLUDE_DIRS} ${TribitsExProj_TPL_INCLUDE_DIRS}) From 9206994415458ecf519bdb638861cccad8caa5ea Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 27 May 2022 17:25:53 -0600 Subject: [PATCH 30/43] Have TPL MPI produce MPI::all_libs and MPIConfig.cmake (#299) This avoids needing to check `if (TARGET ::all_libs)` all over the place. This makes the failing test: TriBITS_TribitsOldSimpleExampleApp_STATIC_MPI_USE_DEPRECATED_TARGETS from the previous commit pass. Next, we can take out all of these silly checks. --- tribits/core/std_tpls/FindTPLMPI.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tribits/core/std_tpls/FindTPLMPI.cmake b/tribits/core/std_tpls/FindTPLMPI.cmake index b3a5bf464..f4917fd6a 100644 --- a/tribits/core/std_tpls/FindTPLMPI.cmake +++ b/tribits/core/std_tpls/FindTPLMPI.cmake @@ -50,3 +50,7 @@ if(WIN32 AND TPL_ENABLE_MPI) global_set(TPL_MPI_LIBRARIES ${MPI_LIBRARIES}) endif() +tribits_tpl_find_include_dirs_and_libraries(MPI) + +# NOTE: Above, we need to generate the MPI::all_libs target and the +# MPIConfig.cmake file that will also provide the MPI::all_libs target. From 700f91679428fd3d28ab28f80909c9bfa4be20f2 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 27 May 2022 20:45:20 -0600 Subject: [PATCH 31/43] Remove worthless `if (TARGET ::all_libs)` checks (#299) Now that the MPI TPL produces MPI::all_libs, there is no more need for these silly checks. This also makes the code have stronger checking in case of mistakes. --- .../package_arch/TribitsAddExecutable.cmake | 8 ++----- .../core/package_arch/TribitsAddLibrary.cmake | 8 ++----- .../TribitsProcessEnabledTpl.cmake | 24 +++++++++---------- .../TribitsWriteClientExportFiles.cmake | 13 +--------- 4 files changed, 16 insertions(+), 37 deletions(-) diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index 312558cbe..fa4294769 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -417,14 +417,10 @@ function(tribits_add_executable EXE_NAME) target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) endforeach() foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) endforeach() foreach(testOnlyLib ${PARSE_TESTONLYLIBS}) target_link_libraries(${EXE_BINARY_NAME} PUBLIC diff --git a/tribits/core/package_arch/TribitsAddLibrary.cmake b/tribits/core/package_arch/TribitsAddLibrary.cmake index 018638e73..2d5b742c9 100644 --- a/tribits/core/package_arch/TribitsAddLibrary.cmake +++ b/tribits/core/package_arch/TribitsAddLibrary.cmake @@ -468,15 +468,11 @@ function(tribits_add_library LIBRARY_NAME_IN) target_link_libraries(${LIBRARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) # ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) endforeach() # ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) - if (TARGET ${depPkg}::all_libs) - target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) - endif() + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) endforeach() # IMPORTEDLIBS foreach(importedLib ${PARSE_IMPORTEDLIBS}) diff --git a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake index d90ae1563..b1e4f1614 100644 --- a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake +++ b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake @@ -154,19 +154,17 @@ function(tribits_process_enabled_tpl TPL_NAME) # Generate the ConfigVersion.cmake file if it has not been # created yet and add install targets for Config[Version].cmake - if (TARGET ${TPL_NAME}::all_libs) - set(buildDirExternalPkgsDir - "${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}") - set(tplConfigFile - "${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} - "${tplConfigVersionFile}") - tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}") - tribits_external_package_install_config_version_file(${TPL_NAME} - "${tplConfigVersionFile}") - endif() + set(buildDirExternalPkgsDir + "${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}") + set(tplConfigFile + "${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} + "${tplConfigVersionFile}") + tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}") + tribits_external_package_install_config_version_file(${TPL_NAME} + "${tplConfigVersionFile}") endif() diff --git a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake index 0572e6a5d..6a9154552 100644 --- a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake +++ b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake @@ -585,9 +585,7 @@ function(tribits_append_dependent_package_config_file_includes_and_enables packa if (${depPkg}_PACKAGE_BUILD_STATUS STREQUAL "INTERNAL") set(packageConfigBaseDir "${pkgConfigFileBaseDir}/${depPkg}") elseif (${depPkg}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") - if (TARGET ${depPkg}::all_libs) # See below NOTE for this if() statement - set(packageConfigBaseDir "${extPkgConfigFileBaseDir}/${depPkg}") - endif() + set(packageConfigBaseDir "${extPkgConfigFileBaseDir}/${depPkg}") else() message(FATAL_ERROR "ERROR: ${depPkg}_PACKAGE_BUILD_STATUS='${${depPkg}_PACKAGE_BUILD_STATUS}' invalid!") endif() @@ -596,15 +594,6 @@ function(tribits_append_dependent_package_config_file_includes_and_enables packa "include(\"${packageConfigBaseDir}/${depPkg}Config.cmake\")\n") endif() endforeach() - # NOTE: Above, every external package/TPL does not have a - # Config.cmake file written for it. For example, special TPLs like - # "MPI" don't have this file created or have an MPI::all_libs target - # created. Therefore, we check for the definition of the target - # ::all_libs before we include the file above. Also, note that in - # the future, compliant external packages that don't need a wrapper - # Config.cmake file created for them will not have a wrapper - # located under "${extPkgConfigFileBaseDir}/". In that case, we will need - # to refactor the code to set _DIR and then run find_dependency(). # Set the output set(${PARSE_CONFIG_FILE_STR_INOUT} "${configFileStr}" PARENT_SCOPE) From 97bcf0d3218ec235509f37f69b0629bd406cd18a Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 3 Jun 2022 13:38:27 -0600 Subject: [PATCH 32/43] Add headers for different sets of unit tests (#483) This is to make the file easier to navigate so I can add more unit tests. This file has gotten way too big and needs to be broken into several smaller files at some point here. --- .../core/TestingFunctionMacro_UnitTests.cmake | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index 8c5058b17..daa71fa3d 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -66,28 +66,23 @@ include(GlobalNullSet) include(AppendStringVar) -##################################################################### +################################################################################ # -# Unit tests for tribits_add_xxx(...) CMake commands run as CMake code +# Unit tests for a collection of TriBITS Core CMake code # -# This file contains a set of unit tests for the package_arch macros -# tribits_add_xxx(...) functions. These unit tests are written in CMake -# itself. This is not a very advanced unit testing system and it not that -# easy to work with. However, it does perform some pretty strong testing and -# is much better than doing nothing. +# These unit tests are written in CMake itself. This is not a very advanced +# unit testing system and it not that easy to work with. However, it does +# perform some pretty strong testing and is much better than doing nothing. +# Each set of tests is in a function scope so as not to impact other tests. # -##################################################################### +################################################################################ +################################################################################ # -# Set up unit test functions that will be called below to actually run the -# unit tests. -# -# The reason that we use functions is so that we can change variables just -# inside of the functions that have their own variable scoping. In that way, -# we can keep variables that are set in one unit test from affecting the -# others. +# Testing misc functions and macros # +################################################################################ function(unittest_append_string_var) @@ -670,6 +665,13 @@ function(unittest_tribits_report_invalid_tribits_usage) endfunction() +################################################################################ +# +# Testing tribits_add_test() +# +################################################################################ + + function(unittest_tribits_add_test_basic) message("\n***") @@ -1304,7 +1306,6 @@ function(unittest_tribits_add_test_basic) "NAME;${PACKEXEN};COMMAND;/some/abs/path/${PACKEXEN}.exe;arg1" ) - # # ADD_DIR_TO_NAME # @@ -2331,6 +2332,13 @@ function(unittest_tribits_add_test_properties) endfunction() +################################################################################ +# +# Testing tribits_add_advanced_test() +# +################################################################################ + + function(unittest_tribits_add_advanced_test_basic) message("\n***") @@ -4135,6 +4143,13 @@ function(unittest_tribits_add_executable_and_test) endfunction() +################################################################################ +# +# Testing TriBITS ETI support code +# +################################################################################ + + function(unittest_tribits_eti_type_expansion) message("*** Test passing invalid arguments to tribits_eti_type_expansion( ... )\n") @@ -4282,6 +4297,7 @@ function(unittest_tribits_add_eti_instantiations_initial) endfunction() + function(unittest_tribits_add_eti_instantiations_cumulative) set(package ${PROJECT_NAME}Framework) @@ -4363,6 +4379,7 @@ function(unittest_tribits_eti_explode) endfunction() + function(unittest_tribits_eti_mangle_symbol) message("*** Testing ETI Mangling ***") @@ -4486,9 +4503,12 @@ function(unittest_tribits_eti_generate_macros) endfunction() + +################################################################################ # # Execute the unit tests # +################################################################################ # Set up some global environment stuff set(${PROJECT_NAME}_HOSTNAME testhost.nowhere.com) @@ -4504,7 +4524,7 @@ set( TRIBITS_ADD_TEST_ADD_TEST_UNITTEST TRUE ) set( TRIBITS_ADD_TEST_ADD_TEST_CAPTURE TRUE ) message("\n***") -message("*** Running little bits of tests") +message("*** Testing misc TriBITS functions and macros") message("***\n") unittest_append_string_var() From ef2397fc7726748ef3782f90c2f3c550cfb392fa Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 2 Jun 2022 11:33:21 -0600 Subject: [PATCH 33/43] message_wrapper() Use arg forwarding to preserve semi-colons (#483) This was not printing out the semi-colons in a list passed to message_wrapper(). I noticed this while working on #483. --- tribits/core/utils/MessageWrapper.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tribits/core/utils/MessageWrapper.cmake b/tribits/core/utils/MessageWrapper.cmake index cf7a0723d..bdcd9e5e2 100644 --- a/tribits/core/utils/MessageWrapper.cmake +++ b/tribits/core/utils/MessageWrapper.cmake @@ -68,11 +68,13 @@ include(GlobalSet) # verify that they say the right thing. # function(message_wrapper) - #message("MESSAGE_WRAPPER: ${ARGN}") + cmake_parse_arguments(PARSE_ARGV 0 FWD "" "" "") + #message("MESSAGE_WRAPPER: ${FWD_UNPARSED_ARGUMENTS}") if (MESSAGE_WRAPPER_UNIT_TEST_MODE) - global_set(MESSAGE_WRAPPER_INPUT "${MESSAGE_WRAPPER_INPUT}" ${ARGN}) + global_set(MESSAGE_WRAPPER_INPUT "${MESSAGE_WRAPPER_INPUT}" + ${FWD_UNPARSED_ARGUMENTS}) else() - message(${ARGN}) + message(${FWD_UNPARSED_ARGUMENTS}) endif() endfunction() From 3d0306df4cddbfc2821967f2505045fdafdfa04b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 3 Jun 2022 13:23:29 -0600 Subject: [PATCH 34/43] Add function unittest_string_var_regex() (#483) I also updated the documentation some for unittest_string_regex(). I do not run the new function unittest_string_var_regex() in this commit but will in a later commit where I manually tested as part of work for #483 to ensure it passes and fails when it should. --- tribits/core/utils/UnitTestHelpers.cmake | 62 +++++++++++++++++-- .../guides/UtilsMacroFunctionDocTemplate.rst | 1 + 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/tribits/core/utils/UnitTestHelpers.cmake b/tribits/core/utils/UnitTestHelpers.cmake index 0345f07e8..912efb0a5 100644 --- a/tribits/core/utils/UnitTestHelpers.cmake +++ b/tribits/core/utils/UnitTestHelpers.cmake @@ -240,12 +240,13 @@ endfunction() # @FUNCTION: unittest_string_regex() # -# Perform a series regexes of given strings and update overall test statistics. +# Perform a series of regexes on a given string and update overall test +# statistics. # # Usage:: # # unittest_string_regex( -# +# "" # REGEX_STRINGS "" "" ... # ) # @@ -279,12 +280,65 @@ function(unittest_string_regex INPUT_STRING) string(REGEX MATCH "${REGEX}" REGEX_MATCH_RESULT "${INPUT_STRING}") + message(" Searching string:") + message(" '${INPUT_STRING}'") + if (REGEX_MATCH_RESULT) + message(" for REGEX {${REGEX}}: [PASSED]\n") + math( EXPR NUMPASSED ${UNITTEST_OVERALL_NUMPASSED}+1 ) + global_set(UNITTEST_OVERALL_NUMPASSED ${NUMPASSED}) + else() + message(" for REGEX {${REGEX}}: [FAILED]\n") + global_set(UNITTEST_OVERALL_PASS FALSE) + message(WARNING "Stack trace for failed unit test") + endif() + + endforeach() + +endfunction() + + +# @FUNCTION: unittest_string_var_regex() +# +# Perform a series of regexes on a given string variable and update overall +# test statistics. +# +# Usage:: +# +# unittest_string_var_regex( +# +# REGEX_STRINGS "" "" ... +# ) +# +# If the ``"${}"`` matches all of the of the regexs +# ``""``, ``""``, ..., then the test passes. Otherwise it fails. +# +# This updates the global variables ``UNITTEST_OVERALL_NUMRUN``, +# ``UNITTEST_OVERALL_NUMPASSED``, and ``UNITTEST_OVERALL_PASS`` which are used +# by the unit test harness system to assess overall pass/fail. +# +function(unittest_string_var_regex inputStringVar) + + cmake_parse_arguments(PARSE_ARGV 1 + PARSE "" "" # prefix, options, one_value_keywords + "REGEX_STRINGS" #multi_value_keywords + ) + tribits_check_for_unparsed_arguments(PARSE) + + foreach(REGEX ${PARSE_REGEX_STRINGS}) + + math( EXPR NUMRUN ${UNITTEST_OVERALL_NUMRUN}+1 ) + global_set(UNITTEST_OVERALL_NUMRUN ${NUMRUN}) + + string(REGEX MATCH "${REGEX}" REGEX_MATCH_RESULT "${${inputStringVar}}") + + message("Searching string variable value '${inputStringVar}':") + message(" '${${inputStringVar}}'") if (REGEX_MATCH_RESULT) - message(" Searching for REGEX {${REGEX}}: [PASSED]\n") + message(" for REGEX {${REGEX}}: [PASSED]\n") math( EXPR NUMPASSED ${UNITTEST_OVERALL_NUMPASSED}+1 ) global_set(UNITTEST_OVERALL_NUMPASSED ${NUMPASSED}) else() - message(" Searching for REGEX {${REGEX}}: [FAILED]\n") + message(" for REGEX {${REGEX}}: [FAILED]\n") global_set(UNITTEST_OVERALL_PASS FALSE) message(WARNING "Stack trace for failed unit test") endif() diff --git a/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst b/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst index e75e63e38..f5c4cf397 100644 --- a/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst @@ -44,5 +44,6 @@ @FUNCTION: unittest_has_substr_const() + @FUNCTION: unittest_not_has_substr_const() + @FUNCTION: unittest_string_regex() + +@FUNCTION: unittest_string_var_regex() + @FUNCTION: unittest_file_regex() + @FUNCTION: unittest_final_result() + From ec9ebfc8ea98581cff2f62a995e0000cf0364bed Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 2 Jun 2022 11:40:57 -0600 Subject: [PATCH 35/43] Moved arg parsing helper functions into new modules (#483) This makes the module TribitsGeneralMacros.cmake smaller and better aggregates these commands. I also added a new macro tribits_assert_parse_arg_one_value() which I just tested manually. It is a very simple macro so I am not too worried about not unit testing it yet. --- .../UserErrorChecking_Tests.cmake | 6 +- .../package_arch/TribitsGeneralMacros.cmake | 60 +------ .../utils/TribitsParseArgumentsHelpers.cmake | 150 ++++++++++++++++++ 3 files changed, 154 insertions(+), 62 deletions(-) create mode 100644 tribits/core/utils/TribitsParseArgumentsHelpers.cmake diff --git a/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake b/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake index b69fa541c..a18c57e26 100644 --- a/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake +++ b/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake @@ -298,7 +298,7 @@ tribits_add_advanced_test( TribitsExampleProject_PkgWithUserErrors_UNPARSED_ARGU -DTribitsExProj_ENABLE_TESTS=ON TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL - "CMake Error at.*TribitsGeneralMacros.cmake:" + "CMake Error at.*TribitsParseArgumentsHelpers.cmake:" "Arguments passed in unrecognized. PARSE_UNPARSED_ARGUMENTS =" "nonsense_jdslkfhlskd" "tribits_read_toplevel_package_deps_files_add_to_graph" @@ -320,7 +320,7 @@ tribits_add_advanced_test( TribitsExampleProject_PkgWithUserErrors_UNPARSED_ARGU -DTribitsExProj_ENABLE_TESTS=ON TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL - "CMake Error at.*TribitsGeneralMacros.cmake:" + "CMake Error at.*TribitsParseArgumentsHelpers.cmake:" "Arguments passed in unrecognized. PARSE_UNPARSED_ARGUMENTS =" "this_shouldnt_be_here" "PkgWithUserErrors/CMakeLists.txt.*tribits_add_library" @@ -343,7 +343,7 @@ tribits_add_advanced_test( TribitsExampleProject_PkgWithUserErrors_UNPARSED_ARGU -DTribitsExProj_ENABLE_TESTS=ON TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL - "CMake Error at.*TribitsGeneralMacros.cmake:" + "CMake Error at.*TribitsParseArgumentsHelpers.cmake:" "Arguments passed in unrecognized. PARSE_UNPARSED_ARGUMENTS =" "misspelled_argument" "PkgWithUserErrors/CMakeLists.txt.*tribits_add_executable" diff --git a/tribits/core/package_arch/TribitsGeneralMacros.cmake b/tribits/core/package_arch/TribitsGeneralMacros.cmake index df170daee..bd05810ae 100644 --- a/tribits/core/package_arch/TribitsGeneralMacros.cmake +++ b/tribits/core/package_arch/TribitsGeneralMacros.cmake @@ -40,6 +40,7 @@ include(AppendSet) include(AssertDefined) include(MessageWrapper) +include(TribitsParseArgumentsHelpers) include(TribitsSortListAccordingToMasterList) @@ -411,62 +412,3 @@ function(tribits_trace_file_processing TYPE_IN PROCESSING_TYPE_IN FILE_PATH) endfunction() -# Check to see if there are unparsed arguments after calling -# cmake_parse_arguments() or tribits_parse_arguments_from_lsit() -# -# Usage:: -# -# tribits_check_for_unparsed_arguments([]) -# -# If `` is not given, it is assumed to be `PARSE`. -# -function(tribits_check_for_unparsed_arguments) - - if ("${ARGC}" GREATER 1) - MESSAGE(FATAL_ERROR - "ERROR tribits_check_for_unparsed_arguments() passed arguments '${ARGV}' but only accepts 0 or 1 arguments (for the )") - endif() - - set(prefix "PARSE") - foreach(arg ${ARGV}) - set(prefix "${arg}") - endforeach() - - if( NOT "${${prefix}_UNPARSED_ARGUMENTS}" STREQUAL "") - message_wrapper( - ${${PROJECT_NAME}_CHECK_FOR_UNPARSED_ARGUMENTS} - "Arguments passed in unrecognized. ${prefix}_UNPARSED_ARGUMENTS = '${${prefix}_UNPARSED_ARGUMENTS}'" - ) - endif() - -endfunction() - - -# Check that a parase argument has at least one value -# -macro(tribits_assert_parse_arg_one_or_more_values PREFIX ARGNAME) - set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") - list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) - if (ARG_NUM_VALS LESS 1) - message_wrapper(FATAL_ERROR - "ERROR: ${ARGNAME} must have at least one value!" ) - return() - # NOTE: The return is needed in unit testing mode - endif() -endmacro() - - -# Check that a parase argument has zero or one value -# -macro(tribits_assert_parse_arg_zero_or_one_value PREFIX ARGNAME) - set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") - if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") - list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) - if (ARG_NUM_VALS GREATER 1) - message_wrapper(FATAL_ERROR - "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' can not have more than one value!" ) - return() - # NOTE: The return is needed in unit testing mode - endif() - endif() -endmacro() diff --git a/tribits/core/utils/TribitsParseArgumentsHelpers.cmake b/tribits/core/utils/TribitsParseArgumentsHelpers.cmake new file mode 100644 index 000000000..c099840d4 --- /dev/null +++ b/tribits/core/utils/TribitsParseArgumentsHelpers.cmake @@ -0,0 +1,150 @@ +# @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 + + +################################################################################ +# +# This module contains function to aid with the usage of +# cmake_parse_arguments(). +# +################################################################################ + + +include(MessageWrapper) + + +# @FUNCTION: tribits_check_for_unparsed_arguments() +# +# Check to see if there are unparsed arguments after calling +# ``cmake_parse_arguments()`` or ``tribits_parse_arguments_from_list()`` +# +# Usage:: +# +# tribits_check_for_unparsed_arguments([]) +# +# If `` is not given, it is assumed to be `PARSE`. +# +function(tribits_check_for_unparsed_arguments) + + if ("${ARGC}" GREATER 1) + message(FATAL_ERROR + "ERROR tribits_check_for_unparsed_arguments() passed arguments '${ARGV}' but only accepts 0 or 1 arguments (for )") + endif() + + set(prefix "PARSE") + foreach(arg ${ARGV}) + set(prefix "${arg}") + endforeach() + + if( NOT "${${prefix}_UNPARSED_ARGUMENTS}" STREQUAL "") + message_wrapper( + ${${PROJECT_NAME}_CHECK_FOR_UNPARSED_ARGUMENTS} + "Arguments passed in unrecognized. ${prefix}_UNPARSED_ARGUMENTS = '${${prefix}_UNPARSED_ARGUMENTS}'" + ) + endif() + +endfunction() + + +# @MACRO: tribits_assert_parse_arg_one_or_more_values() +# +# Assert that a parase argument has at least one value +# +# Usage:: +# +# tribits_assert_parse_arg_one_or_more_values( ) +# +macro(tribits_assert_parse_arg_one_or_more_values PREFIX ARGNAME) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (ARG_NUM_VALS LESS 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME} must have at least one value!" ) + return() + # NOTE: The return() is needed in unit testing mode + endif() +endmacro() + + +# @MACRO: tribits_assert_parse_arg_zero_or_one_value() +# +# Assert that a parase argument has zero or one value +# +# Usage:: +# +# tribits_assert_parse_arg_zero_or_one_value( ) +# +macro(tribits_assert_parse_arg_zero_or_one_value PREFIX ARGNAME) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (ARG_NUM_VALS GREATER 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' can not have more than one value!" ) + return() + # NOTE: The macro return() is needed in unit testing mode + endif() + endif() +endmacro() + + +# @MACRO: tribits_assert_parse_arg_one_value() +# +# Assert that a parse argument has exactly one value +# +# Usage:: +# +# tribits_assert_parse_arg_one_value( ) +# +macro(tribits_assert_parse_arg_one_value PREFIX ARGNAME) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (NOT ARG_NUM_VALS EQUAL 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' Must have exactly one value!" ) + return() + # NOTE: The macro return() is needed in unit testing mode + endif() + endif() +endmacro() + + +# NOTE: Above, we use macros for the assert functions with returns in unit +# test mode so that it will abort the calling function these are called from! From 64dc7e5ce85e3cfaae28ea024e13e2486bd3c8ac Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 3 Jun 2022 07:15:43 -0600 Subject: [PATCH 36/43] Change parse argument assert functions to accept a list of args (#483) This allows more compact argument parsing code and checking --- .../utils/TribitsParseArgumentsHelpers.cmake | 80 ++++++++++--------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/tribits/core/utils/TribitsParseArgumentsHelpers.cmake b/tribits/core/utils/TribitsParseArgumentsHelpers.cmake index c099840d4..c4cd79fdf 100644 --- a/tribits/core/utils/TribitsParseArgumentsHelpers.cmake +++ b/tribits/core/utils/TribitsParseArgumentsHelpers.cmake @@ -84,65 +84,71 @@ endfunction() # @MACRO: tribits_assert_parse_arg_one_or_more_values() # -# Assert that a parase argument has at least one value +# Assert that a set of parse argument have at least one value # # Usage:: # -# tribits_assert_parse_arg_one_or_more_values( ) +# tribits_assert_parse_arg_one_or_more_values( ...) # -macro(tribits_assert_parse_arg_one_or_more_values PREFIX ARGNAME) - set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") - list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) - if (ARG_NUM_VALS LESS 1) - message_wrapper(FATAL_ERROR - "ERROR: ${ARGNAME} must have at least one value!" ) - return() - # NOTE: The return() is needed in unit testing mode - endif() +macro(tribits_assert_parse_arg_one_or_more_values PREFIX) + foreach(ARGNAME ${ARGN}) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (ARG_NUM_VALS LESS 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME} must have at least one value!" ) + return() + # NOTE: The return() is needed in unit testing mode + endif() + endforeach() endmacro() # @MACRO: tribits_assert_parse_arg_zero_or_one_value() # -# Assert that a parase argument has zero or one value +# Assert a set of parse arguments have zero or one value # # Usage:: # -# tribits_assert_parse_arg_zero_or_one_value( ) -# -macro(tribits_assert_parse_arg_zero_or_one_value PREFIX ARGNAME) - set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") - if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") - list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) - if (ARG_NUM_VALS GREATER 1) - message_wrapper(FATAL_ERROR - "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' can not have more than one value!" ) - return() - # NOTE: The macro return() is needed in unit testing mode +# tribits_assert_parse_arg_zero_or_one_value( ...) +# +macro(tribits_assert_parse_arg_zero_or_one_value PREFIX) + foreach(ARGNAME ${ARGN}) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (ARG_NUM_VALS GREATER 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' can not have more than one value!" ) + return() + # NOTE: The macro return() is needed in unit testing mode + endif() endif() - endif() + endforeach() endmacro() # @MACRO: tribits_assert_parse_arg_one_value() # -# Assert that a parse argument has exactly one value +# Assert that a set of parse arguments have exactly one value # # Usage:: # -# tribits_assert_parse_arg_one_value( ) -# -macro(tribits_assert_parse_arg_one_value PREFIX ARGNAME) - set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") - if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") - list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) - if (NOT ARG_NUM_VALS EQUAL 1) - message_wrapper(FATAL_ERROR - "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' Must have exactly one value!" ) - return() - # NOTE: The macro return() is needed in unit testing mode +# tribits_assert_parse_arg_one_value( ...) +# +macro(tribits_assert_parse_arg_one_value PREFIX) + foreach(ARGNAME ${ARGN}) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (NOT ARG_NUM_VALS EQUAL 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' Must have exactly one value!" ) + return() + # NOTE: The macro return() is needed in unit testing mode + endif() endif() - endif() + endforeach() endmacro() From 8721ff0fe227b624cf92dbfa1a6c25d7777d2a42 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 1 Jun 2022 19:56:38 -0600 Subject: [PATCH 37/43] Factor out functions into TribitsGitRepoVersionInfo.cmake (#483) We need to be breaking up TribitsGlobalMacros.cmake because it is too long. I also added a new function to get just the 40-char SHA1 and I added unit tests for it. --- test/core/CMakeLists.txt | 2 +- .../core/TestingFunctionMacro_UnitTests.cmake | 53 ++++- .../TribitsGitRepoVersionInfo.cmake | 187 ++++++++++++++++++ .../package_arch/TribitsGlobalMacros.cmake | 70 +------ 4 files changed, 241 insertions(+), 71 deletions(-) create mode 100644 tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 659f59324..8622e3bcf 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -49,7 +49,7 @@ tribits_add_advanced_test( TestingFunctionMacro_UnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/TestingFunctionMacro_UnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 696" + "Final UnitTests Result: num_run = 703" "Final UnitTests Result: PASSED" ) diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index daa71fa3d..027c23fc0 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -60,6 +60,7 @@ include(TribitsFilepathHelpers) include(TribitsGetVersionDate) include(TribitsTplFindIncludeDirsAndLibraries) include(TribitsReportInvalidTribitsUsage) +include(TribitsGitRepoVersionInfo) include(UnitTestHelpers) include(GlobalSet) include(GlobalNullSet) @@ -487,6 +488,55 @@ function(unittest_tribits_get_version_date_from_raw_git_commit_utc_time) endfunction() +function(unittest_tribits_git_repo_sha1) + + message("\n***") + message("*** Testing tribits_git_repo_sha1()") + message("***\n") + + find_program(GIT_EXECUTABLE ${GIT_NAME}) + + set(tribitsProjDir "${${PROJECT_NAME}_TRIBITS_DIR}/..") + + # Matches any 40-char SHA1 + set(anySha1Regex "") + foreach(i RANGE 0 39) + string(APPEND anySha1Regex "[a-z0-9]") + endforeach() + + if (IS_DIRECTORY "${tribitsProjDir}/.git") + + message("Testing tribits_git_repo_sha1() with the base TriBITS project (without FAILURE_MESSAGE_OUT)\n") + tribits_git_repo_sha1("${tribitsProjDir}" gitRepoSha1) + unittest_string_var_regex(gitRepoSha1 REGEX_STRINGS "${anySha1Regex}") + + message("Testing tribits_git_repo_sha1() with the base TriBITS project (with FAILURE_MESSAGE_OUT)\n") + tribits_git_repo_sha1("${tribitsProjDir}" gitRepoSha1 + FAILURE_MESSAGE_OUT failureMsg) + unittest_string_var_regex(gitRepoSha1 REGEX_STRINGS "${anySha1Regex}") + unittest_compare_const(failureMsg "") + + endif() + + message("Testing tribits_git_repo_sha1(): No GIT_EXECUTABLE (with FAILURE_MESSAGE_OUT)\n") + set(GIT_EXECUTABLE_SAVED "${GIT_EXECUTABLE}") + set(GIT_EXECUTABLE "") + tribits_git_repo_sha1("${tribitsProjDir}" gitRepoSha1 + FAILURE_MESSAGE_OUT failureMsg) + unittest_compare_const(gitRepoSha1 "") + unittest_compare_const(failureMsg "ERROR: The program 'git' could not be found!") + set(GIT_EXECUTABLE "${GIT_EXECUTABLE_SAVED}") + unset(GIT_EXECUTABLE_SAVED) + + message("Testing tribits_git_repo_sha1(): Invalid repo dir (with FAILURE_MESSAGE_OUT)\n") + tribits_git_repo_sha1("/repo/does/not/exist" gitRepoSha1 + FAILURE_MESSAGE_OUT failureMsg) + unittest_compare_const(gitRepoSha1 "") + unittest_compare_const(failureMsg "ERROR: The directory /repo/does/not/exist/.git does not exist!") + +endfunction() + + function(unittest_tribits_tpl_allow_pre_find_package) message("\n***") @@ -4536,6 +4586,7 @@ unittest_tribits_misc() unittest_tribits_strip_quotes_from_str() unittest_tribits_get_version_date_from_raw_git_commit_utc_time() unittest_tribits_get_raw_git_commit_utc_time() +unittest_tribits_git_repo_sha1() unittest_tribits_tpl_allow_pre_find_package() unittest_tribits_report_invalid_tribits_usage() @@ -4592,4 +4643,4 @@ message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(696) +unittest_final_result(703) diff --git a/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake b/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake new file mode 100644 index 000000000..9d4943dc8 --- /dev/null +++ b/tribits/core/package_arch/TribitsGitRepoVersionInfo.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 + +################################################################################ +# +# Module containing functions for getting Git repo information +# +################################################################################ + + +# @FUNCTION: tribits_git_repo_sha1() +# +# Get the Git repo version SHA1. +# +# Usage:: +# +# tribits_git_repo_sha1( +# FAILURE_MESSAGE_OUT ) +# +# If ```` is non-empty on input, then the variable +# ```` will be set to a non-empty value on output with the +# error message if an error occurs and the SHA1 for ```` can not +# be computed. If ```` is empty in input, and there is an +# error, a ``FATAL_ERROR`` will be raised. +# +# NOTE: To get the SHA1 for the Git repo ````, it must contain the +# ``.git/`` directory and the ``git`` executable var ``GIT_EXECUTABLE`` must +# be set. Otherwise, it is an error. +# +function(tribits_git_repo_sha1 gitRepoDir gitRepoSha1Out) + + cmake_parse_arguments( PARSE_ARGV 2 + PARSE "" "" # prefix, options, one_value_keywords + "FAILURE_MESSAGE_OUT" # multi_value_keywords + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_zero_or_one_value(PARSE FAILURE_MESSAGE_OUT) + + set(failureMsg "") + + if (NOT GIT_EXECUTABLE) + set(failureMsg "ERROR: The program '${GIT_NAME}' could not be found!") + elseif (NOT IS_DIRECTORY "${gitRepoDir}/.git") + set(failureMsg "ERROR: The directory ${gitRepoDir}/.git does not exist!") + endif() + + set(gitRepoSha1 "") + if (failureMsg STREQUAL "") + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%H" + WORKING_DIRECTORY ${gitRepoDir} + RESULT_VARIABLE gitCmndRtn OUTPUT_VARIABLE gitCmndOutput + ) + # NOTE: Above we have to add quotes '"' or CMake will not accept the + # command. However, git will put those quotes in the output so we have to + # strip them out below! + + if (NOT gitCmndRtn STREQUAL 0) + set(failureMsg "ERROR: ${GIT_EXECUTABLE} command returned ${gitCmndRtn}!=0 for repo ${gitRepoDir}!") + else() + # Strip the quotes off :-( + string(LENGTH "${gitCmndOutput}" gitCmndOutputLen) + math(EXPR outputNumCharsToKeep "${gitCmndOutputLen}-2") + string(SUBSTRING "${gitCmndOutput}" 1 ${outputNumCharsToKeep} gitRepoSha1) + endif() + endif() + # ToDo: Factor above out into its own function! + + if (NOT failureMsg STREQUAL "" AND PARSE_FAILURE_MESSAGE_OUT STREQUAL "") + message(FATAL_ERROR "${failureMsg}") + elseif (PARSE_FAILURE_MESSAGE_OUT) + set(${PARSE_FAILURE_MESSAGE_OUT} "${failureMsg}" PARENT_SCOPE) + endif() + set(${gitRepoSha1Out} "${gitRepoSha1}" PARENT_SCOPE) + +endfunction() + + +# Run the git log command to get the version info for a git repo +# +function(tribits_generate_single_repo_version_string gitRepoDir + repoVersionStringOut + ) + + tribits_assert_git_executable() + + # A) Get the basic version info. + + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%h [%ad] <%ae>" + WORKING_DIRECTORY ${gitRepoDir} + RESULT_VARIABLE gitCmndRtn + OUTPUT_VARIABLE gitCmndOutput + ) + # NOTE: Above we have to add quotes '"' or CMake will not accept the + # command. However, git will put those quotes in the output so we have to + # strip them out later :-( + + if (NOT gitCmndRtn STREQUAL 0) + message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${gitCmndRtn}!=0" + " for repo ${gitRepoDir}!") + set(gitVersionLine "Error, could not get version info!") + else() + # Strip the quotes off :-( + string(LENGTH "${gitCmndOutput}" gitCmndOutputLen) + math(EXPR outputNumCharsToKeep "${gitCmndOutputLen}-2") + string(SUBSTRING "${gitCmndOutput}" 1 ${outputNumCharsToKeep} + gitVersionLine) + endif() + + # B) Get the first 80 chars of the summary message for more info + + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%s" + WORKING_DIRECTORY ${gitRepoDir} + RESULT_VARIABLE gitCmndRtn + OUTPUT_VARIABLE gitCmndOutput + ) + + if (NOT gitCmndRtn STREQUAL 0) + message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${gitCmndRtn}!=0" + " for extra repo ${gitRepoDir}!") + set(gitSummaryStr "Error, could not get version summary!") + else() + # Strip off quotes and quote the 80 char string + set(maxSummaryLen 80) + math(EXPR maxSummaryLen_PLUS_2 "${maxSummaryLen}+2") + string(LENGTH "${gitCmndOutput}" gitCmndOutputLen) + math(EXPR outputNumCharsToKeep "${gitCmndOutputLen}-2") + string(SUBSTRING "${gitCmndOutput}" 1 ${outputNumCharsToKeep} + gitCmndOutputStripped) + if (gitCmndOutputLen GREATER ${maxSummaryLen_PLUS_2}) + string(SUBSTRING "${gitCmndOutputStripped}" 0 ${maxSummaryLen} + gitSummaryStr) + else() + set(gitSummaryStr "${gitCmndOutputStripped}") + endif() + endif() + + set(${repoVersionStringOut} + "${gitVersionLine}\n${gitSummaryStr}" PARENT_SCOPE) + +endfunction() + + +function(tribits_assert_git_executable) + if (NOT GIT_EXECUTABLE) + message(SEND_ERROR "ERROR, the program '${GIT_NAME}' could not be found!" + " We can not generate the repo version file!") + endif() +endfunction() diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 860e75c65..50340fb5a 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -50,6 +50,7 @@ include(TribitsGetVersionDate) include(TribitsReportInvalidTribitsUsage) include(TribitsReadAllProjectDepsFilesCreateDepsGraph) include(TribitsAdjustPackageEnables) +include(TribitsGitRepoVersionInfo) # Standard TriBITS utilities includes include(TribitsAddOptionAndDefine) @@ -1251,75 +1252,6 @@ macro(tribits_copy_installer_resource _varname _source _destination) COPYONLY) endmacro() -# Run the git log command to get the version info for a git repo -# -function(tribits_generate_single_repo_version_string GIT_REPO_DIR - SINGLE_REPO_VERSION_STRING_OUT - ) - - if (NOT GIT_EXECUTABLE) - message(SEND_ERROR "ERROR, the program '${GIT_NAME}' could not be found!" - " We can not generate the repo version file!") - endif() - - # A) Get the basic version info. - - execute_process( - COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%h [%ad] <%ae>" - WORKING_DIRECTORY ${GIT_REPO_DIR} - RESULT_VARIABLE GIT_RETURN - OUTPUT_VARIABLE GIT_OUTPUT - ) - # NOTE: Above we have to add quotes '"' or CMake will not accept the - # command. However, git will put those quotes in the output so we have to - # strip them out later :-( - - if (NOT GIT_RETURN STREQUAL 0) - message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${GIT_RETURN}!=0" - " for extra repo ${GIT_REPO_DIR}!") - set(GIT_VERSION_INFO "Error, could not get version info!") - else() - # Strip the quotes off :-( - string(LENGTH "${GIT_OUTPUT}" GIT_OUTPUT_LEN) - math(EXPR OUTPUT_NUM_CHARS_TO_KEEP "${GIT_OUTPUT_LEN}-2") - string(SUBSTRING "${GIT_OUTPUT}" 1 ${OUTPUT_NUM_CHARS_TO_KEEP} - GIT_VERSION_INFO) - endif() - - # B) Get the first 80 chars of the summary message for more info - - execute_process( - COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%s" - WORKING_DIRECTORY ${GIT_REPO_DIR} - RESULT_VARIABLE GIT_RETURN - OUTPUT_VARIABLE GIT_OUTPUT - ) - - if (NOT GIT_RETURN STREQUAL 0) - message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${GIT_RETURN}!=0" - " for extra repo ${GIT_REPO_DIR}!") - set(GIT_VERSION_SUMMARY "Error, could not get version summary!") - else() - # Strip ouf quotes and quote the 80 char string - set(MAX_SUMMARY_LEN 80) - math(EXPR MAX_SUMMARY_LEN_PLUS_2 "${MAX_SUMMARY_LEN}+2") - string(LENGTH "${GIT_OUTPUT}" GIT_OUTPUT_LEN) - math(EXPR OUTPUT_NUM_CHARS_TO_KEEP "${GIT_OUTPUT_LEN}-2") - string(SUBSTRING "${GIT_OUTPUT}" 1 ${OUTPUT_NUM_CHARS_TO_KEEP} - GIT_OUTPUT_STRIPPED) - if (GIT_OUTPUT_LEN GREATER ${MAX_SUMMARY_LEN_PLUS_2}) - string(SUBSTRING "${GIT_OUTPUT_STRIPPED}" 0 ${MAX_SUMMARY_LEN} - GIT_SUMMARY_STR) - else() - set(GIT_SUMMARY_STR "${GIT_OUTPUT_STRIPPED}") - endif() - endif() - - set(${SINGLE_REPO_VERSION_STRING_OUT} - "${GIT_VERSION_INFO}\n${GIT_SUMMARY_STR}" PARENT_SCOPE) - -endfunction() - # Get the versions of all the git repos # From 9f76105468e8ea6237dfe0170a1a5330a585a430 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 3 Jun 2022 05:36:27 -0600 Subject: [PATCH 38/43] Set list policy to avoid warning (#483) This comes up with refactorings being done for #483. --- tribits/ctest_driver/TribitsReadTagFile.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/tribits/ctest_driver/TribitsReadTagFile.cmake b/tribits/ctest_driver/TribitsReadTagFile.cmake index 6fac636d7..5400b55f1 100644 --- a/tribits/ctest_driver/TribitsReadTagFile.cmake +++ b/tribits/ctest_driver/TribitsReadTagFile.cmake @@ -10,6 +10,7 @@ function(tribits_read_ctest_tag_file tagFileIn buildStartTimeOut cdashGroupOut cdashModelOut ) + cmake_policy(SET CMP0007 NEW) file(READ "${tagFileIn}" tagFileStr) string(REPLACE "\n" ";" tagFileStrList "${tagFileStr}") list(GET tagFileStrList 0 buildStartTime) From a22b038f338b48e01a119b4afceabaa9caca580e Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 31 May 2022 08:54:23 -0600 Subject: [PATCH 39/43] Rename to TribitsGetCDashUrlsInsideCTestS.cmake (#483) I will be adding functions for getting CDash URLs other than just for builds. --- test/ctest_driver/CTestDriverUnitTests.cmake | 2 +- tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake | 2 +- ...lFromTagFile.cmake => TribitsGetCDashUrlsInsideCTestS.cmake} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename tribits/ctest_driver/{TribitsGetCDashUrlFromTagFile.cmake => TribitsGetCDashUrlsInsideCTestS.cmake} (100%) diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index d81d299e7..67ab8079a 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -50,7 +50,7 @@ include(GlobalSet) include(UnitTestHelpers) include(TribitsReadTagFile) -include(TribitsGetCDashUrlFromTagFile) +include(TribitsGetCDashUrlsInsideCTestS) function(unittest_tribits_read_ctest_tag_file) diff --git a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake index ed329adf1..58ffc6264 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake @@ -38,7 +38,7 @@ # @HEADER -include(TribitsGetCDashUrlFromTagFile) +include(TribitsGetCDashUrlsInsideCTestS) # Wrapper used for unit testing purposes diff --git a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake similarity index 100% rename from tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake rename to tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake From d951cc9ce388ec848a8c872f82a17dd23e29b531 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 1 Jun 2022 10:55:13 -0600 Subject: [PATCH 40/43] Rename to tribits_print_cdash_url(), change print msg (#483) This is part of a refactoring to display more CDash URLs other than just build URLs. --- test/ctest_driver/TribitsExampleProject/CMakeLists.txt | 4 ++-- tribits/ctest_driver/TribitsCTestDriverCore.cmake | 6 ++++-- .../ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt index c2ec213ae..602b6e4a9 100644 --- a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt @@ -1299,9 +1299,9 @@ function(generate_aao_tests) "NONE does not exist, skipping extra repositories" "Final set of enabled packages: SimpleCxx 1" "Final set of enabled SE packages: SimpleCxx 1" - "Results will be submitted on CDash at:" + "Results will be submitted to CDash at:" "File '' does NOT exist so all tests passed" - "See results submitted on CDash at:" + "See results submitted to CDash at:" "${cdash_url_expected_regex}" "TRIBITS_CTEST_DRIVER: OVERALL: ALL PASSED" ALWAYS_FAIL_ON_NONZERO_RETURN diff --git a/tribits/ctest_driver/TribitsCTestDriverCore.cmake b/tribits/ctest_driver/TribitsCTestDriverCore.cmake index e02d292c4..253dea48a 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCore.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCore.cmake @@ -2095,7 +2095,8 @@ function(tribits_ctest_driver) tribits_remember_if_configure_attempted() tribits_get_build_url_and_write_to_file(CDASH_BUILD_URL "${CTEST_BINARY_DIRECTORY}/CDashBuildUrl.txt") - tribits_print_build_url("Results will be submitted on CDash at:" "${CDASH_BUILD_URL}") + tribits_print_cdash_url("Results will be submitted to CDash at:" + "${CDASH_BUILD_URL}") message( "\n***" @@ -2369,7 +2370,8 @@ function(tribits_ctest_driver) report_queued_errors() - tribits_print_build_url("See results submitted on CDash at:" "${CDASH_BUILD_URL}") + tribits_print_cdash_url("See results submitted to CDash at:" + "${CDASH_BUILD_URL}") if ((NOT UPDATE_FAILED) AND ("${${PROJECT_NAME}_FAILED_PACKAGES}" STREQUAL "")) message( diff --git a/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake index 944a598d6..9fc812b63 100644 --- a/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake +++ b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake @@ -53,17 +53,17 @@ function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUr endfunction() -# @FUNCTION: tribits_print_build_url() +# @FUNCTION: tribits_print_cdash_url() # # Print the URL on CDash where build results can be found. # # Usage:: # -# tribits_print_build_url( ) +# tribits_print_cdash_url( ) # -function(tribits_print_build_url msg cdashBuildUrl) +function(tribits_print_cdash_url msg cdashUrl) message("\n${msg}\n") - message(" ${cdashBuildUrl}\n") + message(" ${cdashUrl}\n") endfunction() From 32cc1ad6f58d1bbc5977e26454b96b6eb1b4b40b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 3 Jun 2022 14:49:17 -0600 Subject: [PATCH 41/43] Factor out tribits_get_cdash_site_from_drop_site_and_location() (#483) This will make this easier to reuse to get other CDash URLs. --- test/ctest_driver/CMakeLists.txt | 2 +- test/ctest_driver/CTestDriverUnitTests.cmake | 22 ++++- .../TribitsGetCDashUrlsInsideCTestS.cmake | 84 ++++++++++++++++++- 3 files changed, 101 insertions(+), 7 deletions(-) diff --git a/test/ctest_driver/CMakeLists.txt b/test/ctest_driver/CMakeLists.txt index e4b75a620..92455ce4f 100644 --- a/test/ctest_driver/CMakeLists.txt +++ b/test/ctest_driver/CMakeLists.txt @@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 6" + "Final UnitTests Result: num_run = 9" "Final UnitTests Result: PASSED" ) diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index 67ab8079a..ee6d5b8df 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -73,6 +73,23 @@ function(unittest_tribits_read_ctest_tag_file) endfunction() +function(unittest_tribits_get_cdash_site_from_drop_site_and_location) + + message("\n***") + message("*** Testing tribits_get_cdash_site_from_drop_site_and_location()") + message("***\n") + + tribits_get_cdash_site_from_drop_site_and_location( + CTEST_DROP_SITE "some.site.com" + CTEST_DROP_LOCATION "/cdash/submit.php?project=SomeProject" + CDASH_SITE_URL_OUT cdashSiteUrl + ) + + unittest_compare_const(cdashSiteUrl "https://some.site.com/cdash") + +endfunction() + + function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location) message("\n***") @@ -85,7 +102,7 @@ function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location) INDEX_PHP_URL_OUT indexPhpUrl ) - unittest_compare_const(indexPhpUrl "some.site.com/cdash/index.php") + unittest_compare_const(indexPhpUrl "https://some.site.com/cdash/index.php") endfunction() @@ -142,6 +159,7 @@ unittest_initialize_vars() # Run the unit test functions unittest_tribits_read_ctest_tag_file() +unittest_tribits_get_cdash_site_from_drop_site_and_location() unittest_tribits_get_cdash_index_php_from_drop_site_and_location() unittest_tribits_get_cdash_build_url_from_parts() unittest_tribits_get_cdash_build_url_from_tag_file() @@ -151,4 +169,4 @@ message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(6) +unittest_final_result(9) diff --git a/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake index 9fc812b63..a72a760f4 100644 --- a/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake +++ b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake @@ -1,3 +1,45 @@ +# @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 + + +include(PrintVar) +include(TribitsParseArgumentsHelpers) include(TribitsReadTagFile) @@ -45,7 +87,7 @@ function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUr TAG_FILE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" CDASH_BUILD_URL_OUT cdashBuildUrl ) - set(cdashBuildUrl "https://${cdashBuildUrl}") + set(cdashBuildUrl "${cdashBuildUrl}") if (cdashBuildUrlFile) file(WRITE "${cdashBuildUrlFile}" "${cdashBuildUrl}") endif() @@ -125,11 +167,45 @@ function(tribits_get_cdash_index_php_from_drop_site_and_location) "" #multi_value_keywords ${ARGN} ) + tribits_get_cdash_site_from_drop_site_and_location( + CTEST_DROP_SITE ${PREFIX_CTEST_DROP_SITE} + CTEST_DROP_LOCATION ${PREFIX_CTEST_DROP_LOCATION} + CDASH_SITE_URL_OUT cdashSiteUrl ) + SET(${PREFIX_INDEX_PHP_URL_OUT} "${cdashSiteUrl}/index.php" PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_site_from_drop_site_and_location() +# +# Get the full CDash site base URL from the input CTEST_DROP_SITE and +# CTEST_DROP_LOCATION vars used in a ctest -S script. +# +# Usage:: +# +# tribits_get_cdash_site_from_drop_site_and_location( +# CTEST_DROP_SITE +# CTEST_DROP_LOCATION +# CDASH_SITE_URL_OUT +# ) +# +function(tribits_get_cdash_site_from_drop_site_and_location) + # Parse args + cmake_parse_arguments(PARSE_ARGV 0 + PREFIX #prefix + "" #options + "CTEST_DROP_SITE;CTEST_DROP_LOCATION;CDASH_SITE_URL_OUT" #one_value_keywords + "" #multi_value_keywords + ) + tribits_check_for_unparsed_arguments(PREFIX) + tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_SITE) + tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_LOCATION) + tribits_assert_parse_arg_one_value(PREFIX CDASH_SITE_URL_OUT) + # Get the full CDash site from parts string(FIND "${PREFIX_CTEST_DROP_LOCATION}" "?" endOfSubmitPhpIdx) string(SUBSTRING "${PREFIX_CTEST_DROP_LOCATION}" 0 ${endOfSubmitPhpIdx} submitPhpPart) - string(REPLACE "submit.php" "index.php" indexPhpPart "${submitPhpPart}") - set(indexPhpUrl "${PREFIX_CTEST_DROP_SITE}${indexPhpPart}") - SET(${PREFIX_INDEX_PHP_URL_OUT} "${indexPhpUrl}" PARENT_SCOPE) + string(REPLACE "/submit.php" "" endCDashUrl "${submitPhpPart}") + set(cdashSiteUrl "${PREFIX_CTEST_DROP_SITE}${endCDashUrl}") + set(${PREFIX_CDASH_SITE_URL_OUT} "https://${cdashSiteUrl}" PARENT_SCOPE) endfunction() From 4354ed081b356dd9d6f7be2e100b032cadaeccac Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Sat, 4 Jun 2022 18:36:03 -0600 Subject: [PATCH 42/43] Produce CDash URLs to all builds and nonpassing tests for same repo version (#483) This makes it easy to click on links to these other CDash URLs to see what is happening with all of the builds for the same repo version. The main target is for the GitHub Actions drivers for TriBITS testing. This makes it easy to get at those results. As part of this, I also renamed the function tribits_get_build_url_and_write_to_file() to tribits_get_cdash_build_url() and removed the ability to write to a file. (We just don't need that anymore and it is trivial to write a string to a file.) --- .github/workflows/tribits_testing.yml | 7 +- test/ctest_driver/CTestDriverUnitTests.cmake | 38 +++ .../TribitsExampleMetaProject/CMakeLists.txt | 26 ++ .../TribitsExampleProject/CMakeLists.txt | 19 +- .../ctest_driver/TribitsCTestDriverCore.cmake | 78 ++++- .../TribitsGetCDashUrlsInsideCTestS.cmake | 283 +++++++++++++++++- 6 files changed, 422 insertions(+), 29 deletions(-) diff --git a/.github/workflows/tribits_testing.yml b/.github/workflows/tribits_testing.yml index 600a222a4..7f64e6e2c 100644 --- a/.github/workflows/tribits_testing.yml +++ b/.github/workflows/tribits_testing.yml @@ -93,6 +93,9 @@ jobs: - name: URL to results on CDash run: | cd .. - echo "Result on CDash are posted at:" + echo "See results posted on CDash:" + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo - cat tribits-build/BUILD/CDashBuildUrl.txt + cat tribits-build/BUILD/CDashResults.txt + echo + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index ee6d5b8df..d8d19f89a 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -53,6 +53,42 @@ include(TribitsReadTagFile) include(TribitsGetCDashUrlsInsideCTestS) +function(unittest_tribits_get_cdash_revision_builds_url) + + message("\n***") + message("*** Testing tribits_get_cdash_revision_builds_url()") + message("***\n") + + tribits_get_cdash_revision_builds_url( + CDASH_SITE_URL "somesite.com/my-cdash" + PROJECT_NAME goodProject + GIT_REPO_SHA1 "abc123" + CDASH_REVISION_BUILDS_URL_OUT cdashRevesionBuildsUrlOut + ) + unittest_compare_const(cdashRevesionBuildsUrlOut + "somesite.com/my-cdash/index.php?project=goodProject&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=abc123") + +endfunction() + + +function(unittest_tribits_get_cdash_revision_nonpassing_tests_url) + + message("\n***") + message("*** Testing tribits_get_cdash_revision_nonpassing_tests_url()") + message("***\n") + + tribits_get_cdash_revision_nonpassing_tests_url( + CDASH_SITE_URL "somesite.com/my-cdash" + PROJECT_NAME goodProject + GIT_REPO_SHA1 "abc123" + CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrlOut + ) + unittest_compare_const(cdashRevisionNonpassingTestsUrlOut + "somesite.com/my-cdash/queryTests.php?project=goodProject&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=abc123&field2=status&compare2=62&value2=passed") + +endfunction() + + function(unittest_tribits_read_ctest_tag_file) message("\n***") @@ -158,6 +194,8 @@ endfunction() unittest_initialize_vars() # Run the unit test functions +unittest_tribits_get_cdash_revision_builds_url() +unittest_tribits_get_cdash_revision_nonpassing_tests_url() unittest_tribits_read_ctest_tag_file() unittest_tribits_get_cdash_site_from_drop_site_and_location() unittest_tribits_get_cdash_index_php_from_drop_site_and_location() diff --git a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt index 17a553913..15e465a5a 100644 --- a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt @@ -98,6 +98,19 @@ set(TribitsExampleMetaProject_COMMON_CONFIG_ARGS ########################################################################################## + set(cdash_build_url_expected_regex + "https://testing[.]sandia[.]gov/cdash/index[.]php[?]project=TribitsExampleMetaProject&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=CustomSite&field2=buildname&compare2=61&value2=CTestDriver_TribitsExMetaProj_clone_default_branch_remote&field3=buildstamp&compare3=61&value3=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-Continuous" ) + # NOTE: Above, we have to repeat [0-9] 8 times and 4 times for the regex for + # the number of digits in the buildstarttime. CMake regex does not support + # \d{8}-\d{4} :-( + + set(cdash_revisions_builds_url_expected_regex + "https://testing[.]sandia[.]gov/cdash/index.php[?]project=TribitsExampleMetaProject&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=863461e3035d24c632e175c087761e83db28bdc3") + + set(cdash_revisions_nonpassing_tests_expected_regex + "https://testing[.]sandia[.]gov/cdash/queryTests.php[?]project=TribitsExampleMetaProject&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=863461e3035d24c632e175c087761e83db28bdc3&field2=status&compare2=62&value2=passed" ) + + tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_remote OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 @@ -111,11 +124,19 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re ${COMMON_ENV_ARGS} TribitsExMetaProj_ENABLE_SECONDARY_TESTED_CODE=TRUE CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_default_branch_remote + CTEST_SITE=CustomSite ${CTEST_S_SCRIPT_ARGS} PASS_REGULAR_EXPRESSION_ALL "CTEST_NOTES_FILES=''" "First perform the initial checkout: .*/git. clone -o origin .*github.com.tribits/TribitsExampleMetaProject.git" "Perform checkout in directory: .*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote" + "Results will be submitted on CDash at the following links:" + "Link to this build's results on CDash:" + "${cdash_build_url_expected_regex}" + "Link to all builds for this repo version on CDash:" + "${cdash_revisions_builds_url_expected_regex}" + "Link to all nonpassing tests for all builds for this repo version on CDash:" + "${cdash_revisions_nonpassing_tests_expected_regex}" "Calling ctest_update[(][)] to update base source repo '.*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote/TribitsExampleMetaProject" "Old revision of repository is: [a-z0-9]+" "New revision of repository is: [a-z0-9]+" @@ -315,6 +336,11 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re # * Makes sure some git commit SHA1s are shown in 'Old/New revision of # repository' printouts from ctest_update(). # + # * Checks that CDash URLs that get produced, including for all builds with + # * the same repo version. (This check has to be here since the base + # * project repo must have a .git/ directory and we must know the exact SHA1 + # * of that repo for the test, which we don in this case.) + # # NOTE: The reason that so many tests are done in a single ctest test is the # cost of the initial configure which checks the compilers which is very # expensive. The other runs use diff --git a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt index 602b6e4a9..420e11581 100644 --- a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt @@ -1264,7 +1264,8 @@ function(generate_aao_tests) # CONFIGURE_OPTIONS list is checked to make sure that it does not change # without being noticed. Follow-on tests will not check all of that. - set(cdash_url_expected_regex + + set(cdash_build_url_expected_regex "https://cdash[.]site[.]com/cdash/index[.]php[?]project=CustomTribitsExProj&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=My%20Site&field2=buildname&compare2=61&value2=TriBITS_CTestDriver_AAOP_CDASH_URL&field3=buildstamp&compare3=61&value3=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-Custom%20CDash%20Group" ) # NOTE: Above, we have to repeat [0-9] 8 times and 4 times for the regex for # the number of digits in the buildstarttime. CMake regex does not support @@ -1285,7 +1286,7 @@ function(generate_aao_tests) CTEST_DASHBOARD_ROOT=PWD ${AAO_COMMON_ENV_ARGS} CTEST_PARALLEL_LEVEL=3 - CTEST_DO_SUBMIT=OFF # Never submit this + CTEST_DO_SUBMIT=OFF # Never submit this (see below note) CTEST_SITE="My Site" CTEST_DROP_SITE="cdash.site.com" CTEST_PROJECT_NAME="CustomTribitsExProj" @@ -1299,17 +1300,19 @@ function(generate_aao_tests) "NONE does not exist, skipping extra repositories" "Final set of enabled packages: SimpleCxx 1" "Final set of enabled SE packages: SimpleCxx 1" - "Results will be submitted to CDash at:" + "Results will be submitted on CDash at the following links:" + "Link to this build's results on CDash:" + "${cdash_build_url_expected_regex}" "File '' does NOT exist so all tests passed" - "See results submitted to CDash at:" - "${cdash_url_expected_regex}" + "See results submitted on CDash at the following links:" "TRIBITS_CTEST_DRIVER: OVERALL: ALL PASSED" ALWAYS_FAIL_ON_NONZERO_RETURN TEST_2 - MESSAGE "Check that CDashBuildUrl.txt exists and lists the right URL." - CMND cat ARGS BUILD/CDashBuildUrl.txt + MESSAGE "Check that CDashResults.txt exists and lists the right URL." + CMND cat ARGS BUILD/CDashResults.txt PASS_REGULAR_EXPRESSION_ALL - "${cdash_url_expected_regex}" + "Link to this build's results on CDash:" + "${cdash_build_url_expected_regex}" ) # NOTE: The above test is never actually submitted to CDash, even when # ${PACKAGE_NAME}_CTEST_DRIVER_SUBMIT_TO is set. This is so we can diff --git a/tribits/ctest_driver/TribitsCTestDriverCore.cmake b/tribits/ctest_driver/TribitsCTestDriverCore.cmake index 253dea48a..04deb917a 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCore.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCore.cmake @@ -323,6 +323,7 @@ include(TribitsCTestDriverCoreHelpers) # * `Determining what testing-related actions are performed (tribits_ctest_driver())`_ # * `Determining how the results are displayed on CDash (tribits_ctest_driver())`_ # * `Specifying where the results go to CDash (tribits_ctest_driver())`_ +# * `Links to results on CDash (tribits_ctest_driver())`_ # * `Determining what TriBITS repositories are included (tribits_ctest_driver())`_ # * `All-at-once versus package-by-package mode (tribits_ctest_driver())`_ # * `Multiple ctest -S invocations (tribits_ctest_driver())`_ @@ -1166,6 +1167,63 @@ include(TribitsCTestDriverCoreHelpers) # not be performed. For more details, see `TRIBITS_2ND_CTEST_DROP_SITE`_ and # `TRIBITS_2ND_CTEST_DROP_LOCATION`_. # +# .. _Links to results on CDash (tribits_ctest_driver()): +# +# **Links to results on CDash (tribits_ctest_driver()):** +# +# Links to where the results will be posted on CDash are printed to STDOUT +# before it performs any actions and at end after all of the actions and +# submits have been completed. +# +# The results are printed to STDOUT in a section that looks like:: +# +# Link to this build's results on CDash: +# +# +# +# Link to all builds for this repo version on CDash: +# +# +# +# Link to all nonpassing tests for all builds for this repo version on CDash: +# +# +# +# The URL ```` is created from the buildname, site, and +# buildstartime fields which is known from the TAG file created by CTest. +# This allows access the results for this particular build on CDash by just +# clicking that link. +# +# The URL ```` provides a link to a CDash +# ``index.php`` query that includes all of the builds with the same base Git +# repo SHA1. This allows comparing the results of this build for other builds +# for this same version of the base Git repository. +# +# The URL ```` gives a link to a CDash +# ``queryTests.php`` query for all of the nonpassing tests for all of the +# builds with this same base project Git repo SHA1. This allows comparing +# test failures across all of the builds for the same base project Git repo +# version. +# +# NOTE: The links ```` and +# ```` are only provided if the base +# project Git repo has the ``.git/`` subdirectory and if ``git log`` +# successfully returns the SHA1 for that base Git repo. +# +# NOTE: The links ```` and +# ```` only consider the Git SHA1 of the +# base project Git repo. For multi-repo projects (see `Multi-Repository +# Support`_), you may get results for builds with different subrepo versions +# and therefore may be comparing apples and oranges. (Projects that commit a +# ``SubRepoVersion.txt`` file to their base Git repo or use Git +# Submodules will have unique base project Git repo SHA1s for different +# versions of the project's repos.) +# +# In addition, a text file ``CDashResults.txt`` will be written in the build +# directory that contains this same CDash link information shown above. This +# allows a process to cat the file ``CDashResults.txt`` to get links to the +# results on CDash. +# # .. _Determining what TriBITS repositories are included (tribits_ctest_driver()): # # **Determining what TriBITS repositories are included (tribits_ctest_driver()):** @@ -2093,10 +2151,15 @@ function(tribits_ctest_driver) ctest_start(${CTEST_START_ARGS}) tribits_remember_if_configure_attempted() - tribits_get_build_url_and_write_to_file(CDASH_BUILD_URL - "${CTEST_BINARY_DIRECTORY}/CDashBuildUrl.txt") - tribits_print_cdash_url("Results will be submitted to CDash at:" - "${CDASH_BUILD_URL}") + + tribits_get_cdash_results_string_and_write_to_file( + CDASH_RESULTS_STRING_OUT CDASH_RESULTS_STRING + CDASH_RESULTS_FILE_OUT "${CTEST_BINARY_DIRECTORY}/CDashResults.txt" ) + message("Results will be submitted on CDash at the following links:\n\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" + "${CDASH_RESULTS_STRING}\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + ) message( "\n***" @@ -2370,8 +2433,11 @@ function(tribits_ctest_driver) report_queued_errors() - tribits_print_cdash_url("See results submitted to CDash at:" - "${CDASH_BUILD_URL}") + message("\nSee results submitted on CDash at the following links:\n\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" + "${CDASH_RESULTS_STRING}\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + ) if ((NOT UPDATE_FAILED) AND ("${${PROJECT_NAME}_FAILED_PACKAGES}" STREQUAL "")) message( diff --git a/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake index a72a760f4..04166830c 100644 --- a/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake +++ b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake @@ -43,16 +43,280 @@ include(TribitsParseArgumentsHelpers) include(TribitsReadTagFile) -# @FUNCTION: tribits_get_build_url_and_write_to_file() +################################################################################ # -# Construct the build URL on CDash given the site name, buildname, and -# buildstamp (take from the TAG file) from inside of a running ctest -S +# This module contains functions for constructing CDash URLs to build and test +# results from inside of a CTest -S script. +# +################################################################################ + + +# @FUNCTION: tribits_get_cdash_results_string_and_write_to_file() +# +# Calls `tribits_get_cdash_results_urls_string()`_ and then writes the CDash +# URLs to a file. +# +# Usage:: +# +# tribits_get_cdash_results_string_and_write_to_file( +# [CDASH_RESULTS_STRING_OUT ] +# [CDASH_RESULTS_FILE_OUT ] +# ) +# +function(tribits_get_cdash_results_string_and_write_to_file) + # Parse args + cmake_parse_arguments( PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + "CDASH_RESULTS_STRING_OUT;CDASH_RESULTS_FILE_OUT" # multi_value_keywords + ) + tribits_check_for_unparsed_arguments(PARSE) + tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_RESULTS_STRING_OUT + CDASH_RESULTS_FILE_OUT ) + # Get and set CDash results URL + tribits_get_cdash_results_urls_string(cdashResultsString) + if (PARSE_CDASH_RESULTS_STRING_OUT) + set(${PARSE_CDASH_RESULTS_STRING_OUT} "${cdashResultsString}" PARENT_SCOPE) + endif() + if (PARSE_CDASH_RESULTS_FILE_OUT) + file(WRITE "${PARSE_CDASH_RESULTS_FILE_OUT}" "${cdashResultsString}") + endif() +endfunction() + + +# @FUNCTION: tribits_get_cdash_results_urls_string() +# +# Call `tribits_get_cdash_results_urls()`_ and then construct a CDash URLs +# string fit for printing. +# +# Usage:: +# +# tribits_get_cdash_results_urls_string( +# +# ) +# +# Construct the build and test URLs on CDash given the site name, buildname, +# and buildstamp (taken from the TAG file) from inside of a running ctest -S # program and optionally write it to a file as well. # +function(tribits_get_cdash_results_urls_string cdashResultsUrlsStringOut) + tribits_get_cdash_results_urls( + CDASH_BUILD_URL_OUT cdashBuildUrl + CDASH_REVISION_BUILDS_URL_OUT cdashRevisionBuildsUrl + CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrl + ) + tribits_generate_cdash_results_string_from_urls( + CDASH_BUILD_URL "${cdashBuildUrl}" + CDASH_REVISION_BUILDS_URL "${cdashRevisionBuildsUrl}" + CDASH_REVISION_NONPASSING_TESTS_URL "${cdashRevisionNonpassingTestsUrl}" + CDASH_RESULTS_STRING_OUT cdashResultsUrlsString + ) + set(${cdashResultsUrlsStringOut} "${cdashResultsUrlsString}" PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_generate_cdash_results_string_from_urls() +# +# Generate the CDash results URL string given the individual URLs. +# +# Usage:: +# +# tribits_generate_cdash_results_string_from_urls( +# CDASH_BUILD_URL "" +# [CDASH_REVISION_BUILDS_URL ""] +# [CDASH_REVISION_NONPASSING_TESTS_URL ""] +# CDASH_RESULTS_STRING_OUT +# ) +# +# Takes the URLs returned from `tribits_get_cdash_results_urls()`_ and +# generates a string out of them which is set in the return var +# ````. +# +function(tribits_generate_cdash_results_string_from_urls) + # Parse args + cmake_parse_arguments(PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_BUILD_URL;CDASH_REVISION_BUILDS_URL;CDASH_REVISION_NONPASSING_TESTS_URL;CDASH_RESULTS_STRING_OUT" + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_one_value(PARSE CDASH_BUILD_URL + CDASH_RESULTS_STRING_OUT) + tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_REVISION_BUILDS_URL + CDASH_REVISION_NONPASSING_TESTS_URL) + # Construct CDash results URLs string + set(cdashResultsString "") + string(APPEND cdashResultsString + "Link to this build's results on CDash:\n" + "\n" + " ${PARSE_CDASH_BUILD_URL}\n") + if (PARSE_CDASH_REVISION_BUILDS_URL) + string(APPEND cdashResultsString + "\nLink to all builds for this repo version on CDash:\n" + "\n" + " ${PARSE_CDASH_REVISION_BUILDS_URL}\n") + endif() + if (PARSE_CDASH_REVISION_NONPASSING_TESTS_URL) + string(APPEND cdashResultsString + "\nLink to all nonpassing tests for all builds for this repo version on CDash:\n" + "\n" + " ${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL}\n") + endif() + # Set output + set(${PARSE_CDASH_RESULTS_STRING_OUT} ${cdashResultsString} PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_results_urls() +# +# Construct the build and test URLs on CDash given the site name, buildname, +# and buildstamp (taken from the TAG file) from inside of a running ctest -S +# program and optionally write it to a file as well. +# +# Usage:: +# +# tribits_get_cdash_results_urls( +# CDASH_BUILD_URL_OUT +# [CDASH_REVISION_BUILDS_URL_OUT ] +# [CDASH_REVISION_NONPASSING_TESTS_URL_OUT ] +# ) +# +# Here, the CDash URLs are constructed the following CMake variables already +# set in a ``ctest -S`` process: +# +# * ``CTEST_DROP_SITE`` +# * ``CTEST_DROP_LOCATION`` (``submit.php`` is replaced with ``index.php``) +# * ``CTEST_PROJECT_NAME`` +# * ``CTEST_SITE`` +# * ``CTEST_BUILD_NAME`` +# * ``CTEST_BINARY_DIRECTORY`` +# * ``CTEST_SOURCE_DIRECTORY`` +# +# and other information derived from that. +# +# The buildstamp is read in from the file +# ``${CTEST_BINARY_DIRECTORY}/Testing/TAG``. +# +# If available, the revision SHA1 is obtained from the git repo at +# ``CTEST_SOURCE_DIRECTORY`` if the directory +# ``${CTEST_SOURCE_DIRECTORY}/.git`` exists. If the base project source +# directory is not a git reposistory, then ```` and +# ````, if requested, will be set to +# empty. +# +# Note that the CDash URLs will have ``https://`` added to the beginning so +# that GitHub Actions and other systems will put in a hyperlink to them. +# +function(tribits_get_cdash_results_urls) + # Parse args + cmake_parse_arguments(PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_BUILD_URL_OUT;CDASH_REVISION_BUILDS_URL_OUT;CDASH_REVISION_NONPASSING_TESTS_URL_OUT" + ) + tribits_check_for_unparsed_arguments(PARSE) + tribits_assert_parse_arg_one_value(PARSE CDASH_BUILD_URL_OUT) + tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_REVISION_BUILDS_URL_OUT + CDASH_REVISION_NONPASSING_TESTS_URL_OUT) + # Get the info + tribits_get_cdash_build_url(cdashBuildUrl) + tribits_git_repo_sha1("${CTEST_SOURCE_DIRECTORY}" gitRepoSha1 + FAILURE_MESSAGE_OUT gitRepoSha1FailureMsg) + if (gitRepoSha1) + tribits_get_cdash_site_from_drop_site_and_location( + CTEST_DROP_SITE "${CTEST_DROP_SITE}" + CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION}" + CDASH_SITE_URL_OUT cdashSiteUrl + ) + tribits_get_cdash_revision_builds_url( + CDASH_SITE_URL "${cdashSiteUrl}" + PROJECT_NAME "${CTEST_PROJECT_NAME}" + GIT_REPO_SHA1 "${gitRepoSha1}" + CDASH_REVISION_BUILDS_URL_OUT cdashRevisionBuildsUrl + ) + tribits_get_cdash_revision_nonpassing_tests_url( + CDASH_SITE_URL "${cdashSiteUrl}" + PROJECT_NAME "${CTEST_PROJECT_NAME}" + GIT_REPO_SHA1 "${gitRepoSha1}" + CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrl + ) + else() + set(cdashRevisionBuildsUrl "") + set(cdashRevisionNonpassingTestsUrl "") + endif() + # Set the outputs + set(${PARSE_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) + set(${PARSE_CDASH_REVISION_BUILDS_URL_OUT} "${cdashRevisionBuildsUrl}" + PARENT_SCOPE) + set(${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL_OUT} "${cdashRevisionNonpassingTestsUrl}" + PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_revision_builds_url() +# +# Get the CDash URL for all builds with the same repo version SHA1 +# # Usage:: # -# tribits_get_build_url_and_write_to_file( -# [ ] ) +# tribits_get_cdash_revision_builds_url( +# CDASH_SITE_URL +# PROJECT_NAME +# GIT_REPO_SHA1 +# CDASH_REVISION_BUILDS_URL_OUT +# ) +# +function(tribits_get_cdash_revision_builds_url) + cmake_parse_arguments(PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_SITE_URL;PROJECT_NAME;GIT_REPO_SHA1;CDASH_REVISION_BUILDS_URL_OUT" + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_one_value(PARSE CDASH_SITE_URL PROJECT_NAME + GIT_REPO_SHA1 CDASH_REVISION_BUILDS_URL_OUT) + set(${PARSE_CDASH_REVISION_BUILDS_URL_OUT} + "${PARSE_CDASH_SITE_URL}/index.php?project=${PARSE_PROJECT_NAME}&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=${PARSE_GIT_REPO_SHA1}" + PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_revision_nonpassing_tests_url() +# +# Get the CDash URL for all non-passing tests with the same repo version SHA1 +# +# Usage:: +# +# tribits_get_cdash_revision_nonpassing_tests_url( +# CDASH_SITE_URL +# PROJECT_NAME +# GIT_REPO_SHA1 +# CDASH_REVISION_NONPASSING_TESTS_URL_OUT +# ) +# +function(tribits_get_cdash_revision_nonpassing_tests_url) + cmake_parse_arguments( PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_SITE_URL;PROJECT_NAME;GIT_REPO_SHA1;CDASH_REVISION_NONPASSING_TESTS_URL_OUT" + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_one_value(PARSE CDASH_SITE_URL PROJECT_NAME + GIT_REPO_SHA1 CDASH_REVISION_NONPASSING_TESTS_URL_OUT) + set(${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL_OUT} + "${PARSE_CDASH_SITE_URL}/queryTests.php?project=${PARSE_PROJECT_NAME}&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=${PARSE_GIT_REPO_SHA1}&field2=status&compare2=62&value2=passed" + PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_build_url() +# +# Construct the build URL on CDash given the site name, buildname, and +# buildstamp (taken from the TAG file) from inside of a running ctest -S +# program. +# +# Usage:: +# +# tribits_get_cdash_build_url() # # Here, ```` returns the CDash Build URL constructed from # the following CMake variables already set in a ``ctest -S`` process: @@ -70,10 +334,7 @@ include(TribitsReadTagFile) # beginning of it so that GitHub Actions and other systems will put in a link # to them. # -# If the file name argument ```` is non-empty, then that -# CDash URL will be written to the file as a single line. -# -function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUrlFile) +function(tribits_get_cdash_build_url cdashBuildUrlOut) tribits_get_cdash_index_php_from_drop_site_and_location( CTEST_DROP_SITE "${CTEST_DROP_SITE}" CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION}" @@ -87,10 +348,6 @@ function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUr TAG_FILE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" CDASH_BUILD_URL_OUT cdashBuildUrl ) - set(cdashBuildUrl "${cdashBuildUrl}") - if (cdashBuildUrlFile) - file(WRITE "${cdashBuildUrlFile}" "${cdashBuildUrl}") - endif() set(${cdashBuildUrlOut} "${cdashBuildUrl}" PARENT_SCOPE) endfunction() From e5e9be8a73d69ab7c70b14900b5d1467f0e6cda9 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Sun, 5 Jun 2022 08:18:29 -0600 Subject: [PATCH 43/43] Have 'dashboard' target set CTEST_UPDATE_VERSION_ONLY=TRUE This will post the base repo version info to CDash which provides more info right on CDash on the main index.php page. However, it will set CTEST_DO_UPDATES=OFF unless the base repo is a Git repo and we can extract the SHA1 from the repo with tribits_git_repo_sha1() (which is a very robust function). --- test/ctest_driver/TribitsExampleProject/CMakeLists.txt | 4 ++-- tribits/ctest_driver/TribitsAddDashboardTarget.cmake | 10 ++++++++++ tribits/ctest_driver/experimental_build_test.cmake | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt index 420e11581..1201b75c4 100644 --- a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt @@ -704,7 +704,7 @@ tribits_add_advanced_test( CTestDriver_PBP_Dashboard_ST_ALL_PASS "Running package-by-package experimental dashboard" "A[)] Clean out the list of packages" "B[)] Run the dashboard command setting the list of packages" - "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON TribitsExProj_CTEST_DO_ALL_AT_ONCE=FALSE CTEST_DO_COVERAGE_TESTING=OFF CTEST_DO_SUBMIT=.* CTEST_DROP_METHOD=.* CTEST_DROP_SITE=.* CTEST_DROP_LOCATION=.* TribitsExProj_EXTRAREPOS_FILE=.*/tribits/examples/TribitsExampleProject/cmake/ExtraRepositoriesList.cmake TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE= TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=FALSE TribitsExProj_EXTRA_REPOSITORIES= TribitsExProj_PACKAGES=SimpleCxx[;]MixedLang[;]WithSubpackagesA[;]WithSubpackagesB[;]WithSubpackagesC[;]WithSubpackages[;]WrapExternal PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/bin/ctest -V -S .*/tribits/ctest_driver/experimental_build_test.cmake" + "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON CTEST_DO_UPDATES=OFF TribitsExProj_CTEST_DO_ALL_AT_ONCE=FALSE CTEST_DO_COVERAGE_TESTING=OFF CTEST_DO_SUBMIT=.* CTEST_DROP_METHOD=.* CTEST_DROP_SITE=.* CTEST_DROP_LOCATION=.* TribitsExProj_EXTRAREPOS_FILE=.*/tribits/examples/TribitsExampleProject/cmake/ExtraRepositoriesList.cmake TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE= TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=FALSE TribitsExProj_EXTRA_REPOSITORIES= TribitsExProj_PACKAGES=SimpleCxx[;]MixedLang[;]WithSubpackagesA[;]WithSubpackagesB[;]WithSubpackagesC[;]WithSubpackages[;]WrapExternal PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/bin/ctest -V -S .*/tribits/ctest_driver/experimental_build_test.cmake" "-- ENV_TribitsExProj_ENABLE_SECONDARY_TESTED_CODE='ON'" "TribitsExProj_ENABLE_SECONDARY_TESTED_CODE='ON'" "Final set of packages to be explicitly processed by CTest/CDash: SimpleCxx MixedLang WithSubpackages WrapExternal 4" @@ -785,7 +785,7 @@ tribits_add_advanced_test( CTestDriver_AAO_Dashboard_ForwardArgs CTEST_DASHBOARD_ROOT= make dashboard PASS_REGULAR_EXPRESSION_ALL - "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=OFF TribitsExProj_CTEST_DO_ALL_AT_ONCE=TRUE CTEST_BUILD_NAME=MyCustomBuildName CTEST_DO_COVERAGE_TESTING=FALSE CTEST_BUILD_FLAGS='-j6' CTEST_PARALLEL_LEVEL=10 CTEST_DO_SUBMIT=FALSE CTEST_DROP_METHOD=OFF CTEST_DROP_SITE=OFF CTEST_DROP_LOCATION=OFF CTEST_DROP_SITE_COVERAGE=FALSE CTEST_DROP_LOCATION_COVERAGE=FALSE TRIBITS_2ND_CTEST_DROP_LOCATION=FALSE TRIBITS_2ND_CTEST_DROP_SITE=FALSE TribitsExProj_EXTRAREPOS_FILE=FALSE TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE=NONE TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=TRUE TribitsExProj_EXTRA_REPOSITORIES=DummyRepo1,DummyRepo2,DummyRepo3 TribitsExProj_PACKAGES=${TribitsExProj_PACKAGES_list} PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/ctest -VV -S .*/tribits/ctest_driver/experimental_build_test.cmake" + "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=OFF CTEST_DO_UPDATES=OFF TribitsExProj_CTEST_DO_ALL_AT_ONCE=TRUE CTEST_BUILD_NAME=MyCustomBuildName CTEST_DO_COVERAGE_TESTING=FALSE CTEST_BUILD_FLAGS='-j6' CTEST_PARALLEL_LEVEL=10 CTEST_DO_SUBMIT=FALSE CTEST_DROP_METHOD=OFF CTEST_DROP_SITE=OFF CTEST_DROP_LOCATION=OFF CTEST_DROP_SITE_COVERAGE=FALSE CTEST_DROP_LOCATION_COVERAGE=FALSE TRIBITS_2ND_CTEST_DROP_LOCATION=FALSE TRIBITS_2ND_CTEST_DROP_SITE=FALSE TribitsExProj_EXTRAREPOS_FILE=FALSE TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE=NONE TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=TRUE TribitsExProj_EXTRA_REPOSITORIES=DummyRepo1,DummyRepo2,DummyRepo3 TribitsExProj_PACKAGES=${TribitsExProj_PACKAGES_list} PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/ctest -VV -S .*/tribits/ctest_driver/experimental_build_test.cmake" "ENV_PROJECT_SOURCE_DIR='.*/tribits/examples/TribitsExampleProject'" "ENV_CTEST_BUILD_NAME='MyCustomBuildName'" diff --git a/tribits/ctest_driver/TribitsAddDashboardTarget.cmake b/tribits/ctest_driver/TribitsAddDashboardTarget.cmake index 3e7b85dcd..a9a8b6992 100644 --- a/tribits/ctest_driver/TribitsAddDashboardTarget.cmake +++ b/tribits/ctest_driver/TribitsAddDashboardTarget.cmake @@ -38,11 +38,14 @@ # @HEADER +################################################################################ # # This file gets included in the main TriBITS framework. It is put here to # reduce the size of the tribits/core/ directory. # +################################################################################ +include(TribitsGitRepoVersionInfo) # # Macro that drives a experimental 'dashboard' target @@ -95,6 +98,13 @@ macro(tribits_add_dashboard_target) append_set(EXPR_CMND_ARGS "${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS='${${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS}'") append_set(EXPR_CMND_ARGS "${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE=${${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE}") + # Determine if base repo is a git repo (by seeing if SHA1 can be extracted) + tribits_git_repo_sha1("${PROJECT_SOURCE_DIR}" projectGitRepoSha1 + FAILURE_MESSAGE_OUT projectGitRepoSha1FailureMsg) + if (projectGitRepoSha1 STREQUAL "") + append_set(EXPR_CMND_ARGS "CTEST_DO_UPDATES=OFF") + endif() + # Conditionally override options used only for the 'dashboard' target. # These options have no use in a a basic build/test so we don't want to # interfere with options users might set on the env. diff --git a/tribits/ctest_driver/experimental_build_test.cmake b/tribits/ctest_driver/experimental_build_test.cmake index 0b36b05e8..0c70ab4a7 100644 --- a/tribits/ctest_driver/experimental_build_test.cmake +++ b/tribits/ctest_driver/experimental_build_test.cmake @@ -100,7 +100,7 @@ include(SetDefaultAndFromEnv) # All these can be changed by env vars set(CTEST_TEST_TYPE Experimental) -set(CTEST_DO_UPDATES FALSE) +set(CTEST_UPDATE_VERSION_ONLY TRUE) set(${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS "-Werror") # Don't change these in the env!