Repository navigation
build(windows): the ImageMagick closure links zlib.lib, not a bare z.lib - #822
Merged
Merged
Conversation
#801 added zlib to the ImageMagick delegate closure in src/cvc/CMakeLists.txt as "zlib|z". On a native MSVC build that finds a pkg-config (MSYS2's C:/msys64/mingw64/bin/pkg-config.exe on PATH; the PKG_CONFIG_LIBDIR pin keeps it on the cvcpkg .pc files), pkg_check_modules(... zlib) succeeds from cvcpkg's zlib.pc, whose Libs: line is `-lz`. FindPkgConfig then cannot find_library() a `z` (pkgcfg_lib__im_dep_zlib_z-NOTFOUND), because the MSVC import library is zlib.lib, and it keeps the unresolved name bare in _im_dep_zlib_LINK_LIBRARIES and in PkgConfig::_im_dep_zlib. The loop trusted _FOUND and hung that target off ImageMagick::MagickCore, so every link of cvc.dll asked link.exe for z.lib: LINK : fatal error LNK1181: cannot open input file 'z.lib' CI stays green because the GitHub windows-2022 image has no pkg-config. The loop takes the find_library fallback there, `NAMES z` finds nothing, and zlib is silently left out of the closure. On MSVC, the loop now uses a pkg-config answer only when every library in <prefix>_LINK_LIBRARIES resolved to an absolute path. Otherwise it takes the find_library fallback. Other toolchains keep today's behaviour, because their linkers search for a bare name themselves. The wasm libxml-2.0.pc lists `-lm`, which no sysroot file backs and emcc handles itself, so a stricter rule there would move wasm's libxml2 off the pkg-config path #801 just made work. A closure entry can now list several library names. zlib's are `z zlib`, and the fallback uses NAMES_PER_DIR so the prefix's zlib.lib is not passed over for a later directory that matches `z`. With or without pkg-config, cvc.dll now links deps/lib/zlib.lib. The static-export handling is unchanged: delegates still hang off the build-local ImageMagick::MagickCore and never reach cvcTargets.cmake.
Owner
Author
|
Verified on sandipaws (Windows, MSVC 14.44, Ninja, shared Release, ImageMagick ON, MSYS2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a local-Windows regression from #801 (5536b65): a native MSVC build with
CVC_ENABLE_IMAGEMAGICK=ONstops linkingcvc.dll.Cause
#801 added
"zlib|z"to the ImageMagick delegate closure insrc/cvc/CMakeLists.txt. When CMake finds a pkg-config on a Windows box (MSYS2'sC:/msys64/mingw64/bin/pkg-config.exeon PATH, which is normal on a dev machine), the steps go like this:pkg_check_modules(_im_dep_zlib ... IMPORTED_TARGET zlib)succeeds from cvcpkg'szlib.pc. ThePKG_CONFIG_LIBDIRpin keeps pkg-config on the cvcpkg prefix, so the.pcfile is the right one. ItsLibs:line is-lz.find_library(z), which fails (pkgcfg_lib__im_dep_zlib_z-NOTFOUND), because the MSVC import library iszlib.lib. FindPkgConfig keeps an unresolved-lname bare in_im_dep_zlib_LINK_LIBRARIESand inPkgConfig::_im_dep_zlib, but still reports_FOUND._FOUNDand hung that target offImageMagick::MagickCore. On a fresh configure here,build.ninjahad 314 barez.liblink inputs,cvc.dllamong them.CI stays green because the GitHub
windows-2022image has no pkg-config. There the loop takes thefind_libraryfallback,NAMES zfinds nothing, and zlib is silently left out of the closure.Fix
<prefix>_LINK_LIBRARIESresolved to an absolute path. Otherwise the loop takes thefind_libraryfallback.libxml-2.0.pclists-lm, which no emsdk sysroot file backs and emcc handles itself. A stricter rule would move wasm's libxml2 off the pkg-config path wasm: build the gallery and pycvc-gl with ImageMagick ON, and make it work #801 just made work.z zlib. The fallback usesNAMES_PER_DIR, so the first directory that has the library under either name wins.Unchanged:
ImageMagick::MagickCore. The generatedcvcTargets.cmakenames onlyImageMagick::Magick++/ImageMagick::MagickCore, with no zlib path and noPkgConfig::_im_dep_*(checked).cvcConfig.cmake.in, which isn't affected: it runs only for a static MagickCore and never asks pkg-config for the delegates.Verification (sandipaws, native MSVC 14.4x, CMake 3.31.7,
./depscvcpkg prefix)z.libshim on LIB)_im_dep_zlibresolves toz.libin build.ninjaninja cvcz(pkgcfg_lib_..._z-NOTFOUND)deps/lib/zlib.lib(fallback)bin/cvc.dlllinks-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON(like CI)deps/lib/zlib.libcvc.dlllink inputs as the row aboveAll the other delegates resolve to the same
deps/lib/*.libpaths before and after. One translation unit's INCLUDES/FLAGS/DEFINES are byte-identical between master and this branch, so only the link changes.Not run locally: Linux, macOS and wasm. The pkg-config change is gated on
MSVC. The fallback changes there are limited to zlib's extra name andNAMES_PER_DIR, which only matters for entries with more than one name.