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

Missing cache on build with cmake-variants

Open KoeMai opened this issue 9 years ago • 11 comments

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:

  1. Open the enclosed cmake project in vscode
  2. Choose build type Debug when the extension is ready
  3. 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:

  1. No CMakeCache.txt in Debug folder

  2. 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 the Unknown folder and the build in the Debug.

  3. The cmake server instance was started on start of the extension. This instance use Unknown as 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

KoeMai avatar Sep 17 '17 08:09 KoeMai

Same here!

decimad avatar Sep 18 '17 11:09 decimad

Ouch! I'll take a look at this. I want to get issues like this out with an impending refactor. Stay tuned!

vector-of-bool avatar Sep 22 '17 02:09 vector-of-bool

Seems like I am experiencing this same bug, but it has not been fixed, am I correct?

winterismute avatar Nov 27 '17 14:11 winterismute

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.

vector-of-bool avatar Nov 27 '17 19:11 vector-of-bool

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.

Semitalis avatar Jan 10 '18 12:01 Semitalis

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.

dprandle avatar Mar 30 '18 04:03 dprandle

@KoeMai have you been seeing this issue in the beta? Your changes to the way init is handled might have fixed this issue.

vector-of-bool avatar Mar 30 '18 05:03 vector-of-bool

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 avatar Mar 31 '18 23:03 dprandle

@dprandle What debug config are you talking about? Or rather, what are you trying to do exactly?

no-realm avatar Mar 31 '18 23:03 no-realm

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 avatar Mar 31 '18 23:03 dprandle

@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.

no-realm avatar Mar 31 '18 23:03 no-realm