Missing cache on build with cmake-variants
I have tried to build a project with different variants in cmake-variants.json (see attached file).
I changed the cmake.buildDirectory to ${workspaceRoot}/build/${buildType} in my settings file.
Scenario:
- Open the enclosed cmake project in vscode
- Choose build type
Debugwhen the extension is ready - Build
-- Configuring done
-- Generating done
Execute cmake with arguments: --build,/home/matthias/Projekte/vscode-cmake-tools/test/test_variant_project/build/Debug,--target,all,--config,Debug,--,-j,10
[vscode] Executing command: cmake --build /home/matthias/Projekte/vscode-cmake-tools/test/test_variant_project/build/Debug --target all --config Debug -- -j 10
Error: could not load cache
[vscode] cmake exited with return code 1
Other symptoms:
-
No
CMakeCache.txtinDebugfolder -
Inconsistent configuration The saved configuration (
.cmaketools.json) is inconsistent with the executed buildDirectory. In this case, the cmake configuration looks like it was executed in theUnknownfolder and the build in theDebug. -
The cmake server instance was started on start of the extension. This instance use
Unknownas buildtype. It looks like the default build type is not selected from variants or the variants are not loaded.
Test-Project test_variant_project.tar.gz
Same here!
Ouch! I'll take a look at this. I want to get issues like this out with an impending refactor. Stay tuned!
Seems like I am experiencing this same bug, but it has not been fixed, am I correct?
It has not yet been fixed. The refactoring is taking longer than I hoped, with real life getting in the way a lot of the time. I am making progress, though, slowly but surely.
I would like to bump this issue :-) I have a project here, where I would like to switch between build types and not have to regenerate the whole build directory each time.
Indeed this is still a problem - I tried messing with the src code and couldnt get it to work correctly. Basically it seems that during the generation of .cmake_tools command ${buildType} is not set or somehow gets unset causing it to take the value "Unknown", but it gets set correctly during the build command.
The CMAKE_BUILD_TYPE does get set correctly during configuration - so im not really sure whats going on.
@KoeMai have you been seeing this issue in the beta? Your changes to the way init is handled might have fixed this issue.
I downloaded and installed the beta - it does fix the issue above. Now I'm looking through the new docs trying to figure out why variable substitution for ${buildType} in debugConfig doesn't seem to work (trying to pass "cwd" along using ${buildType}) while ${workspaceRoot} does work
@dprandle What debug config are you talking about? Or rather, what are you trying to do exactly?
in the global settings file "cmake.buildDirectory": "${workspaceRoot}/build/${buildType}", "cmake.debugConfig": { "cwd": "${workspaceRoot}/build/${buildType}/bin", "externalConsole": false },
Note if I replace the above with: "cmake.buildDirectory": "${workspaceRoot}/build/${buildType}", "cmake.debugConfig": { "cwd": "${workspaceRoot}/build/Debug/bin", "externalConsole": false },
when on the Debug build type configuration, it launches in debug mode no problem. So I'm pretty sure its just not replacing that variable anymore - though I don't know if this is on purpose - perhaps the new version has a different setting for configuring the cwd for build executables?
@dprandle I will need to look into how debugConfig is used, but it probably doesn't fully support variable substitution yet.
Edit: Yes, like I thought, no variable substitution takes place there. Could you please open a new issue for this. I will look into adding variable substitution support later.
I will now close this issue.