mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-24 02:19:00 +08:00
Vcpkg via FetchContent (#27158)
Show how to easily incorporate vcpkg into a CMake project without git submodules
This commit is contained in:
parent
694ca7cbe5
commit
aed63d2200
23
README.md
23
README.md
@ -33,6 +33,7 @@ you can run `vcpkg help`, or `vcpkg help [command]` for command-specific help.
|
||||
- [Vcpkg with Visual Studio CMake Projects](#vcpkg-with-visual-studio-cmake-projects)
|
||||
- [Vcpkg with CLion](#vcpkg-with-clion)
|
||||
- [Vcpkg as a Submodule](#vcpkg-as-a-submodule)
|
||||
- [Vcpkg via FetchContent](#vcpkg-via-FetchContent)
|
||||
- [Tab-Completion/Auto-Completion](#tab-completionauto-completion)
|
||||
- [Examples](#examples)
|
||||
- [Contributing](#contributing)
|
||||
@ -262,6 +263,28 @@ This will still allow people to not use vcpkg,
|
||||
by passing the `CMAKE_TOOLCHAIN_FILE` directly,
|
||||
but it will make the configure-build step slightly easier.
|
||||
|
||||
### Vcpkg via FetchContent
|
||||
|
||||
You can also grab vcpkg with CMake's built-in [FetchContent](https://cmake.org/cmake/help/v3.24/module/FetchContent.html) module.
|
||||
|
||||
Don't worry about the bootstrap scripts, since `vcpkg.cmake` will run them for you!
|
||||
|
||||
```
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(vcpkg
|
||||
GIT_REPOSITORY https://github.com/microsoft/vcpkg/
|
||||
GIT_TAG 2022.09.27
|
||||
)
|
||||
FetchContent_MakeAvailable(vcpkg)
|
||||
|
||||
# NOTE: This must be defined before the first project call
|
||||
set(CMAKE_TOOLCHAIN_FILE "${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "")
|
||||
|
||||
project(FOOBAR LANGUAGES "CXX")
|
||||
```
|
||||
|
||||
[getting-started:using-a-package]: docs/examples/installing-and-using-packages.md
|
||||
[getting-started:integration]: docs/users/buildsystems/integration.md
|
||||
[getting-started:git]: https://git-scm.com/downloads
|
||||
|
Loading…
Reference in New Issue
Block a user