diff options
Diffstat (limited to 'fortran/src/CMakeLists.txt')
-rw-r--r-- | fortran/src/CMakeLists.txt | 93 |
1 files changed, 62 insertions, 31 deletions
diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index d5cbc1b..3d1c127 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -1,16 +1,7 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.6) PROJECT (HDF5_F90_SRC C CXX Fortran) #----------------------------------------------------------------------------- -# When building utility executables that generate other (source) files : -# we make use of the following variables defined in the root CMakeLists. -# Certain systems may add /Debug or /Release to output paths -# and we need to call the executable from inside the CMake configuration -#----------------------------------------------------------------------------- -#inherit EXE_EXT from parent HDF5 cmake project -#inherit CFG_INIT from parent HDF5 cmake project - -#----------------------------------------------------------------------------- # Setup the Fortran auto-detection utilities # H5test_kind(_SIZEOF).f90 used to generate H5fortran_detect.f90 # H5fortran_detect.f90 used to generate H5fort_type_defines.h @@ -39,7 +30,7 @@ IF (WIN32 AND MSVC) ENDIF (WIN32 AND MSVC) SET_TARGET_PROPERTIES (H5test_FortranHavekind PROPERTIES LINKER_LANGUAGE Fortran) -SET (CMD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${CFG_INIT}/H5test_FortranHavekind${EXE_EXT}) +SET (CMD $<TARGET_FILE:H5test_FortranHavekind>) ADD_CUSTOM_COMMAND ( OUTPUT ${HDF5_F90_BINARY_DIR}/H5fortran_detect.f90 COMMAND ${CMD} @@ -63,9 +54,9 @@ IF (WIN32 AND MSVC) LINK_FLAGS "/SUBSYSTEM:CONSOLE" ) ENDIF (WIN32 AND MSVC) -SET_TARGET_PROPERTIES (H5test_FortranHavekind PROPERTIES LINKER_LANGUAGE Fortran) +SET_TARGET_PROPERTIES (H5fortran_detect PROPERTIES LINKER_LANGUAGE Fortran) -SET (CMD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${CFG_INIT}/H5fortran_detect${EXE_EXT}) +SET (CMD $<TARGET_FILE:H5fortran_detect>) ADD_CUSTOM_COMMAND ( OUTPUT ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h COMMAND ${CMD} @@ -80,7 +71,7 @@ ADD_EXECUTABLE (H5match_types ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h ${HDF5_F90_SRC_SOURCE_DIR}/H5match_types.c ) -SET (CMD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}${CFG_INIT}/H5match_types${EXE_EXT}) +SET (CMD $<TARGET_FILE:H5match_types>) ADD_CUSTOM_COMMAND ( OUTPUT ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/H5fortran_types.f90 @@ -124,9 +115,21 @@ ENDIF (H5_HAVE_PARALLEL) SET_SOURCE_FILES_PROPERTIES (${f90CStub_C_SRCS} PROPERTIES LANGUAGE C) ADD_LIBRARY (${HDF5_F90_C_LIB_TARGET} ${LIB_TYPE} ${f90CStub_C_SRCS}) -TARGET_LINK_LIBRARIES (${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET}) +TARGET_LINK_LIBRARIES (${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIB_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIB_TARGET} ${HDF5_F90_C_LIB_NAME} ${LIB_TYPE}) +SET_TARGET_PROPERTIES (${HDF5_F90_C_LIB_TARGET} PROPERTIES FOLDER libraries/fortran) + +#----------------------------------------------------------------------------- +# Fortran 2003 standard +#----------------------------------------------------------------------------- +IF (FORTRAN_HAVE_ISO_C_BINDING AND HDF5_ENABLE_F2003) + # default real is 4 bytes, so include double signatures + SET (F_STATUS "_F03") +ELSE (FORTRAN_HAVE_ISO_C_BINDING AND HDF5_ENABLE_F2003) + # default real is 8 bytes, so exclude double signatures + SET (F_STATUS "_F90") +ENDIF (FORTRAN_HAVE_ISO_C_BINDING AND HDF5_ENABLE_F2003) #----------------------------------------------------------------------------- # Fortran Real Size @@ -148,6 +151,7 @@ SET (f90_F_SRCS # normal distribution ${HDF5_F90_SRC_SOURCE_DIR}/H5f90global.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5_ff${F_STATUS}.f90 ${HDF5_F90_SRC_SOURCE_DIR}/H5_ff.f90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff.f90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff.f90 @@ -162,24 +166,32 @@ SET (f90_F_SRCS ${HDF5_F90_SRC_SOURCE_DIR}/H5Sff.f90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Tff.f90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Zff.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff${F_STATUS}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff${F_STATUS}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Eff${F_STATUS}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Lff${F_STATUS}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Off${F_STATUS}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Pff${F_STATUS}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Rff${F_STATUS}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Tff${F_STATUS}.f90 ${HDF5_F90_SRC_SOURCE_DIR}/H5_DBLE_Interface${F_DBLE}.f90 ) #----------------------------------------------------------------------------- # Add H5FDMPIO if parallel #----------------------------------------------------------------------------- -IF (H5_HAVE_PARALLEL) +IF (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) SET (f90_F_SRCS ${f90_F_SRCS} ${HDF5_F90_SRC_SOURCE_DIR}/HDF5mpio.f90 ${HDF5_F90_SRC_SOURCE_DIR}/H5FDmpioff.f90 ) -ELSE (H5_HAVE_PARALLEL) +ELSE (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) SET (f90_F_SRCS ${f90_F_SRCS} ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.f90 ) -ENDIF (H5_HAVE_PARALLEL) +ENDIF (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) #----------------------------------------------------------------------------- # Add Main fortran library @@ -189,23 +201,31 @@ SET (SHARED_LINK_FLAGS " ") IF (WIN32 AND NOT CYGWIN) IF (BUILD_SHARED_LIBS) SET_PROPERTY (TARGET ${HDF5_F90_LIB_TARGET} - APPEND PROPERTY COMPILE_DEFINITIONS - BUILD_HDF5_DLL - ) + APPEND PROPERTY COMPILE_DEFINITIONS + BUILD_HDF5_DLL + ) IF (MSVC) - SET (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_SOURCE_DIR}/hdf5_fortrandll.def") + IF (H5_HAVE_PARALLEL) + SET (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_SOURCE_DIR}/phdf5_fortrandll.def") + ELSE (H5_HAVE_PARALLEL) + SET (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_SOURCE_DIR}/hdf5_fortrandll.def") + ENDIF (H5_HAVE_PARALLEL) ENDIF (MSVC) ENDIF (BUILD_SHARED_LIBS) SET_PROPERTY (TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS - HDF5F90_WINDOWS + HDF5F90_WINDOWS ) ENDIF (WIN32 AND NOT CYGWIN) TARGET_FORTRAN_WIN_PROPERTIES (${HDF5_F90_LIB_TARGET} ${SHARED_LINK_FLAGS}) SET_TARGET_PROPERTIES (${HDF5_F90_LIB_TARGET} PROPERTIES LINKER_LANGUAGE Fortran) TARGET_LINK_LIBRARIES (${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET}) +IF (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) + TARGET_LINK_LIBRARIES (${HDF5_F90_LIB_TARGET} ${MPI_Fortran_LIBRARIES}) +ENDIF (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIB_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_LIB_TARGET} ${HDF5_F90_LIB_NAME} ${LIB_TYPE}) +SET_TARGET_PROPERTIES (${HDF5_F90_LIB_TARGET} PROPERTIES FOLDER libraries/fortran) #----------------------------------------------------------------------------- # Add file(s) to CMake Install @@ -223,14 +243,25 @@ INSTALL ( fortheaders ) -INSTALL ( - DIRECTORY - ${CMAKE_Fortran_MODULE_DIRECTORY}/\${BUILD_TYPE}/ - DESTINATION - ${HDF5_INSTALL_INCLUDE_DIR}/fortran - COMPONENT - fortheaders -) +IF (WIN32 AND NOT CYGWIN) + INSTALL ( + DIRECTORY + ${CMAKE_Fortran_MODULE_DIRECTORY}/\${BUILD_TYPE}/ + DESTINATION + ${HDF5_INSTALL_INCLUDE_DIR}/fortran + COMPONENT + fortheaders + ) +ELSE (WIN32 AND NOT CYGWIN) + INSTALL ( + DIRECTORY + ${CMAKE_Fortran_MODULE_DIRECTORY}/ + DESTINATION + ${HDF5_INSTALL_INCLUDE_DIR}/fortran + COMPONENT + fortheaders + ) +ENDIF (WIN32 AND NOT CYGWIN) #----------------------------------------------------------------------------- # Add Target(s) to CMake Install for import into other projects |