Skip to content

Commit 9291a61

Browse files
committed
feat: use $VCPKG_ROOT if vcpkg submodule not found
This *should* allow installing from sdist, provided the user clones vcpkg somewhere themselves. resolves #17.
1 parent 9538b5f commit 9291a61

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v5
1515
with:
16+
# NOTE: this should not be recursive, we really don't want to bundle vcpkg
1617
submodules: true
1718

1819
- name: Build SDist
@@ -93,7 +94,6 @@ jobs:
9394
with:
9495
submodules: recursive
9596

96-
# TODO: this is somewhat expensive. maybe we can drop the vcpkg submodule somehow?
9797
- name: Unshallow vcpkg submodule
9898
run: git -C libdave/cpp/vcpkg fetch --unshallow
9999

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,25 @@ set(
2626

2727
# General build environment/toolchain setup
2828
set(LIBDAVE_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libdave/cpp)
29-
30-
set(CMAKE_TOOLCHAIN_FILE "${LIBDAVE_SRC_PATH}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
3129
set(VCPKG_MANIFEST_DIR "${LIBDAVE_SRC_PATH}/vcpkg-alts/${LIBDAVE_CRYPTO}" CACHE STRING "")
3230

31+
set(_VCPKG_TOOLCHAIN "${LIBDAVE_SRC_PATH}/vcpkg/scripts/buildsystems/vcpkg.cmake")
32+
if (NOT EXISTS ${_VCPKG_TOOLCHAIN})
33+
if (DEFINED ENV{VCPKG_ROOT})
34+
set(_VCPKG_TOOLCHAIN "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
35+
else()
36+
message(FATAL_ERROR "\
37+
vcpkg toolchain not found.
38+
If you're installing from PyPI, clone https://github.com/microsoft/vcpkg
39+
and set the $VCPKG_ROOT environment variable to that location.
40+
(If you are a developer contributing to this package, ensure that
41+
all submodules are initialized instead).
42+
")
43+
endif()
44+
endif()
45+
set(CMAKE_TOOLCHAIN_FILE ${_VCPKG_TOOLCHAIN} CACHE STRING "")
46+
message(STATUS "Using vcpkg toolchain ${CMAKE_TOOLCHAIN_FILE}")
47+
3348

3449
# Architecture-specific ~~hacks~~ target specification
3550
if (WIN32)

0 commit comments

Comments
 (0)