Implement CMAKE_CURRENT_LIST_DIR for older CMake
authorAlexander Nitsch <nitsch@ht.tu-berlin.de>
Thu, 19 Feb 2015 23:55:26 +0000 (00:55 +0100)
committerAlexander Nitsch <nitsch@ht.tu-berlin.de>
Thu, 19 Feb 2015 23:55:26 +0000 (00:55 +0100)
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

index 6d1c1a9..de7fe80 100644 (file)
@@ -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()