Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on multiple find_package calls for the same library #33297

Closed
petersteneteg opened this issue Aug 21, 2023 · 5 comments · Fixed by #40548
Closed

Error on multiple find_package calls for the same library #33297

petersteneteg opened this issue Aug 21, 2023 · 5 comments · Fixed by #40548
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support depends:upstream-changes Waiting on a change to the upstream project

Comments

@petersteneteg
Copy link
Contributor

Describe the bug
Calling find_package in cmake multiple times on the same library leads to cmake errors for trying to define the same library multiple times.

For example:

  • jsoncpp adds JsonCpp::JsonCpp without any checks for if it already exists.
  • liblzma adds LibLZMA::LibLZMA without any checks for if it already exists.
  • utf9cpp adds utf8::cpp without any checks for if it already exists.

I suppose I should report this upstream and not complain here in principle. But I think it would be great if there was a CI test for this in vcpkg to avoid this happening. It gets quite confusing for users of vcpkg to track down these problems.

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install jsoncpp
  2. in cmake run

find_package(jsoncpp)
find_package(jsoncpp)

@dg0yt
Copy link
Contributor

dg0yt commented Aug 21, 2023

CMake code generated by CMake (export) should (EDIT:) NOT (/EDIT) show this problem, but hand-written CMake code can.
If the code isn't added by vcpkg, it should be fixed upstream.

  • jsoncpp: There is a problem in jsoncpp-namespaced-targets.cmake.
  • liblzma: There is a problem in liblzma-config.cmake.
  • utfcpp: There is a problem utf8cppConfig.cmake.

Fixing it already in vcpkg shouldn't need to wait for upstream. But upstream should really be notified.

I think it would be great if there was a CI test for this in vcpkg to avoid this happening. It gets quite confusing for users of vcpkg to track down these problems.

This needs special conditions to trigger, and so it is rare. There are some more frequent problems which should get CI tests (such as missing find_dependency). Unfortunately, build script solutions were rejected in the past, and nobody stepped up to add the desired hooks to the vcpkg tool.

@Adela0814 Adela0814 added category:port-bug The issue is with a library, which is something the port should already support depends:upstream-changes Waiting on a change to the upstream project labels Aug 22, 2023
Copy link

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

@github-actions github-actions bot added the Stale label Aug 19, 2024
@petersteneteg
Copy link
Contributor Author

I think this is fixed in liblzma and utfcpp but still a issue in jsoncpp

@dg0yt

This comment was marked as outdated.

@dg0yt
Copy link
Contributor

dg0yt commented Aug 19, 2024

jsoncpp

... has a pure cmake-generated config ...

Wait, it is still broken in "namespaced-targets" 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support depends:upstream-changes Waiting on a change to the upstream project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants