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

Need VCPKG_FORCE_SYSTEM_BINARIES env for installing vcpkg dependencies on ARM #84

Open
ljishen opened this issue Feb 20, 2022 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@ljishen
Copy link

ljishen commented Feb 20, 2022

When installing libraries, vcpkg raises this error:

Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, and ppc64le platforms.

Ref: https://github.com/microsoft/vcpkg-tool/blob/2022-02-11/src/vcpkg.cpp#L61

Originally, I was hoping to use the detect_architecture() function in VCEnvironment.cmake to solve this problem, but it turned out detect_architecture cannot detect the ARCH on ARM. Here is a similar issue: microsoft/vcpkg#17832

For cmake < 3.17, CMAKE_HOST_SYSTEM_PROCESSOR uses the command uname -p to get the result but it simply returns "unknown" on ARM: https://cmake.org/cmake/help/v3.16/variable/CMAKE_HOST_SYSTEM_PROCESSOR.html

An unrelated suggestion is that I would like to move the inclusion of Utilities.cmake outside of the file VCEnvironment.cmake, since the functions in Utilities.cmake are no longer exclusively used by that single file.

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar
@aminya
Copy link
Owner

aminya commented Mar 1, 2022

@ljishen In #87, I have refactored the detect_architecture function. Is there a special variable that VCPKG uses so I can add it here?

@ljishen
Copy link
Author

ljishen commented Mar 1, 2022

@aminya No, VCPKG uses cpp for detecting the ARCH: https://github.com/microsoft/vcpkg-tool/blob/2022-02-24/src/vcpkg.cpp#L257-L266

cmake >=3.17.0 fixed this problem by using the result of uname -m on Linux.

And this is what I'm doing in my configuration:

# CMAKE_HOST_SYSTEM_PROCESSOR is not helpful because it outputs "unknown" on
# Linux on ARM.
execute_process(
  COMMAND "uname" "--machine" OUTPUT_VARIABLE MACHINE_HARDWARE_NAME
                                              COMMAND_ERROR_IS_FATAL LAST)
string(TOLOWER "${MACHINE_HARDWARE_NAME}" MACHINE_HARDWARE_NAME_LOWER)

# vcpkg: Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm,
# s390x, and ppc64le platforms.
# See https://github.com/microsoft/vcpkg-tool/blob/2022-02-24/src/vcpkg.cpp#L257-L266
if((MACHINE_HARDWARE_NAME_LOWER MATCHES "^arm"
    OR MACHINE_HARDWARE_NAME_LOWER MATCHES "^aarch64"
    OR MACHINE_HARDWARE_NAME_LOWER MATCHES "^s390x"
    OR MACHINE_HARDWARE_NAME_LOWER MATCHES "^ppc64"
   )
   AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows"
   AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  set(ENV{VCPKG_FORCE_SYSTEM_BINARIES} 1)
endif()

For the placement of including the Utilities.cmake, if eventually we solve the problem of setting the VCPKG_FORCE_SYSTEM_BINARIES for vcpkg running on ARM, I think we should include the Utilities.cmake before including the Vcpkg.cmake in Index.cmake.

@aminya aminya added this to the v1.0.0 milestone Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants