summaryrefslogtreecommitdiffstats
path: root/hl/fortran/src/CMakeLists.txt
blob: da9cde8106677259c417cbb890368bf42121ccb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
cmake_minimum_required (VERSION 2.8)
PROJECT(HDF5_HL_F90_SRC C CXX Fortran)

#-----------------------------------------------------------------------------
# Setup include Directories
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (${HDF5_F90_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES (${HDF5_F90_BINARY_DIR})
INCLUDE_DIRECTORIES (${HDF5_F90_SRC_BINARY_DIR})

INCLUDE_DIRECTORIES (${HDF5_HL_F90_SRC_SOURCE_DIR})
INCLUDE_DIRECTORIES (${HDF5_HL_SOURCE_DIR}/src)

INCLUDE_DIRECTORIES (${CMAKE_Fortran_MODULE_DIRECTORY} ${HDF5_F90_BINARY_DIR} ${HDF5_F90_SOURCE_DIR}/src)
LINK_DIRECTORIES (
    ${CMAKE_Fortran_MODULE_DIRECTORY}
    ${HDF5_HL_F90_BINARY_DIR}
    ${HDF5_F90_BINARY_DIR}
    ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)
#-----------------------------------------------------------------------------
# List Source files
#-----------------------------------------------------------------------------
SET (HDF5_HL_F90_F_SRCS
    ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5TBff.f90
    ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTff.f90
    ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMff.f90
)

SET (HDF5_HL_F90_C_SRCS
    ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTfc.c
    ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMfc.c
    ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMcc.c
    ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5TBfc.c
)

SET (HDF5_HL_F90_HEADERS ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTf90proto.h)

ADD_LIBRARY (${HDF5_HL_F90_C_LIB_TARGET} ${LIB_TYPE} ${HDF5_HL_F90_C_SRCS} ${HDF5_HL_F90_HEADERS})
TARGET_LINK_LIBRARIES (${HDF5_HL_F90_C_LIB_TARGET}
    ${HDF5_F90_C_LIB_TARGET}
    ${HDF5_HL_LIB_TARGET}
)
#
# To Ensure that generated files are built, we must force a dependency
#
ADD_DEPENDENCIES(${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET})

SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT
    "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIB_TARGET}"
)
H5_SET_LIB_OPTIONS (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_HL_F90_C_LIB_NAME} ${LIB_TYPE})

ADD_LIBRARY (${HDF5_HL_F90_LIB_TARGET} ${LIB_TYPE} ${HDF5_HL_F90_F_SRCS})
IF (BUILD_SHARED_LIBS)
  IF (WIN32)
    SET_PROPERTY (TARGET ${HDF5_HL_F90_LIB_TARGET} 
	    APPEND PROPERTY COMPILE_DEFINITIONS 
		    BUILD_HDF5_DLL
	)
    IF (MSVC)
      SET_TARGET_PROPERTIES (${HDF5_HL_F90_LIB_TARGET}
          PROPERTIES
              COMPILE_FLAGS "/dll"
              LINK_FLAGS "/SUBSYSTEM:CONSOLE /DLL"
      ) 
    ENDIF (MSVC)
  ENDIF (WIN32)
ENDIF (BUILD_SHARED_LIBS)
IF (WIN32)
  SET_PROPERTY (TARGET ${HDF5_HL_F90_LIB_TARGET} 
      APPEND PROPERTY COMPILE_DEFINITIONS 
  	    HDF5F90_WINDOWS
  )
  SET_TARGET_PROPERTIES (${HDF5_HL_F90_LIB_TARGET} PROPERTIES LINKER_LANGUAGE Fortran)
ENDIF (WIN32)
SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT
    "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_LIB_TARGET}"
)
TARGET_LINK_LIBRARIES (${HDF5_HL_F90_LIB_TARGET}
    ${HDF5_HL_F90_C_LIB_TARGET}
)
H5_SET_LIB_OPTIONS (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_LIB_NAME} ${LIB_TYPE})
ADD_DEPENDENCIES (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_C_LIB_TARGET})

#-----------------------------------------------------------------------------
# Add Target(s) to CMake Install for import into other projects
#-----------------------------------------------------------------------------
IF (HDF5_EXPORTED_TARGETS)
  INSTALL (
      TARGETS
          ${HDF5_HL_F90_C_LIB_TARGET}
          ${HDF5_HL_F90_LIB_TARGET}
      EXPORT
          ${HDF5_EXPORTED_TARGETS}
      LIBRARY DESTINATION lib COMPONENT hlfortlibraries
      ARCHIVE DESTINATION lib COMPONENT hlfortlibraries
      RUNTIME DESTINATION bin COMPONENT hlfortlibraries
  )
ENDIF (HDF5_EXPORTED_TARGETS)