Skip to content

Commit 43847df

Browse files
author
Lior Lahav
committed
Fix delay-load propagation from ImageCodec
ImageCodec now publishes the MSVC delay-load requirements for the DLL-backed codecs it enables, so final consumers inherit the correct link behavior while codec implementation libraries stay private. The codec-local delay-load blocks were removed, and zlib delay loading is applied to png_shared where zlib is actually imported.
1 parent 550553b commit 43847df

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

Codecs/CodecJPG/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,3 @@ set(TargetName CodecJPG)
149149
add_library (${TargetName} ${sourceFiles} )
150150

151151
target_link_libraries(${TargetName} PRIVATE libjpeg-turbo::libjpeg-turbo) # adjust to match built target name
152-
153-
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") AND NOT MINGW)
154-
target_link_options(${TargetName} PUBLIC "/DELAYLOAD:turbojpeg.dll")
155-
endif()

Codecs/CodecPNG/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,3 @@ target_include_directories(${TargetName} PRIVATE ${LibPNGFolder})
6161
target_include_directories(${TargetName} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external/libpng)
6262
target_link_libraries(${TargetName} png_shared )
6363
target_include_directories(png_shared PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
64-
65-
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"))
66-
target_link_options(${TargetName} PUBLIC "/DELAYLOAD:$<TARGET_FILE_BASE_NAME:png_shared>.dll")
67-
target_link_options(${TargetName} PUBLIC "/DELAYLOAD:$<TARGET_FILE_BASE_NAME:zlib>.dll")
68-
endif()

Codecs/CodecTiff/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,3 @@ target_include_directories(${TargetName} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ext
8383

8484

8585
target_link_libraries(${TargetName} tiff)
86-
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") AND NOT MINGW)
87-
target_link_options(${TargetName} PUBLIC "/DELAYLOAD:$<TARGET_FILE_BASE_NAME:tiff>.dll")
88-
endif()

ImageCodec/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,15 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND
5151
(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") AND
5252
NOT MINGW)
5353
target_link_libraries(${TargetName} PUBLIC delayimp)
54+
if ( ${IMCODEC_BUILD_CODEC_JPG})
55+
target_link_options(${TargetName} PUBLIC "/DELAYLOAD:turbojpeg.dll")
56+
endif()
57+
if ( ${IMCODEC_BUILD_CODEC_PNG})
58+
target_link_options(${TargetName} PUBLIC "/DELAYLOAD:$<TARGET_FILE_BASE_NAME:png_shared>.dll")
59+
set_property(TARGET png_shared APPEND PROPERTY LINK_LIBRARIES delayimp)
60+
set_property(TARGET png_shared APPEND PROPERTY LINK_OPTIONS "/DELAYLOAD:$<TARGET_FILE_BASE_NAME:zlib>.dll")
61+
endif()
62+
if ( ${IMCODEC_BUILD_CODEC_TIFF})
63+
target_link_options(${TargetName} PUBLIC "/DELAYLOAD:$<TARGET_FILE_BASE_NAME:tiff>.dll")
64+
endif()
5465
endif()

0 commit comments

Comments
 (0)