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

[feature] Support more Variable Substitution of `cmake tools`.

Open hwhsu1231 opened this issue 2 years ago • 5 comments

Problem to solve

According to the README.md, it looks like qt-tools only supports ${buildType}, ${buildKit}, and ${workspaceFolder} now. If we use another Variable Substitution in cmake.buildDirectory, the bottom status bar of qt-tools will show "Qt not found". Therefore, we cannot use the command such as Qt: Launch Qt Designer.

Can qt-tools support more Variable Substitution of cmake-tools?

Screenshots

img--qt_not_found+qtdesigner_not_exists

Platform and Version:

  • OS: Windows 11
  • Qt Tools: 0.10.1
  • VSCode: 1.65.2

hwhsu1231 avatar Mar 16 '22 06:03 hwhsu1231

@hwhsu1231 which Qt version do you use?

Typically the extension read the directory where the qt tools are automatically from the cmake build cache, so normally you don't need to configure anything.

Can you check if there are Qt variable in your cmake cache?

tonka3000 avatar Mar 16 '22 23:03 tonka3000

Here is what I test:

  • If I set the cmake.buildDirectory only with those mentioned in the README.md, the bottom status bar will show "Qt found".

    "cmake.buildDirectory": "${workspaceFolder}/build/${buildType}"
    
  • If I set the cmake.buildDirectory with other Variable Substitution, the bottom status bar will show "Qt not found".

    "cmake.buildDirectory": "${workspaceFolder}/build/${buildKitTargetOs}-${buildKitVendor}-${buildKitTargetArch}-${buildType}"
    

Screenshots

img--Qt_found img--Qt_not_found

hwhsu1231 avatar Mar 17 '22 02:03 hwhsu1231

By the way, the following are screenshots of my find_package() in CMakeLists.txt and Qt_DIR in CMakeCache.txt.

img--find_package img--Qt_DIR

hwhsu1231 avatar Mar 17 '22 02:03 hwhsu1231

@tonka3000 How is this issue going?

hwhsu1231 avatar Mar 31 '22 13:03 hwhsu1231

@hwhsu1231 The variables are resolved by the cmake-extension itself. It seems that the vscode-cmake tools changed their behavior. Previously the buildDirectory from the cmake-extension was set when something change in the settings.json. Now it seems that it only set the buildDirectory when you change the file and trigger cmake configure again. After that it works normally.

Please try this on your side

  • Change the cmake.BuildDirectory to whatever you want include the other variable you mentioned above
  • Then trigger the command cmake: Configure
  • Then rescan for Qt

The current behavior is a fallback impl. when there is no cmake extension running. I can only support the given variables because cmake-tools has no APIs to get the other values.

tonka3000 avatar Apr 01 '22 15:04 tonka3000