ARTICLE AD BOX
I would like compile a simple example using Clang, CMake, and Ninja on Windows in order to closely match a Linux C++ build setup. I have installed the tools using msys2. However, when I run "CMake: Delete Cache and Reconfigure" it seems that somewhere along the line, the paths get messed up, and I get this error (the project path is appended to itself?):
[cmake] CMake Error: The source directory "/c/Users/UserName/Documents/Random/testproj/build/C:/Users/UserName/Documents/Random/testproj" does not exist.Here is the full output:
[main] Configuring project: testproj [proc] Executing command: C:\msys64\usr\bin\cmake.exe -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\msys64\usr\bin\clang.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\msys64\usr\bin\clang++.exe --no-warn-unused-cli -S C:/Users/UserName/Documents/Random/testproj -B c:/Users/UserName/Documents/Random/testproj/build -G Ninja [cmake] CMake Error: The source directory "/c/Users/UserName/Documents/Random/testproj/build/C:/Users/UserName/Documents/Random/testproj" does not exist. [cmake] Specify --help for usage, or press the help button on the CMake GUI. [cmake] Not searching for unused variables given on the command line. [proc] The command: C:\msys64\usr\bin\cmake.exe -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\msys64\usr\bin\clang.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\msys64\usr\bin\clang++.exe --no-warn-unused-cli -S C:/Users/UserName/Documents/Random/testproj -B c:/Users/UserName/Documents/Random/testproj/build -G Ninja exited with code: 1I can reproduce the issue with the following minimal example:
CMakeLists.txt
cmake_minimum_required(VERSION 3.20) project(hello-world) add_executable(hello-world main.cpp)CMakePresets.json
{ "version": 3, "configurePresets": [ { "name": "default", "hidden": true, "generator": "Ninja", "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { } }, { "name": "Debug", "inherits": "default", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "Release", "inherits": "default", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } } ], "buildPresets": [ { "name": "Debug", "configurePreset": "Debug" }, { "name": "Release", "configurePreset": "Release" } ] }workspace.code-workspace
{ "folders": [ { "path": "." } ], "settings": { "cmake.cmakePath": "C:\\msys64\\usr\\bin\\cmake.exe" } }main.cpp
#include <iostream> int main() { std::cout << "hello world" << std::endl; return 0; }