mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
FindHDF5: check that compiler wrapper can compile a minimal program
There are common setups where the compiler wrapper is broken and will give non-useful flags to CMake.
This commit is contained in:
committed by
Brad King
parent
6e14fe4d1f
commit
d9e39f3f89
@@ -343,35 +343,46 @@ macro( _HDF5_invoke_compiler language output return_value version is_parallel)
|
|||||||
elseif("${language}" STREQUAL "Fortran")
|
elseif("${language}" STREQUAL "Fortran")
|
||||||
set(test_file ${scratch_dir}/cmake_hdf5_test.f90)
|
set(test_file ${scratch_dir}/cmake_hdf5_test.f90)
|
||||||
endif()
|
endif()
|
||||||
|
# Verify that the compiler wrapper can actually compile: sometimes the compiler
|
||||||
|
# wrapper exists, but not the compiler. E.g. Miniconda / Anaconda Python
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file}
|
COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} ${test_file}
|
||||||
OUTPUT_VARIABLE ${output}
|
|
||||||
ERROR_VARIABLE ${output}
|
|
||||||
RESULT_VARIABLE ${return_value}
|
RESULT_VARIABLE ${return_value}
|
||||||
)
|
)
|
||||||
if(NOT ${${return_value}} EQUAL 0)
|
if(NOT ${${return_value}} EQUAL 0)
|
||||||
message(STATUS
|
message(STATUS
|
||||||
"Unable to determine HDF5 ${language} flags from HDF5 wrapper.")
|
"HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.")
|
||||||
endif()
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig
|
|
||||||
OUTPUT_VARIABLE config_output
|
|
||||||
ERROR_VARIABLE config_output
|
|
||||||
RESULT_VARIABLE config_return
|
|
||||||
)
|
|
||||||
if(NOT ${return_value} EQUAL 0)
|
|
||||||
message( STATUS
|
|
||||||
"Unable to determine HDF5 ${language} version from HDF5 wrapper.")
|
|
||||||
endif()
|
|
||||||
string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}")
|
|
||||||
if(version_match)
|
|
||||||
string(REPLACE "HDF5 Version: " "" ${version} "${version_match}")
|
|
||||||
string(REPLACE "-patch" "." ${version} "${${version}}")
|
|
||||||
endif()
|
|
||||||
if(config_output MATCHES "Parallel HDF5: yes")
|
|
||||||
set(${is_parallel} TRUE)
|
|
||||||
else()
|
else()
|
||||||
set(${is_parallel} FALSE)
|
execute_process(
|
||||||
|
COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file}
|
||||||
|
OUTPUT_VARIABLE ${output}
|
||||||
|
ERROR_VARIABLE ${output}
|
||||||
|
RESULT_VARIABLE ${return_value}
|
||||||
|
)
|
||||||
|
if(NOT ${${return_value}} EQUAL 0)
|
||||||
|
message(STATUS
|
||||||
|
"Unable to determine HDF5 ${language} flags from HDF5 wrapper.")
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig
|
||||||
|
OUTPUT_VARIABLE config_output
|
||||||
|
ERROR_VARIABLE config_output
|
||||||
|
RESULT_VARIABLE config_return
|
||||||
|
)
|
||||||
|
if(NOT ${return_value} EQUAL 0)
|
||||||
|
message( STATUS
|
||||||
|
"Unable to determine HDF5 ${language} version from HDF5 wrapper.")
|
||||||
|
endif()
|
||||||
|
string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}")
|
||||||
|
if(version_match)
|
||||||
|
string(REPLACE "HDF5 Version: " "" ${version} "${version_match}")
|
||||||
|
string(REPLACE "-patch" "." ${version} "${${version}}")
|
||||||
|
endif()
|
||||||
|
if(config_output MATCHES "Parallel HDF5: yes")
|
||||||
|
set(${is_parallel} TRUE)
|
||||||
|
else()
|
||||||
|
set(${is_parallel} FALSE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user