microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.43k stars 430 forks source link

CMAKE_MAKE_PROGRAM is not set. (Again) #3513

Open atom0s opened 6 months ago

atom0s commented 6 months ago

Brief Issue Summary

I am once again getting this error upon updating to the latest VSCode Insiders and vscode-cmake-tools extension versions.

Previous error reported here: https://github.com/microsoft/vscode-cmake-tools/issues/3443

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.86.0-insider",
  "cmtVersion": "1.16.32",
  "configurations": [
    {
      "folder": "c:\\Users\\atom0s\\Desktop\\cmake_test",
      "cmakeVersion": "3.27.2",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": true,
      "compilers": {
        "C": "cl.exe",
        "CXX": "cl.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 0,
    "librariesCount": 1,
    "targets": [
      {
        "name": "cmake_test",
        "type": "MODULE_LIBRARY"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[main] Configuring project: cmake_test 
[main] Saving open files before configure/build
[driver] Removing C:/Users/atom0s/Desktop/cmake_test/out/build/x86-debug-win/CMakeCache.txt
[driver] Removing C:\Users\atom0s\Desktop\cmake_test\out\build\x86-debug-win\CMakeFiles
[driver] Start configure 
[driver] Running pre-configure checks and steps
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe with arguments ["-DCMAKE_C_COMPILER=cl.exe","-DCMAKE_CXX_COMPILER=cl.exe","-DCMAKE_BUILD_TYPE=Debug","-DCMAKE_INSTALL_PREFIX=C:/Users/atom0s/Desktop/cmake_test/out/install/x86-debug-win","-SC:/Users/atom0s/Desktop/cmake_test","-BC:/Users/atom0s/Desktop/cmake_test/out/build/x86-debug-win","-G","Ninja"]
[proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=C:/Users/atom0s/Desktop/cmake_test/out/install/x86-debug-win -SC:/Users/atom0s/Desktop/cmake_test -BC:/Users/atom0s/Desktop/cmake_test/out/build/x86-debug-win -G Ninja
[proc]   with environment: {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\atom0s\\AppData\\Roaming","ASHITA4_DEPS_PATH":"X:\\SourceCode\\GitHub\\Ashita\\","ASHITA4_SDK_PATH":"X:\\SourceCode\\GitHub\\Ashita\\Ashita-src\\Ashita\\Data\\plugins\\sdk\\","COMPUTERNAME":"ATOM0S-LAPTOP","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","DXSDK_DIR":"C:\\Program Files (x86)\\Microsoft DirectX SDK (June 2010)\\","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","ELECTRON_RUN_AS_NODE":"1","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\atom0s","LOCALAPPDATA":"C:\\Users\\atom0s\\AppData\\Local","LOGONSERVER":"\\\\ATOM0S-LAPTOP","LUA_DEV":"C:\\Program Files (x86)\\Lua\\5.1","LUA_PATH":";;C:\\Program Files (x86)\\Lua\\5.1\\lua\\?.luac","MSMPI_BENCHMARKS":"C:\\Program Files\\Microsoft MPI\\Benchmarks\\","MSMPI_BIN":"C:\\Program Files\\Microsoft MPI\\Bin\\","NUMBER_OF_PROCESSORS":"32","NVM_HOME":"C:\\Users\\atom0s\\AppData\\Roaming\\nvm","NVM_SYMLINK":"C:\\Program Files\\nodejs","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","OneDrive":"C:\\Users\\atom0s\\OneDrive","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW;.wlua;.lexe","POSH_INSTALLER":"winget","POSH_THEMES_PATH":"C:\\Users\\atom0s\\AppData\\Local\\Programs\\oh-my-posh\\themes","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 183 Stepping 1, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"b701","PSModulePath":"%ProgramFiles%\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules;C:\\Program Files (x86)\\Microsoft SQL Server\\160\\Tools\\PowerShell\\Modules\\","PUBLIC":"C:\\Users\\Public","Path":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22621.0\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\VC\\VCPackages;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\bin\\Roslyn;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Team Tools\\Performance Tools;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\;C:\\Program Files (x86)\\HTML Help Workshop;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\FSharp\\Tools;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Team Tools\\DiagnosticsHub\\Collector;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\Extensions\\Microsoft\\CodeCoverage.Console;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22621.0\\\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\\\MSBuild\\Current\\Bin\\amd64;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools\\;C:\\Program Files (x86)\\VMware\\VMware Workstation\\bin\\;C:\\Program Files\\Microsoft MPI\\Bin\\;C:\\Program Files\\Python311\\Scripts\\;C:\\Program Files\\Python311\\;C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\Microsoft VS Code Insiders\\bin;C:\\Program Files\\010 Editor;C:\\Program Files (x86)\\WinMerge;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Users\\atom0s\\AppData\\Roaming\\nvm;C:\\Program Files\\nodejs;C:\\Program Files (x86)\\Lua\\5.1;C:\\Program Files (x86)\\Lua\\5.1\\clibs;C:\\Program Files (x86)\\Microsoft SQL Server\\160\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\160\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\160\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\160\\DTS\\Binn\\;C:\\Program Files\\Azure Data Studio\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\TortoiseGit\\bin;C:\\Program Files\\Git\\cmd;C:\\Users\\atom0s\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Tools\\hugo\\;C:\\Users\\atom0s\\.dotnet\\tools;C:\\Users\\atom0s\\AppData\\Local\\Programs\\Fiddler;C:\\Users\\atom0s\\.dotnet\\tools;C:\\Users\\atom0s\\AppData\\Local\\Programs\\oh-my-posh\\bin;C:\\Tools\\gzip\\bin;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\Llvm\\bin;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\VC\\Linux\\bin\\ConnectionManagerExe","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","SystemDrive":"C:","SystemRoot":"C:\\Windows","TEMP":"C:\\Users\\atom0s\\AppData\\Local\\Temp","TMP":"C:\\Users\\atom0s\\AppData\\Local\\Temp","USERDOMAIN":"ATOM0S-LAPTOP","USERDOMAIN_ROAMINGPROFILE":"ATOM0S-LAPTOP","USERNAME":"atom0s","USERPROFILE":"C:\\Users\\atom0s","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\atom0s\\AppData\\Roaming\\Code - Insiders\\CachedData\\9621add46007f7a1ab37d1fce9bcdcecca62aeb0","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"C:\\Windows\\system32","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\04f3321aca05619bf2f9ddd699282dd5-1.86.0-insider-main-sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"4916","ZES_ENABLE_SYSMAN":"1","configsetroot":"C:\\Windows\\ConfigSetRoot","windir":"C:\\Windows","DevEnvDir":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\","Framework40Version":"v4.0","FrameworkDir":"C:\\Windows\\Microsoft.NET\\Framework\\","FrameworkDIR32":"C:\\Windows\\Microsoft.NET\\Framework\\","FrameworkVersion":"v4.0.30319","FrameworkVersion32":"v4.0.30319","INCLUDE":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\include;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\ATLMFC\\include;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\VS\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22621.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\um;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\cppwinrt;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um","LIB":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\ATLMFC\\lib\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\lib\\x86;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.22621.0\\ucrt\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.22621.0\\\\um\\x86","LIBPATH":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\ATLMFC\\lib\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\lib\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.38.33130\\lib\\x86\\store\\references;C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.22621.0;C:\\Program Files (x86)\\Windows Kits\\10\\References\\10.0.22621.0;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319","NETFXSDKDir":"C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\","UCRTVersion":"10.0.22621.0","UniversalCRTSdkDir":"C:\\Program Files (x86)\\Windows Kits\\10\\","VCIDEInstallDir":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\VC\\","VCINSTALLDIR":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\","VCToolsRedistDir":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Redist\\MSVC\\14.38.33130\\","VisualStudioVersion":"17.0","VSINSTALLDIR":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\","WindowsLibPath":"C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.22621.0;C:\\Program Files (x86)\\Windows Kits\\10\\References\\10.0.22621.0","WindowsSdkBinPath":"C:\\Program Files (x86)\\Windows Kits\\10\\bin\\","WindowsSdkDir":"C:\\Program Files (x86)\\Windows Kits\\10\\","WindowsSDKLibVersion":"10.0.22621.0\\","WindowsSDKVersion":"10.0.22621.0\\","WindowsSDK_ExecutablePath_x64":"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\x64\\","WindowsSDK_ExecutablePath_x86":"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\","VS170COMNTOOLS":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools","CC":"cl.exe","CXX":"cl.exe"}
[cmake] CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=C:/Users/atom0s/Desktop/cmake_test/out/install/x86-debug-win -SC:/Users/atom0s/Desktop/cmake_test -BC:/Users/atom0s/Desktop/cmake_test/out/build/x86-debug-win -G Ninja exited with code: 1
[extension] [2262] cmake.cleanConfigure finished (returned 1)

Additional Information

This is happening similar to the previous time I reported this. https://github.com/microsoft/vscode-cmake-tools/issues/3443

atom0s commented 6 months ago

Following up on this; I've done some more testing and have found the cause of the above error happening again. This time it does not appear to be the same cause as the last time, but this does look to be a potential new bug.

This new cause for this error message appears to be based on when the following is potentially called:

set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)

If a project makes use of this setting in the same manner anywhere before the project is actually defined using the project(..) call, then this error will occur. This can happen if:

I believe this is technically a bug still as the documentation for CMake does not strictly state when this call can happen. It is also not explicit when describing when project(..) should be called, other than that it must be called in the main CMakeLists.txt. It also only recommends in the docs that the call to project(..) is made close to the top of the file and only encourages its use after cmake_minimum_required is called.

Moving the project(..) call above any attempts of using the above fixes the error.

gcampbell-msft commented 6 months ago

@atom0s Thanks for the additional investigation and information! Do you happen to know if this reproduced on the command line as well?

Could you please send us a repro project so that I can also find your investigation findings? It'd be good to make sure we have an entirely full understanding so that we can know where the issue (or at least the confusion) is stemming from. It may be that this issue is not stemming from the extension but from CMake itself. Thank you!

atom0s commented 6 months ago

Do you happen to know if this reproduced on the command line as well?

Yes, this same issue happens directly from CMakes command line. This is looking more like a CMake bug or simply a lack of good documentation on when project(..) should be called. The official documentation page gives some basic overview of when it should be called but doesn't explicitly say other calls can't come before it except that cmake_minimum_required must be first.

https://cmake.org/cmake/help/latest/command/project.html#project

Could you please send us a repro project so that I can also find your investigation findings?

Sure, I don't believe this issue is the fault of vscode-cmake-tools now after command line testing, but will still attach and explain my process in case its useful for other purposes.

Attached to this post is a simple project that tries to build a single .cpp file. I tried to keep things bare minimum to reproduce the bug and still be able to compile normally when 'fixed'.

As-is, the project should fail to configure with CMake due to this 'bug'.

Reproducing The Error

To reproduce with the zip I have attached, here's the steps I am using locally:

cmake -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=C:/Users/atom0s/Desktop/test_cmake_bug/out/install/x86-debug-win -SC:/Users/atom0s/Desktop/test_cmake_bug -BC:/Users/atom0s/Desktop/test_cmake_bug/out/build/x86-debug-win -G Ninja

Fixing The Error

The error can be fixed by simply moving where project(..) is called in the main CMakeLists.txt of the project.

Attached is the example project. test_cmake_bug.zip

gcampbell-msft commented 3 months ago

@atom0s Thank you very much for the detailed information. My apologies for the delayed response.

In order to best try to get you answers and possibly a solution, could you please open an issue on https://gitlab.kitware.com/cmake/cmake/-/issues? I would typically do this for you, but I think you'll be best suited to give all of the necessary context and explanation.

In the meantime, I've moved this issue to the Tracking milestone and marked it in our project and with a label that it is an external issue.

Thank you!