summaryrefslogtreecommitdiffstats
path: root/hl/tools/h5watch/CMakeLists.txt
blob: 7e04329b4ee6973f35c3484d6a60379637cedfbc (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
cmake_minimum_required (VERSION 3.12)
project (HDF5_HL_TOOLS_H5WATCH C)

#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
set (H5WATCH_SOURCES
    ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watch.c
)

#-- Add h5watch program
if (NOT ONLY_SHARED_LIBS)
  add_executable (h5watch ${H5WATCH_SOURCES})
  target_compile_options(h5watch PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (h5watch PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  TARGET_C_PROPERTIES (h5watch STATIC)
  target_link_libraries (h5watch PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
  set_target_properties (h5watch PROPERTIES FOLDER tools/hl)
  set (H5_DEP_EXECUTABLES h5watch)
endif ()
if (BUILD_SHARED_LIBS)
  add_executable (h5watch-shared ${H5WATCH_SOURCES})
  target_compile_options(h5watch-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (h5watch-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  TARGET_C_PROPERTIES (h5watch-shared SHARED)
  target_link_libraries (h5watch-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET})
  set_target_properties (h5watch-shared PROPERTIES FOLDER tools/hl)
  set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5watch-shared)
endif ()

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

if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL)
  #-- Add swmr_check_compat_vfd program
  set (hl_swmr_check_compat_vfd_SOURCES
      ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/swmr_check_compat_vfd.c
  )
  add_executable (hl_swmr_check_compat_vfd ${hl_swmr_check_compat_vfd_SOURCES})
  target_compile_options(hl_swmr_check_compat_vfd PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (hl_swmr_check_compat_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  if (NOT ONLY_SHARED_LIBS)
    TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd STATIC)
    target_link_libraries (hl_swmr_check_compat_vfd PRIVATE ${HDF5_LIB_TARGET})
  else ()
    TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd SHARED)
    target_link_libraries (hl_swmr_check_compat_vfd PRIVATE ${HDF5_LIBSH_TARGET})
  endif ()
  set_target_properties (hl_swmr_check_compat_vfd PROPERTIES FOLDER tools/hl)

  #-----------------------------------------------------------------------------
  # Add Target to clang-format
  #-----------------------------------------------------------------------------
  if (HDF5_ENABLE_FORMATTERS)
    clang_format (HDF5_HL_TOOLS_H5WATCH_hl_swmr_check_compat_vfd_FORMAT hl_swmr_check_compat_vfd)
  endif ()

  #-- Add extend_dset program
  set (extend_dset_SOURCES
      ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/extend_dset.c
  )
  add_executable (extend_dset ${extend_dset_SOURCES})
  target_compile_options(extend_dset PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (extend_dset PRIVATE "${HDF5_HL_SRC_DIR}/test;${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  if (NOT ONLY_SHARED_LIBS)
    TARGET_C_PROPERTIES (extend_dset STATIC)
    target_link_libraries (extend_dset PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
  else ()
    TARGET_C_PROPERTIES (extend_dset SHARED)
    target_link_libraries (extend_dset PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET})
  endif ()
  set_target_properties (extend_dset PROPERTIES FOLDER tools/hl)

  #-----------------------------------------------------------------------------
  # Add Target to clang-format
  #-----------------------------------------------------------------------------
  if (HDF5_ENABLE_FORMATTERS)
    clang_format (HDF5_HL_TOOLS_H5WATCH_extend_dset_FORMAT extend_dset)
  endif ()

  add_executable (h5watchgentest ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watchgentest.c)
  target_compile_options(h5watchgentest PRIVATE "${HDF5_CMAKE_C_FLAGS}")
  target_include_directories (h5watchgentest PRIVATE "${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  if (NOT ONLY_SHARED_LIBS)
    TARGET_C_PROPERTIES (h5watchgentest STATIC)
    target_link_libraries (h5watchgentest PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET})
  else ()
    TARGET_C_PROPERTIES (h5watchgentest SHARED)
    target_link_libraries (h5watchgentest PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
  endif ()
  set_target_properties (h5watchgentest PROPERTIES FOLDER generator/tools/hl)

  #-----------------------------------------------------------------------------
  # Add Target to clang-format
  #-----------------------------------------------------------------------------
  if (HDF5_ENABLE_FORMATTERS)
    clang_format (HDF5_HL_TOOLS_H5WATCH_h5watchgentest_FORMAT h5watchgentest)
  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 ()