microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.36k stars 6.46k forks source link

Enable compiler selection in vcpkg.json #41114

Open Melnytskyi opened 2 months ago

Melnytskyi commented 2 months ago

I propose adding the ability to select the default compiler directly in the vcpkg.json manifest file. This feature would allow users to specify the compiler for building dependencies and set the CMake variables CMAKE_C_COMPILER and CMAKE_CXX_COMPILER for proper binary linking.

Current Approach:

Currently, setting the compiler requires using overlay triplets, which is not user-friendly. Users must create their own triplet and overlay triplet or use one from GitHub, often needing to fix bugs. This process is cumbersome and slows down the development workflow compared to the otherwise straightforward dependency management provided by vcpkg.

Suggested Improvement:

Allowing compiler selection in the vcpkg.json manifest would:

Possibly Formats:

{
    "name": "Name",
    "version": "1.0.0",
    "compiler":  "gcc",
    "dependencies":[]
}
{
    "name": "Name",
    "version": "1.0.0",
    "compiler": {
        "name": "gcc",
        "version": "9..10.2",
        "path": "Optional path"
    },
    "dependencies": []
}
Osyotr commented 2 months ago

IMHO, this is impossible to maintain. And it's vcpkg that must be told to use some toolchain, not the other way around.

JonLiu1993 commented 2 months ago

@Melnytskyi, Thanks for posting this issue, This feature is very difficult to add and maintain, because different compilers and different versions will affect the installation and compilation of different versions of ports in vcpkg, which is very inconvenient for users and maintainers.