microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 457 forks source link

Project outline does not show sources of custom targets with commands #3886

Open thokra1 opened 4 months ago

thokra1 commented 4 months ago

Brief Issue Summary

Expected behavior

Show files listed in the SOURCES list of a custom target.

Visual Studio 2022 shows the whole list of sources including the proper hierarchy, if any.

Actual behavior

Source files and folder structure, if any, are not shown.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

VS Code version: 1.91.0 Version of the extension: v1.18.42

Yingzi1234 commented 4 months ago

@gcampbell-msft We can reproduce the issue as detailed below. But we are not sure if this is by design, could you help us to see it? Thanks!

ENV:

  1. VSCode version: v1.91.0(user setup)
  2. C/C++ version: v1.21.0(pre-release)
  3. CMake tools version: v1.19.18(pre-release)

Repro steps:

  1. Create a standard CMake project with CMake presets
  2. Click F1 and run "CMake: configure"
  3. Go to the CMake page to see if the "Project Outline" is fully displayed

Actual result: Only shows the "CMakeLists.txt" and "main.cpp" and "CMakePresets.json" file on "Project Outline" page 3886

thokra1 commented 4 months ago

@Yingzi1234 The GIF doesn't show a custom target, but a regular executable. The latter work fine. This report is about custom targets, i.e. targets added with add_custom_target(..... SOURCES ...) that don't work.

thokra1 commented 4 months ago

Just noticed that it works fins for custom targets that don't specify any COMMANDs. I have not tested any further.

Consider this snippet:

add_custom_target(schmerp COMMAND npm install WORKING_DIRECTORY . SOURCES gerp.js )

In VS 22 we then have image

but in VS Code we have image

Removing the COMMAND yields the following in VS Code image

Yingzi1234 commented 4 months ago

@gcampbell-msft We can reproduce the issue as detailed below. Please let me know if you have any concern! Thank you!

ENV:

  1. VSCode version: v1.91.1(user setup)
  2. C/C++ version: v1.21.0(pre-release)
  3. CMake tools version: v1.19.22(pre-release)

Repro steps:

  1. Create a standard CMake project with CMake presets
  2. Click F1 and run "CMake: configure"
  3. Copy the below code to CMakeListst.txt file add_custom_target(schmerp COMMAND npm install WORKING_DIRECTORY . SOURCES gerp.js )
  4. Go to ‘CMake Project Outline’ to see if the full list is shown
  5. Go to CMakeLists.txt file and delete the code COMMAND npm install
  6. Go to ‘CMake Project Outline’ to see if the full list is shown

Actual result: Remove the code and the gerp.js file will appear in the list Issue3886

gcampbell-msft commented 4 months ago

@thokra1 This is an interesting use case, however, we do attempt to mirror functionality from VS here, so I will mark it as an enhancement request for the Project Outline view! Thanks.

fr89k commented 1 month ago

If DEPENDS is added to the custom target, vscode also doesn't show the SOURCES files.