`VCPKG_CHAINLOAD_TOOLCHAIN_FILE` has two different meanings
- Dominant language
- CMake
- Stars
- 27.5k
- Forks
- 7.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 321
Description
I believe `VCPKG_CHAINLOAD_TOOLCHAIN_FILE` may be set in two different places, affecting different parts of a project using CMake and vcpkg:
- The project scope, which sets the toolchain for the consuming project;
- in a triplet file, which is in vcpkg's 'scope' (for lack of a better word). This sets the toolchain that ports will be compiled with.
This is documented for the above two use-cases respectively:
- [vcpkg in CMake projects: Using multiple toolchain files](https://learn.microsoft.com/en-gb/vcpkg/users/buildsystems/cmake-integration#using-multiple-toolchain-files)
- [Triplets: `VCPKG_CHAINLOAD_TOOLCHAIN_FILE`](https://learn.microsoft.com/en-us/vcpkg/users/triplets#vcpkg_chainload_toolchain_file)
This dual behaviour is clearly noted in the first link above:
> [!NOTE]
> vcpkg does not automatically apply your toolchain's settings, such as your compiler or compilation flags, while building libraries. To change vcpkg's library settings, you must make a [custom triplet file](https://learn.microsoft.com/en-gb/vcpkg/users/tripletsd) (which can [share your toolchain](https://learn.microsoft.com/en-gb/vcpkg/users/triplets#vcpkg_chainload_toolchain_file))**
Furthermore, note that the URL [further up in the same page](https://github.com/microsoft/vcpkg-docs/blob/c5cdb2dfe77169593ab19d271e8c0d8f80d5252d/vcpkg/users/buildsystems/cmake-integration.md?plain=1#L31) is also misleading (it goes to the triplets page, rather than linking to the section further down). I am guessing even the documentation writer had mixed the two variables up.
I suggest renaming *both* to clarify the scope of these variables. For instance:
- `VCPKG_PROJECT_CHAINLOAD_TOOLCHAIN_FILE`
- `VCPKG_PORTS_CHAINLOAD_TOOLCHAIN_FILE`
This is, in my opinion, so much clearer.
Furthermore, it would be good to implement some sort of boolean option in vcpkg that would automatically compile all ports with the project's toolchain, rather than requiring users to set up a custom triplet and then re-include a toolchain. Perhaps, `VCPKG_USE_PROJECT_TOOLCHAIN_FOR_PORTS`?
Contributor guide
Assessment
This issue has not been assessed yet.