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

Using VCPKG_OVERRIDE_FIND_PACKAGE_NAME results in calls to unknown command _find_package #25649

Open
tusharb86 opened this issue Jul 8, 2022 · 8 comments
Assignees
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)

Comments

@tusharb86
Copy link

Describe the bug
I am using 'VCPKG_OVERRIDE_FIND_PACKAGE_NAME to override the name of find_package to effectively change it to find_vcpkg_package for use in our project. In doing so, I have found that the scripts in vcpkg have made an assumption that find_package has been overloaded and that _find_package is to be called. (See lines 792, 796, 798, etc. in vcpkg.cmake, for example). Unfortunately, this leads to errors like this:

error: XPlat:WinX64: CMake Error at G:/sb-cache/8d9ddd9c2d/installed/x64-windows/share/zlib/vcpkg-cmake-wrapper.cmake:12 (_find_package):
  Message
    Unknown CMake command "_find_package".
  Call Stack (most recent call first):
    G:/sb-cache/8d9ddd9c2d/scripts/buildsystems/vcpkg.cmake:749 (include)
    G:/hup1/Build/Debug/Install/Externals-WinX64/cmake/Externals-WinX64Config.cmake:110 (find_vcpkg_package)
    CMakeLists.txt:8 (find_package)

In this specific case, the issue is in the vcpkg-cmake-wrapper.cmake script where it is assuming that _find_package exists.

Environment

  • OS: All

To Reproduce
Set VCPKG_OVERRIDE_FIND_PACKAGE_NAME as you normally would on the command line for CMake to something like find_vcpkg_package. Somewhere in your project, add a call to find_vcpkg_package for any library of your choosing.

Expected behavior
I would expect that VCPKG_OVERRIDE_FIND_PACKAGE_NAME is honored everywhere. If it is defined, then find_package must be called. If it is NOT defined, then _find_package can be called.

@Neumann-A
Copy link
Contributor

VCPKG_OVERRIDE_FIND_PACKAGE_NAME is broken. Don't use it. Without cmake_language(CALL) the correct behavior was never implementable.

@Neumann-A
Copy link
Contributor

If you have problems with find_package being overriden by you somehow. Look at #23195

@tusharb86
Copy link
Author

Thanks for the details @Neumann-A! It would be great to get that PR through. The workaround I used in my case was to add the following macro:

    macro(_find_package)
        find_package(${ARGV})
    endmacro()

This allows VCPKG_OVERRIDE_FIND_PACKAGE_NAME to work.

@JackBoosY JackBoosY self-assigned this Jul 9, 2022
@JackBoosY JackBoosY linked a pull request Jul 9, 2022 that will close this issue
@JackBoosY JackBoosY added the category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) label Jul 9, 2022
@LilyWangLL LilyWangLL assigned Cheney-W and unassigned JackBoosY Dec 6, 2022
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 Dec 17, 2023
@Neumann-A
Copy link
Contributor

still relevant

@github-actions github-actions bot removed the Stale label Dec 18, 2023
@ArslanIbragimov
Copy link

relevant

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 Jun 26, 2024
@Cheney-W
Copy link
Contributor

still relevant

@github-actions github-actions bot removed the Stale label Jun 27, 2024
@github-actions github-actions bot added the Stale label Dec 25, 2024
@microsoft microsoft deleted a comment from github-actions bot Dec 25, 2024
@Cheney-W Cheney-W removed the Stale label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@tusharb86 @Neumann-A @Cheney-W @JackBoosY @ArslanIbragimov and others