diff --git a/samples/cpp/fetch_opencv.cmake b/samples/cpp/fetch_opencv.cmake index f075b8bc63..ee148dfd4b 100644 --- a/samples/cpp/fetch_opencv.cmake +++ b/samples/cpp/fetch_opencv.cmake @@ -7,6 +7,7 @@ function(ov_genai_link_opencv target_name) set(required_components core imgproc videoio imgcodecs) endif() + set(OpenCV_STATIC ON) find_package(OpenCV QUIET COMPONENTS ${required_components}) if(NOT OpenCV_FOUND) @@ -16,7 +17,9 @@ function(ov_genai_link_opencv target_name) cmake_policy(SET CMP0135 NEW) endif() - set(BUILD_SHARED_LIBS ON) + set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set(OPENCV_ENABLE_PLUGINS OFF CACHE BOOL "" FORCE) set(WITH_FFMPEG ON) set(WITH_PROTOBUF OFF CACHE BOOL "" FORCE) set(WITH_GSTREAMER OFF CACHE BOOL "" FORCE) @@ -67,21 +70,6 @@ function(ov_genai_link_opencv target_name) target_include_directories(${target_name} PRIVATE ${OPENCV_MODULE_opencv_${component}_LOCATION}/include) endforeach() - - if(LINUX) - set_target_properties(${target_name} ${opencv_targets} PROPERTIES - INSTALL_RPATH "$ORIGIN/../lib" - INSTALL_RPATH_USE_LINK_PATH ON) - elseif(APPLE) - set_target_properties(${target_name} ${opencv_targets} PROPERTIES - INSTALL_RPATH "@loader_path/../lib" - INSTALL_RPATH_USE_LINK_PATH ON) - endif() - - # Signal to callers that OpenCV was built from source via FetchContent, - # so target-scoped CMake can emit any runtime deployment rules it needs - # (e.g., installing the fetched DLLs next to a Windows sample EXE). - set_property(GLOBAL PROPERTY OV_GENAI_FETCHED_OPENCV TRUE) else() set(opencv_targets ${OpenCV_LIBS}) if(OpenCV_INCLUDE_DIRS) diff --git a/samples/cpp/image_generation/CMakeLists.txt b/samples/cpp/image_generation/CMakeLists.txt index 94358783bc..fde6898ed3 100644 --- a/samples/cpp/image_generation/CMakeLists.txt +++ b/samples/cpp/image_generation/CMakeLists.txt @@ -54,22 +54,6 @@ set_target_properties(denoising_process PROPERTIES # Ensure out of box LC_RPATH on macOS with SIP INSTALL_RPATH_USE_LINK_PATH ON) -# Windows: when OpenCV was built from source via FetchContent, deploy the -# component DLLs next to denoising_process.exe in samples_bin/. The Windows -# loader has no rpath, and install/samples_bin/ is not on PATH at runtime -# unless the user puts it there. Skipped when find_package found a system -# OpenCV, since those installs ship their own runtime path. -get_property(_ov_genai_opencv_fetched GLOBAL PROPERTY OV_GENAI_FETCHED_OPENCV) -if(WIN32 AND _ov_genai_opencv_fetched) - install(FILES "$" - "$" - "$" - "$" - DESTINATION samples_bin/ - COMPONENT samples_bin - EXCLUDE_FROM_ALL) -endif() - install(TARGETS denoising_process RUNTIME DESTINATION samples_bin/ COMPONENT samples_bin