vscode-cmake-tools
                                
                                 vscode-cmake-tools copied to clipboard
                                
                                    vscode-cmake-tools copied to clipboard
                            
                            
                            
                        "Delete Cache and Reconfigure" not working properly
Brief Issue Summary
My use case is a bit odd, I'm swaping between few computers for work, and my project folder is synced by usb drive or network drive.
That means the abs path won't be same between computers. So when I try to build after move computer, cmake will complain some config issues caused by path chage, understandable.
However, when I select CMake: Delete Cache and Reconfigure, the cache is not fully cleared, cmake is still complaining something in CMakeCache.txt isn't right, unless I manually remove the build folder entirely.
Make things worse, sometime it seems vscode/cmake is holding build folder open so I cannot remove it within vscode, I have to close everything then remove the folder and open everything again.
Could we have an option to force remove build folder or make the ext clear cache properly?
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response
Hi @424778940z, could you please provide us with a sample project that reproduces your issue? It would be much easier to investigate with it, thanks!
Hi @424778940z, could you please provide us with a sample project that reproduces your issue? It would be much easier to investigate with it, thanks!
nothing complex, it's not about the project, it's caused by system / source pathchange even a simple hello world should be able to reproduce the issue
- create a simple hello world cmake project
- compile on current computer with whatever version of gcc (or other compilers)
- copy the whole folder to another computer's different path
- build again
- you get the error from cmake (which is totally fine)
- clear cache in vscode
- build again
- you still get the error from cmake (which is not fine...)
@424778940z Thank you for the detailed repro steps. We'll investigate the issue as soon as we have enough capacity.
@424778940z Two members from our team attempted the repro and it didn't reproduce. If there is any other information you could provide that might help us reproduce, that would be great, otherwise, we will close the issue.
@424778940z Could you confirm whether this is still reproducing? Specifically on the most recent pre-release CMake Tools version? Thank you!
Here is an example, which is my tiny C playground for some quick testing, which the cmakelist.txt only few lines, and a single source code
It was built at 
C:/_projects/_playgrounds/c_std_pg, then I copy the whole c_std_pg folder to d:/c_std_pg, then cmake will complain about the location change, which is fine, but the "Clean" or "Clean and rebuild" from Cmaketools won't work because cmake refuse to work due to location change
hummm, seems the CMake: Delete Cache and Reconfigure is working now, before it was like the cache is not fully removed, somehow the cmakecache.txt still had the old information
I will test on my Linux machine tomorrow see if that works too...
Confirmed it is working under linux. We could close the issue now
unfortunately, I have to open this issue again, it seems the CMake: Delete Cache and Reconfigure is only removing following two files, but in some cases, this is NOT enough, as there are many things in the build folder.
I can't give you the whole project to repurduce the issue, but could you just give an option to let CMake: Delete Cache and Reconfigure nuke the whole build folder instead of removing those two files?
[driver] Removing /home/user/Desktop/firmware/.build/CMakeCache.txt
[driver] Removing /home/user/Desktop/firmware/.build/CMakeFiles
@424778940z @gcampbell-msft Thanks for your feedback, we can reproduce the problem using the following environment and steps and we will continue to follow the issue:
ENV:
- OS: Win10 22H2
- VS Code version: 1.88.1
- CMake Tools extension: 1.18.31(pre-release)
Repro Steps:
- Download and unzip Test project.
- Open Test project with VS Code.
- Press F1 and run command 'CMake: Delete Cache and Reconfigure'.
Expected Result: Provide an option to delete the entire build folder, not just the two files.
Actual Result: Only CMakeCache.txt/CMakeFiles have been removed.
Before running the 'CMake: Delete Cache and Reconfigure' command:
After running the 'CMake: Delete Cache and Reconfigure' command:
[driver] Removing c:/Users/v-ericawu/Desktop/Test/build/CMakeCache.txt
[driver] Removing c:\Users\v-ericawu\Desktop\Test\build\CMakeFiles
Verified on CMake Tools v1.18.43(release), this issue still repro: only CMakeCache.txt/CMakeFiles have been removed.
@Ashley-Li Did you turn on the setting that was added?
@gcampbell-msft Thank you for your guidance. After setting cmake.deleteBuildDirOnCleanConfigure is true, this issue has fixed. Now deleted the entire build folder, not just the two files.
could we have a checkbox for this option in settings menu?
could we have a checkbox for this option in settings menu?
Hi @424778940z Please press "Ctrl+,"  to open setting page, then search keywords and find "Cmake:Delete Build Dir On Clean Configure" and switch to Workspace, then select the checkbox to enable. Please see below: