Skip to content

Commit

Permalink
Merge Pull Request #10930 from bartlettroscoe/Trilinos/10774-final-fixes
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Final fixes for TriBITS upgrade to modern CMake targets (#10614, #10774) 
PR Author: bartlettroscoe
  • Loading branch information
trilinos-autotester authored Aug 25, 2022
2 parents 40726a9 + e3e9012 commit 963e937
Show file tree
Hide file tree
Showing 36 changed files with 483 additions and 192 deletions.
21 changes: 14 additions & 7 deletions cmake/tribits/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
ChangeLog for TriBITS
----------------------------------------

## 2022-08-22:

* **Added:** Added support for exporting cache variables for packages in their
`<Package>Config.cmake` files using the new function
`tribits_pkg_export_cache_var()`.

## 2022-08-18:

* **Changed:** Made setting parent package tests/examples enable/disable
correctly propagate down to subpackages in a more intuitive way (see
[TriBITSPub/TriBITS#268](https://github.com/TriBITSPub/TriBITS/issues/268)).
This also results in not enabling tests for subpackages that are not
explicitly enabled or enabled as part of the forward sweep of packages
enables due to `<Project>_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON`.

## 2022-08-11:

Expand All @@ -11,13 +25,6 @@ ChangeLog for TriBITS
and
[TriBITSPub/TriBITS#510](https://github.com/TriBITSPub/TriBITS/issues/510)).

* **Changed:** Made setting parent package tests/examples enables correctly
propagate down to subpackages in a more intuitive way (see
[TriBITSPub/TriBITS#268](https://github.com/TriBITSPub/TriBITS/issues/268)).
This also results in not enabling tests for subpackages that are not
explicitly enabled or enabled as part of the forward sweep of packages
enables due to `<Project>_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON`.

## 2022-07-20:

* **Changed:** Fixed TriBITS generated and installed `<tplName>Config.cmake`
Expand Down
2 changes: 1 addition & 1 deletion cmake/tribits/common_tpls/FindTPLNetcdf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if ("${TPL_Netcdf_PARALLEL}" STREQUAL "")
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")
"True if netcdf compiled with parallel enabled")
endif()
endif()
if ("${TPL_Netcdf_PARALLEL}" STREQUAL "")
Expand Down
18 changes: 9 additions & 9 deletions cmake/tribits/common_tpls/find_modules/FindHDF5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ else()

foreach( _component ${HDF5_VALID_COMPONENTS} )
set(target ${HDF5_${_component}_TARGET})
if ( TARGET ${target} )
set(HDF5_${_component}_LIBRARY ${target})
list(APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY})
endif()
if ( TARGET ${target} )
set(HDF5_${_component}_LIBRARY ${target})
list(APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY})
endif()
endforeach()

# Define HDF5_C_LIBRARIES to contain hdf5 and hdf5_hl C libraries
Expand Down Expand Up @@ -470,7 +470,7 @@ else()
LOCATION ${_HDF5_C_LIBRARY}
LINK_LANGUAGES "C"
LINK_INTERFACE_LIBRARIES "${HDF5_LINK_LIBRARIES}")
set(HDF5_C_LIBRARY ${HDF5_C_TARGET})
set(HDF5_C_LIBRARY ${HDF5_C_TARGET})

# --- Search for the other possible component libraries

Expand All @@ -495,7 +495,7 @@ else()
# Define the HDF5_<component>_LIBRARY to point to the target
foreach ( _component ${HDF5_VALID_COMPONENTS} )
if ( TARGET ${HDF5_${_component}_TARGET} )
set(HDF5_${_component}_LIBRARY ${HDF5_${_component}_TARGET})
set(HDF5_${_component}_LIBRARY ${HDF5_${_component}_TARGET})
endif()
endforeach()

Expand All @@ -513,7 +513,7 @@ else()
set(HDF5_LIBRARIES)
foreach (_component ${HDF5_VALID_COMPONENTS})
if ( TARGET ${HDF5_${_component}_TARGET} )
list(APPEND HDF5_LIBRARIES ${_HDF5_${_component}_LIBRARY})
list(APPEND HDF5_LIBRARIES ${_HDF5_${_component}_LIBRARY})
endif()
endforeach()
list(APPEND HDF5_LIBRARIES ${HDF5_LINK_LIBRARIES})
Expand Down Expand Up @@ -581,8 +581,8 @@ if ( NOT HDF5_FIND_QUIETLY )
set(HDF5_COMPONENTS_NOTFOUND)
foreach (_component ${HDF5_VALID_COMPONENTS} )
if ( HDF5_${_component}_FOUND )
#message(STATUS "\t HDF5_${_component}_LIBRARY\t\t=${HDF5_${_component}_LIBRARY}")
message(STATUS "\t${HDF5_${_component}_LIBRARY}")
#message(STATUS "\t HDF5_${_component}_LIBRARY\t\t=${HDF5_${_component}_LIBRARY}")
message(STATUS "\t${HDF5_${_component}_LIBRARY}")
else()
list(APPEND HDF5_COMPONENTS_NOTFOUND ${_component})
endif()
Expand Down
24 changes: 12 additions & 12 deletions cmake/tribits/common_tpls/find_modules/FindNetCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,21 @@ else(NetCDF_LIBRARIES AND NetCDF_INCLUDE_DIRS)
set(NetCDF_LARGE_DIMS FALSE)
endif()

set(NetCDF_PARALLEL False)
set(NetCDF_PARALLEL False)
find_path(meta_path
NAMES "netcdf_meta.h"
NAMES "netcdf_meta.h"
HINTS ${NetCDF_INCLUDE_DIR}
NO_DEFAULT_PATH)
if(meta_path)
# Search meta for NC_HAS_PARALLEL setting...
# Note that there is both NC_HAS_PARALLEL4 and NC_HAS_PARALLEL, only want NC_HAS_PARALLEL
# so add a space to end to avoid getting NC_HAS_PARALLEL4
file(STRINGS "${meta_path}/netcdf_meta.h" netcdf_par_string REGEX "NC_HAS_PARALLEL ")
string(REGEX REPLACE "[^0-9]" "" netcdf_par_val "${netcdf_par_string}")
# NOTE: The line for NC_HAS_PARALLEL has an hdf5 string in it which results
# Search meta for NC_HAS_PARALLEL setting...
# Note that there is both NC_HAS_PARALLEL4 and NC_HAS_PARALLEL, only want NC_HAS_PARALLEL
# so add a space to end to avoid getting NC_HAS_PARALLEL4
file(STRINGS "${meta_path}/netcdf_meta.h" netcdf_par_string REGEX "NC_HAS_PARALLEL ")
string(REGEX REPLACE "[^0-9]" "" netcdf_par_val "${netcdf_par_string}")
# NOTE: The line for NC_HAS_PARALLEL has an hdf5 string in it which results
# netcdf_par_val being set to 05 or 15 above...
if (netcdf_par_val EQUAL 15)
set(NetCDF_PARALLEL True)
if (netcdf_par_val EQUAL 15)
set(NetCDF_PARALLEL True)
endif()
endif()

Expand Down Expand Up @@ -291,8 +291,8 @@ else(NetCDF_LIBRARIES AND NetCDF_INCLUDE_DIRS)
message(STATUS "\tNetCDF_ROOT is ${NetCDF_ROOT}")
find_program(netcdf_config nc-config
PATHS ${NetCDF_ROOT}/bin ${NetCDF_BIN_DIR}
NO_DEFAULT_PATH
NO_CMAKE_SYSTEM_PATH
NO_DEFAULT_PATH
NO_CMAKE_SYSTEM_PATH
DOC "NetCDF configuration script")

if (netcdf_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
#
##############################################################################

if(CMAKE_VERSION VERSION_LESS 3.3)
set(${PDOLLAR}{CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"${PACKAGE_NAME} requires CMake 3.3 or later for 'if (... IN_LIST ...)'"
)
set(${PDOLLAR}{CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
cmake_minimum_required(VERSION 3.3...${TRIBITS_CMAKE_MINIMUM_REQUIRED})

## ---------------------------------------------------------------------------
## Compilers used by ${PROJECT_NAME}/${PACKAGE_NAME} build
## ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
#
##############################################################################

if(CMAKE_VERSION VERSION_LESS 3.3)
set(${PDOLLAR}{CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"${PROJECT_NAME} requires CMake 3.3 or later for 'if (... IN_LIST ...)'"
)
set(${PDOLLAR}{CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
cmake_minimum_required(VERSION 3.3...${TRIBITS_CMAKE_MINIMUM_REQUIRED})

## ---------------------------------------------------------------------------
## Compilers used by ${PROJECT_NAME} build
## ---------------------------------------------------------------------------
Expand Down
18 changes: 9 additions & 9 deletions cmake/tribits/core/package_arch/TribitsAddAdvancedTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ function(tribits_add_advanced_test TEST_NAME_IN)
""
# multi_value_keywords
"COPY_FILES_TO_TEST_DIR;SOURCE_DIR;DEST_DIR"
# Arguments to parse
# Arguments to parse
${PARSE_TEST_${TEST_CMND_IDX}}
)
tribits_check_for_unparsed_arguments()
Expand All @@ -1113,20 +1113,20 @@ function(tribits_add_advanced_test TEST_NAME_IN)
# Parse TEST_<IDX> block args for types EXEC and CMND

set(testBlockOptionsList NOEXEPREFIX NOEXESUFFIX NO_ECHO_OUTPUT PASS_ANY
STANDARD_PASS_OUTPUT ALWAYS_FAIL_ON_NONZERO_RETURN ALWAYS_FAIL_ON_ZERO_RETURN
WILL_FAIL ADD_DIR_TO_NAME SKIP_CLEAN_WORKING_DIRECTORY
STANDARD_PASS_OUTPUT ALWAYS_FAIL_ON_NONZERO_RETURN ALWAYS_FAIL_ON_ZERO_RETURN
WILL_FAIL ADD_DIR_TO_NAME SKIP_CLEAN_WORKING_DIRECTORY
)

set(testBlockMultiValueKeywordsList EXEC CMND ARGS DIRECTORY MESSAGE
WORKING_DIRECTORY OUTPUT_FILE NUM_MPI_PROCS NUM_TOTAL_CORES_USED
PASS_REGULAR_EXPRESSION_ALL FAIL_REGULAR_EXPRESSION PASS_REGULAR_EXPRESSION
)
WORKING_DIRECTORY OUTPUT_FILE NUM_MPI_PROCS NUM_TOTAL_CORES_USED
PASS_REGULAR_EXPRESSION_ALL FAIL_REGULAR_EXPRESSION PASS_REGULAR_EXPRESSION
)

cmake_parse_arguments(
PARSE #prefix
"${testBlockOptionsList}"
"" # one_value_keywords
"${testBlockMultiValueKeywordsList}"
"${testBlockOptionsList}"
"" # one_value_keywords
"${testBlockMultiValueKeywordsList}"
${PARSE_TEST_${TEST_CMND_IDX}}
)

Expand Down
6 changes: 3 additions & 3 deletions cmake/tribits/core/package_arch/TribitsAddLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ function(tribits_add_library_assert_deplibs)
else()
message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY},"
" depLibAlreadyInPkgLibs=${depLibAlreadyInPkgLibs},"
" depLibIsTestOnlyLib=${depLibIsTestOnlyLib}, has"
" depLibIsTestOnlyLib=${depLibIsTestOnlyLib}, has"
" not yet been handled!")
endif()

Expand Down Expand Up @@ -781,15 +781,15 @@ function(tribits_add_library_determine_install_lib_and_or_headers
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 ...")
" 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 ...")
" BUILD_SHARED_LIBS=TRUE ...")
endif()
set(installHeaders OFF)
endif()
Expand Down
19 changes: 18 additions & 1 deletion cmake/tribits/core/package_arch/TribitsAddOptionAndDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
# ************************************************************************
# @HEADER

include(TribitsPkgExportCacheVars)
include(GlobalSet)


# @MACRO: tribits_add_option_and_define()
#
# Add an option and a define variable in one shot.
# Add an option and an optional macro define variable in one shot.
#
# Usage::
#
Expand All @@ -58,6 +59,18 @@ include(GlobalSet)
#
# #cmakedefine <macroDefineName>
#
# NOTE: This also calls `tribits_pkg_export_cache_var()`_ to export the
# variables ``<userOptionName>`` and ``<macroDefineName>``. This also
# requires that local variables with the same names of these cache variables
# not be assigned with a different value from these cache variables. If they
# are, then an error will occur later when these variables are read.
#
# NOTE: The define var name ``<macroDefineName>`` can be empty "" in which
# case all logic related to ``<macroDefineName>`` is skipped. (But in this
# case, it would be better to just call::
#
# set(<userOptionName> <defaultValue> CACHE BOOL "<docStr>")
#
macro(tribits_add_option_and_define USER_OPTION_NAME MACRO_DEFINE_NAME
DOCSTRING DEFAULT_VALUE
)
Expand All @@ -70,6 +83,10 @@ macro(tribits_add_option_and_define USER_OPTION_NAME MACRO_DEFINE_NAME
global_set(${MACRO_DEFINE_NAME} OFF)
endif()
endif()
tribits_pkg_export_cache_var(${USER_OPTION_NAME})
if(NOT ${MACRO_DEFINE_NAME} STREQUAL "")
tribits_pkg_export_cache_var(${MACRO_DEFINE_NAME})
endif()
endmacro()

# 2008/10/05: rabartl: ToDo: Add an option to automatically add the macro
Expand Down
4 changes: 2 additions & 2 deletions cmake/tribits/core/package_arch/TribitsAddTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ function(tribits_add_test EXE_NAME)
"${EXECUTABLE_PATH}" "${PARSE_CATEGORIES}" "${NUM_PROCS_USED}"
"${NUM_TOTAL_CORES_USED}"
"${SET_RUN_SERIAL}" "${SET_DISABLED_AND_MSG}" ADDED_TEST_NAME ${INARGS}
"${${TEST_NAME_INSTANCE}_EXTRA_ARGS}" )
"${${TEST_NAME_INSTANCE}_EXTRA_ARGS}" )
if(PARSE_ADDED_TESTS_NAMES_OUT AND ADDED_TEST_NAME)
list(APPEND ADDED_TESTS_NAMES_OUT ${ADDED_TEST_NAME})
endif()
Expand Down Expand Up @@ -1054,7 +1054,7 @@ function(tribits_add_test EXE_NAME)
"${EXECUTABLE_PATH}" "${PARSE_CATEGORIES}" "${NUM_PROCS_USED}"
"${NUM_TOTAL_CORES_USED}"
"${SET_RUN_SERIAL}" "${SET_DISABLED_AND_MSG}" ADDED_TEST_NAME ${INARGS}
"${${TEST_NAME_INSTANCE}_EXTRA_ARGS}"
"${${TEST_NAME_INSTANCE}_EXTRA_ARGS}"
)
if(PARSE_ADDED_TESTS_NAMES_OUT AND ADDED_TEST_NAME)
list(APPEND ADDED_TESTS_NAMES_OUT ${ADDED_TEST_NAME})
Expand Down
4 changes: 2 additions & 2 deletions cmake/tribits/core/package_arch/TribitsAddTestHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,10 @@ function(tribits_add_test_process_skip_ctest_add_test ADD_THE_TEST_OUT)
if(${PACKAGE_NAME}_SKIP_CTEST_ADD_TEST OR ${PARENT_PACKAGE_NAME}_SKIP_CTEST_ADD_TEST)
if (PARENT_PACKAGE_NAME STREQUAL PACKAGE_NAME)
set(DISABLE_VAR_MSG
"${PACKAGE_NAME}_SKIP_CTEST_ADD_TEST='${${PACKAGE_NAME}_SKIP_CTEST_ADD_TEST}'")
"${PACKAGE_NAME}_SKIP_CTEST_ADD_TEST='${${PACKAGE_NAME}_SKIP_CTEST_ADD_TEST}'")
else()
set(DISABLE_VAR_MSG
"${PARENT_PACKAGE_NAME}_SKIP_CTEST_ADD_TEST='${${PARENT_PACKAGE_NAME}_SKIP_CTEST_ADD_TEST}'")
"${PARENT_PACKAGE_NAME}_SKIP_CTEST_ADD_TEST='${${PARENT_PACKAGE_NAME}_SKIP_CTEST_ADD_TEST}'")
endif()
message_wrapper(
"-- ${TEST_NAME}: NOT added test because ${DISABLE_VAR_MSG}!")
Expand Down
Loading

0 comments on commit 963e937

Please sign in to comment.