Merge pull request #23292 from CSBVision:patch-4

Add ENABLE_DELAYLOAD option
pull/23375/head
Alexander Smorkalov 2 years ago committed by GitHub
commit 752ac19a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CMakeLists.txt
  2. 23
      cmake/OpenCVModule.cmake

@ -511,6 +511,7 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
# ===================================================
OCV_OPTION(ENABLE_CCACHE "Use ccache" (UNIX AND (CMAKE_GENERATOR MATCHES "Makefile" OR CMAKE_GENERATOR MATCHES "Ninja" OR CMAKE_GENERATOR MATCHES "Xcode")) )
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" MSVC IF (MSVC OR (NOT IOS AND NOT CMAKE_CROSSCOMPILING) ) )
OCV_OPTION(ENABLE_DELAYLOAD "Enable delayed loading of OpenCV DLLs" OFF VISIBLE_IF MSVC AND BUILD_SHARED_LIBS)
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CV_GCC )
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CV_GCC )

@ -368,6 +368,29 @@ macro(ocv_glob_modules main_root)
# resolve dependencies
__ocv_resolve_dependencies()
# optionally configure delay load
if(MSVC AND BUILD_SHARED_LIBS AND ENABLE_DELAYLOAD AND NOT BUILD_opencv_world)
if(${CMAKE_SHARED_LINKER_FLAGS} MATCHES "delayimp.lib")
set(DELAYFLAGS "")
else()
set(DELAYFLAGS "delayimp.lib")
endif()
foreach(mod ${OPENCV_MODULES_BUILD})
if(NOT ${mod} STREQUAL "opencv_core" AND NOT ${mod} MATCHES "bindings_generator|python")
set(DELAYFLAGS "${DELAYFLAGS} /DELAYLOAD:${mod}${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}.dll")
endif()
endforeach()
if(NOT ${CMAKE_SHARED_LINKER_FLAGS} MATCHES "/IGNORE:4199")
set(DELAYFLAGS "${DELAYFLAGS} /IGNORE:4199")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DELAYFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${DELAYFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${DELAYFLAGS}")
endif()
# create modules
set(OPENCV_INITIAL_PASS OFF)
ocv_cmake_hook(PRE_MODULES_CREATE)

Loading…
Cancel
Save