microsoft / microsoft/vscode-cmake-tools

Add multiple directories to the workspace and all directories will be configured even if I only want to configure one directory

Open
#3,311 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Feature: configure
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

Brief Issue Summary

Brief

Add multiple directories to the workspace and all directories will be configured even if I only want to configure one directory.

Reproduce

Step1. Open a new VSCode window.
Step2. Add multiple folders to the workspace (untitled).

image
Then like this:
image
Note: both are top directories, with no subdirectory or include.

Step3. Write some list files:

image
Code in CMakeLists.txt of TEST01:

cmake_minimum_required(VERSION 3.25)
project(TEST01)
list(APPEND CMAKE_MESSAGE_INDENT "[TEST01]  ")
message(STATUS "hello from test01.")

Code in CMakeLists.txt of TEST02:

cmake_minimum_required(VERSION 3.25)
project(TEST02)
list(APPEND CMAKE_MESSAGE_INDENT "[TEST02]  ")
message(STATUS "hello from test02.")
Step4. Try configure
Try1. Configure All Projects button

image
Outputs here:

[main] Configuring project: TEST01 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SD:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01 -Bd:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01/build -G "Visual Studio 17 2022" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
[cmake] -- [TEST01]  hello from test01.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: D:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01/build
[visual-studio] Patch Windows SDK path from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64 for C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat
[main] Configuring project: TEST02 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SD:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02 -Bd:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02/build -G "Visual Studio 17 2022" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
[cmake] -- [TEST02]  hello from test02.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: D:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02/build
[visual-studio] Patch Windows SDK path from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64 for C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat

Conclusion: The two projects (folders) are configured.

Try2. Set TEST01 as active and configure

image
Outputs are the same with Try1:

[main] Configuring project: TEST01 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SD:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01 -Bd:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01/build -G "Visual Studio 17 2022" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
[cmake] -- [TEST01]  hello from test01.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: D:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01/build
[visual-studio] Patch Windows SDK path from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64 for C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat
[main] Configuring project: TEST02 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SD:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02 -Bd:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02/build -G "Visual Studio 17 2022" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
[cmake] -- [TEST02]  hello from test02.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: D:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02/build
[visual-studio] Patch Windows SDK path from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64 for C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat

Conclusion: I want only configure TEST01, but the two projects (folders) are configured.

Try3. Set TEST02 as active and configure

image
image
Outputs are the same with Try1 and Try2:

[main] Configuring project: TEST01 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SD:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01 -Bd:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01/build -G "Visual Studio 17 2022" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
[cmake] -- [TEST01]  hello from test01.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: D:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST01/build
[visual-studio] Patch Windows SDK path from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64 for C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat
[main] Configuring project: TEST02 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SD:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02 -Bd:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02/build -G "Visual Studio 17 2022" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
[cmake] -- [TEST02]  hello from test02.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: D:/Workspace/CPP/PROFESSIONAL-CMAKE-TEST/TEST02/build
[visual-studio] Patch Windows SDK path from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64 for C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat

Conclusion: The same. I want only configure TEST02, but the two projects (folders) are configured.

Conclusion

The two folders (projects) are both top. They are added into the WORKSPACE, no subdirectory or include. Configure one project, but all projects are configured.

CMake Tools Diagnostics
{
  "os": "win32",
  "vscodeVersion": "1.81.1",
  "cmtVersion": "1.15.31",
  "configurations": [
    {
      "folder": "d:\\Workspace\\CPP\\PROFESSIONAL-CMAKE-TEST\\TEST01",
      "cmakeVersion": "3.27.3",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "d:\\Workspace\\CPP\\PROFESSIONAL-CMAKE-TEST\\TEST02",
      "cmakeVersion": "3.27.3",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}
Debug Log

No response

Additional Information
  • CMake Debugger has the same problem.
  • The build process is ok. I have precise control over which project to build, or to build all of them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the multi-root workspace using the TEST01 and TEST02 CMakeLists.txt files, then inspect how the active-folder Configure command selects projects. Verify the fix by confirming that configuring an active folder runs only that project's CMake command, while Configure All Projects still runs both commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.