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(<VAR> <FileName> PATH [CACHE])

for cmake version >= 2.8.11
  get_filename_component(<VAR> <FileName> DIRECTORY [CACHE])

Update OpenCVConfig.cmake

Update OpenCVConfig.cmake.in
This commit is contained in:
qiao 2016-03-21 21:38:10 +08:00
parent 7783206934
commit a7fe73f284
2 changed files with 11 additions and 2 deletions

View File

@ -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")

View File

@ -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)