vscode-cmake-tools: envs for cl.exe is not set automatically when using CMakePresets.json (v1.16.29+)

Brief Issue Summary

Environment variables for cl.exe is not set automatically when using CMakePresets.json (v1.16.29+)
The same CMakePresets.json works well for v1.15.31.

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 4
  • Comments: 15 (1 by maintainers)

Most upvoted comments

@gcampbell-msft

{
    "version": 6,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 25
    },
    "configurePresets": [
        {
            "name": "base",
            "hidden": true,
            "displayName": "Custom configure preset",
            "description": "Sets Ninja generator, build and install directory",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/.out/build/${presetName}",
            "installDir": "${sourceDir}/.out/install/${presetName}",
            "cacheVariables": {
                "CPACK_PACKAGE_DIRECTORY": "${sourceDir}/.out/pack/${presetName}",
                "CMAKE_EXPORT_COMPILE_COMMANDS": true,
                "CMAKE_POSITION_INDEPENDENT_CODE": true
            },
            "toolset": {
                "strategy": "external",
                "value": "host=x64"
            }
        },
        {
            "name": "debug",
            "description": "Debug build",
            "hidden": true,
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Debug"
            }
        },
        {
            "name": "release",
            "description": "Release build",
            "hidden": true,
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Release"
            }
        },
        {
            "name": "sanitize",
            "description": "Release with debug info",
            "hidden": true,
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "RelWithDebInfo"
            }
        },
        {
            "name": "x64",
            "description": "64bit build (on windows)",
            "hidden": true,
            "architecture": {
                "value": "x64",
                "strategy": "external"
            }
        },
        {
            "name": "x86",
            "description": "32bit build (on windows)",
            "hidden": true,
            "architecture": {
                "value": "x86",
                "strategy": "external"
            }
        },
        {
            "name": "compiler-clang",
            "hidden": true,
            "description": "Use clang as the C/C++ compiler",
            "cacheVariables": {
                "CMAKE_C_COMPILER": "clang",
                "CMAKE_CXX_COMPILER": "clang++"
            }
        },
        {
            "name": "compiler-gcc",
            "hidden": true,
            "description": "Use GCC as the C/C++ compiler",
            "cacheVariables": {
                "CMAKE_C_COMPILER": "gcc",
                "CMAKE_CXX_COMPILER": "g++"
            }
        },
        {
            "name": "compiler-msvc",
            "hidden": true,
            "description": "Use MSVC as the C/C++ compiler",
            "cacheVariables": {
                "CMAKE_C_COMPILER": "cl",
                "CMAKE_CXX_COMPILER": "cl"
            }
        },
        {
            "name": "MSVC-x86-DEV",
            "description": "MSVC x86 debug build in a dev environment",
            "inherits": [
                "base",
                "x86",
                "debug",
                "compiler-msvc"
            ]
        },
        {
            "name": "MSVC-x64-DEV",
            "description": "MSVC x64 debug build in a dev environment",
            "inherits": [
                "base",
                "x64",
                "debug",
                "compiler-msvc"
            ]
        },
        {
            "name": "MSVC-x86-REL",
            "description": "MSVC x86 release build in a release environment",
            "inherits": [
                "base",
                "x86",
                "release",
                "compiler-msvc"
            ]
        },
        {
            "name": "MSVC-x64-REL",
            "description": "MSVC x64 release build in a release environment",
            "inherits": [
                "base",
                "x64",
                "release",
                "compiler-msvc"
            ]
        },
        {
            "name": "MSVC-x64-SANITIZE",
            "description": "MSVC x64 release with debug info",
            "inherits": [
                "base",
                "x64",
                "sanitize",
                "compiler-msvc"
            ]
        },
        {
            "name": "GCC-x86-DEV",
            "description": "GCC x86 debug build in a dev environment",
            "inherits": [
                "base",
                "x86",
                "debug",
                "compiler-gcc"
            ]
        },
        {
            "name": "GCC-x64-DEV",
            "description": "GCC x64 debug build in a dev environment",
            "inherits": [
                "base",
                "x64",
                "debug",
                "compiler-gcc"
            ]
        },
        {
            "name": "GCC-x86-REL",
            "description": "GCC x86 release build in a release environment",
            "inherits": [
                "base",
                "x86",
                "release",
                "compiler-gcc"
            ]
        },
        {
            "name": "GCC-x64-REL",
            "description": "GCC x64 release build in a release environment",
            "inherits": [
                "base",
                "x64",
                "release",
                "compiler-gcc"
            ]
        },
        {
            "name": "CLANG-x86-DEV",
            "description": "Clang x86 debug build in a dev environment",
            "inherits": [
                "base",
                "x86",
                "debug",
                "compiler-clang"
            ]
        },
        {
            "name": "CLANG-x64-DEV",
            "description": "Clang x64 debug build in a dev environment",
            "inherits": [
                "base",
                "x64",
                "debug",
                "compiler-clang"
            ]
        },
        {
            "name": "CLANG-x86-REL",
            "description": "Clang x86 release build in a release environment",
            "inherits": [
                "base",
                "x86",
                "release",
                "compiler-clang"
            ]
        },
        {
            "name": "CLANG-x64-REL",
            "description": "Clang x64 release build in a release environment",
            "inherits": [
                "base",
                "x64",
                "release",
                "compiler-clang"
            ]
        }
    ],
    "buildPresets": [
        {
            "name": "base",
            "jobs": 6,
            "cleanFirst": true,
            "hidden": true
        },
        {
            "name": "release",
            "configuration": "Release",
            "hidden": true,
            "inherits": [
                "base"
            ]
        },
        {
            "name": "debug",
            "configuration": "Debug",
            "hidden": true,
            "inherits": [
                "base"
            ]
        },
        {
            "name": "sanitize",
            "configuration": "RelWithDebInfo",
            "hidden": true,
            "inherits": [
                "base"
            ]
        },
        {
            "name": "MSVC-x86-DEV",
            "configurePreset": "MSVC-x86-DEV",
            "inherits": [
                "debug"
            ]
        },
        {
            "name": "MSVC-x64-DEV",
            "configurePreset": "MSVC-x64-DEV",
            "inherits": [
                "debug"
            ]
        },
        {
            "name": "MSVC-x86-REL",
            "configurePreset": "MSVC-x86-REL",
            "inherits": [
                "release"
            ]
        },
        {
            "name": "MSVC-x64-REL",
            "configurePreset": "MSVC-x64-REL",
            "inherits": [
                "release"
            ]
        },
        {
            "name": "MSVC-x64-SANITIZE",
            "configurePreset": "MSVC-x64-SANITIZE",
            "inherits": [
                "sanitize"
            ]
        },
        {
            "name": "GCC-x86-DEV",
            "configurePreset": "GCC-x86-DEV",
            "inherits": [
                "debug"
            ]
        },
        {
            "name": "GCC-x64-DEV",
            "configurePreset": "GCC-x64-DEV",
            "inherits": [
                "debug"
            ]
        },
        {
            "name": "GCC-x86-REL",
            "configurePreset": "GCC-x86-REL",
            "inherits": [
                "release"
            ]
        },
        {
            "name": "GCC-x64-REL",
            "configurePreset": "GCC-x64-REL",
            "inherits": [
                "release"
            ]
        },
        {
            "name": "CLANG-x86-DEV",
            "configurePreset": "CLANG-x86-DEV",
            "inherits": [
                "debug"
            ]
        },
        {
            "name": "CLANG-x64-DEV",
            "configurePreset": "CLANG-x64-DEV",
            "inherits": [
                "debug"
            ]
        },
        {
            "name": "CLANG-x86-REL",
            "configurePreset": "CLANG-x86-REL",
            "inherits": [
                "release"
            ]
        },
        {
            "name": "CLANG-x64-REL",
            "configurePreset": "CLANG-x64-REL",
            "inherits": [
                "release"
            ]
        }
    ],
    "testPresets": [
        {
            "name": "MSVC-x86-DEV",
            "configurePreset": "MSVC-x86-DEV"
        },
        {
            "name": "MSVC-x64-DEV",
            "configurePreset": "MSVC-x64-DEV"
        },
        {
            "name": "MSVC-x86-REL",
            "configurePreset": "MSVC-x86-REL"
        },
        {
            "name": "MSVC-x64-REL",
            "configurePreset": "MSVC-x64-REL"
        },
        {
            "name": "MSVC-x64-SANITIZE",
            "configurePreset": "MSVC-x64-SANITIZE"
        },
        {
            "name": "GCC-x86-DEV",
            "configurePreset": "GCC-x86-DEV"
        },
        {
            "name": "GCC-x64-DEV",
            "configurePreset": "GCC-x64-DEV"
        },
        {
            "name": "GCC-x86-REL",
            "configurePreset": "GCC-x86-REL"
        },
        {
            "name": "GCC-x64-REL",
            "configurePreset": "GCC-x64-REL"
        },
        {
            "name": "CLANG-x86-DEV",
            "configurePreset": "CLANG-x86-DEV"
        },
        {
            "name": "CLANG-x64-DEV",
            "configurePreset": "CLANG-x64-DEV"
        },
        {
            "name": "CLANG-x86-REL",
            "configurePreset": "CLANG-x86-REL"
        },
        {
            "name": "CLANG-x64-REL",
            "configurePreset": "CLANG-x64-REL"
        }
    ]
}

Just use configure preset MSVC-x64-DEV.

I also have the same problem.