[Issue] CMake error invoke sh

When I am using PowerShell and VS Code, CMake incorrectly invoked the sh in MSYS, and the sh in msys2 incorrectly handled Windows-style paths, which resulted in my clang not being called correctly. How should I handle this situation?

CMake Error at C:/Program Files/CMake/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "C:/Program Files/LLVM/bin/clang.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'Y:/flash-tool/libadb/CMakeFiles/CMakeScratch/TryCompile-qqomqn'

    Run Build Command(s): F:/msys64/usr/bin/ninja.exe -v cmTC_9d7d3
    [1/2] C:\PROGRA~1\LLVM\bin\clang.exe   -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -MD -MT CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -MF CMakeFiles\cmTC_9d7d3.dir\testCCompiler.c.obj.d -o CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -c 'Y:/flash-tool/libadb/CMakeFiles/CMakeScratch/TryCompile-qqomqn/testCCompiler.c'
    FAILED: CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj
    C:\PROGRA~1\LLVM\bin\clang.exe   -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -MD -MT CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -MF CMakeFiles\cmTC_9d7d3.dir\testCCompiler.c.obj.d -o CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -c 'Y:/flash-tool/libadb/CMakeFiles/CMakeScratch/TryCompile-qqomqn/testCCompiler.c'
    /bin/sh: line 1: C:PROGRA~1LLVMbinclang.exe: command not found
    ninja: build stopped: subcommand failed.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:35 (project)


-- Configuring incomplete, errors occurred!

From the CMake output log, it is clear that the path which should have been C:\PROGRA~1\LLVM\bin\clang.exe has become C:PROGRA~1LLVMbinclang.exe.
By the way, I had no issues configuring this project in CLion.

All programs should be of the same type, either native Windows or MSYS. Mixing them is quite error-prone.

In your case, you’re using a native CMake and clang, but Ninja is from MSYS. Use a Windows native Ninja, then it should use cmd.