Skip to content

Conversation

@perdrix52
Copy link

vcpkg ports are typically archive files rather than .so/.dylibs, so when building under vcpkg there were unresolved externs for stuff from ZLIB and BZip2.

I've added logic such that specifying -DIS_VCPKG_BUILD=ON will add find_package calls for BZip2 and ZLIB,
and to add target_link_libraries for them as well.

perdrix52 added 7 commits July 4, 2025 08:03
Add find_package for BZip2 if running under vcpkg
If running under vcpkg we need to add:

target_link_libraries(uchmviewer PRIVATE BZip2::BZip2)
Update test for BZip2
Update test for linking with BZip2
Remove PRIVATE keyword
Add find_package for ZLIB
Add ZLIB to target link libs
@u-235
Copy link
Member

u-235 commented Jul 4, 2025

There is a cmake/Findlibzip.cmake file in the project, so maybe it would be better to put your changes in it? It seems logical if we are looking for libzip dependencies.

@perdrix52
Copy link
Author

Once I have sorted out a few issues I'm fighting, I'll take a look at your suggestion...

@perdrix52
Copy link
Author

perdrix52 commented Jul 9, 2025

HI there, I looked at Findlibzip.cmake, and I am not convinced that there's great benefit in moving the find_package() invocations from the top level CMakeLists.txt to there, largely because that pollutes its purpose which is simply to find the libzip stuff ...

Out of considerable curiosity why did you have to write your own Findlibzip.cmake file? I thought libzip provided its own Findlibzip.cmake file, or is it only the vcpkg port of it that does that?

I'm quite happy to be persuaded that moving the find_package() invocations is the right thing to do, but as I said above, I don't think it brings any benefit, and is arguably harmful.

Cheers
David

@u-235
Copy link
Member

u-235 commented Jul 9, 2025

Hi.
libzip provides libzip-config.cmake file since May 2020, but in some distributions this file is still not available. At the same time, cmake/Findlibzip.cmake works fine except for your case. And there is a simple hack for you - delete or rename cmake/Findlibzip.cmake and then find_package() will work with libzip-config.cmake from vcpkg.

The essence of the problem is that cmake/Findlibzip.cmake does not add zlib as a dependency for libzip, for a dynamic library this is not needed. My vision is that the root CmakeLists.txt should not know such subtleties and the libzip target should have all the necessary dependencies. Therefore, I will add code to cmake/Findlibzip.cmake to check for the presence of libzip-config.cmake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants