From 9665e08bac0d647b80dfc5a81f90c01fe42ed697 Mon Sep 17 00:00:00 2001 From: Alexander Nitsch Date: Fri, 20 Feb 2015 00:55:26 +0100 Subject: [PATCH 1/2] Implement CMAKE_CURRENT_LIST_DIR for older CMake The use of built-in CMAKE_CURRENT_LIST_DIR requires at least CMake 2.8.3. This fix properly defines the variable to allow its use in versions < 2.8.3 as well. Fixes issue #4205. --- cmake/templates/OpenCVConfig.cmake.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index 6d1c1a990..de7fe8047 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -46,6 +46,11 @@ if(NOT DEFINED OpenCV_MODULES_SUFFIX) endif() if(NOT TARGET opencv_core) + # Extract directory name from full path of the file currently being processed. + # Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR, but we do this + # manually to support older versions of CMake as well. + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) endif() From c2944dbc0c66bd7f6106907f5afb3bc9c8998067 Mon Sep 17 00:00:00 2001 From: Alexander Nitsch Date: Fri, 20 Feb 2015 19:54:14 +0100 Subject: [PATCH 2/2] Exclude >= 2.8.3 from reimplementation of CMAKE_CURRENT_LIST_DIR This avoids violation of possible future CMake policy checks regarding reserved/read-only variables. --- cmake/templates/OpenCVConfig.cmake.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index de7fe8047..6de0eaf28 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -47,9 +47,11 @@ endif() if(NOT TARGET opencv_core) # Extract directory name from full path of the file currently being processed. - # Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR, but we do this - # manually to support older versions of CMake as well. - get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + # Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it + # for older versions of CMake to support these as well. + if(CMAKE_VERSION VERSION_LESS "2.8.3") + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + endif() include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) endif()