summaryrefslogtreecommitdiff
path: root/Modules/FindHDF5.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-24 20:16:40 -0400
committerBrad King <brad.king@kitware.com>2023-03-29 17:18:29 -0400
commit72915b10683cd7a6f1345f4e438722f12dcb1973 (patch)
tree94d5e87090f2b4581ac587a6fe6ab9e0aacf620e /Modules/FindHDF5.cmake
parent63441bb92029a1e28898cf573e87ce4cbf9d7c75 (diff)
downloadcmake-72915b10683cd7a6f1345f4e438722f12dcb1973.tar.gz
FindHDF5: Fix compiler wrapper checks with spaces in path
Some HDF5 compiler wrappers do not support source file paths that contain spaces. Pass source files to them using a file name in the current working directory to avoid spaces.
Diffstat (limited to 'Modules/FindHDF5.cmake')
-rw-r--r--Modules/FindHDF5.cmake20
1 files changed, 10 insertions, 10 deletions
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 96c71c28e5..c1e6a64889 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -219,7 +219,7 @@ endif()
function(_HDF5_test_regular_compiler_C success version is_parallel)
if(NOT ${success} OR
NOT EXISTS ${_HDF5_TEST_DIR}/compiler_has_h5_c)
- file(WRITE "${_HDF5_TEST_SRC}"
+ file(WRITE "${_HDF5_TEST_DIR}/${_HDF5_TEST_SRC}"
"#include <hdf5.h>\n"
"const char* info_ver = \"INFO\" \":\" H5_VERSION;\n"
"#ifdef H5_HAVE_PARALLEL\n"
@@ -235,7 +235,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} SOURCES "${_HDF5_TEST_SRC}"
+ try_compile(${success} SOURCES "${_HDF5_TEST_DIR}/${_HDF5_TEST_SRC}"
COPY_FILE ${_HDF5_TEST_DIR}/compiler_has_h5_c
)
endif()
@@ -263,7 +263,7 @@ endfunction()
function(_HDF5_test_regular_compiler_CXX success version is_parallel)
if(NOT ${success} OR
NOT EXISTS ${_HDF5_TEST_DIR}/compiler_has_h5_cxx)
- file(WRITE "${_HDF5_TEST_SRC}"
+ file(WRITE "${_HDF5_TEST_DIR}/${_HDF5_TEST_SRC}"
"#include <H5Cpp.h>\n"
"#ifndef H5_NO_NAMESPACE\n"
"using namespace H5;\n"
@@ -281,7 +281,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} SOURCES "${_HDF5_TEST_SRC}"
+ try_compile(${success} SOURCES "${_HDF5_TEST_DIR}/${_HDF5_TEST_SRC}"
COPY_FILE ${_HDF5_TEST_DIR}/compiler_has_h5_cxx
)
endif()
@@ -308,14 +308,14 @@ endfunction()
function(_HDF5_test_regular_compiler_Fortran success is_parallel)
if(NOT ${success})
- file(WRITE "${_HDF5_TEST_SRC}"
+ file(WRITE "${_HDF5_TEST_DIR}/${_HDF5_TEST_SRC}"
"program hdf5_hello\n"
" use hdf5\n"
" integer error\n"
" call h5open_f(error)\n"
" call h5close_f(error)\n"
"end\n")
- try_compile(${success} SOURCES "${_HDF5_TEST_SRC}")
+ try_compile(${success} SOURCES "${_HDF5_TEST_DIR}/${_HDF5_TEST_SRC}")
if(${success})
execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig
OUTPUT_VARIABLE config_output
@@ -588,23 +588,23 @@ if(NOT HDF5_FOUND)
# First check to see if our regular compiler is one of wrappers
if(_lang STREQUAL "C")
- set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.c)
+ set(_HDF5_TEST_SRC cmake_hdf5_test.c)
if(CMAKE_CXX_COMPILER_LOADED AND NOT CMAKE_C_COMPILER_LOADED)
# CXX project without C enabled
- set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.cxx)
+ set(_HDF5_TEST_SRC cmake_hdf5_test.cxx)
endif()
_HDF5_test_regular_compiler_C(
HDF5_${_lang}_COMPILER_NO_INTERROGATE
HDF5_${_lang}_VERSION
HDF5_${_lang}_IS_PARALLEL)
elseif(_lang STREQUAL "CXX")
- set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.cxx)
+ set(_HDF5_TEST_SRC cmake_hdf5_test.cxx)
_HDF5_test_regular_compiler_CXX(
HDF5_${_lang}_COMPILER_NO_INTERROGATE
HDF5_${_lang}_VERSION
HDF5_${_lang}_IS_PARALLEL)
elseif(_lang STREQUAL "Fortran")
- set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.f90)
+ set(_HDF5_TEST_SRC cmake_hdf5_test.f90)
_HDF5_test_regular_compiler_Fortran(
HDF5_${_lang}_COMPILER_NO_INTERROGATE
HDF5_${_lang}_IS_PARALLEL)