diff options
Diffstat (limited to 'Modules/FindHDF5.cmake')
-rw-r--r-- | Modules/FindHDF5.cmake | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 40ed9a9..db03c54 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -222,6 +222,10 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) if(NOT ${success} OR NOT EXISTS ${scratch_directory}/compiler_has_h5_c) set(test_file ${scratch_directory}/cmake_hdf5_test.c) + # CXX project without C enabled + if(CMAKE_CXX_COMPILER_LOADED AND NOT CMAKE_C_COMPILER_LOADED) + set(test_file ${scratch_directory}/cmake_hdf5_test.cpp) + endif() file(WRITE ${test_file} "#include <hdf5.h>\n" "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" @@ -238,7 +242,7 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" " return 0;\n" "}") - try_compile(${success} ${scratch_directory} ${test_file} + try_compile(${success} SOURCES ${test_file} COPY_FILE ${scratch_directory}/compiler_has_h5_c ) endif() @@ -286,7 +290,7 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel) " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" " return 0;\n" "}") - try_compile(${success} ${scratch_directory} ${test_file} + try_compile(${success} SOURCES ${test_file} COPY_FILE ${scratch_directory}/compiler_has_h5_cxx ) endif() @@ -323,7 +327,7 @@ function(_HDF5_test_regular_compiler_Fortran success is_parallel) " call h5open_f(error)\n" " call h5close_f(error)\n" "end\n") - try_compile(${success} ${scratch_directory} ${test_file}) + try_compile(${success} SOURCES ${test_file}) if(${success}) execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig OUTPUT_VARIABLE config_output |