Skip to content

Commit 8ae1552

Browse files
committed
cmake: avoid excessive output from cmake --trace/--trace-expand
- `cmake . --trace-expand -DCMAKE_TRACE_MODE=1`
1 parent 12a36b5 commit 8ae1552

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cmake/OpenCVUtils.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ include(CMakeParseArguments)
88
function(ocv_cmake_dump_vars)
99
set(OPENCV_SUPPRESS_DEPRECATIONS 1) # suppress deprecation warnings from variable_watch() guards
1010
get_cmake_property(__variableNames VARIABLES)
11-
cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
11+
cmake_parse_arguments(DUMP "FORCE" "TOFILE" "" ${ARGN})
12+
13+
# avoid generation of excessive logs with "--trace" or "--trace-expand" parameters
14+
# Note: `-DCMAKE_TRACE_MODE=1` should be passed to CMake through command line. It is not a CMake buildin variable for now (2020-12)
15+
# Use `cmake . -UCMAKE_TRACE_MODE` to remove this variable from cache
16+
if(CMAKE_TRACE_MODE AND NOT DUMP_FORCE)
17+
if(DUMP_TOFILE)
18+
file(WRITE ${CMAKE_BINARY_DIR}/${DUMP_TOFILE} "Skipped due to enabled CMAKE_TRACE_MODE")
19+
else()
20+
message(AUTHOR_WARNING "ocv_cmake_dump_vars() is skipped due to enabled CMAKE_TRACE_MODE")
21+
endif()
22+
return()
23+
endif()
24+
1225
set(regex "${DUMP_UNPARSED_ARGUMENTS}")
1326
string(TOLOWER "${regex}" regex_lower)
1427
set(__VARS "")

0 commit comments

Comments
 (0)