diff options
Diffstat (limited to 'Modules/FindHDF5.cmake')
-rw-r--r-- | Modules/FindHDF5.cmake | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 6fab08f..a44c6f9 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,22 +308,29 @@ 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 ERROR_VARIABLE config_error RESULT_VARIABLE config_result ) - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE PARENT_SCOPE) + if(config_output MATCHES "Parallel HDF5: ([A-Za-z0-9]+)") + # The value may be anything used when HDF5 was configured, + # so see if CMake interprets it as "true". + set(parallelHDF5 "${CMAKE_MATCH_1}") + if(parallelHDF5) + set(${is_parallel} TRUE PARENT_SCOPE) + else() + set(${is_parallel} FALSE PARENT_SCOPE) + endif() else() set(${is_parallel} FALSE PARENT_SCOPE) endif() @@ -349,9 +356,13 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var ERROR_VARIABLE output RESULT_VARIABLE return_value ) - if(return_value AND NOT HDF5_FIND_QUIETLY) - message(STATUS - "HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.") + if(NOT return_value EQUAL 0) + message(CONFIGURE_LOG + "HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.\n\n${output}") + if(NOT HDF5_FIND_QUIETLY) + message(STATUS + "HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.") + endif() else() execute_process( COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} "${_HDF5_TEST_SRC}" @@ -361,9 +372,13 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var RESULT_VARIABLE return_value OUTPUT_STRIP_TRAILING_WHITESPACE ) - if(return_value AND NOT HDF5_FIND_QUIETLY) - message(STATUS - "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") + if(NOT return_value EQUAL 0) + message(CONFIGURE_LOG + "Unable to determine HDF5 ${language} flags from HDF5 wrapper.\n\n${output}") + if(NOT HDF5_FIND_QUIETLY) + message(STATUS + "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") + endif() endif() execute_process( COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig @@ -372,17 +387,26 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var RESULT_VARIABLE return_value OUTPUT_STRIP_TRAILING_WHITESPACE ) - if(return_value AND NOT HDF5_FIND_QUIETLY) - message(STATUS - "Unable to determine HDF5 ${language} version_var from HDF5 wrapper.") + if(NOT return_value EQUAL 0) + message(CONFIGURE_LOG + "Unable to determine HDF5 ${language} version_var from HDF5 wrapper.\n\n${output}") + if(NOT HDF5_FIND_QUIETLY) + message(STATUS + "Unable to determine HDF5 ${language} version_var from HDF5 wrapper.") + endif() endif() string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version "${config_output}") if(version) string(REPLACE "HDF5 Version: " "" version "${version}") string(REPLACE "-patch" "." version "${version}") endif() - if(config_output MATCHES "Parallel HDF5: yes") - set(is_parallel TRUE) + if(config_output MATCHES "Parallel HDF5: ([A-Za-z0-9]+)") + # The value may be anything used when HDF5 was configured, + # so see if CMake interprets it as "true". + set(parallelHDF5 "${CMAKE_MATCH_1}") + if(parallelHDF5) + set(is_parallel TRUE) + endif() endif() endif() foreach(var output return_value version is_parallel) @@ -576,23 +600,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) |