From ea5a3e557f93844fdb5e54e3e8acfc5f61c6fd9f Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 1 Jan 2018 15:56:14 +0000 Subject: [PATCH] python: filter modules headers (from /include directory) --- cmake/OpenCVUtils.cmake | 15 +++++++++++++++ modules/python/bindings/CMakeLists.txt | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index 7fd9ac7e8d..8b836c10eb 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -667,6 +667,21 @@ macro(ocv_list_filterout lst regex) endforeach() endmacro() +# filter matching elements from the list +macro(ocv_list_filter lst regex) + set(dst ${ARGN}) + if(NOT dst) + set(dst ${lst}) + endif() + set(__result ${${lst}}) + foreach(item ${__result}) + if(NOT item MATCHES "${regex}") + list(REMOVE_ITEM __result "${item}") + endif() + endforeach() + set(${dst} ${__result}) +endmacro() + # stable & safe duplicates removal macro macro(ocv_list_unique __lst) diff --git a/modules/python/bindings/CMakeLists.txt b/modules/python/bindings/CMakeLists.txt index d0b80c3bef..037cb9a39d 100644 --- a/modules/python/bindings/CMakeLists.txt +++ b/modules/python/bindings/CMakeLists.txt @@ -20,7 +20,8 @@ endforeach() set(opencv_hdrs "") set(opencv_userdef_hdrs "") foreach(m ${OPENCV_PYTHON_MODULES}) - list(APPEND opencv_hdrs ${OPENCV_MODULE_${m}_HEADERS}) + ocv_list_filter(OPENCV_MODULE_${m}_HEADERS "${OPENCV_MODULE_${m}_LOCATION}/include" __hdrs) + list(APPEND opencv_hdrs ${__hdrs}) file(GLOB userdef_hdrs ${OPENCV_MODULE_${m}_LOCATION}/misc/python/pyopencv*.hpp) list(APPEND opencv_userdef_hdrs ${userdef_hdrs}) endforeach(m)