summaryrefslogtreecommitdiffstats
path: root/config/cmake/HDF5DeveloperBuild.cmake
blob: 40efb0e0711e6c50d802986b46a5d5bc5d23fd25 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#
# Copyright by The HDF Group.
# All rights reserved.
#
# This file is part of HDF5.  The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#

# CMake settings for HDF5 Developer mode builds

# Set CMake C++ flags based off of Debug build flags
set (CMAKE_CXX_FLAGS_DEVELOPER ${CMAKE_CXX_FLAGS_DEBUG} CACHE STRING
  "Flags used by the C++ compiler during developer builds." FORCE
)

# Set CMake C flags based off of Debug build flags. Add in -Og
# option to disable some GCC optimizations that might affect
# debugging negatively and also include some GCC compiler passes
# that collect debugging information
set (CMAKE_C_FLAGS_DEVELOPER "${CMAKE_C_FLAGS_DEBUG} -Og" CACHE STRING
  "Flags used by the C compiler during developer builds." FORCE
)

# Set CMake binary linker flags based off of Debug binary linker flags
set (CMAKE_EXE_LINKER_FLAGS_DEVELOPER ${CMAKE_EXE_LINKER_FLAGS_DEBUG}
  CACHE STRING "Flags used for linking binaries during developer builds."
  FORCE
)

# Set CMake shared library linker flags based off of Debug shared library
# linker flags
set (CMAKE_SHARED_LINKER_FLAGS_DEVELOPER ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}
  CACHE STRING "Flags used by the shared libraries linker during developer builds."
  FORCE
)

mark_as_advanced (
  CMAKE_CXX_FLAGS_DEVELOPER
  CMAKE_C_FLAGS_DEVELOPER
  CMAKE_EXE_LINKER_FLAGS_DEVELOPER
  CMAKE_SHARED_LINKER_FLAGS_DEVELOPER
)

#-----------------------------------------------------------------------------
# Define various HDF5 macros for debugging the library
#-----------------------------------------------------------------------------

# Enable debugging of various HDF5 modules
set (HDF5_ENABLE_DEBUG_APIS ON CACHE BOOL "Turn on extra debug output in all packages" FORCE)

# HDF5 module debug definitions for debug code which either isn't
# currently integrated with HDF5_ENABLE_DEBUG_APIS, or which isn't
# well integrated with HDF5's H5DEBUG(X) (where 'X' is a package
# letter) system. This type of debug code usually always prints output
# to stdout, regardless of whether debugging for its particular module
# has been requested via the HDF5_DEBUG environment variable. Therefore,
# we don't automatically enable this debug code, but allow developers
# to quickly add those definitions into their build here, without
# needing to hack up source files.
option (HDF5_ENABLE_DEBUG_H5AC_DIRTY_BYTES "Enable printing of H5AC module dirty bytes information" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5AC_DIRTY_BYTES)
if (HDF5_ENABLE_DEBUG_H5AC_DIRTY_BYTES)
  list (APPEND HDF5_DEBUG_APIS H5AC_DEBUG_DIRTY_BYTES_CREATION)
endif ()

