microsoft / vscode-cmake-tools

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

Improve the experience around missing CMakeLists.txt files #1042

Open bobbrow opened 4 years ago

bobbrow commented 4 years ago

I have a multi-root workspace, where one of the roots is for Python code, one is for CMake, and one is just for a reference to common headers that are not under the CMake root. I use the 1.3.0-beta of CMake Tools and it works fine. It would be even better if CMake Tools did not complain or otherwise react on roots that don't have CMakeLists.txt file.

Originally posted by @astraujums in https://github.com/microsoft/vscode-cmake-tools/issues/271#issuecomment-581034133

bobbrow commented 4 years ago

We do want the extension to warn users for the cases when they are not configured correctly, but I think we could potentially add a "Ignore this folder" button so that you are not repeatedly warned for the same non-CMake folder.

The trouble lies with the extension being activated on a folder that it would not normally activate on (since there's no CMakeLists.txt anywhere). The extension assumes that if it is activated it's because there should be a CMakeLists.txt *somewhere*. With multi-root this is not always the case.

giantmustache commented 4 years ago

I would like to add to this that even a CMakeLists.txt file might not be an actual project. We have a common folder with a CMakeLists.txt and it is used in multiple projects to build with different compilers. I don't want it to build on itself.

Also, a button is not always an option, I would rather see settings in my workspace file.

bobbrow commented 4 years ago

That's a valid point. If we do add a button we should store the state in a setting.

gentooise commented 3 years ago

Hi @bobbrow, I'm also interested in this (about @giantmustache proposal in particular). Any news?

I also wanted to add that this:

We do want the extension to warn users for the cases when they are not configured correctly, but I think we could potentially add a "Ignore this folder" button so that you are not repeatedly warned for the same non-CMake folder.

seems not true for me.

I have a multi-root workspace with two folders:

  1. one folder has CMakeLists.txt and also .vscode folder filled with code-workspace file, cmake-kits.json and cmake-variants.json etc. -> this is the folder I want CMake Tools to start configuration from.
  2. another folder without any CMakeLists.txt nor any .vscode folder with cmake-*.json settings.

The problem is that CMake Tools runs twice, resulting in two outputs: one good configuration/output build folder, and one bad.

Is there some workaround to avoid generating the bad one? (As you say, it should just warning of unexisting CMakeLists.txt file instead of configuring something not existing...). How is that possible?

Thank you.


UPDATE: the above behavior seems related to the "cmake.sourceDirectory": "${workspaceFolder:myFolder1}" setting I had into my project.code-workspace file. Is this expected @bobbrow ?

Anyway, it seems solved by removing the above settings, since CMake Tools automatically recognizes which folder should be configured.

Now I reproduce the same issue reported in this thread.

Zingam commented 2 years ago

I have Swift and Rust projects with a workspace file and without one. Whenever I open the project I get a complaint by CMakeTools about missing CMakeLists.txt. My setup is: a root directory with just README.md and .vscode and the projects are in subdirectories.

I think this message shouldn't pop up by default.

image

gcampbell-msft commented 3 months ago

Related to #3646 and the ideas we've discussed there.