-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[libusb] Compatibility to projects with imported targets #18442
Comments
First, In the PCL upstream, you can add this cmake directly and change the cmake code to use it. This will not affect the PCL in vcpkg, because we will patch it. |
The question about how to work around the problem was not related to the PCL port of vcpkg, but how in general to deal with problems of this kind when using vcpkg as a toolchain (e.g. when using |
My suggestion is to add an option |
This seems like a cumbersome way to handle this. We could end up having special cases for all kinds of package managers? If a PR for suggestion 2 is openened, wouldn't be the better solution? It would give more ways to use LIBUSB in downstream projects. Either by directly using the INCLUDE / LIBRARIES variables or by using the target defined, ie. libusb::libusb? |
This can be accepted if the upstream libusb adds this method or cmake provides this method. Otherwise, other ports may also provide the same method and cannot achieve consistency. |
I think this particular conflict is the usage of
This style makes it clear whether you use external find support or internal build system features. This is not meant offensive - I just want to present an alternative which is not listed in the original post. |
Using plan # Main CMakeLists.txt
if(WIN32)
set(Win32_WinExtras WinExtras)
endif()
find_package(MyDependency 5.14 COMPONENTS Gui Test ${Win32_WinExtras} REQUIRED) it would really decrease readability when you have to write instead # Main CMakeLists.txt
set(MyDependency_Components Gui Test)
set(MyDependency_MinVersion 5.14)
if(WIN32)
list(APPEND MyDependency_Components WinExtras)
endif()
include(find_package_mydependency.cmake)
# Main find_package_mydependency.cmake
find_package(MyDependency ${MyDependency_MinVersion} COMPONENTS ${MyDependency_Components} REQUIRED) # call to find_package vcpkg or native module
...
# additional logic which is usually within own find script There are some reasons why using
This leads to massively more code just to allow package managers. |
The example sounds like Qt, but for that, my recommendation was "Use |
@SunBlack wrote:
@JackBoosY wrote:
To be honest, I find this policy a little bit inconsistent on the vcpkg side. When it is not acceptable to create non-standard targets, how can it be acceptable to create non-standard cache variables and interfer with lookup of custom find modules? |
I took indeed the example from Qt as I didn't had another example in our code where we have switch between different components (just replaced Qt by MyDependency to avoid the discussion that Qt isn't an library where you need an own find script) ;-).
Yep, that is the point. As libusb has no find script itself it is not clear, which properties/variables are allowed to defined or not. |
According to our policy, we should not add the code for finding libusb to the wrapper, but export unofficial targets or adapt the |
Generally, many ports contain internal Find modules, and when building these ports using vcpkg, these modules will be used by default unless there are some path problems. |
This allows using the port with imported targes form the mixxx module folder Fixes: microsoft#18442
Currently within PointCloudLibrary we have the problem (PointCloudLibrary/pcl#4653) that we have a
Findlibusb.cmake
that creates an imported targetlibusb::libusb
, but when you build the PCl with vcpkg the script is not called so the imported target is not created.The question now is how to work around this problem, and there are several ways:
libusb::libusb
target in a separate wrapper file, since the PCL'sFindlibusb.cmake
is never called.libusb::libusb
here_find_package(${ARGS})
at the beginning ofvcpkg-cmake-wrapper.cmake
- doesn't really work because the PCL's find script doesn't know the path"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
sincefind_library
is not overridden likefind_package
Is there a recommended way to handle this issue?
The text was updated successfully, but these errors were encountered: