Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hidden CMake presets picked up at first configuration - project outline empty #2976

Closed
vdilecce opened this issue Jan 26, 2023 · 12 comments · Fixed by #2978
Closed

Hidden CMake presets picked up at first configuration - project outline empty #2976

vdilecce opened this issue Jan 26, 2023 · 12 comments · Fixed by #2978
Assignees
Labels
bug a bug in the product Feature: presets
Milestone

Comments

@vdilecce
Copy link

vdilecce commented Jan 26, 2023

Brief Issue Summary

VSCode: 1.74.3
CMake Tools: 1.13.42
CPPTools: 1.13.9

At the first configuration of a project, when the CMakePresets.json contains hidden presets, the extension picks the hidden preset as default (status bar), leaving the project outline in the Activity Bar empty (verified with build presets).

Selecting a proper (non-hidden) preset, configuring again, and restarting VSCode makes the targets appear in the project outline.

Verified on Windows and Linux.

CMake Tools Diagnostics

At first run:

{
  "os": "win32",
  "vscodeVersion": "1.74.3",
  "cmtVersion": "1.13.42",
  "configurations": [
    {
      "folder": "XXXXXXXXXXXXXXXXX",
      "cmakeVersion": "3.25.0",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": true,
      "compilers": {
        "CXX": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}


After configuring again with proper build preset and restarting VSCode:

{
  "os": "win32",
  "vscodeVersion": "1.74.3",
  "cmtVersion": "1.13.42",
  "configurations": [
    {
      "folder": "XXXXXXXXXXXXXXXXXXXXXXXXX",
      "cmakeVersion": "3.25.0",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": true,
      "compilers": {
        "CXX": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug",
      "Release",
      "RelWithDebInfo"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": <actual number>,
    "executablesCount": <actual number>,
    "librariesCount": <actual number>,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

No response

Additional Information

Steps to reproduce:

  • Have a project with a CMakePresets.json with a build preset inheriting from a hidden build preset (the hidden build preset sets the configure preset)
  • Reset CMake Tools Extension State
  • Hit F1 and configure the project (you will be asked the configure preset)
  • Project configures with the status bar showing the hidden build preset
  • After configuration, project outline is empty
  • Select a proper build preset and configure again
  • Restart VSCode
  • Project outline shows targets
@elahehrashedi
Copy link
Contributor

Following the current steps, I am not able to repro this issue.
Do you face this issue in multi-project/multi-root settings?
I can repro in the multi-root, i.e. a hidden "config" preset is being picked (but not a hidden "build" preset).

@elahehrashedi elahehrashedi added bug a bug in the product more info needed More info is needed from the community for us to properly triage and investigate. labels Jan 26, 2023
@vdilecce
Copy link
Author

It's one project in a subfolder of the root folder (handled in the CMakePreset.json). I'll try to set up a minimal example to repro the issue.

@elahehrashedi
Copy link
Contributor

I could repro in a single project with these steps:
1: selecting a config preset that is not hidden.
2. closing the project and changing the preset to hidden.
3. restarting the project.
The config preset is saved from the previous session, so CMake Tools will set that as default, without checking if the preset is still valid.

However, please share your steps, if it's different.

@vdilecce
Copy link
Author

I have a setup to reproduce the issue. It's 3 files:

  • .vscode/settings.json
  • cxx/CMakeLists.txt
  • cxx/CMakePresets.json

Versions

  • VSCode 1.74.3
  • CMake 3.25.0
  • CMake Tools 1.13.43
  • CPPTools 1.13.9
  • Visual Studio 2022 17.4

Procedure (updated)

  • Reset CMake Tools Extension State
  • Hit F1 and configure the project
  • Select Configure preset "Visual Studio 17 2022"

After configure is complete, two problems are:

  • CMake Tools switches in the status bar to build preset "vs2022-base" which is hidden (I guess only non-hidden presets should be picked?)

  • The targets appear in the the CMake Project outline only after executing the "Developer: Reload Window" VSCode command (also, at this point the cpptools extension correctly complains that "The build configurations generated do not contain the active build configuration", which is the hidden "vs2022-base" that does not contain any).

The files

.vscode/settings.json:

{
  "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
  "cmake.allowUnsupportedPresetsVersions": true,
  "cmake.configureOnEdit": false,
  "cmake.configureOnOpen": false,
  "cmake.sourceDirectory": "${workspaceFolder}/cxx"
}

cxx/CMakeLists.txt:

cmake_minimum_required(VERSION 3.25)
project(testcase LANGUAGES CXX)
add_custom_target(echo1 COMMAND ${CMAKE_COMMAND} -E echo "This is target 1")
add_custom_target(echo2 COMMAND ${CMAKE_COMMAND} -E echo "This is target 2")
add_custom_target(echo3 COMMAND ${CMAKE_COMMAND} -E echo "This is target 3")

cxx/CMakePresets.json:

{
  "version": 6,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 25,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "multi-config-base",
      "binaryDir": "${sourceDir}/build",
      "hidden": true
    },
    {
      "name": "vs-base",
      "hidden": true,
      "architecture": {
        "value": "x64",
        "strategy": "set"
      },
      "toolset": {
        "value": "host=x64",
        "strategy": "set"
      },
      "cacheVariables": {
        "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo"
      }
    },
    {
      "name": "vs2022",
      "inherits": [
        "windows-base",
        "vs-base",
        "multi-config-base"
      ],
      "displayName": "Visual Studio 2022",
      "description": "Architecture x64 - Toolset v143",
      "generator": "Visual Studio 17 2022"
    }
  ],
  "buildPresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "debug-base",
      "configuration": "Debug",
      "hidden": true
    },
    {
      "name": "release-base",
      "configuration": "Release",
      "hidden": true
    },
    {
      "name": "relwithdebinfo-base",
      "configuration": "RelWithDebInfo",
      "hidden": true
    },
    {
      "name": "vs2022-base",
      "configurePreset": "vs2022",
      "hidden": true
    },
    {
      "name": "vs2022-debug",
      "displayName": "Debug",
      "inherits": [
        "windows-base",
        "vs2022-base",
        "debug-base"
      ]
    },
    {
      "name": "vs2022-release",
      "displayName": "Release",
      "inherits": [
        "windows-base",
        "vs2022-base",
        "release-base"
      ]
    },
    {
      "name": "vs2022-relwithdebinfo",
      "displayName": "RelWithDebInfo",
      "inherits": [
        "windows-base",
        "vs2022-base",
        "relwithdebinfo-base"
      ]
    }
  ],
  "testPresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "debug-base",
      "configuration": "Debug",
      "hidden": true
    },
    {
      "name": "release-base",
      "configuration": "Release",
      "hidden": true
    },
    {
      "name": "relwithdebinfo-base",
      "configuration": "RelWithDebInfo",
      "hidden": true
    },
    {
      "name": "vs2022-base",
      "configurePreset": "vs2022",
      "hidden": true
    },
    {
      "name": "vs2022-debug",
      "displayName": "Debug",
      "inherits": [
        "windows-base",
        "vs2022-base",
        "debug-base"
      ]
    },
    {
      "name": "vs2022-release",
      "displayName": "Release",
      "inherits": [
        "windows-base",
        "vs2022-base",
        "release-base"
      ]
    },
    {
      "name": "vs2022-relwithdebinfo",
      "displayName": "RelWithDebInfo",
      "inherits": [
        "windows-base",
        "vs2022-base",
        "relwithdebinfo-base"
      ]
    }
  ],
  "packagePresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "release-base",
      "configurations": [
        "Release"
      ],
      "hidden": true
    },
    {
      "name": "vs2022",
      "inherits": [
        "windows-base",
        "release-base"
      ],
      "configurePreset": "vs2022",
      "displayName": "Release"
    }
  ]
}

