Skip to content

Commit b4238e4

Browse files
committed
build: alias VCPKG_ROOT env variable to VCPKG_DIR
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]>
1 parent 5830df7 commit b4238e4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Diff for: contrib/buildsystems/CMakeLists.txt

+14-5
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ This process generates a Makefile(Linux/*BSD/MacOS), Visual Studio solution(Wind
4444
Run `make` to build Git on Linux/*BSD/MacOS.
4545
Open git.sln on Windows and build Git.
4646
47-
NOTE: By default CMake will install vcpkg locally to your source tree on configuration,
48-
to avoid this, add `-DUSE_VCPKG=FALSE` to the command line when configuring.
47+
NOTE: By default CMake will install vcpkg locally to your source
48+
tree on configuration, to avoid this, add `-DUSE_VCPKG=FALSE` to
49+
the command line when configuring.
50+
51+
To use your own vcpkg clone, set the environment variable VCPKG_ROOT
52+
to the path or pass the path as `-DVCPKG_DIR=/your/clone/of/vcpkg`.
4953
5054
To set the vcpkg arch (target triplet) pass `VCPKG_ARCH` or
5155
`VCPKG_TARGET_TRIPLET` e.g.: `-DVCPKG_ARCH=x64-windows`.
@@ -74,16 +78,21 @@ if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
7478
endif()
7579

7680
if(USE_VCPKG)
81+
build_option(
82+
VCPKG_DIR
83+
PATH "Path to vcpkg clone."
84+
"${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg"
85+
ALIASES ENV{VCPKG_ROOT}
86+
)
87+
7788
build_option(
7889
VCPKG_ARCH
7990
STRING "vcpkg arch/triplet, e.g. x64-windows."
8091
x64-windows
8192
ALIASES VCPKG_TARGET_TRIPLET
8293
)
8394

84-
set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
85-
set(ENV{VCPKG_ROOT} "${VCPKG_DIR}")
86-
message("WIN32: ${WIN32}") # show its underlying text values
95+
message("WIN32: ${WIN32}")
8796
message("VCPKG_DIR: ${VCPKG_DIR}")
8897
message("VCPKG_ARCH: ${VCPKG_ARCH}")
8998
message("CMAKE_GENERATOR: ${CMAKE_GENERATOR}")

0 commit comments

Comments
 (0)