From 9d4ee2f54d5a3823e8d3f2af320efb805543bd37 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 25 Dec 2015 17:35:38 +0300 Subject: [PATCH 1/3] cmake: added generation of CMakeVars.txt related: #5845 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cdc849f0..166feef79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1255,3 +1255,6 @@ endif() # ---------------------------------------------------------------------------- include(cmake/OpenCVPackaging.cmake) + +# This should be the last command +ocv_cmake_dump_vars("" TOFILE "CMakeVars.txt") From 9cd67318947d801dea558dcd9ac119e941aeef63 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 15 Jan 2016 14:03:48 +0300 Subject: [PATCH 2/3] cmake: add DEBUG_PRE/DEBUG_POST commands handling Useful for debug purposes: cmake -DDEBUG_POST="ocv_cmake_dump_vars(CUDA)" . cmake -DCMAKE_PRE="ocv_cmake_dump_vars(\"OPENCL|opencl\")" . --- CMakeLists.txt | 3 +++ cmake/OpenCVUtils.cmake | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 166feef79..fc0c415c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,8 @@ endif() include(cmake/OpenCVUtils.cmake) +ocv_cmake_eval(DEBUG_PRE ONCE) + ocv_clear_vars(OpenCVModules_TARGETS) # ---------------------------------------------------------------------------- @@ -1258,3 +1260,4 @@ include(cmake/OpenCVPackaging.cmake) # This should be the last command ocv_cmake_dump_vars("" TOFILE "CMakeVars.txt") +ocv_cmake_eval(DEBUG_POST ONCE) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index b60f357d4..75073f5a8 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -1,3 +1,5 @@ +include(CMakeParseArguments) + # Debugging function function(ocv_cmake_dump_vars) cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN}) @@ -16,6 +18,15 @@ function(ocv_cmake_dump_vars) endif() endfunction() +function(ocv_cmake_eval var_name) + if(DEFINED ${var_name}) + file(WRITE "${CMAKE_BINARY_DIR}/CMakeCommand-${var_name}.cmake" ${${var_name}}) + include("${CMAKE_BINARY_DIR}/CMakeCommand-${var_name}.cmake") + endif() + if(";${ARGN};" MATCHES ";ONCE;") + unset(${var_name} CACHE) + endif() +endfunction() # Search packages for host system instead of packages for target system # in case of cross compilation thess macro should be defined by toolchain file From 8f37a3a37c34c6f3af93ed16278bf4f44bdd6098 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 15 Jan 2016 14:38:25 +0300 Subject: [PATCH 3/3] cmake: make ocv_cmake_dump_vars() case insensitive --- cmake/OpenCVUtils.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index 75073f5a8..765ee7109 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -2,12 +2,14 @@ include(CMakeParseArguments) # Debugging function function(ocv_cmake_dump_vars) + set(VARS "") + get_cmake_property(_variableNames VARIABLES) cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN}) set(regex "${DUMP_UNPARSED_ARGUMENTS}") - get_cmake_property(_variableNames VARIABLES) - set(VARS "") + string(TOLOWER "${regex}" regex_lower) foreach(_variableName ${_variableNames}) - if(_variableName MATCHES "${regex}") + string(TOLOWER "${_variableName}" _variableName_lower) + if(_variableName MATCHES "${regex}" OR _variableName_lower MATCHES "${regex_lower}") set(VARS "${VARS}${_variableName}=${${_variableName}}\n") endif() endforeach()