cmake: don't export external target twice

This commit is contained in:
Alexander Alekhin 2023-07-11 01:09:31 +00:00
parent bb61cc0dba
commit f89b705049

View File

@ -1632,13 +1632,19 @@ function(ocv_add_external_target name inc link def)
endif()
endfunction()
set(__OPENCV_EXPORTED_EXTERNAL_TARGETS "" CACHE INTERNAL "")
function(ocv_install_used_external_targets)
if(NOT BUILD_SHARED_LIBS
AND NOT (CMAKE_VERSION VERSION_LESS "3.13.0") # upgrade CMake: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/2152
)
foreach(tgt in ${ARGN})
if(tgt MATCHES "^ocv\.3rdparty\.")
install(TARGETS ${tgt} EXPORT OpenCVModules)
list(FIND __OPENCV_EXPORTED_EXTERNAL_TARGETS "${tgt}" _found)
if(_found EQUAL -1) # don't export target twice
install(TARGETS ${tgt} EXPORT OpenCVModules)
list(APPEND __OPENCV_EXPORTED_EXTERNAL_TARGETS "${tgt}")
set(__OPENCV_EXPORTED_EXTERNAL_TARGETS "${__OPENCV_EXPORTED_EXTERNAL_TARGETS}" CACHE INTERNAL "")
endif()
endif()
endforeach()
endif()