option (HDF5_ENABLE_DEBUG_H5FA "Enable debugging of H5FA module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FA)
if (HDF5_ENABLE_DEBUG_H5FA)
  list (APPEND HDF5_DEBUG_APIS H5FA_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5FD_ALLOC "Enable debugging of H5FD module allocation code" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FD_ALLOC)
if (HDF5_ENABLE_DEBUG_H5FD_ALLOC)
  list (APPEND HDF5_DEBUG_APIS H5FD_ALLOC_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5FL "Enable debugging of H5FL module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FL)
if (HDF5_ENABLE_DEBUG_H5FL)
  list (APPEND HDF5_DEBUG_APIS H5FL_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5FS "Enable debugging of H5FS module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FS)
if (HDF5_ENABLE_DEBUG_H5FS)
  list (APPEND HDF5_DEBUG_APIS H5FS_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5FS_SINFO "Enable debugging of H5FS module section info" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FS_SINFO)
if (HDF5_ENABLE_DEBUG_H5FS_SINFO)
  list (APPEND HDF5_DEBUG_APIS H5FS_SINFO_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5MF_AGGR "Enable debugging of H5MF module aggregation code" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_AGGR)
if (HDF5_ENABLE_DEBUG_H5MF_AGGR)
  list (APPEND HDF5_DEBUG_APIS H5MF_AGGR_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5MF_ALLOC "Enable debugging of H5MF module allocation code" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_ALLOC)
if (HDF5_ENABLE_DEBUG_H5MF_ALLOC)
  list (APPEND HDF5_DEBUG_APIS H5MF_ALLOC_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5MF_ALLOC_MORE "Enable extra debugging of H5MF module allocation code" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_ALLOC_MORE)
if (HDF5_ENABLE_DEBUG_H5MF_ALLOC_MORE)
  list (APPEND HDF5_DEBUG_APIS H5MF_ALLOC_DEBUG_MORE)
endif ()

option (HDF5_ENABLE_DEBUG_H5MF_ALLOC_DUMP "Enable printing of debugging info for H5MF module allocation code" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_ALLOC_DUMP)
if (HDF5_ENABLE_DEBUG_H5MF_ALLOC_DUMP)
  list (APPEND HDF5_DEBUG_APIS H5MF_ALLOC_DEBUG_DUMP)
endif ()

option (HDF5_ENABLE_DEBUG_H5R "Enable debugging of H5R module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5R)
if (HDF5_ENABLE_DEBUG_H5R)
  list (APPEND HDF5_DEBUG_APIS H5R_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5S_HYPER "Enable debugging of H5S hyperslab code" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5S_HYPER)
if (HDF5_ENABLE_DEBUG_H5S_HYPER)
  list (APPEND HDF5_DEBUG_APIS H5S_HYPER_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5T_REF "Enable debugging of H5T module reference code" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5T_REF)
if (HDF5_ENABLE_DEBUG_H5T_REF)
  list (APPEND HDF5_DEBUG_APIS H5T_REF_DEBUG)
endif ()

# HDF5 module debug definitions for debug code which may add
# considerable amounts of overhead when enabled and is usually
# only useful for specific circumstances rather than general
# developer use.
option (HDF5_ENABLE_DEBUG_H5B "Enable debugging of H5B module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5B)
if (HDF5_ENABLE_DEBUG_H5B)
  list (APPEND HDF5_DEBUG_APIS H5B_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5B2 "Enable debugging of H5B2 module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5B2)
if (HDF5_ENABLE_DEBUG_H5B2)
  list (APPEND HDF5_DEBUG_APIS H5B2_DEBUG)
endif ()

option (HDF5_ENABLE_DEBUG_H5C_SANITY_CHECKS "Enable full sanity checking in H5C module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5C_SANITY_CHECKS)
if (HDF5_ENABLE_DEBUG_H5C_SANITY_CHECKS)
  list (APPEND HDF5_DEBUG_APIS H5C_DO_SANITY_CHECKS)
  list (APPEND HDF5_DEBUG_APIS H5C_DO_SLIST_SANITY_CHECKS)
  list (APPEND HDF5_DEBUG_APIS H5C_DO_TAGGING_SANITY_CHECKS)
  list (APPEND HDF5_DEBUG_APIS H5C_DO_EXTREME_SANITY_CHECKS)

  # See note in H5Cprivate.h about this #define
  # list (APPEND HDF5_DEBUG_APIS H5C_DO_MEMORY_SANITY_CHECKS=1)
endif ()

option (HDF5_ENABLE_DEBUG_H5FL_TRACK "Enable tracking of free list allocations" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FL_TRACK)
if (HDF5_ENABLE_DEBUG_H5FL_TRACK)
  list (APPEND HDF5_DEBUG_APIS H5FL_TRACK)

  # Free list tracking requires the codestack functionality
  set (HDF5_ENABLE_CODESTACK ON CACHE BOOL "Enable the function stack tracing (for developer debugging)." FORCE)
else ()
  unset (HDF5_ENABLE_CODESTACK CACHE)
endif ()

option (HDF5_ENABLE_DEBUG_H5FS_ASSERT "Enable extra debugging of H5FS module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FS_ASSERT)
if (HDF5_ENABLE_DEBUG_H5FS_ASSERT)
  list (APPEND HDF5_DEBUG_APIS H5FS_DEBUG_ASSERT)
endif ()

# If HDF5 free list debugging wasn't specifically enabled, disable
# free lists entirely for developer build modes, as they can
# make certain types of issues (like references to stale pointers)
# much more difficult to debug
if (NOT HDF5_ENABLE_DEBUG_H5FL AND NOT HDF5_ENABLE_DEBUG_H5FL_TRACK)
  list (APPEND HDF5_DEVELOPER_DEFS H5_NO_FREE_LISTS)
endif ()

# Enable strict checking of the file format
list (APPEND HDF5_DEVELOPER_DEFS H5_STRICT_FORMAT_CHECKS)