From 8b9d8c4ddc9ff4d4cac396e84c8a44c622871ee9 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Thu, 15 Jun 2017 15:04:01 -0500 Subject: FindHDF5: Fix parallel detection when primary compiler is an HDF5 wrapper This is covering a different use case where your primary compilers are HDF5 wrappers, as is the case when using the Cray Programming Environment. The existing code tries to query the compiler using options only available to h5cc and friends, which doesn't work when your wrapper is not h5cc, as is the case with the CrayPE. This change instead pulls strings out of a test binary when testing for "is your regular compiler an HDF5 wrapper" while the "query wrapper for options" is reserved for the "I found the hdf5 wrappers but they're not your main compiler" mode. --- Modules/FindHDF5.cmake | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 5962c5b..2d9d2a2 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -187,8 +187,16 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) file(WRITE ${test_file} "#include \n" "#include \n" - "int main(void) {\n" - " char const* info_ver = \"INFO\" \":\" H5_VERSION;\n" + "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" + "#ifdef H5_HAVE_PARALLEL\n" + "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" + "#endif\n" + "int main(int argc, char **argv) {\n" + " int require = 0;\n" + " require += info_ver[argc];\n" + "#ifdef H5_HAVE_PARALLEL\n" + " require += info_parallel[argc];\n" + "#endif\n" " hid_t fid;\n" " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" " return 0;\n" @@ -198,11 +206,11 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) ) endif() if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_VER - REGEX "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" + file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS + REGEX "^INFO:" ) string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_VER}" + INFO_VER "${INFO_STRINGS}" ) set(${version} ${CMAKE_MATCH_1}) if(CMAKE_MATCH_3) @@ -210,12 +218,7 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) endif() set(${version} ${${version}} PARENT_SCOPE) - execute_process(COMMAND ${CMAKE_C_COMPILER} -showconfig - OUTPUT_VARIABLE config_output - ERROR_VARIABLE config_error - RESULT_VARIABLE config_result - ) - if(config_output MATCHES "Parallel HDF5: yes") + if(INFO_STRINGS MATCHES "INFO:PARALLEL") set(${is_parallel} TRUE PARENT_SCOPE) else() set(${is_parallel} FALSE PARENT_SCOPE) @@ -233,8 +236,16 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel) "#ifndef H5_NO_NAMESPACE\n" "using namespace H5;\n" "#endif\n" + "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" + "#ifdef H5_HAVE_PARALLEL\n" + "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" + "#endif\n" "int main(int argc, char **argv) {\n" - " char const* info_ver = \"INFO\" \":\" H5_VERSION;\n" + " int require = 0;\n" + " require += info_ver[argc];\n" + "#ifdef H5_HAVE_PARALLEL\n" + " require += info_parallel[argc];\n" + "#endif\n" " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" " return 0;\n" "}") @@ -243,11 +254,11 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel) ) endif() if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_VER - REGEX "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" + file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS + REGEX "^INFO:" ) string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_VER}" + INFO_VER "${INFO_STRINGS}" ) set(${version} ${CMAKE_MATCH_1}) if(CMAKE_MATCH_3) @@ -255,12 +266,7 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel) endif() set(${version} ${${version}} PARENT_SCOPE) - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -showconfig - OUTPUT_VARIABLE config_output - ERROR_VARIABLE config_error - RESULT_VARIABLE config_result - ) - if(config_output MATCHES "Parallel HDF5: yes") + if(INFO_STRINGS MATCHES "INFO:PARALLEL") set(${is_parallel} TRUE PARENT_SCOPE) else() set(${is_parallel} FALSE PARENT_SCOPE) -- cgit v0.12