From 83b7fbe376f6e9735d94282c4987d8233b15fc39 Mon Sep 17 00:00:00 2001
From: Alexander Alekhin <alexander.alekhin@itseez.com>
Date: Thu, 17 Oct 2013 23:42:37 +0400
Subject: [PATCH] cmake: cleanup OpenCVModules_TARGETS from cache

This will allow to disable modules between cmake runs
---
 CMakeLists.txt          | 2 ++
 cmake/OpenCVUtils.cmake | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c30845e4f..27ce4cefe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,6 +62,8 @@ endif()
 
 include(cmake/OpenCVUtils.cmake)
 
+ocv_clear_vars(OpenCVModules_TARGETS)
+
 # ----------------------------------------------------------------------------
 # Break in case of popular CMake configuration mistakes
 # ----------------------------------------------------------------------------
diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake
index 22aa00ab2..818ec9b4b 100644
--- a/cmake/OpenCVUtils.cmake
+++ b/cmake/OpenCVUtils.cmake
@@ -458,7 +458,6 @@ function(ocv_install_target)
 
   if(DEFINED __package)
     list(APPEND ${__package}_TARGETS ${__target})
-    list(REMOVE_DUPLICATES ${__package}_TARGETS)
     set(${__package}_TARGETS "${${__package}_TARGETS}" CACHE INTERNAL "List of ${__package} targets")
   endif()