Skip to content

Commit

Permalink
[Backport release-2.18] Use FetchContent to get vcpkg if we are not i…
Browse files Browse the repository at this point in the history
…n a Git repository. (#4529)

Backport 1f4ed0a from #4484.

---
TYPE: BUILD
DESC: Fix errors when building from a directory that is not a Git
repository.
  • Loading branch information
teo-tsirpanis authored Nov 23, 2023
1 parent 71ca8b4 commit 5582d6f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmake/Options/TileDBToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,27 @@ if(DEFINED ENV{VCPKG_ROOT})
set(CMAKE_TOOLCHAIN_FILE
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
else()
# Try to initialize the submodule only if we are in a Git repository.
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../.git")
include(init-submodule)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/external/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
elseif(NOT DEFINED ENV{TILEDB_DISABLE_AUTO_VCPKG})
# Inspired from https://github.com/Azure/azure-sdk-for-cpp/blob/azure-core_1.10.3/cmake-modules/AzureVcpkg.cmake
message("TILEDB_DISABLE_AUTO_VCPKG is not defined. Fetch a local copy of vcpkg.")
# To help with resolving conflicts, when you update the commit, also update its date.
# Also make sure the externals/vcpkg submodule is updated to the same commit.
set(VCPKG_COMMIT_STRING 1b4d69f3028d74401a001aa316986a670ca6289a) # 2023-09-27
message("Vcpkg commit string used: ${VCPKG_COMMIT_STRING}")
include(FetchContent)
FetchContent_Declare(
vcpkg
GIT_REPOSITORY https://github.com/microsoft/vcpkg.git
GIT_TAG ${VCPKG_COMMIT_STRING}
)
FetchContent_MakeAvailable(vcpkg)
set(CMAKE_TOOLCHAIN_FILE "${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
endif()

if(APPLE AND NOT DEFINED VCPKG_TARGET_TRIPLET)
Expand Down

0 comments on commit 5582d6f

Please sign in to comment.