microsoft / microsoft/vcpkg

Feature request: add VCPKG_EXECUTABLE as custom path to vcpkg binary into vcpkg toolchain

Open
#45,815 2 comments 1 reaction 1 assignee Claimed by @Cheney-W View on GitHub
category:tool-update Stale
Dominant language
CMake
Stars
27.5k
Forks
7.7k
Avg merge
2d 19h
Merged PRs (30d)
321

Description

Currently, there is no way to properly override custom vcpkg executable (or I didn't find it?), and `vcpkg.cmake` just uses this cloned repo as root and runs `bootstrap-vcpkg` script. The one workaround that I found is to make a symlink to custom vcpkg inside the root dir (known as "Z_VCPKG_ROOT_DIR" in toolchain code).

There are already [a bunch of distros](https://repology.org/projects/?search=vcpkg) which have vcpkg in packages, and their end users couldn't use the distros' vcpkg with `vcpkg.cmake` toolchain

The potential implementation would look like this CMake pseudocode for [those lines](https://github.com/microsoft/vcpkg/blob/43819d3734f73ef27055ac80b44f1e75be2f00a8/scripts/buildsystems/vcpkg.cmake#L456C1-L464C1):
```cmake
if(NOT DEFINED VCPKG_EXECUTABLE)
# CMAKE_EXECUTABLE_SUFFIX is not yet defined
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(Z_VCPKG_EXECUTABLE "${Z_VCPKG_ROOT_DIR}/vcpkg.exe")
set(Z_VCPKG_BOOTSTRAP_SCRIPT "${Z_VCPKG_ROOT_DIR}/bootstrap-vcpkg.bat")
else()
set(Z_VCPKG_EXECUTABLE "${Z_VCPKG_ROOT_DIR}/vcpkg")
set(Z_VCPKG_BOOTSTRAP_SCRIPT "${Z_VCPKG_ROOT_DIR}/bootstrap-vcpkg.sh")
endif()
else()
set(Z_VCPKG_EXECUTABLE ${VCPKG_EXECUTABLE})
endif()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.