[bug] Failed to use CMake installed on MSYS2 and Cygwin.
Brief Issue Summary
Based on what CMake Team said in this topic of CMake Discourse, we should use the CMake installed on MSYS2 and Cygwin when targeting Cygwin’s or MSYS2’s runtime environments. For example:
- we should use
C:\msys64\usr\bin\cmake.exe - instead of
C:\Program Files\CMake\bin\cmake.exe
If the target platform is
Windows, regardless of whether the target ABI is GNU-style (MinGW) or MSVC-style, then theC:\Program Files\CMake\bin\cmake.exetool should work. It’s only when targeting cygwin’s or msys2’s runtime environments that one needs a CMake built for them, and such a CMake won’t work for targeting Windows. These platforms are all independent of each other and tooling cannot be mixed among them.
However, there are SOME problems when configuring with CMake Tools.
Environments and Versions
- OS version: Windows 11
- Compiler version: GCC 11.3.0
- CMake version: CMake 3.23.2
- CMake Tools version: 1.13.21
CMake Tools Diagnostics
Click to expand
{
"os": "win32",
"vscodeVersion": "1.73.0",
"cmtVersion": "1.13.21",
"configurations": [
{
"folder": "f:\\GitRepo\\tmp\\cmake-tools-msys2-cygwin",
"cmakeVersion": "3.23.2",
"configured": true,
"generator": "Ninja",
"usesPresets": true,
"compilers": {
"C": "C:/msys64/usr/bin/gcc.exe",
"CXX": "C:/msys64/usr/bin/g++.exe"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": false,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 0,
"executablesCount": 0,
"librariesCount": 0,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": false
}
]
}
Debug Log
Click to expand
[main] Configuring folder: cmake-tools-msys2-cygwin
[main] Saving open files before configure/build
[driver] Start configure
[driver] Running pre-configure checks and steps
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake C:/msys64/usr/bin/cmake.exe with arguments ["-DCMAKE_C_COMPILER=gcc.exe","-DCMAKE_CXX_COMPILER=g++.exe","-DCMAKE_BUILD_TYPE=Debug","-DCMAKE_INSTALL_PREFIX=F:/GitRepo/tmp/cmake-tools-msys2-cygwin/install/msys2-gcc-x64-ninja-debug","-SF:/GitRepo/tmp/cmake-tools-msys2-cygwin","-BF:/GitRepo/tmp/cmake-tools-msys2-cygwin/build/msys2-gcc-x64-ninja-debug","-G","Ninja"]
[proc] Executing command: C:/msys64/usr/bin/cmake.exe -DCMAKE_C_COMPILER=gcc.exe -DCMAKE_CXX_COMPILER=g++.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=F:/GitRepo/tmp/cmake-tools-msys2-cygwin/install/msys2-gcc-x64-ninja-debug -SF:/GitRepo/tmp/cmake-tools-msys2-cygwin -BF:/GitRepo/tmp/cmake-tools-msys2-cygwin/build/msys2-gcc-x64-ninja-debug -G Ninja
[proc] with environment: {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\hwhsu1231\\AppData\\Roaming","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","CHROME_CRASHPAD_PIPE_NAME":"\\\\.\\pipe\\crashpad_19660_GLSMDCZFVNJSGFHW","CommonProgramFiles":"C:\\Program Files\\Common Files","CommonProgramFiles(x86)":"C:\\Program Files (x86)\\Common Files","CommonProgramW6432":"C:\\Program Files\\Common Files","COMPUTERNAME":"VVB-WINDOWS","ComSpec":"C:\\WINDOWS\\system32\\cmd.exe","CONAN_USER_HOME":"D:\\.conan\\home","CONAN_USER_HOME_SHORT":"D:\\.conan\\short","CONAN_USE_ALWAYS_SHORT_PATHS":"1","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","ELECTRON_RUN_AS_NODE":"1","GDAL_DATA":"C:\\Program Files\\PostgreSQL\\14\\gdal-data","HOME":"C:\\Users\\hwhsu1231","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\hwhsu1231","LOCALAPPDATA":"C:\\Users\\hwhsu1231\\AppData\\Local","LOGONSERVER":"\\\\VVB-WINDOWS","NUMBER_OF_PROCESSORS":"8","OneDrive":"C:\\Users\\hwhsu1231\\OneDrive","OneDriveConsumer":"C:\\Users\\hwhsu1231\\OneDrive","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","Path":"C:\\msys64\\usr\\bin;C:/Python/Python310/Scripts/;C:\\Python\\Python310\\;C:/Program Files/Eclipse Foundation/jdk-8.0.302.8-hotspot/bin;C:\\Windows\\system32;C:/Windows;C:\\Windows\\System32\\Wbem;C:/Windows/System32/WindowsPowerShell/v1.0/;C:\\Windows\\System32\\OpenSSH\\;C:/Program Files/dotnet/;C:\\Program Files\\CMake\\bin;C:/Program Files/Intel/WiFi/bin/;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:/Program Files (x86)/gsudo/;C:\\Program Files\\NASM;C:/Program Files/Git/cmd;C:\\Program Files\\Typora;C:/WINDOWS/system32;C:\\WINDOWS;C:/WINDOWS/System32/Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:/WINDOWS/System32/OpenSSH/;C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build;C:/Program Files (x86)/Pulse Secure/VC142.CRT/X64/;C:\\Program Files (x86)\\Pulse Secure\\VC142.CRT\\X86\\;C:/Program Files (x86)/Common Files/Pulse Secure/TNC Client Plugin/;C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin;C:/Program Files/Microsoft VS Code/bin;C:\\Program Files\\MySQL\\MySQL Shell 8.0\\bin\\;C:/Users/hwhsu1231/AppData/Local/Microsoft/WindowsApps;C:\\Users\\hwhsu1231\\.dotnet\\tools;","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW","POSTGIS_ENABLE_OUTDB_RASTERS":"1","POSTGIS_GDAL_ENABLED_DRIVERS":"GTiff PNG JPEG GIF XYZ DTED USGSDEM AAIGrid","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 142 Stepping 11, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"8e0b","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","PROJ_LIB":"C:\\Program Files\\PostgreSQL\\14\\share\\contrib\\postgis-3.3\\proj","PSModulePath":"C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules","PUBLIC":"C:\\Users\\Public","SESSIONNAME":"Console","SystemDrive":"C:","SystemRoot":"C:\\WINDOWS","TEMP":"C:\\Users\\HWHSU1~1\\AppData\\Local\\Temp","TMP":"C:\\Users\\HWHSU1~1\\AppData\\Local\\Temp","USERDOMAIN":"VVB-WINDOWS","USERDOMAIN_ROAMINGPROFILE":"VVB-WINDOWS","USERNAME":"hwhsu1231","USERPROFILE":"C:\\Users\\hwhsu1231","VS160COMCOMNTOOLS":"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\Tools\\","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\hwhsu1231\\AppData\\Roaming\\Code\\CachedData\\8fa188b2b301d36553cbc9ce1b0a146ccb93351f","VSCODE_CWD":"C:\\Program Files\\Microsoft VS Code","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\442678ec4eab5b341d7a96847e309fe9-1.73.0-main-sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"19660","VSLANG":"1033","windir":"C:\\WINDOWS"}
[cmake] -- The C compiler identification is unknown
[cmake] -- The CXX compiler identification is unknown
[cmake] -- Detecting C compiler ABI info
[cmake] CMake Error:
[cmake] Running
[cmake]
[cmake] '/usr/bin/ninja.exe' '-C' 'F:/GitRepo/tmp/cmake-tools-msys2-cygwin/build/msys2-gcc-x64-ninja-debug/CMakeFiles/CMakeTmp' '-t' 'recompact'
[cmake]
[cmake] failed with:
[cmake]
[cmake] ninja: error: build.ninja:128: unknown target 'all'
[cmake]
[cmake] default all
[cmake]
[cmake] ^ near here
[cmake]
[cmake]
[cmake]
[cmake] CMake Error at /usr/share/cmake-3.23.2/Modules/CMakeDetermineCompilerABI.cmake:49 (try_compile):
[cmake] Failed to generate test project build system.
[cmake] Call Stack (most recent call first):
[cmake] /usr/share/cmake-3.23.2/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
[cmake] CMakeLists.txt:2 (project)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: C:/msys64/usr/bin/cmake.exe -DCMAKE_C_COMPILER=gcc.exe -DCMAKE_CXX_COMPILER=g++.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=F:/GitRepo/tmp/cmake-tools-msys2-cygwin/install/msys2-gcc-x64-ninja-debug -SF:/GitRepo/tmp/cmake-tools-msys2-cygwin -BF:/GitRepo/tmp/cmake-tools-msys2-cygwin/build/msys2-gcc-x64-ninja-debug -G Ninja exited with code: 1 and signal: null
[extension] [9751] cmake.configure finished (returned 1)
Additional Information
Click to expand CMakePresets.json
{
"version": 4,
"configurePresets": [
{
"name": "msys2-gcc-x64-ninja-debug",
"displayName": "MSYS2 GCC x64 (Ninja) Debug",
"description": "Using GCC x64 compiler with \"Ninja\" geneartor on MSYS2 - Debug",
"generator": "Ninja",
"cmakeExecutable": "C:\\msys64\\usr\\bin\\cmake.exe",
"environment": {
"PATH": "C:\\msys64\\usr\\bin;$penv{PATH}"
},
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc.exe",
"CMAKE_CXX_COMPILER": "g++.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
}
]
}
Prerequisites
Intall the following packages on MSYS2.
pacman -S base-devel
pacman -S gcc
pacman -S cmake
pacman -S ninja
Thank you for reporting this issue. We are aware that there are some problems with Msys2. We will used your data while attempting to solve the issues.
Any progress on this? One thing I noticed is CMake is converting Windows paths passed by Visual Studio Code to Unix paths relative to the source dir.
This has result in a folder named 'D0' being created (as I have a D drive).
Any progress on this?
can cmake-tool select shell when configure or build ...
Thanks for reporting this issue. Could you please help check it the below video described your issue? If not, please share us a demo project with clear repro steps in order to investigate this issue further. We are looking forward to hearing from you. Thanks.
Thanks for reporting this issue. Could you please help check it the below video described your issue? If not, please share us a demo project with clear repro steps in order to investigate this issue further. We are looking forward to hearing from you. Thanks.
I currently swapped from Windows to Linux, but from what I remember of this issue, its some sort of disconnect between VSCode and Cygwin/MSYS2's CMake in regards to file paths resulting in CMake using the wrong file path then what is expected.
As I stated in my reply earlier, something created a folder named 'D0', but in reality, it was supposed to be 'D:'
Thanks for your reply. The cache generated failed when use the C:\msys64\usr\bin\CMake.exe, and it created a folder like C. Please see the below picture: Is this your problem? Thanks.
Yes, that indeed looks like it, I believe its because that CMake executable expects a Unix file path while VSCode is providing a Windows file path.
Thanks for your reply. Our Development Team will continue to investigate this issue. We will get back to you if there are any updates. Thank you for your support.
duplicate of #1376
Thank you for your comments. Please continue to track both issues. If there are any updates, we will add comments . Thank you.