vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

CMake tools should not configure the project if cache is available

Open WSUFan opened this issue 6 years ago • 11 comments

Hi guys.

I'm new to use CMake tools for VScode. Right now I'm developing a C++ project using the Docker and VScode remote SSH. Everything works fine except for one thing. The project is managed by CMake. So I have installed the CMake extension in VScode. When I reconnect to the remote container (like reload the VScode), the CMake tool will always configure the project first (it may think I did not configure the project before but I did!!). I believe all data is mounted through outside and can be persisted. So anyone knows how to solve this thing?

Thanks

WSUFan avatar Dec 23 '19 19:12 WSUFan

There is a setting cmake.configureOnOpen that controls whether a configure is run automatically when the folder opens. By default it should be disabled, so I'm not sure why you're seeing what you're seeing. But in general, the extension will do a configure before building if one hasn't been run yet in that session because it doesn't know the state of the project when it loads.

bobbrow avatar Dec 23 '19 20:12 bobbrow

Thanks for replying. Actually I disable that setting. And what do you mean by "current session"? The session state is not saved somewhere? Because when I reopen the VScode I will need to configure the project again even I have already configured it before.

WSUFan avatar Dec 23 '19 21:12 WSUFan

The "current session" is when you open the folder in VS Code. If you close and reopen the folder that starts a new "session".

In any case, we recommend that CMake Tools configure your project on open and will probably change the default for the setting to true in a future release. The C++ extension can't ask CMake Tools for project information so that IntelliSense will work better unless CMake Tools has run the configure step.

bobbrow avatar Dec 23 '19 21:12 bobbrow

Ok. That makes sense. Is that possible that the tool can cache the current session state so that it does not need to run the configuration again when each time I open the same folder?

WSUFan avatar Dec 23 '19 21:12 WSUFan

We'll have to look into it. It seems like CMake should allow us to get project information if the cache file is present. It will be up to the user to ensure the cache is up to date in this case though.

How long does your configure step take?

bobbrow avatar Dec 26 '19 17:12 bobbrow

Sounds great. My project is very big so it takes a couple of minutes to configure.

WSUFan avatar Dec 26 '19 17:12 WSUFan

In my case vscode 1.43.2 seem to configure always after stopping the build. Even with cmake.configureOnOpen set to true. Then after opening vscode configures the workspace once. When I build then no configuration is done. When I let the build finish not configuration is done again, but if I interrupt the build and build it again, it will unnecessarily configure the workspace again.

I think that it is completely useless to run CMake configure step if there already is a CMake configuration in the directory. In this case let CMake decide whether to run configure step again or not. So letting the user decide would be great.

stefanweiser avatar Apr 02 '20 15:04 stefanweiser

CMake Tools 1.4.0 Beta is available on GitHub. https://github.com/microsoft/vscode-cmake-tools/releases/tag/1.4.0-beta

Please try it out and let us know if you encounter any issues.

andreeis avatar May 15 '20 19:05 andreeis

This fix is available in CMake Tools #1.4.0 which has been released.

andreeis avatar May 20 '20 21:05 andreeis

This issue doesn't seem to be entirely resolved. I have two variants Debug vs. Release, which use two different build directories ("build/Debug" and "build/Release") and therefore caches. Even if I set "Skip over the configure process if cache is present", configure seems to always rerun upon switching between the variants. Is there currently a way to prevent this, or does this require a fix?

I can confirm that in other circumstances this fix/option seems to do the right thing: If I simply stop the build and restart (without switching variants) I see the following in the output and configure is indeed skipped:

The extension determined that a configuration is needed at this moment but we are skipping because the setting cmake.skipConfigureWhenCachePresent is ON. Make sure the CMake cache is in sync with the latest configuration changes.

wkjarosz avatar Sep 15 '21 17:09 wkjarosz

For this issue we prioritized getting the extension to provide IntelliSense configurations when a workspace opens and cmake.configureOnOpen is not set to true. Your case is also valid, but I will create a new issue for it.

bobbrow avatar Sep 15 '21 18:09 bobbrow