diff options
author | David Young <dyoung@hdfgroup.org> | 2019-12-09 16:30:58 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2019-12-09 16:30:58 (GMT) |
commit | c8f533cfc33ac743227cbed8eba361c715a2976f (patch) | |
tree | bcae5320f80bac774647cacbbd8493604f9384d2 /config/cmake/HDF5UseFortran.cmake | |
parent | adcf8a315e82c0848d126e7e46b662930c081896 (diff) | |
download | hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.zip hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.gz hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.bz2 |
Merge all of my changes from merge-back-to-feature-vfd_swmr-attempt-1,
including the merge of `hdffv/hdf5/develop`, back to the branch that Vailin and
I share.
Now I need to put this branch on a fork with a less confusing name than
vchoi_fork!
Diffstat (limited to 'config/cmake/HDF5UseFortran.cmake')
-rw-r--r-- | config/cmake/HDF5UseFortran.cmake | 176 |
1 files changed, 80 insertions, 96 deletions
diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 1f66bad..2d3d371 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -14,86 +14,61 @@ # This file provides functions for HDF5 specific Fortran support. # #------------------------------------------------------------------------------- -ENABLE_LANGUAGE (Fortran) +enable_language (Fortran) + set (HDF_PREFIX "H5") include (CheckFortranFunctionExists) -## Check for non-standard extenstion quadmath.h - -CHECK_INCLUDE_FILES(quadmath.h C_HAVE_QUADMATH) - -if (${C_HAVE_QUADMATH}) - set(${HDF_PREFIX}_HAVE_QUADMATH_H 1) -else () - set(${HDF_PREFIX}_HAVE_QUADMATH_H 0) -endif () - # The provided CMake Fortran macros don't provide a general compile/run function # so this one is used. #----------------------------------------------------------------------------- -macro (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN) -# -# if (NOT DEFINED ${RUN_RESULT_VAR}) - message (STATUS "Detecting Fortran ${FUNCTION}") - if (CMAKE_REQUIRED_LIBRARIES) - set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - else () - set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) - endif () +macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 RETURN_VAR) + message (STATUS "Detecting Fortran ${FUNCTION_NAME}") file (WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 - "${CODE}" + "${SOURCE_CODE}" ) TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 - CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" - RUN_OUTPUT_VARIABLE OUTPUT + LINK_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}" ) - set(${RETURN} ${OUTPUT}) - - #message ( "Test result1 ${RETURN} ") - #message ( "Test result3 ${RESULT} ") - #message ( "Test result2 ${CMAKE_MATCH_0} ") - #message ( "Test result4 ${CMAKE_MATCH_1} ") - #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - #message ( "Test result2 ${COMPILE_RESULT_VAR} ") - #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - #message ( "Test result1 ${RUN_RESULT_VAR} ") - #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - if (${COMPILE_RESULT_VAR}) + set(${RETURN_VAR} ${RUN_RESULT_VAR}) if (${RUN_RESULT_VAR} MATCHES 0) - message (STATUS "Testing Fortran ${FUNCTION} - OK") + message (STATUS "Testing Fortran ${FUNCTION_NAME} - OK") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n" - "${OUTPUT}\n\n" + "Determining if the Fortran ${FUNCTION_NAME} exists passed\n" ) else () - message (STATUS "Testing Fortran ${FUNCTION} - Fail") + message (STATUS "Testing Fortran ${FUNCTION_NAME} - Fail") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n" - "${OUTPUT}\n\n") + "Determining if the Fortran ${FUNCTION_NAME} exists failed: ${RUN_RESULT_VAR}\n" + ) endif () + else () + message (STATUS "Compiling Fortran ${FUNCTION_NAME} - Fail") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran ${FUNCTION_NAME} compiles failed: ${COMPILE_RESULT_VAR}\n" + ) + set(${RETURN_VAR} ${COMPILE_RESULT_VAR}) endif () -# endif () endmacro () # Read source line beginning at the line matching Input:"START" and ending at the line matching Input:"END" -macro (READ_SOURCE START END RETURN) - file (READ "${HDF5_SOURCE_DIR}/m4/aclocal_fc.f90" CODE) - string (REGEX MATCH "${START}[\\\t\\\n\\\r[].+]*${END}" CODE ${CODE}) - set (RETURN "${CODE}") +macro (READ_SOURCE SOURCE_START SOURCE_END RETURN_VAR) + file (READ "${HDF5_SOURCE_DIR}/m4/aclocal_fc.f90" SOURCE_MASTER) + string (REGEX MATCH "${SOURCE_START}[\\\t\\\n\\\r[].+]*${SOURCE_END}" SOURCE_CODE ${SOURCE_MASTER}) + set (RETURN_VAR "${SOURCE_CODE}") endmacro () #----------------------------------------------------------------------------- # Check to see C_LONG_DOUBLE is available -READ_SOURCE("PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" "END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" CODE) +READ_SOURCE("PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" "END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" SOURCE_CODE) CHECK_FORTRAN_FEATURE(c_long_double - "${CODE}" + "${SOURCE_CODE}" FORTRAN_HAVE_C_LONG_DOUBLE ) @@ -105,9 +80,9 @@ endif () # Check to see C_LONG_DOUBLE is different from C_DOUBLE -READ_SOURCE("MODULE type_mod" "END PROGRAM PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE" CODE) +READ_SOURCE("MODULE type_mod" "END PROGRAM PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE" SOURCE_CODE) CHECK_FORTRAN_FEATURE(c_long_double - "${CODE}" + "${SOURCE_CODE}" FORTRAN_C_LONG_DOUBLE_IS_UNIQUE ) if (${FORTRAN_C_LONG_DOUBLE_IS_UNIQUE}) @@ -133,12 +108,12 @@ endif () # Determine the available KINDs for REALs and INTEGERs #----------------------------------------------------------------------------- -READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" CODE) +READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) FORTRAN_RUN ("REAL and INTEGER KINDs" - "${CODE}" - XX - YY - PROG_OUTPUT + "${SOURCE_CODE}" + XX + YY + PROG_RESULT ) # dnl The output from the above program will be: # dnl -- LINE 1 -- valid integer kinds (comma seperated list) @@ -197,15 +172,18 @@ foreach (KIND ${VAR} ) USE ISO_C_BINDING IMPLICIT NONE INTEGER (KIND=${KIND}) a - WRITE(*,'(I0)') ${FC_SIZEOF_A} + OPEN(8,FILE='pac_validIntKinds.out',FORM='formatted') + WRITE(8,'(I0)') ${FC_SIZEOF_A} + CLOSE(8) END " ) FORTRAN_RUN("INTEGER KIND SIZEOF" ${PROG_SRC} - XX - YY - PROG_OUTPUT1 + XX + YY + PROG_RESULT1 ) + file (READ "${CMAKE_BINARY_DIR}/pac_validIntKinds.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_int_sizeof "${pack_int_sizeof} ${PROG_OUTPUT1},") endforeach () @@ -241,20 +219,23 @@ foreach (KIND ${VAR} ) USE ISO_C_BINDING IMPLICIT NONE REAL (KIND=${KIND}) a - WRITE(*,'(I0)') ${FC_SIZEOF_A} + OPEN(8,FILE='pac_validRealKinds.out',FORM='formatted') + WRITE(8,'(I0)') ${FC_SIZEOF_A} + CLOSE(8) END " ) FORTRAN_RUN ("REAL KIND SIZEOF" ${PROG_SRC} - XX - YY - PROG_OUTPUT1 + XX + YY + PROG_RESULT1 ) + file (READ "${CMAKE_BINARY_DIR}/pac_validRealKinds.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_real_sizeof "${pack_real_sizeof} ${PROG_OUTPUT1},") endforeach () -if (pack_int_sizeof STREQUAL "") +if (pack_real_sizeof STREQUAL "") message (FATAL_ERROR "Failed to find available REAL KINDs for Fortran") endif () @@ -288,18 +269,21 @@ FORTRAN_RUN ("SIZEOF NATIVE KINDs" INTEGER a REAL b DOUBLE PRECISION c - WRITE(*,*) ${FC_SIZEOF_A} - WRITE(*,*) kind(a) - WRITE(*,*) ${FC_SIZEOF_B} - WRITE(*,*) kind(b) - WRITE(*,*) ${FC_SIZEOF_C} - WRITE(*,*) kind(c) + OPEN(8,FILE='pac_sizeof_native_kinds.out',FORM='formatted') + WRITE(8,*) ${FC_SIZEOF_A} + WRITE(8,*) kind(a) + WRITE(8,*) ${FC_SIZEOF_B} + WRITE(8,*) kind(b) + WRITE(8,*) ${FC_SIZEOF_C} + WRITE(8,*) kind(c) + CLOSE(8) END " - XX - YY - PROG_OUTPUT -) + XX + YY + PROG_RESULT + ) + file (READ "${CMAKE_BINARY_DIR}/pac_sizeof_native_kinds.out" PROG_OUTPUT) # dnl The output from the above program will be: # dnl -- LINE 1 -- sizeof INTEGER # dnl -- LINE 2 -- kind of INTEGER @@ -372,50 +356,50 @@ ENABLE_LANGUAGE (C) # The provided CMake C macros don't provide a general compile/run function # so this one is used. #----------------------------------------------------------------------------- -macro (C_RUN FUNCTION CODE RETURN) - message (STATUS "Detecting C ${FUNCTION}") - if (CMAKE_REQUIRED_LIBRARIES) +macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) + message (STATUS "Detecting C ${FUNCTION_NAME}") + if (HDF5_REQUIRED_LIBRARIES) set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") else () set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) endif () file (WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c - ${CODE} + ${SOURCE_CODE} ) TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" - RUN_OUTPUT_VARIABLE OUTPUT + RUN_OUTPUT_VARIABLE OUTPUT_VAR ) - set (${RETURN} ${OUTPUT}) + set (${RETURN_VAR} ${OUTPUT_VAR}) - #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - #message ( "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ") - #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - #message ( "Test RUN_RESULT_VAR ${RUN_RESULT_VAR} ") - #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + #message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + #message (STATUS "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ") + #message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + #message (STATUS "Test RUN_RESULT_VAR ${RUN_RESULT_VAR} ") + #message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") if (${COMPILE_RESULT_VAR}) if (${RUN_RESULT_VAR} MATCHES 1) - set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION}") - message (STATUS "Testing C ${FUNCTION} - OK") + set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") + message (STATUS "Testing C ${FUNCTION_NAME} - OK") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C ${FUNCTION} exists passed with the following output:\n" - "${OUTPUT}\n\n" + "Determining if the C ${FUNCTION_NAME} exists passed with the following output:\n" + "${OUTPUT_VAR}\n\n" ) else () - message (STATUS "Testing C ${FUNCTION} - Fail") - set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION}") + message (STATUS "Testing C ${FUNCTION_NAME} - Fail") + set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the C ${FUNCTION} exists failed with the following output:\n" - "${OUTPUT}\n\n") + "Determining if the C ${FUNCTION_NAME} exists failed with the following output:\n" + "${OUTPUT_VAR}\n\n") endif () else () - message (FATAL_ERROR "Compilation of C ${FUNCTION} - Failed") + message (FATAL_ERROR "Compilation of C ${FUNCTION_NAME} - Failed") endif () endmacro () |