diff options
author | Brad King <brad.king@kitware.com> | 2023-03-30 11:22:11 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-03-30 11:22:17 (GMT) |
commit | 1d1ee2b049ec3010d1740f276c8a3413ad4c76d3 (patch) | |
tree | c2fa12b58ef3bd24fa5e365af8a8d6e667a2a1f5 /Tests | |
parent | a4e166fe7a4ed30342e731a8780e7a1cb3f0e2d4 (diff) | |
parent | d38c752de294c95e9efbe06f6f0eac1c94ccbc32 (diff) | |
download | CMake-1d1ee2b049ec3010d1740f276c8a3413ad4c76d3.zip CMake-1d1ee2b049ec3010d1740f276c8a3413ad4c76d3.tar.gz CMake-1d1ee2b049ec3010d1740f276c8a3413ad4c76d3.tar.bz2 |
Merge topic 'ci-FindHDF5'
d38c752de2 ci: Enable FindHDF5 tests on Linux builds
28c4945a8a ci: Add HDF5 to Debian and Fedora base images
ad9e151045 Tests: Add cases covering FindHDF5 variables and imported targets
0e87e6c1a4 Tests: Add FindMPI test environment modification option
ee075a53c8 FindHDF5: Record compiler wrapper checks to configure log
72915b1068 FindHDF5: Fix compiler wrapper checks with spaces in path
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8378
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/FindHDF5/CMakeLists.txt | 84 | ||||
-rw-r--r-- | Tests/FindHDF5/Test/CMakeLists.txt | 58 | ||||
-rw-r--r-- | Tests/FindMPI/CMakeLists.txt | 3 |
4 files changed, 146 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 446e400..e92d1c1 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1450,6 +1450,7 @@ if(BUILD_TESTING) GnuTLS GSL GTK2 + HDF5 Iconv ICU ImageMagick diff --git a/Tests/FindHDF5/CMakeLists.txt b/Tests/FindHDF5/CMakeLists.txt new file mode 100644 index 0000000..373759e --- /dev/null +++ b/Tests/FindHDF5/CMakeLists.txt @@ -0,0 +1,84 @@ +# These tests may be configured by cache entries: +# +# CMake_TEST_FindHDF5:BOOL=ON +# Enable this directory. +# +# CMake_TEST_FindHDF5_<variant>_<lang>_COMPILER:FILEPATH=... +# Enable testing for a variant/language combination with the given wrapper. +# Variants: Serial, OpenMPI, MPICH +# Languages: C, CXX, Fortran +# +# CMake_TEST_FindHDF5_<variant>_<lang>_COMPILER_EXPLICIT:BOOL=ON +# Pass the above wrapper path to the test as HDF5_<lang>_COMPILER_EXECUTABLE. + +set(test_langs C CXX) +if(CMAKE_Fortran_COMPILER) + list(APPEND test_langs Fortran) +endif() + +# Test detection without any special hints. +add_test(NAME FindHDF5.Default COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindHDF5/Test" + "${CMake_BINARY_DIR}/Tests/FindHDF5/Test-Default" + ${build_generator_args} + --build-project TestFindHDF5 + --build-options ${build_options} -DTEST_SERIAL=1 "-DTEST_LANGS=${test_langs}" + ) + +foreach(variant Serial OpenMPI MPICH) + set(wrapper "") + set(wrapper_langs "") + set(wrapper_as_compiler "") + foreach(lang IN LISTS test_langs) + if(CMake_TEST_FindHDF5_${variant}_${lang}_COMPILER) + list(APPEND wrapper_langs ${lang}) + list(APPEND wrapper_as_compiler -DCMAKE_${lang}_COMPILER=${CMake_TEST_FindHDF5_${variant}_${lang}_COMPILER}) + if(CMake_TEST_FindHDF5_${variant}_${lang}_COMPILER_EXPLICIT) + list(APPEND wrapper -DHDF5_${lang}_COMPILER_EXECUTABLE=${CMake_TEST_FindHDF5_${variant}_${lang}_COMPILER}) + endif() + endif() + endforeach() + + if(NOT wrapper_langs) + continue() + endif() + + if(variant STREQUAL "Serial") + set(test_kind -DTEST_SERIAL=1) + else() + set(test_kind -DTEST_PARALLEL=1) + endif() + + # Test detection using the HDF5 compiler wrappers as a reference. + add_test(NAME FindHDF5.${variant} COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindHDF5/Test" + "${CMake_BINARY_DIR}/Tests/FindHDF5/Test-${variant}" + ${build_generator_args} + --build-project TestFindHDF5 + --build-options ${build_options} ${test_kind} "-DTEST_LANGS=${wrapper_langs}" ${wrapper} + ) + if(CMake_TEST_FindHDF5_${variant}_ENVMOD) + set_property(TEST FindHDF5.${variant} PROPERTY ENVIRONMENT_MODIFICATION ${CMake_TEST_FindHDF5_${variant}_ENVMOD}) + endif() + + # Test detection using the HDF5 compiler wrappers as the compiler. + # Skip this if there are spaces in the path. The HDF5 wrappers do not like them. + if(NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ") + add_test(NAME FindHDF5.${variant}-Wrapper COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindHDF5/Test" + "${CMake_BINARY_DIR}/Tests/FindHDF5/Test-${variant}-Wrapper" + ${build_generator_args} + --build-project TestFindHDF5 + --build-options ${build_options} ${test_kind} "-DTEST_LANGS=${wrapper_langs}" -D TEST_WRAPPER_AS_COMPILER=1 ${wrapper_as_compiler} + ) + if(CMake_TEST_FindHDF5_${variant}_ENVMOD) + set_property(TEST FindHDF5.${variant}-Wrapper PROPERTY ENVIRONMENT_MODIFICATION ${CMake_TEST_FindHDF5_${variant}_ENVMOD}) + endif() + endif() +endforeach() diff --git a/Tests/FindHDF5/Test/CMakeLists.txt b/Tests/FindHDF5/Test/CMakeLists.txt new file mode 100644 index 0000000..53ad633 --- /dev/null +++ b/Tests/FindHDF5/Test/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 3.26) +project(TestFindHDF5 LANGUAGES ${TEST_LANGS}) +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +if(TEST_PARALLEL) + set(HDF5_PREFER_PARALLEL 1) +endif() + +find_package(HDF5 REQUIRED COMPONENTS ${TEST_LANGS} HL) + +set(variables HDF5_FOUND HDF5_VERSION) +if(NOT TEST_WRAPPER_AS_COMPILER) + list(APPEND variables HDF5_INCLUDE_DIRS HDF5_LIBRARIES HDF5_HL_LIBRARIES) + foreach(lang ${TEST_LANGS}) + list(APPEND variables + HDF5_${lang}_COMPILER_EXECUTABLE + HDF5_${lang}_INCLUDE_DIRS + HDF5_${lang}_LIBRARIES + HDF5_${lang}_HL_LIBRARIES + ) + endforeach() + endif() +foreach(var IN LISTS variables) + message(STATUS "${var}='${${var}}'") +endforeach() +foreach(var IN LISTS variables) + if(NOT DEFINED ${var}) + message(SEND_ERROR "Variable '${var}' is not defined!") + endif() +endforeach() + +set(targets HDF5::HDF5) +if(CMAKE_C_COMPILER_LOADED) + list(APPEND targets hdf5::hdf5 hdf5::hdf5_hl) +endif() +if(CMAKE_CXX_COMPILER_LOADED) + list(APPEND targets hdf5::hdf5_cpp hdf5::hdf5_hl_cpp) +endif() +if(CMAKE_Fortran_COMPILER_LOADED) + list(APPEND targets hdf5::hdf5_fortran hdf5::hdf5_hl_fortran) +endif() +foreach(target IN LISTS targets) + if(NOT TARGET ${target}) + message(SEND_ERROR "Target '${target}' not defined!") + endif() +endforeach() + +message(STATUS "HDF5_IS_PARALLEL='${HDF5_IS_PARALLEL}'") +if(TEST_SERIAL) + if(HDF5_IS_PARALLEL) + message(SEND_ERROR "HDF5_IS_PARALLEL is true in serial test.") + endif() +endif() +if(TEST_PARALLEL) + if(NOT HDF5_IS_PARALLEL) + message(SEND_ERROR "HDF5_IS_PARALLEL is false in parallel test.") + endif() +endif() diff --git a/Tests/FindMPI/CMakeLists.txt b/Tests/FindMPI/CMakeLists.txt index 121d978..1bc12c8 100644 --- a/Tests/FindMPI/CMakeLists.txt +++ b/Tests/FindMPI/CMakeLists.txt @@ -19,3 +19,6 @@ add_test(NAME FindMPI.Test COMMAND -DMPI_TEST_Fortran=${CMake_TEST_FindMPI_FLAG_Fortran} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) +if(CMake_TEST_FindMPI_ENVMOD) + set_property(TEST FindMPI.Test PROPERTY ENVIRONMENT_MODIFICATION ${CMake_TEST_FindMPI_ENVMOD}) +endif() |