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

Unspecified doesn't let CMake guess what compilers and environment to use #3405

Closed
gerard-ryan-immersaview opened this issue Oct 25, 2023 · 9 comments
Assignees
Labels
bug a bug in the product Feature: kits investigation needed issues needs a developer assigned to it and investigation done in order to implement a fix
Milestone

Comments

@gerard-ryan-immersaview
Copy link

gerard-ryan-immersaview commented Oct 25, 2023

Brief Issue Summary

When the selected kit is [Unspecified] Unspecified (Let CMake guess what compilers and environment to use), -G Ninja is added to the CMake command and No CMAKE_C_COMPILER could be found.

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.83.1",
  "cmtVersion": "1.15.31",
  "configurations": [
    {
      "folder": "c:\\Users\\gerard\\Desktop\\cmake-tools-mre",
      "cmakeVersion": "3.27.7",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    }
  ]
}

Debug Log

[main] Configuring project: cmake-tools-mre 
[main] Saving open files before configure/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake C:\Program Files\CMake\bin\cmake.EXE with arguments ["--no-warn-unused-cli","-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-SC:/Users/gerard/Desktop/cmake-tools-mre","-Bc:/Users/gerard/Desktop/cmake-tools-mre/build","-G","Ninja"]
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/gerard/Desktop/cmake-tools-mre -Bc:/Users/gerard/Desktop/cmake-tools-mre/build -G Ninja
[proc]   with environment: {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\gerard\\AppData\\Roaming","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","CHROME_CRASHPAD_PIPE_NAME":"\\\\.\\pipe\\crashpad_18836_OKEYJCUPEFXBSHSL","CLIENTNAME":"david","COMPUTERNAME":"EGYPTIAN-WINDOW","ComSpec":"C:\\Windows\\system32\\cmd.exe","CommonProgramFiles":"C:\\Program Files\\Common Files","CommonProgramFiles(x86)":"C:\\Program Files (x86)\\Common Files","CommonProgramW6432":"C:\\Program Files\\Common Files","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","ELECTRON_RUN_AS_NODE":"1","HOME":"C:\\Users\\gerard","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\gerard","LOCALAPPDATA":"C:\\Users\\gerard\\AppData\\Local","LOGONSERVER":"\\\\EGYPTIAN-WINDOW","NUMBER_OF_PROCESSORS":"28","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","OneDrive":"C:\\Users\\gerard\\OneDrive","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","POWERSHELL_DISTRIBUTION_CHANNEL":"MSI:Windows 10 Pro","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD","PROCESSOR_LEVEL":"25","PROCESSOR_REVISION":"2100","PSModulePath":"C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules","PUBLIC":"C:\\Users\\Public","Path":"C:\\Program Files (x86)\\Razer Chroma SDK\\bin;C:\\Program Files\\Razer Chroma SDK\\bin;C:\\Program Files (x86)\\Razer\\ChromaBroadcast\\bin;C:\\Program Files\\Razer\\ChromaBroadcast\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files (x86)\\Yarn\\bin\\;C:\\Windows\\system32\\config\\systemprofile\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance Toolkit\\;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\Git\\cmd;C:\\Program Files\\nodejs\\;C:\\Program Files\\Meson\\;C:\\Program Files\\CMake\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Users\\gerard\\AppData\\Local\\Programs\\Python\\Python310\\Scripts\\;C:\\Users\\gerard\\AppData\\Local\\Programs\\Python\\Python310\\;C:\\Users\\gerard\\.cargo\\bin;C:\\Users\\gerard\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\gerard\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\gerard\\bin;C:\\Users\\gerard\\AppData\\Local\\Yarn\\bin;C:\\Program Files\\Beyond Compare 4;C:\\Users\\gerard\\AppData\\Roaming\\npm","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","SESSIONNAME":"RDP-Tcp#0","SystemDrive":"C:","SystemRoot":"C:\\Windows","TEMP":"C:\\Users\\gerard\\AppData\\Local\\Temp","TMP":"C:\\Users\\gerard\\AppData\\Local\\Temp","USERDOMAIN":"EGYPTIAN-WINDOW","USERDOMAIN_ROAMINGPROFILE":"EGYPTIAN-WINDOW","USERNAME":"gerard","USERPROFILE":"C:\\Users\\gerard","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\gerard\\AppData\\Roaming\\Code\\CachedData\\f1b07bd25dfad64b0167beb15359ae573aecd2cc","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"C:\\Users\\gerard\\AppData\\Local\\Programs\\Microsoft VS Code","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\0ae14acbf34bd9585d14601c1a261927-1.83.1-main-sock","VSCODE_L10N_BUNDLE_LOCATION":"","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-au\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"18836","WIX":"C:\\Program Files (x86)\\WiX Toolset v3.11\\","windir":"C:\\Windows"}
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is unknown
[cmake] -- The CXX compiler identification is unknown
[cmake] CMake Error at CMakeLists.txt:2 (project):
[cmake]   No CMAKE_C_COMPILER could be found.
[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:2 (project):
[cmake]   No CMAKE_CXX_COMPILER could be found.
[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" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/gerard/Desktop/cmake-tools-mre -Bc:/Users/gerard/Desktop/cmake-tools-mre/build -G Ninja exited with code: 1
[extension] [2304] cmake.configureAll finished (returned 1)

Additional Information

# CMakeLists.txt
cmake_minimum_required(VERSION 3.27)
project(cmake-tools-mre)

If I truly let CMake decide by running it on the CLI it finds the Compiler and environment I'd expect it to use.

PS C:\Users\gerard\Desktop\cmake-tools-mre> & "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/gerard/Desktop/cmake-tools-mre -Bc:/Users/gerard/Desktop/cmake-tools-mre/build
Not searching for unused variables given on the command line.
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.34.31947.0
-- The CXX compiler identification is MSVC 19.34.31947.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (4.4s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/gerard/Desktop/cmake-tools-mre/build
@gcampbell-msft gcampbell-msft added bug a bug in the product Feature: kits investigation needed issues needs a developer assigned to it and investigation done in order to implement a fix and removed triage labels Oct 27, 2023
@github-project-automation github-project-automation bot moved this to Needs Triaging in CMake Tools Nov 21, 2023
@github-project-automation github-project-automation bot moved this to Triage Needed in CMake Tools Nov 29, 2023
@gcampbell-msft gcampbell-msft moved this from Triage Needed to Repro Needed in CMake Tools Jan 19, 2024
@gerard-ryan-immersaview
Copy link
Author

@gcampbell-msft is there any more info needed to repro?

Just tried again, and this CMakeLists.txt in a folder of its own

# CMakeLists.txt
cmake_minimum_required(VERSION 3.27)
project(cmake-tools-mre)

gave me

[main] Configuring project: cmake-tools-mre 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/gerard/Desktop/cmake-tools-mre -Bc:/Users/gerard/Desktop/cmake-tools-mre/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is unknown
[cmake] -- The CXX compiler identification is unknown
[cmake] CMake Error at CMakeLists.txt:2 (project):
[cmake]   No CMAKE_C_COMPILER could be found.
[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:2 (project):
[cmake]   No CMAKE_CXX_COMPILER could be found.
[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" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/gerard/Desktop/cmake-tools-mre -Bc:/Users/gerard/Desktop/cmake-tools-mre/build -G Ninja exited with code: 1

whereas running

 "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/gerard/Desktop/cmake-tools-mre -Bc:/Users/gerard/Desktop/cmake-tools-mre/build

in the same folder gave me a successful

"C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/Users/gerard/Desktop/cmake-tools-mre -Bc:/Users/gerard/Desktop/cmake-tools-mre/build
Not searching for unused variables given on the command line.
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.39.33523.0
-- The CXX compiler identification is MSVC 19.39.33523.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features       
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features       
-- Detecting CXX compile features - done
-- Configuring done (4.8s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/gerard/Desktop/cmake-tools-mre/build

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.88.1",
  "cmtVersion": "1.17.17",
  "configurations": [
    {
      "folder": "c:\\Users\\gerard\\Desktop\\cmake-tools-mre",
      "cmakeVersion": "3.29.2",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    }
  ]
}

@v-frankwang
Copy link
Collaborator

@gerard-ryan-immersaview I still can't reproduce the problem after following your tips, am I going about it the wrong way? Are you able to give some advice?
image

@gerard-ryan-immersaview
Copy link
Author

@gerard-ryan-immersaview I still can't reproduce the problem after following your tips, am I going about it the wrong way? Are you able to give some advice? image

And you configured the kit to be unspecified?

image

I noticed that you use the CMake version that comes with Visual Studio and not the direct one too.

@v-frankwang
Copy link
Collaborator

v-frankwang commented Apr 24, 2024

@gcampbell-msft @gerard-ryan-immersaview Following the steps given by the user, this issue we can reproduce on top of the latest VSCode and you can get some information below:

ENV:
VS Code: 1.88.1
CMake tools: 1.18.29
C/C++:1.20.2

Repro steps recording:
1. Create a folder named "cmake-tools-mre".
2. Add to it a CMakeLists.txt file containing the following code:
cmake_minimum_required(VERSION 3.27)
project(cmake-tools-mre)
3. Open it with VS Code.
4. Executing the CMake: configure command
5. Configured the kit to be Unspecified
repro1

@gcampbell-msft
Copy link
Collaborator

@gerard-ryan-immersaview Does this issue still reproduce if you clear the setting cmake.generator? Thanks, adding this issue to the backlog so we can track better and investigate when we can.

@gcampbell-msft gcampbell-msft added this to the Backlog milestone Jun 24, 2024
@gcampbell-msft gcampbell-msft moved this from Repro Needed to Pending Prioritization in CMake Tools Jun 24, 2024
@gerard-ryan-immersaview
Copy link
Author

@gerard-ryan-immersaview Does this issue still reproduce if you clear the setting cmake.generator? Thanks, adding this issue to the backlog so we can track better and investigate when we can.

Yes

@gcampbell-msft gcampbell-msft modified the milestones: Backlog, 1.19 Jun 25, 2024
@gcampbell-msft gcampbell-msft moved this from Pending Prioritization to Ready to be Assigned in CMake Tools Jun 26, 2024
@v-frankwang
Copy link
Collaborator

@gerard-ryan-immersaview Thank you very much for your reply, we have added this issue to the backlog and will follow up with our developers to deal with this issue and will be the first to add a comment if there is any progress!

@snehara99
Copy link
Contributor

Hey @v-frankwang this issue should now be fixed in the latest pre-release :)

@snehara99 snehara99 moved this from In Progress to Completed in CMake Tools Jul 15, 2024
@v-frankwang
Copy link
Collaborator

v-frankwang commented Jul 16, 2024

@snehara99 Thank you very much for your reply, I verified the issue on latest pre-release: v1.19.20 (pre-release) and it was fixed.

ENV:
CMake Tools: v1.19.21 (pre-release)
vscode: 1.19.1 (user setup)
C/C++:v1.21.1(pre-release)

image

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 investigation needed issues needs a developer assigned to it and investigation done in order to implement a fix
Projects
Status: Completed
Development

No branches or pull requests

4 participants