summaryrefslogtreecommitdiffstats
path: root/config/cmake/HDF5PluginMacros.cmake
blob: 4e05399becbca77b494d30adfe56ad164f2fd848 (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
101
102
103
104
105
106
107
108
#-------------------------------------------------------------------------------
# Plugins must be built SHARED
#-------------------------------------------------------------------------------
macro (EXTERNAL_PLUGIN_LIBRARY compress_type)
  if (${compress_type} MATCHES "GIT")
    FetchContent_Declare (PLUGIN
        GIT_REPOSITORY ${PLUGIN_URL}
        GIT_TAG ${PLUGIN_BRANCH}
    )
  elseif (${compress_type} MATCHES "TGZ")
    FetchContent_Declare (PLUGIN
        URL ${PLUGIN_URL}
        URL_HASH ""
    )
  endif ()
  FetchContent_GetProperties(PLUGIN)
  if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
    message (VERBOSE "HDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIR}")
  endif ()
  if(NOT PLUGIN_POPULATED)
    FetchContent_Populate(PLUGIN)
    include (${HDF_RESOURCES_DIR}/HDF5PluginCache.cmake)
    set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
    add_subdirectory(${plugin_SOURCE_DIR} ${plugin_BINARY_DIR})
    if (ENABLE_BLOSC)
      add_dependencies (h5blosc ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_blosc ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_blosc PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_BSHUF)
      add_dependencies (h5bshuf ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_bshuf ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_bshuf PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_BZIP2)
      add_dependencies (h5bz2 ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_bzip2 ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_bzip2 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_JPEG)
      add_dependencies (h5jpeg ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_jpeg ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_jpeg PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_LZ4)
      add_dependencies (h5lz4 ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_lz4 ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_lz4 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_LZF)
      add_dependencies (h5lzf ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_lzf ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_lzf PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_MAFISC)
      add_dependencies (h5mafisc ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_mafisc ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_mafisc PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_SZF)
      add_dependencies (h5szf ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_sz ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_sz PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
    if (ENABLE_ZFP)
      add_dependencies (h5zfp ${HDF5_LIBSH_TARGET})
      add_dependencies (h5ex_d_zfp ${HDF5_LIBSH_TARGET})
      target_include_directories (h5ex_d_zfp PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}")
    endif ()
  endif ()
  if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
    message (VERBOSE "HDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIR}")
  endif ()
  set (PLUGIN_BINARY_DIR "${plugin_BINARY_DIR}")
  set (PLUGIN_SOURCE_DIR "${plugin_SOURCE_DIR}")
  set (PLUGIN_LIBRARY "PLUGIN")
  set (PLUGIN_FOUND 1)
endmacro ()

#-------------------------------------------------------------------------------
macro (FILTER_OPTION plname)
  string(TOLOWER ${plname} PLUGIN_NAME)
  option (ENABLE_${plname} "Enable Library Building for ${plname} plugin" ON)
  if (ENABLE_${plname})
    option (HDF_${plname}_USE_EXTERNAL "Use External Library Building for ${PLUGIN_NAME} plugin" 0)
    if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
      set (HDF_${plname}_USE_EXTERNAL 1 CACHE BOOL "Use External Library Building for ${PLUGIN_NAME} plugin" FORCE)
      if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
        set (HDF_${plname}_URL ${HDF_${plname}_GIT_URL})
        set (HDF_${plname}_BRANCH ${HDF_${plname}_GIT_BRANCH})
      elseif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
        if (NOT TGZPATH)
          set (TGZPATH ${H5PL_SOURCE_DIR})
        endif ()
        set (HDF_${plname}_URL ${TGZPATH}/${HDF_${plname}_TGZ_NAME})
      endif ()
    endif ()
    add_subdirectory (${plname})
    set_global_variable (H5PL_LIBRARIES_TO_EXPORT "${H5PL_LIBRARIES_TO_EXPORT};${H5${plname}_LIBRARIES_TO_EXPORT}")
  endif ()
endmacro ()

#-------------------------------------------------------------------------------
macro (PACKAGE_PLUGIN_LIBRARY compress_type)
  if (${compress_type} MATCHES "GIT" OR ${compress_type} MATCHES "TGZ")
    message (STATUS "Filter PLUGIN is to be packaged")
  endif ()
endmacro ()