Use FetchContent_MakeAvailable for vcpkg in case they add CMakeLists.txt

main
Duncan Ogilvie 2 years ago
parent 5768460827
commit 13255c68cf

@ -105,6 +105,8 @@ The vcpkg `version` will automatically generate the `url` from the [official rep
To specify package features you can use the following syntax: `imgui[docking-experimental,freetype,sdl2-binding,opengl3-binding]`.
The `crt-linkage` specifies the MSVC runtime library variant to use while compiling packages. `library-linkage` is whether libraries built are dynamic (default) or static.
## Packages
```toml
@ -116,8 +118,6 @@ config = true
components = ["mycomponent"]
```
The `crt-linkage` specifies the MSVC runtime library variant to use while compiling packages. `library-linkage` is whether libraries built are dynamic (default) or static.
## FetchContent
**Note**: The `[fetch-content]` feature is unpolished and will likely change in a future release.

@ -634,14 +634,18 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
cmd("include")("FetchContent");
cmd("message")("STATUS", "Fetching vcpkg (" + version_name + ")...");
cmd("FetchContent_Declare")("vcpkg", "URL", url);
cmd("FetchContent_MakeAvailable")("vcpkg");
if (!project.vcpkg.crt_linkage.empty()) {
cmd("set")("VCPKG_CRT_LINKAGE", project.vcpkg.crt_linkage);
}
if (!project.vcpkg.library_linkage.empty()) {
cmd("set")("VCPKG_LIBRARY_LINKAGE", project.vcpkg.library_linkage);
}
cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake");
// Not using FetchContent_MakeAvailable here in case vcpkg adds CMakeLists.txt
cmd("FetchContent_GetProperties")("vcpkg");
cmd("if")("NOT", "vcpkg_POPULATED");
cmd("FetchContent_Populate")("vcpkg");
if (!project.vcpkg.crt_linkage.empty()) {
cmd("set")("VCPKG_CRT_LINKAGE", project.vcpkg.crt_linkage);
}
if (!project.vcpkg.library_linkage.empty()) {
cmd("set")("VCPKG_LIBRARY_LINKAGE", project.vcpkg.library_linkage);
}
cmd("include")("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake");
cmd("endif")();
cmd("endif")();
endl();
// clang-format on

Loading…
Cancel
Save