Skip to content

Commit 5442c59

Browse files
committed
Refactor helpers module, extract dump() and dd() into own module
We should expect that more debugging utils will be added in future versions and it is therefore a good idea to have a custom "debug" module, in the top-level.
1 parent 3116175 commit 5442c59

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

cmake/rsp/debug.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -------------------------------------------------------------------------------------------------------------- #
2+
# Debug utilities functions
3+
# -------------------------------------------------------------------------------------------------------------- #
4+
5+
include_guard(GLOBAL)
6+
7+
# Debug
8+
message(VERBOSE "rsp/debug module included")
9+
10+
if (NOT COMMAND "dump")
11+
12+
#! dump : Outputs given variables' name and value
13+
#
14+
# @param ... Variables to output
15+
#
16+
function(dump)
17+
foreach (var ${ARGN})
18+
message("${var} = ${${var}}")
19+
endforeach ()
20+
21+
# Output as warning so that the developer is able to see call stack!
22+
message(WARNING " ${CMAKE_CURRENT_FUNCTION}() called from ${CMAKE_CURRENT_LIST_FILE}")
23+
endfunction()
24+
endif ()
25+
26+
if (NOT COMMAND "dd")
27+
28+
#! dump and die: Outputs given variables' name and value and stops build
29+
#
30+
# @param ... Variables to output
31+
#
32+
function(dd)
33+
foreach (var ${ARGN})
34+
message("${var} = ${${var}}")
35+
endforeach ()
36+
37+
# Output as fatal error to ensure that build stops.
38+
message(FATAL_ERROR " ${CMAKE_CURRENT_FUNCTION}() called from ${CMAKE_CURRENT_LIST_FILE}")
39+
endfunction()
40+
endif ()

cmake/rsp/helpers.cmake

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -120,35 +120,3 @@ if (NOT COMMAND "safeguard_properties")
120120
endforeach ()
121121
endfunction()
122122
endif ()
123-
124-
if (NOT COMMAND "dump")
125-
126-
#! dump : Outputs given variables' name and value
127-
#
128-
# @param ... Variables to output
129-
#
130-
function(dump)
131-
foreach (var ${ARGN})
132-
message("${var} = ${${var}}")
133-
endforeach ()
134-
135-
# Output as warning so that the developer is able to see call stack!
136-
message(WARNING " ${CMAKE_CURRENT_FUNCTION}() called from ${CMAKE_CURRENT_LIST_FILE}")
137-
endfunction()
138-
endif ()
139-
140-
if (NOT COMMAND "dd")
141-
142-
#! dump and die: Outputs given variables' name and value and stops build
143-
#
144-
# @param ... Variables to output
145-
#
146-
function(dd)
147-
foreach (var ${ARGN})
148-
message("${var} = ${${var}}")
149-
endforeach ()
150-
151-
# Output as fatal error to ensure that build stops.
152-
message(FATAL_ERROR " ${CMAKE_CURRENT_FUNCTION}() called from ${CMAKE_CURRENT_LIST_FILE}")
153-
endfunction()
154-
endif ()

0 commit comments

Comments
 (0)