Skip to content

Commit 68eab8e

Browse files
committed
Merge pull request opencv#5884 from alalek:cmake_vars
2 parents 6405796 + 8f37a3a commit 68eab8e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ endif()
9898

9999
include(cmake/OpenCVUtils.cmake)
100100

101+
ocv_cmake_eval(DEBUG_PRE ONCE)
102+
101103
ocv_clear_vars(OpenCVModules_TARGETS)
102104

103105
# ----------------------------------------------------------------------------
@@ -1254,3 +1256,7 @@ endif()
12541256
# ----------------------------------------------------------------------------
12551257

12561258
include(cmake/OpenCVPackaging.cmake)
1259+
1260+
# This should be the last command
1261+
ocv_cmake_dump_vars("" TOFILE "CMakeVars.txt")
1262+
ocv_cmake_eval(DEBUG_POST ONCE)

cmake/OpenCVUtils.cmake

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
include(CMakeParseArguments)
2+
13
# Debugging function
24
function(ocv_cmake_dump_vars)
5+
set(VARS "")
6+
get_cmake_property(_variableNames VARIABLES)
37
cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
48
set(regex "${DUMP_UNPARSED_ARGUMENTS}")
5-
get_cmake_property(_variableNames VARIABLES)
6-
set(VARS "")
9+
string(TOLOWER "${regex}" regex_lower)
710
foreach(_variableName ${_variableNames})
8-
if(_variableName MATCHES "${regex}")
11+
string(TOLOWER "${_variableName}" _variableName_lower)
12+
if(_variableName MATCHES "${regex}" OR _variableName_lower MATCHES "${regex_lower}")
913
set(VARS "${VARS}${_variableName}=${${_variableName}}\n")
1014
endif()
1115
endforeach()
@@ -16,6 +20,15 @@ function(ocv_cmake_dump_vars)
1620
endif()
1721
endfunction()
1822

23+
function(ocv_cmake_eval var_name)
24+
if(DEFINED ${var_name})
25+
file(WRITE "${CMAKE_BINARY_DIR}/CMakeCommand-${var_name}.cmake" ${${var_name}})
26+
include("${CMAKE_BINARY_DIR}/CMakeCommand-${var_name}.cmake")
27+
endif()
28+
if(";${ARGN};" MATCHES ";ONCE;")
29+
unset(${var_name} CACHE)
30+
endif()
31+
endfunction()
1932

2033
# Search packages for host system instead of packages for target system
2134
# in case of cross compilation thess macro should be defined by toolchain file

0 commit comments

Comments
 (0)