Skip to content

Commit

Permalink
vcpkg 移除 submodule 改为 clone
Browse files Browse the repository at this point in the history
  • Loading branch information
zxffffffff committed Dec 27, 2024
1 parent 574cd9d commit 5758f5b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ out/*
.vscode
enc_temp_folder
.DS_Store
vcpkg
.idea
.venv
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@ if(DEFINED ENV{VCPKG_ROOT})
# 使用 VCPKG_ROOT 环境变量
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
else()
# 使用 submodule
# 从 github 下载到根目录
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg")
message(STATUS "Cloning vcpkg into ${CMAKE_CURRENT_SOURCE_DIR}")
execute_process(
COMMAND git clone https://github.com/microsoft/vcpkg.git "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg"
RESULT_VARIABLE GIT_CLONE_RESULT
)
if(NOT GIT_CLONE_RESULT EQUAL "0")
message(FATAL_ERROR "Failed to clone vcpkg repository.")
endif()
endif()
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
endif()
message(STATUS "[start-cpp-vcpkg] CMAKE_TOOLCHAIN_FILE : ${CMAKE_TOOLCHAIN_FILE}")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@

## Vcpkg

- 安装 `vcpkg` 工具 (参考本工程 `.gitmodules`)
- 手动引入建议使用 `git submodule add -f https://github.com/microsoft/vcpkg.git vcpkg`
- 初始化、拉取更新可以使用 `git submodule update --init --recursive`
- 安装 `vcpkg` 参考本工程 `CMakeLists.txt`
- 手动安装建议使用 `git clone https://github.com/microsoft/vcpkg.git`
- 推荐使用环境变量 VCPKG_ROOT、VCPKG_DOWNLOADS 避免重复下载编译

### 参考

Expand Down
1 change: 0 additions & 1 deletion vcpkg
Submodule vcpkg deleted from b32236

0 comments on commit 5758f5b

Please sign in to comment.