From 18c2970a97da3644c60f3cb7c9ddfb69f4fe318c Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Mon, 20 Feb 2023 19:05:05 -0800 Subject: FindHDF5: Fix detection of Parallel HDF5 To detect Parallel HDF5, the output of `h5pcc -showconfig` was compared with `Parallel HDF5: yes`. However, the Boolean flag is not always `yes` or `no`, because it was set by the value in `HDF5_ENABLE_PARALLEL` if CMake was used for the configuration. This commit instead checks to see if the value is interpreted by CMake as "true". --- Modules/FindHDF5.cmake | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index db03c54..62c492c 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -334,8 +334,15 @@ function(_HDF5_test_regular_compiler_Fortran success is_parallel) 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() @@ -401,8 +408,13 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var 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) -- cgit v0.12