summaryrefslogtreecommitdiffstats
path: root/hl/tools/gif2h5/CMakeLists.txt
blob: 372fb6050badd77ff66b4ede2ca35a505d75fa63 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
cmake_minimum_required (VERSION 3.12)
project (HDF5_HL_TOOLS_GIF2H5 C)

#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
set (GIF2H5_SOURCES
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/gif.h
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/decompress.c
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/gif2hdf.c
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/gif2mem.c
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/gifread.c
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/writehdf.c
)

#-- Add gif2hdf5 program
if (NOT ONLY_SHARED_LIBS)
  add_executable (gif2h5 ${GIF2H5_SOURCES})
  target_compile_options(gif2h5 PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (gif2h5 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  TARGET_C_PROPERTIES (gif2h5 STATIC)
  target_link_libraries (gif2h5 PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
  set_target_properties (gif2h5 PROPERTIES FOLDER tools/hl)
  set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};gif2h5")
  set (H5_DEP_EXECUTABLES
      gif2h5
  )
endif ()

if (BUILD_SHARED_LIBS)
  add_executable (gif2h5-shared ${GIF2H5_SOURCES})
  target_compile_options(gif2h5-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (gif2h5-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  TARGET_C_PROPERTIES (gif2h5-shared SHARED)
  target_link_libraries (gif2h5-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET})
  set_target_properties (gif2h5-shared PROPERTIES FOLDER tools/hl)
  set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};gif2h5-shared")
  set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
      gif2h5-shared
  )
endif ()

#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
  if (NOT ONLY_SHARED_LIBS)
    clang_format (HDF5_HL_TOOLS_GIF2H5_FORMAT gif2h5)
  else ()
    clang_format (HDF5_HL_TOOLS_GIF2H5_FORMAT gif2h5-shared)
  endif ()
endif ()

#-- Add h52gif program
set (hdf2gif_SOURCES
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/hdf2gif.c
    ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/hdfgifwr.c
)
if (NOT ONLY_SHARED_LIBS)
  add_executable (h52gif ${hdf2gif_SOURCES})
  target_compile_options(h52gif PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (h52gif PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  TARGET_C_PROPERTIES (h52gif STATIC)
  target_link_libraries (h52gif PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
  set_target_properties (h52gif PROPERTIES FOLDER tools/hl)
  set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h52gif")
  set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
      h52gif
  )
endif ()

if (BUILD_SHARED_LIBS)
  add_executable (h52gif-shared ${hdf2gif_SOURCES})
  target_compile_options(h52gif-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (h52gif-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  TARGET_C_PROPERTIES (h52gif-shared SHARED)
  target_link_libraries (h52gif-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} PRIVATE ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET})
  set_target_properties (h52gif-shared PROPERTIES FOLDER tools/hl)
  set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h52gif-shared")
  set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
      h52gif-shared
  )
endif ()

#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
  if (NOT ONLY_SHARED_LIBS)
    clang_format (HDF5_HL_TOOLS_H52GIF_FORMAT h52gif)
  else ()
    clang_format (HDF5_HL_TOOLS_H52GIF_FORMAT h52gif-shared)
  endif ()
endif ()

if (BUILD_TESTING AND HDF5_TEST_SERIAL)
  # --------------------------------------------------------------------
  # This executable can generate the actual test files - Currently not
  #  used in the CMake Build system as we rely on the test files that are
  #  shipped with HDF5 source archives
  # --------------------------------------------------------------------
  if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS)
      add_executable (hl_h52gifgentest ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/h52gifgentst.c)
      target_include_directories (hl_h52gifgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
      TARGET_C_PROPERTIES (hl_h52gifgentest STATIC)
      target_link_libraries (hl_h52gifgentest PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET})
      set_target_properties (hl_h52gifgentest PROPERTIES FOLDER generator/tools/hl)

      #-----------------------------------------------------------------------------
      # Add Target to clang-format
      #-----------------------------------------------------------------------------
      if (HDF5_ENABLE_FORMATTERS)
        clang_format (HDF5_HL_TOOLS_hl_h52gifgentest_FORMAT hl_h52gifgentest)
      endif ()

#      add_test (NAME hl_h52gifgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hl_h52gifgentest>)
  endif ()

  if (HDF5_TEST_TOOLS)
    include (CMakeTests.cmake)
  endif ()
endif ()

#-----------------------------------------------------------------------------
# Add file(s) to CMake Install
#-----------------------------------------------------------------------------
if (HDF5_EXPORTED_TARGETS)
  install (
      TARGETS
          ${H5_DEP_EXECUTABLES}
      EXPORT
          ${HDF5_EXPORTED_TARGETS}
      RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT hltoolsapplications
  )
endif ()