From 5f7d922b106d62ef822731d353acff0c7ce9b810 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Fri, 13 Aug 2021 14:20:32 +0300 Subject: [PATCH] Option to enable/disable plugin linking with OpenCV --- cmake/OpenCVPluginStandalone.cmake | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmake/OpenCVPluginStandalone.cmake b/cmake/OpenCVPluginStandalone.cmake index 15b7a8085e..129ede1ae1 100644 --- a/cmake/OpenCVPluginStandalone.cmake +++ b/cmake/OpenCVPluginStandalone.cmake @@ -78,10 +78,17 @@ function(ocv_create_plugin module default_name dependency_target dependency_targ set_target_properties(${OPENCV_PLUGIN_NAME} PROPERTIES PREFIX "${OPENCV_PLUGIN_MODULE_PREFIX}") endif() - if(APPLE) - set_target_properties(${OPENCV_PLUGIN_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") - elseif(WIN32) - # Hack for Windows only, Linux/MacOS uses global symbol table (without exact .so binding) + if(WIN32 OR NOT APPLE) + set(OPENCV_PLUGIN_NO_LINK FALSE CACHE BOOL "") + else() + set(OPENCV_PLUGIN_NO_LINK TRUE CACHE BOOL "") + endif() + + if(OPENCV_PLUGIN_NO_LINK) + if(APPLE) + set_target_properties(${OPENCV_PLUGIN_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") + endif() + else() find_package(OpenCV REQUIRED ${module} ${OPENCV_PLUGIN_DEPS}) target_link_libraries(${OPENCV_PLUGIN_NAME} PRIVATE ${OpenCV_LIBRARIES}) endif()