Skip to content

Commit

Permalink
build: alias VCPKG_ROOT env variable to VCPKG_DIR
Browse files Browse the repository at this point in the history
Use the build_option() function introduced in 3db0658 (build: add
build_option() to cmake/Utilities.cmake, 2022-02-10) to alias the
VCPKG_ROOT environment variable to VCPKG_DIR.

Support for VCPKG_ROOT was added to vcpkg_install.bat in 98c6a0d
(build: support VCPKG_ROOT env in vcpkg_install.bat, 2022-02-08).

Add a note about VCPKG_DIR and ENV{VCPKG_ROOT} to the cmake doc.

Signed-off-by: Rafael Kitover <[email protected]>
  • Loading branch information
rkitover committed Feb 15, 2022
1 parent 7473c3c commit f201457
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions contrib/buildsystems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ This process generates a Makefile(Linux/*BSD/MacOS), Visual Studio solution(Wind
Run `make` to build Git on Linux/*BSD/MacOS.
Open git.sln on Windows and build Git.
NOTE: By default CMake will install vcpkg locally to your source tree on configuration,
to avoid this, add `-DUSE_VCPKG=FALSE` to the command line when configuring.
NOTE: By default CMake will install vcpkg locally to your source
tree on configuration, to avoid this, add `-DUSE_VCPKG=FALSE` to
the command line when configuring.
To use your own vcpkg clone, set the environment variable VCPKG_ROOT
to the path or pass the path as `-DVCPKG_DIR=/your/clone/of/vcpkg`.
To set the vcpkg arch (target triplet) pass `VCPKG_ARCH` or
`VCPKG_TARGET_TRIPLET` e.g.: `-DVCPKG_ARCH=x64-windows`.
Expand Down Expand Up @@ -74,16 +78,21 @@ if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
endif()

if(USE_VCPKG)
build_option(
VCPKG_DIR
PATH "Path to vcpkg clone."
"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg"
ALIASES ENV{VCPKG_ROOT}
)

build_option(
VCPKG_ARCH
STRING "vcpkg arch/triplet, e.g. x64-windows."
x64-windows
ALIASES VCPKG_TARGET_TRIPLET
)

set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
set(ENV{VCPKG_ROOT} "${VCPKG_DIR}")
message(STATUS "WIN32: ${WIN32}") # show its underlying text values
message(STATUS "WIN32: ${WIN32}")
message(STATUS "VCPKG_DIR: ${VCPKG_DIR}")
message(STATUS "VCPKG_ARCH: ${VCPKG_ARCH}")
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
Expand Down

0 comments on commit f201457

Please sign in to comment.