From a7fe73f284c801524d305d1590180b1a120a5da3 Mon Sep 17 00:00:00 2001 From: qiao Date: Mon, 21 Mar 2016 21:38:10 +0800 Subject: [PATCH] fix OpenCV_CONFIG_PATH get null value after CMake 2.8.11 syntax of cmake "get_filename_component" changed after version 2.8.11 for cmake version < 2.8.11 get_filename_component( PATH [CACHE]) for cmake version >= 2.8.11 get_filename_component( DIRECTORY [CACHE]) Update OpenCVConfig.cmake Update OpenCVConfig.cmake.in --- cmake/OpenCVConfig.cmake | 7 ++++++- cmake/templates/OpenCVConfig.cmake.in | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVConfig.cmake b/cmake/OpenCVConfig.cmake index 83bcb39fe..fdc371b19 100644 --- a/cmake/OpenCVConfig.cmake +++ b/cmake/OpenCVConfig.cmake @@ -109,7 +109,12 @@ if(NOT OpenCV_FIND_QUIETLY) message(STATUS "OpenCV STATIC: ${OpenCV_STATIC}") endif() -get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE) +if(CMAKE_VERSION VERSION_LESS "2.8.12") + get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE) +else() + get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY CACHE) +endif() + if(OpenCV_RUNTIME AND OpenCV_ARCH) if(OpenCV_STATIC AND EXISTS "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib/OpenCVConfig.cmake") if(OpenCV_CUDA AND EXISTS "${OpenCV_CONFIG_PATH}/gpu/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib/OpenCVConfig.cmake") diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index 80ffbaf01..468732b8b 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -110,7 +110,11 @@ set(OpenCV_SHARED @BUILD_SHARED_LIBS@) set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@) # Extract the directory where *this* file has been installed (determined at cmake run-time) -get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE) +if(CMAKE_VERSION VERSION_LESS "2.8.12") + get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE) +else() + get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY CACHE) +endif() if(NOT WIN32 OR ANDROID) if(ANDROID)