summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2020-02-10 21:16:46 (GMT)
committerBrad King <brad.king@kitware.com>2020-02-11 15:42:41 (GMT)
commitd9e39f3f89e618b1ea5c1f7d8133104850ff508c (patch)
tree4e5185ae98a2b0cc1d2d73ebac1ac34c05f2f384 /Modules
parent6e14fe4d1f4d1f56101e67d9b97a96c013879314 (diff)
downloadCMake-d9e39f3f89e618b1ea5c1f7d8133104850ff508c.zip
CMake-d9e39f3f89e618b1ea5c1f7d8133104850ff508c.tar.gz
CMake-d9e39f3f89e618b1ea5c1f7d8133104850ff508c.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindHDF5.cmake59
1 files changed, 35 insertions, 24 deletions
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index b488418..874f8dc 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -343,35 +343,46 @@ macro( _HDF5_invoke_compiler language output return_value version is_parallel)
elseif("${language}" STREQUAL "Fortran")
set(test_file ${scratch_dir}/cmake_hdf5_test.f90)
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(
- COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file}
- OUTPUT_VARIABLE ${output}
- ERROR_VARIABLE ${output}
+ COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} ${test_file}
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)
+ message(STATUS
+ "HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.")
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()
endmacro()