Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kit with preferredGenerator isn't finding generator #4031

Closed
gcampbell-msft opened this issue Aug 30, 2024 · 11 comments · Fixed by #4033
Closed

Kit with preferredGenerator isn't finding generator #4031

gcampbell-msft opened this issue Aug 30, 2024 · 11 comments · Fixed by #4033
Labels
bug a bug in the product Feature: kits regression used to work and no longer does. Regressions are typically high priority

Comments

@gcampbell-msft
Copy link
Collaborator

          Reproduce issue like this:

Install jom (https://wiki.qt.io/Jom).
Add jom.exe location to your system PATH.
In cmake-tools-kits.json add the following kit:
{"name": "JOM test kit", "preferredGenerator": {"name": "NMake Makefiles JOM"}}

Open a CMake project and try to configure it with the "JOM test kit".
You will get the error:

[main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found.

Originally posted by @KorkiFork in #4019 (comment)

@github-project-automation github-project-automation bot moved this to Blocked in CMake Tools Aug 30, 2024
@gcampbell-msft gcampbell-msft changed the title Reproduce issue like this: Kit with preferredGenerator isn't finding generator Aug 30, 2024
@gcampbell-msft gcampbell-msft added bug a bug in the product Feature: kits regression used to work and no longer does. Regressions are typically high priority and removed triage labels Aug 30, 2024
@marcogmaia
Copy link

marcogmaia commented Aug 30, 2024

My scenario is the following:

I have a CMakePresets.json in which I have this:

  "configurePresets": [
    {
      "name": "windows",
      "inherits": "base",
      "cacheVariables": {
        "CMAKE_C_COMPILER": "cl.exe",
        "CMAKE_CXX_COMPILER": "cl.exe"
      }
    }
  ]

And base contains the following, that is relevant:

    "generator": "Ninja",
    "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"

I don't have the compiler in my PATH, and I was relying on the invocation of the devenv from the extension.

In the v1.18 it is working fine, starting from v1.19 it isn't resolving... The PR #4024 fixed the environment variables expansion in the CMakePresets.json, but not this specific case that was described above.

@gcampbell-msft
Copy link
Collaborator Author

Ah, it might be that the PR from #4028 fixes this? I'll try to reproduce your project, despite not having a full repro. Thanks

@gcampbell-msft
Copy link
Collaborator Author

gcampbell-msft commented Aug 30, 2024

@marcogmaia Could you test with the vsix from this comment: #4023 (comment)?

After some investigation, I think I see what's happening. Could you try this vsix here?

cmake-tools.zip

@marcogmaia
Copy link

marcogmaia commented Aug 30, 2024

Still not working.

Diagnostic log:

{
  "os": "win32",
  "vscodeVersion": "1.92.2",
  "cmtVersion": "1.13.0",
  "configurations": [
    {
      "folder": "c:\\Users\\marco\\Documents\\dev\\random_folder",
      "cmakeVersion": "3.30.0",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": true,
      "compilers": {
        "C": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe",
        "CXX": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Build log:

[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DX_VCPKG_APPLOCAL_DEPS_INSTALL=1 -DVCPKG_INSTALLED_DIR=C:/Users/marco/Documents/dev/random_folder/out/vcpkg_installed -DVCPKG_OVERLAY_TRIPLETS=C:/Users/marco/Documents/dev/random_folder/3rd_party/triplets -DCMAKE_TOOLCHAIN_FILE=C:/Users/marco/Documents/dev/games/git/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=C:/Users/marco/Documents/dev/random_folder/out/install/windows-debug -SC:/Users/marco/Documents/dev/random_folder -BC:/Users/marco/Documents/dev/random_folder/out/build/windows-debug -G Ninja
[cmake] -- Running vcpkg install
[cmake] All requested packages are currently installed.
[cmake] Total install time: 200 ns
[cmake] bext-di is header-only and can be used from CMake via:
...
...
[cmake]   find_package(Qt6Xml CONFIG REQUIRED)
[cmake]   target_link_libraries(main PRIVATE Qt::Xml Qt6::Xml Qt::XmlPrivate Qt6::XmlPrivate)
[cmake]
...
... 
[cmake] -- Running vcpkg install - done
[cmake] -- The C compiler identification is unknown
[cmake] -- The CXX compiler identification is unknown
[cmake] CMake Error at CMakeLists.txt:21 (project):
[cmake]   The CMAKE_C_COMPILER:
[cmake] 
[cmake]     cl.exe
[cmake] 
[cmake]   is not a full path and was not found in the PATH.  Perhaps the extension is
[cmake]   missing?
[cmake] 
[cmake]   Tell CMake where to find the compiler by setting either the environment
[cmake]   variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
[cmake]   the compiler, or to the compiler name if it is in the PATH.
[cmake] 
[cmake] 
[cmake] CMake Error at CMakeLists.txt:21 (project):
[cmake]   The CMAKE_CXX_COMPILER:
[cmake] 
[cmake]     cl.exe
[cmake] 
[cmake]   is not a full path and was not found in the PATH.  Perhaps the extension is
[cmake]   missing?
[cmake] 
[cmake]   Tell CMake where to find the compiler by setting either the environment
[cmake]   variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
[cmake]   to the compiler, or to the compiler name if it is in the PATH.
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DX_VCPKG_APPLOCAL_DEPS_INSTALL=1 -DVCPKG_INSTALLED_DIR=C:/Users/marco/Documents/dev/random_folder/out/vcpkg_installed -DVCPKG_OVERLAY_TRIPLETS=C:/Users/marco/Documents/dev/random_folder/3rd_party/triplets -DCMAKE_TOOLCHAIN_FILE=C:/Users/marco/Documents/dev/games/git/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=C:/Users/marco/Documents/dev/random_folder/out/install/windows-debug -SC:/Users/marco/Documents/dev/random_folder -BC:/Users/marco/Documents/dev/random_folder/out/build/windows-debug -G Ninja exited with code: 1

@gcampbell-msft
Copy link
Collaborator Author

gcampbell-msft commented Aug 30, 2024

Could you please make a minimal repro so that I can directly test so that I can best investigate?

I've confirmed with a test I made with your preset that the toolchain file is being correctly grabbed, and that the environment includes the developer environment. Therefore, I'll need more information and more concrete repro in order to see what's going on. Thanks.

@gcampbell-msft
Copy link
Collaborator Author

@marcogmaia I've tested that this configure preset works as expected:

{
"version": 8,
"configurePresets": [
{
"name": "base",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"generator": "Ninja"
},
{
"name": "windows",
"inherits": "base",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
}
}
]
}

@marcogmaia
Copy link

I'll test it later with a clean repo to see if it works with a minimal setup.

@gcampbell-msft
Copy link
Collaborator Author

@marcogmaia Thank you, apologies for the confusion, we're working on a couple of different items that slightly regressed, I appreciate your patience and willingness to help test. If you can get me a CMakeLists.txt to go with a the presets you passed that would be helpful. As far as I currently can tell #4028 fixes the issue right now. We hope to merge that PR today sometime

@gcampbell-msft
Copy link
Collaborator Author

gcampbell-msft commented Aug 30, 2024

@KorkiFork Could you test with this vsix, modify the extension from .zip to .vsix? I believe that it may fix your issue and it would help if you could confirm

cmake-tools.zip

@github-project-automation github-project-automation bot moved this from Blocked to Completed in CMake Tools Aug 30, 2024
@gcampbell-msft
Copy link
Collaborator Author

The fix for this issue will be released in the next hour or so in v1.20.2.

@marcogmaia
Copy link

@gcampbell-msft, the pre-release version is working fine. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: kits regression used to work and no longer does. Regressions are typically high priority
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

2 participants