Skip to content

Fix cmake.installPrefix not being passed to CMake when using presets#4706

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-cmake-install-prefix
Draft

Fix cmake.installPrefix not being passed to CMake when using presets#4706
Copilot wants to merge 2 commits intomainfrom
copilot/fix-cmake-install-prefix

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

This change addresses item #4358

This changes visible behavior

The following changes are proposed:

  • Move installPrefix expansion in _refreshExpansions() out of the if (!this.useCMakePresets) block so this._installDir is populated regardless of preset usage
  • Add CMAKE_INSTALL_PREFIX to generateConfigArgsFromPreset(), following the same precedence pattern as CMAKE_EXPORT_COMPILE_COMMANDS: preset cacheVariables > configureArgs > cmake.installPrefix setting
  • Include installPrefix in checkConfigureOverridesPresent() so the override notification fires when this setting is active with presets

The purpose of this change

cmake.installPrefix was silently ignored when using presets because:

  1. _refreshExpansions() only expanded it inside the non-preset branch, leaving _installDir null
  2. generateConfigArgsFromPreset() never read installDir to emit -DCMAKE_INSTALL_PREFIX

The non-preset path in generateConfigArgsFromSettings()generateCMakeSettingsFlags() already handled this correctly.

Other Notes/Information

Precedence (highest → lowest):

  1. Preset's cacheVariables.CMAKE_INSTALL_PREFIX
  2. -DCMAKE_INSTALL_PREFIX in cmake.configureArgs
  3. cmake.installPrefix VS Code setting

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 2wrvsblobprodwus2180.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • 40vvsblobprodwus2135.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • b15vsblobprodwus2164.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • b53vsblobprodwus2154.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • d94vsblobprodwus2119.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • k4pvsblobprodwus2140.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • n6wvsblobprodwus2123.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • p2tvsblobprodwus2189.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • v41vsblobprodwus2175.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] cmake.installPrefix is not passed to CMake when using presets</issue_title>
<issue_description>### Brief Issue Summary

cmake.installPrefix is not passed to CMake as CMAKE_INSTALL_PREFIX when using presets. Here is the minimal project setting for reproducing the problem.

CMakeLists.txt

cmake_minimum_required(VERSION 3.24)
project(my_project VERSION 0.1)

message("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")

CMakePresets.json

{
  "version": 6,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 25,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "default"
    }
  ]
}

.vscode/setting.json

{
    "cmake.installPrefix": "/some_path",
    "cmake.loggingLevel": "debug"
}

I expect message("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") this line shows /some_path, but it show the system(cmake)'s default value (/usr/local in my case).

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.98.2",
  "cmtVersion": "1.19.52",
  "configurations": [
    {
      "folder": "~/test_cmake_installdir",
      "cmakeVersion": "3.26.4",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": true,
      "compilers": {
        "C": "~/anaconda3/bin/x86_64-conda-linux-gnu-cc",
        "CXX": "~/anaconda3/bin/x86_64-conda-linux-gnu-c++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [
      ""
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Configuring project: test_cmake_installdir 
[main] Saving open files before configure/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake ~/anaconda3/bin/cmake with arguments ["-S~/test_cmake_installdir","-B~/test_cmake_installdir/out/build/default"]
[proc] Executing command: ~/anaconda3/bin/cmake -S~/test_cmake_installdir -B~/test_cmake_installdir/out/build/default
[proc]   with environment: {"CONDA_SHLVL":"1","DWP":"~/anaconda3/bin/x86_64-conda-linux-gnu-dwp","CONDA_EXE":"~/anaconda3/bin/conda","SSH_CONNECTION":"114.43.134.107 12819 140.112.101.71 22","host_alias":"x86_64-conda-linux-gnu","GPROF":"~/anaconda3/bin/x86_64-conda-linux-gnu-gprof","GXX":"~/anaconda3/bin/x86_64-conda-linux-gnu-g++","OLDPWD":"~/.vscode-server","LD_GOLD":"~/anaconda3/bin/x86_64-conda-linux-gnu-ld.gold","CMAKE_ARGS":"-DCMAKE_AR=~/anaconda3/bin/x86_64-conda-linux-gnu-ar -DCMAKE_CXX_COMPILER_AR=~/anaconda3/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_C_COMPILER_AR=~/anaconda3/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_RANLIB=~/anaconda3/bin/x86_64-conda-linux-gnu-ranlib -DCMAKE_CXX_COMPILER_RANLIB=~/anaconda3/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_C_COMPILER_RANLIB=~/anaconda3/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_LINKER=~/anaconda3/bin/x86_64-conda-linux-gnu-ld -DCMAKE_STRIP=~/anaconda3/bin/x86_64-conda-linux-gnu-strip -DCMAKE_BUILD_TYPE=Release","DEBUG_CPPFLAGS":"-D_DEBUG -D_FORTIFY_SOURCE=2 -Og -isystem ~/anaconda3/include","DEBUG_CFLAGS":"-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fvar-tracking-assignments -ffunction-sections -pipe -isystem ~/anaconda3/include","GCC_NM":"~/anaconda3/bin/x86_64-conda-linux-gnu-gcc-nm","GSETTINGS_SCHEMA_DIR_CONDA_BACKUP":"","CONDA_PREFIX":"~/anaconda3","GCC_RANLIB":"~/anaconda3/bin/x86_64-conda-linux-gnu-gcc-ranlib","CFLAGS":"-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem ~/anaconda3/include","GCC_AR":"~/anaconda3/bin/x86_64-conda-linux-gnu-gcc-ar","FC_FOR_BUILD":"~/anaconda3/bin/x86_64-conda-linux-gnu-gfortran","SSH_AUTH_SOCK":"/run/user/1227/vscode-ssh-auth-sock-208288784","CONDA_TOOLCHAIN_HOST":"x86_64-conda-linux-gnu","_CE_M":"","CC":"~/anaconda3/bin/x86_64-conda-linux-gnu-cc","READELF":"~/anaconda3/bin/x86_64-conda-linux-gnu-readelf","XDG_SESSION_ID":"57","USER":"ivanac","CONDA_TOOLCHAIN_BUILD":"x86_64-conda-linux-gnu","CXXFLAGS":"-fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem ~/anaconda3/include","STRIP":"~/anaconda3/bin/x86_64-conda-linux-gnu-strip","DEBUG_FFLAGS":"-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem ~/anaconda3/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes microsoft/vscode-cmake-tools#4358

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/vscode-cmake-tools/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Fixes #4358

Move installPrefix expansion out of the non-preset-only block in
_refreshExpansions() so it runs for both preset and non-preset modes.
Add CMAKE_INSTALL_PREFIX handling in generateConfigArgsFromPreset(),
following the same pattern as CMAKE_EXPORT_COMPILE_COMMANDS.
Update checkConfigureOverridesPresent() to include installPrefix.

Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cmake.installPrefix not passed to CMake presets Fix cmake.installPrefix not being passed to CMake when using presets Feb 9, 2026
Copilot AI requested a review from hanniavalera February 9, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants