summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-31 12:06:30 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-03-31 12:06:37 (GMT)
commitafaeee52a7d80789d4e452d7c831052fc0cbd170 (patch)
tree46c3ddf0aa560b5f3f5a4999eca5c93e48cc8133
parentae9f725b9b5133bba181dfbe3524379b70c487bb (diff)
parent75bb2a2ee412d303903123913555a7d9129539b5 (diff)
downloadCMake-afaeee52a7d80789d4e452d7c831052fc0cbd170.zip
CMake-afaeee52a7d80789d4e452d7c831052fc0cbd170.tar.gz
CMake-afaeee52a7d80789d4e452d7c831052fc0cbd170.tar.bz2
Merge topic 'ci-FindHDF5'
75bb2a2ee4 Tests: Extend FindHDF5 tests to link and run executables 919de8785b ci: Patch HDF5 Fortran compiler wrappers in Fedora jobs Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8381
-rw-r--r--.gitlab/ci/configure_fedora37_makefiles.cmake2
-rw-r--r--.gitlab/ci/env_fedora37_makefiles.sh5
-rw-r--r--Tests/FindHDF5/CMakeLists.txt3
-rw-r--r--Tests/FindHDF5/Test/CMakeLists.txt48
-rw-r--r--Tests/FindHDF5/Test/test_C.c12
-rw-r--r--Tests/FindHDF5/Test/test_CXX.cxx14
-rw-r--r--Tests/FindHDF5/Test/test_Fortran.f906
7 files changed, 89 insertions, 1 deletions
diff --git a/.gitlab/ci/configure_fedora37_makefiles.cmake b/.gitlab/ci/configure_fedora37_makefiles.cmake
index 0a271bf..c2f9982 100644
--- a/.gitlab/ci/configure_fedora37_makefiles.cmake
+++ b/.gitlab/ci/configure_fedora37_makefiles.cmake
@@ -36,7 +36,7 @@ set(CMake_TEST_FindHDF5_MPICH_Fortran_COMPILER "/usr/lib64/mpich/bin/h5pfc" CACH
set(CMake_TEST_FindHDF5_OpenMPI_C_COMPILER "/usr/lib64/openmpi/bin/h5pcc" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_OpenMPI_ENVMOD "PATH=path_list_prepend:/usr/lib64/openmpi/bin;LD_LIBRARY_PATH=path_list_prepend:/usr/lib64/openmpi/lib" CACHE STRING "")
# set(CMake_TEST_FindHDF5_OpenMPI_CXX_COMPILER "/usr/lib64/openmpi/bin/h5pc++" CACHE FILEPATH "") # h5pc++ does not exist
-# set(CMake_TEST_FindHDF5_OpenMPI_Fortran_COMPILER "/usr/lib64/openmpi/bin/h5pfc" CACHE FILEPATH "") # cannot find its own hdf5.mod
+set(CMake_TEST_FindHDF5_OpenMPI_Fortran_COMPILER "/usr/lib64/openmpi/bin/h5pfc" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_Serial_C_COMPILER "/usr/bin/h5cc" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_Serial_CXX_COMPILER "/usr/bin/h5c++" CACHE FILEPATH "")
set(CMake_TEST_FindHDF5_Serial_Fortran_COMPILER "/usr/bin/h5fc" CACHE FILEPATH "")
diff --git a/.gitlab/ci/env_fedora37_makefiles.sh b/.gitlab/ci/env_fedora37_makefiles.sh
index 217ff30..c482642 100644
--- a/.gitlab/ci/env_fedora37_makefiles.sh
+++ b/.gitlab/ci/env_fedora37_makefiles.sh
@@ -1,3 +1,8 @@
if test "$CMAKE_CI_NIGHTLY" = "true"; then
source .gitlab/ci/ispc-env.sh
fi
+
+# Patch HDF5 Fortran compiler wrappers to work around Fedora bug.
+# https://bugzilla.redhat.com/show_bug.cgi?id=2183289
+sed -i '/^includedir=/ s|/mpich-x86_64||' /usr/lib64/mpich/bin/h5pfc
+sed -i '/^includedir=/ s|/openmpi-x86_64||' /usr/lib64/openmpi/bin/h5pfc
diff --git a/Tests/FindHDF5/CMakeLists.txt b/Tests/FindHDF5/CMakeLists.txt
index 373759e..6bc551a 100644
--- a/Tests/FindHDF5/CMakeLists.txt
+++ b/Tests/FindHDF5/CMakeLists.txt
@@ -25,6 +25,7 @@ add_test(NAME FindHDF5.Default COMMAND
${build_generator_args}
--build-project TestFindHDF5
--build-options ${build_options} -DTEST_SERIAL=1 "-DTEST_LANGS=${test_langs}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
foreach(variant Serial OpenMPI MPICH)
@@ -60,6 +61,7 @@ foreach(variant Serial OpenMPI MPICH)
${build_generator_args}
--build-project TestFindHDF5
--build-options ${build_options} ${test_kind} "-DTEST_LANGS=${wrapper_langs}" ${wrapper}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
if(CMake_TEST_FindHDF5_${variant}_ENVMOD)
set_property(TEST FindHDF5.${variant} PROPERTY ENVIRONMENT_MODIFICATION ${CMake_TEST_FindHDF5_${variant}_ENVMOD})
@@ -76,6 +78,7 @@ foreach(variant Serial OpenMPI MPICH)
${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}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
if(CMake_TEST_FindHDF5_${variant}_ENVMOD)
set_property(TEST FindHDF5.${variant}-Wrapper PROPERTY ENVIRONMENT_MODIFICATION ${CMake_TEST_FindHDF5_${variant}_ENVMOD})
diff --git a/Tests/FindHDF5/Test/CMakeLists.txt b/Tests/FindHDF5/Test/CMakeLists.txt
index 53ad633..da1b369 100644
--- a/Tests/FindHDF5/Test/CMakeLists.txt
+++ b/Tests/FindHDF5/Test/CMakeLists.txt
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.26)
project(TestFindHDF5 LANGUAGES ${TEST_LANGS})
+include(CTest)
message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
if(TEST_PARALLEL)
@@ -56,3 +57,50 @@ if(TEST_PARALLEL)
message(SEND_ERROR "HDF5_IS_PARALLEL is false in parallel test.")
endif()
endif()
+
+if(TEST_PARALLEL)
+ set(MPI_CXX_SKIP_MPICXX TRUE)
+ set(MPI_CXX_VALIDATE_SKIP_MPICXX TRUE)
+ find_package(MPI REQUIRED)
+ set(mpi_C_tgt MPI::MPI_C)
+ set(mpi_C_inc ${MPI_C_INCLUDE_PATH})
+ set(mpi_C_lib ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES})
+ set(mpi_Fortran_tgt MPI::MPI_Fortran)
+ set(mpi_Fortran_inc ${MPI_Fortran_INCLUDE_PATH})
+ set(mpi_Fortran_lib ${MPI_Fortran_LIBRARIES})
+endif()
+
+if(CMAKE_C_COMPILER_LOADED)
+ add_executable(test_C_tgt test_C.c)
+ target_link_libraries(test_C_tgt PRIVATE hdf5::hdf5 ${mpi_C_tgt})
+ add_test(NAME test_C_tgt COMMAND test_C_tgt test_C_tgt.h5)
+
+ add_executable(test_C_var test_C.c)
+ target_include_directories(test_C_var PRIVATE ${HDF5_C_INCLUDE_DIRS} ${mpi_C_inc})
+ target_link_libraries(test_C_var PRIVATE ${HDF5_C_LIBRARIES} ${mpi_C_lib})
+ add_test(NAME test_C_var COMMAND test_C_var test_C_var.h5)
+endif()
+
+if(CMAKE_CXX_COMPILER_LOADED)
+ add_executable(test_CXX_tgt test_CXX.cxx)
+ target_link_libraries(test_CXX_tgt PRIVATE hdf5::hdf5_cpp
+ hdf5::hdf5 # FIXME: hdf5::hdf5_cpp should link hdf5::hdf5 automatically.
+ ${mpi_C_tgt})
+ add_test(NAME test_CXX_tgt COMMAND test_CXX_tgt test_CXX_tgt.h5)
+
+ add_executable(test_CXX_var test_CXX.cxx)
+ target_include_directories(test_CXX_var PRIVATE ${HDF5_CXX_INCLUDE_DIRS} ${mpi_C_inc})
+ target_link_libraries(test_CXX_var PRIVATE ${HDF5_CXX_LIBRARIES} ${mpi_C_lib})
+ add_test(NAME test_CXX_var COMMAND test_CXX_var test_CXX_var.h5)
+endif()
+
+if(CMAKE_Fortran_COMPILER_LOADED)
+ add_executable(test_Fortran_tgt test_Fortran.f90)
+ target_link_libraries(test_Fortran_tgt PRIVATE hdf5::hdf5_fortran ${mpi_Fortran_tgt})
+ add_test(NAME test_Fortran_tgt COMMAND test_Fortran_tgt)
+
+ add_executable(test_Fortran_var test_Fortran.f90)
+ target_include_directories(test_Fortran_var PRIVATE ${HDF5_Fortran_INCLUDE_DIRS} ${mpi_Fortran_inc})
+ target_link_libraries(test_Fortran_var PRIVATE ${HDF5_Fortran_LIBRARIES} ${mpi_Fortran_lib})
+ add_test(NAME test_Fortran_var COMMAND test_Fortran_var)
+endif()
diff --git a/Tests/FindHDF5/Test/test_C.c b/Tests/FindHDF5/Test/test_C.c
new file mode 100644
index 0000000..4c18364
--- /dev/null
+++ b/Tests/FindHDF5/Test/test_C.c
@@ -0,0 +1,12 @@
+#include <hdf5.h>
+
+int main(int argc, const char* argv[])
+{
+ hid_t fid;
+ if (argc != 2) {
+ return 1;
+ }
+ fid = H5Fcreate(argv[1], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ H5Fclose(fid);
+ return 0;
+}
diff --git a/Tests/FindHDF5/Test/test_CXX.cxx b/Tests/FindHDF5/Test/test_CXX.cxx
new file mode 100644
index 0000000..93fb462
--- /dev/null
+++ b/Tests/FindHDF5/Test/test_CXX.cxx
@@ -0,0 +1,14 @@
+#include <H5Cpp.h>
+
+#ifndef H5_NO_NAMESPACE
+using namespace H5;
+#endif
+
+int main(int argc, const char* argv[])
+{
+ if (argc != 2) {
+ return 1;
+ }
+ H5File f(argv[1], H5F_ACC_TRUNC);
+ return 0;
+}
diff --git a/Tests/FindHDF5/Test/test_Fortran.f90 b/Tests/FindHDF5/Test/test_Fortran.f90
new file mode 100644
index 0000000..4c12c8c
--- /dev/null
+++ b/Tests/FindHDF5/Test/test_Fortran.f90
@@ -0,0 +1,6 @@
+program hdf5_hello
+ use hdf5
+ integer error
+ call h5open_f(error)
+ call h5close_f(error)
+end