'How to apply different settings when swtiching between Windows and WSL?

for example, I'm using CMake to build. But the toolchain arg is configured in setting.json, so when I switch to WSL from Windows, I have to change the directory so that CMake can find the right toolchain file.

"cmake.configureArgs": [
    // "-DCMAKE_TOOLCHAIN_FILE=/home/isudfv/vcpkg/scripts/buildsystems/vcpkg.cmake"
    "-DCMAKE_TOOLCHAIN_FILE=C:\\Program Files\\Vcpkg\\scripts\\buildsystems\\vcpkg.cmake",
    "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
]


Solution 1:[1]

You can use project_options, which automatically installs vcpkg in a cross-platform way.

To do this manually, install vcpkg in an os-agnostic path like ~/vcpkg.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amin