@bobbrow
Copy link
Member

bobbrow commented Jan 27, 2023

I see you have packagePresets. Are you using the new cmake.allowUnsupportedPresetsVersions setting to tell us to ignore those? Just checking...

@vdilecce
Copy link
Author

The cmake.AllowUnsupportedPresetsVersions is set to true, as from the settings.json above. I've also tried downgrading the setup to CMakePresets.json to version 3 removing the package presets, but the problem still occurs.

@bobbrow
Copy link
Member

bobbrow commented Jan 27, 2023

Thanks. Yeah, I overlooked the setting.

@bobbrow
Copy link
Member

bobbrow commented Jan 27, 2023

We have PR #2978 which should hopefully address your issue.

@bobbrow bobbrow removed the more info needed More info is needed from the community for us to properly triage and investigate. label Jan 27, 2023
@elahehrashedi
Copy link
Contributor

elahehrashedi commented Jan 30, 2023

PR #2978 fixed some scenarios for me (where the preset was modified between sessions), but I could repro the bug for when we needed to pick a default build preset for a config preset that was picked correctly in the previous sessions.

@bobbrow bobbrow modified the milestones: 1.14, 1.13 patches Jan 30, 2023
@elahehrashedi
Copy link
Contributor

The #PR #2978 has been modified to fix this issue.
@vdilecce I will provide a VSIX for you to test and see if you still repro or not.

@elahehrashedi elahehrashedi self-assigned this Jan 30, 2023
@elahehrashedi
Copy link
Contributor

@vdilecce can you please install this VSIX and let us know if this solves your issue?
https://github.com/microsoft/vscode-cmake-tools/suites/10669784913/artifacts/533557581

@vdilecce
Copy link
Author

I confirm that the issue is solved in 1.13.44. Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: presets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants