summaryrefslogtreecommitdiffstats
path: root/fortran/src/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'fortran/src/CMakeLists.txt')
-rw-r--r--fortran/src/CMakeLists.txt163
1 files changed, 101 insertions, 62 deletions
diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt
index 71b7d41..a29fb86 100644
--- a/fortran/src/CMakeLists.txt
+++ b/fortran/src/CMakeLists.txt
@@ -33,7 +33,7 @@ if (HAVE_FLOAT128)
endif ()
configure_file (${HDF5_F90_SRC_SOURCE_DIR}/H5config_f.inc.cmake ${HDF5_F90_BINARY_DIR}/H5config_f.inc @ONLY)
-configure_file (${HDF5_F90_SRC_SOURCE_DIR}/H5fort_type_defines.h.in ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h @ONLY)
+configure_file (${HDF5_F90_SRC_SOURCE_DIR}/H5fort_type_defines.h.cmake ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h @ONLY)
set (Fortran_COMPILER_ID CMAKE_Fortran_COMPILER_ID)
@@ -43,22 +43,27 @@ set (Fortran_COMPILER_ID CMAKE_Fortran_COMPILER_ID)
# H5fort_type_defines.h used to generate H5f90i_gen.h + H5fortran_types.F90
#-----------------------------------------------------------------------------
-add_executable (H5_buildiface
- ${HDF5_F90_SRC_SOURCE_DIR}/H5_buildiface.F90
- )
-target_include_directories(H5_buildiface PRIVATE "${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}")
-if (WIN32 AND MSVC)
- if (BUILD_SHARED_LIBS)
- set_target_properties (H5_buildiface
- PROPERTIES
- COMPILE_FLAGS "/MT"
- )
- endif ()
- set_target_properties (H5_buildiface
- PROPERTIES
- LINK_FLAGS "/SUBSYSTEM:CONSOLE"
- )
-endif ()
+add_executable (H5_buildiface ${HDF5_F90_SRC_SOURCE_DIR}/H5_buildiface.F90)
+target_include_directories(H5_buildiface
+ PRIVATE
+ "${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}"
+)
+#if (BUILD_SHARED_LIBS)
+# target_compile_definitions(H5_buildiface
+# PRIVATE
+# $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:/MT>
+# )
+#endif ()
+if(MSVC)
+ set_property(TARGET H5_buildiface PROPERTY COMPILE_FLAGS "/MT")
+endif()
+#set_property(TARGET H5_buildiface APPEND PROPERTY
+# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">
+#)
+if(MSVC)
+ set_property(TARGET H5_buildiface PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE")
+endif()
+
set_target_properties (H5_buildiface PROPERTIES
LINKER_LANGUAGE Fortran
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
@@ -131,31 +136,36 @@ set (f90CStub_C_SHHDRS
)
add_library (${HDF5_F90_C_LIB_TARGET} STATIC ${f90CStub_C_SOURCES} ${f90CStub_C_HDRS})
-set_property(TARGET ${HDF5_F90_C_LIB_TARGET} APPEND PROPERTY INCLUDE_DIRECTORIES "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static")
-TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} STATIC " " " ")
+target_include_directories(${HDF5_F90_C_LIB_TARGET}
+ PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static"
+ INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
+)
+TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} STATIC)
target_link_libraries (${HDF5_F90_C_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET})
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} STATIC 0)
set_target_properties (${HDF5_F90_C_LIB_TARGET} PROPERTIES
FOLDER libraries/fortran
LINKER_LANGUAGE C
- INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
set (install_targets ${HDF5_F90_C_LIB_TARGET})
if (BUILD_SHARED_LIBS)
add_library (${HDF5_F90_C_LIBSH_TARGET} SHARED ${f90CStub_C_SOURCES} ${f90CStub_C_SHHDRS})
- set_property(TARGET ${HDF5_F90_C_LIBSH_TARGET} APPEND PROPERTY INCLUDE_DIRECTORIES "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared")
- TARGET_C_PROPERTIES (${HDF5_F90_C_LIBSH_TARGET} SHARED " " " ")
+ target_include_directories(${HDF5_F90_C_LIBSH_TARGET}
+ PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared"
+ INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
+ )
+ target_compile_definitions(${HDF5_F90_C_LIBSH_TARGET}
+ PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
+ )
+ TARGET_C_PROPERTIES (${HDF5_F90_C_LIBSH_TARGET} SHARED)
target_link_libraries (${HDF5_F90_C_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET})
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIBSH_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_F90_C_LIB_NAME} SHARED "F")
set_target_properties (${HDF5_F90_C_LIBSH_TARGET} PROPERTIES
FOLDER libraries/fortran
LINKER_LANGUAGE C
- COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB"
- INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
- INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1
)
set (install_targets ${install_targets} ${HDF5_F90_C_LIBSH_TARGET})
endif ()
@@ -245,58 +255,87 @@ endif ()
# Add Main fortran library
#-----------------------------------------------------------------------------
add_library (${HDF5_F90_LIB_TARGET} STATIC ${f90_F_SOURCES})
-set (SHARED_LINK_FLAGS " ")
-TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIB_TARGET} STATIC " " " ")
-target_link_libraries (${HDF5_F90_LIB_TARGET} PUBLIC ${HDF5_F90_C_LIB_TARGET})
-target_link_libraries (${HDF5_F90_LIB_TARGET} PRIVATE ${LINK_Fortran_LIBS})
-target_include_directories (${HDF5_F90_LIB_TARGET} PUBLIC "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR}")
-if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
- target_include_directories (${HDF5_F90_LIB_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
-endif ()
-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} STATIC 0)
+target_include_directories (${HDF5_F90_LIB_TARGET}
+ PRIVATE
+ "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>"
+ INTERFACE
+ "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
+)
+target_compile_definitions(${HDF5_F90_LIB_TARGET}
+ PRIVATE
+ $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:HDF5F90_WINDOWS>
+ $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>
+)
+target_link_libraries (${HDF5_F90_LIB_TARGET}
+ PUBLIC
+ ${HDF5_F90_C_LIB_TARGET}
+ PRIVATE
+ ${LINK_Fortran_LIBS}
+ $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}>
+)
+#set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY
+# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">
+#)
+#set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY
+# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>
+#)
+if(MSVC)
+ set_property(TARGET ${HDF5_F90_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}")
+endif()
set_target_properties (${HDF5_F90_LIB_TARGET} PROPERTIES
FOLDER libraries/fortran
LINKER_LANGUAGE Fortran
- INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static
)
-if (WIN32)
- set_property (TARGET ${HDF5_F90_LIB_TARGET}
- APPEND PROPERTY COMPILE_DEFINITIONS "HDF5F90_WINDOWS"
- )
-endif ()
+H5_SET_LIB_OPTIONS (${HDF5_F90_LIB_TARGET} ${HDF5_F90_LIB_NAME} STATIC 0)
+set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIB_TARGET}")
set (install_targets ${install_targets} ${HDF5_F90_LIB_TARGET})
add_dependencies(${HDF5_F90_LIB_TARGET} H5gen)
if (BUILD_SHARED_LIBS)
add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED})
- set (SHARED_LINK_FLAGS " ")
- if (WIN32 AND MSVC)
- set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def")
- endif ()
- TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS})
- target_link_libraries (${HDF5_F90_LIBSH_TARGET} PUBLIC ${HDF5_F90_C_LIBSH_TARGET})
- target_link_libraries (${HDF5_F90_LIBSH_TARGET} PRIVATE ${LINK_Fortran_LIBS})
- target_include_directories (${HDF5_F90_LIBSH_TARGET} PUBLIC "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR}")
- if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
- target_include_directories (${HDF5_F90_LIBSH_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
- endif ()
- set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIBSH_TARGET}")
- H5_SET_LIB_OPTIONS (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_LIB_NAME} SHARED "F")
+ target_include_directories (${HDF5_F90_LIBSH_TARGET}
+ PRIVATE
+ "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>"
+ INTERFACE
+ "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
+ )
+ target_compile_definitions(${HDF5_F90_LIBSH_TARGET}
+ PUBLIC
+ "H5_BUILT_AS_DYNAMIC_LIB"
+ PRIVATE
+ $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:BUILD_HDF5_DLL;HDF5F90_WINDOWS>
+ $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:/dll>
+ $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>
+ )
+ target_link_libraries (${HDF5_F90_LIBSH_TARGET}
+ PUBLIC
+ ${HDF5_F90_C_LIBSH_TARGET}
+ PRIVATE
+ ${LINK_Fortran_LIBS} $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}>
+ )
+# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY
+# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">
+# )
+# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY
+# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>
+# )
+# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY
+# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DLL">
+# )
+# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY
+# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def">
+# )
+ if(MSVC)
+ set_property(TARGET ${HDF5_F90_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} /DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def")
+ endif()
set_target_properties (${HDF5_F90_LIBSH_TARGET} PROPERTIES
FOLDER libraries/fortran
LINKER_LANGUAGE Fortran
- COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB"
- INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
- INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared
)
- if (WIN32)
- set_property (TARGET ${HDF5_F90_LIBSH_TARGET}
- APPEND PROPERTY COMPILE_DEFINITIONS "BUILD_HDF5_DLL;HDF5F90_WINDOWS"
- )
- endif ()
+ set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIBSH_TARGET}")
+ H5_SET_LIB_OPTIONS (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_LIB_NAME} SHARED "F")
set (install_targets ${install_targets} ${HDF5_F90_LIBSH_TARGET})
add_dependencies(${HDF5_F90_LIBSH_TARGET} H5genSH)
endif ()