Skip to content

Commit 36d7712

Browse files
committed
cmake: CMakeVars.txt (for debugging purpose)
1 parent ac118ae commit 36d7712

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,3 +1107,6 @@ endif()
11071107
# ----------------------------------------------------------------------------
11081108

11091109
include(cmake/OpenCVPackaging.cmake)
1110+
1111+
# This should be the last command
1112+
ocv_cmake_dump_vars("" TOFILE "CMakeVars.txt")

cmake/OpenCVUtils.cmake

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,37 @@ if(NOT COMMAND find_host_program)
1111
endmacro()
1212
endif()
1313

14+
if(NOT COMMAND cmake_parse_arguments)
15+
include(CMakeParseArguments OPTIONAL) # CMake 2.8.3+
16+
endif()
17+
18+
# Debugging function
19+
function(ocv_cmake_dump_vars)
20+
set(VARS "")
21+
get_cmake_property(_variableNames VARIABLES)
22+
if(COMMAND cmake_parse_arguments222)
23+
cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
24+
set(regex "${DUMP_UNPARSED_ARGUMENTS}")
25+
else()
26+
set(regex "${ARGV0}")
27+
if(ARGV1 STREQUAL "TOFILE")
28+
set(DUMP_TOFILE "${ARGV2}")
29+
endif()
30+
endif()
31+
string(TOLOWER "${regex}" regex_lower)
32+
foreach(_variableName ${_variableNames})
33+
string(TOLOWER "${_variableName}" _variableName_lower)
34+
if(_variableName MATCHES "${regex}" OR _variableName_lower MATCHES "${regex_lower}")
35+
set(VARS "${VARS}${_variableName}=${${_variableName}}\n")
36+
endif()
37+
endforeach()
38+
if(DUMP_TOFILE)
39+
file(WRITE ${CMAKE_BINARY_DIR}/${DUMP_TOFILE} "${VARS}")
40+
else()
41+
message(AUTHOR_WARNING "${VARS}")
42+
endif()
43+
endfunction()
44+
1445
# assert macro
1546
# Note: it doesn't support lists in arguments
1647
# Usage samples:

0 commit comments

Comments
 (0)