Clang GNU-like command-line with custom MSVC SDK
Hello,
When I try to compile with a GNU-like command-line with a MSVC ABI various arguments are broken. Without vcvarsall.bat I have it working in a different build system. Is this possible with CMake?
The CXX compiler identification is Clang 11.0.1 with GNU-like command-line
The C compiler identification is Clang 11.0.1 with GNU-like command-line
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - failed
Check for working CXX compiler: ms_build/llvm_toolchain/bin/clang.exe
Check for working CXX compiler: ms_build/llvm_toolchain/bin/clang.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/CMakeTestCXXCompiler.cmake:59 (message):
The C++ compiler
ms_build/llvm_toolchain/bin/clang.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: build/CMakeFiles/CMakeTmp
Run Build Command(s):scripts/ninja/ninja.exe cmTC_5d006 && [1/2] Building CXX object CMakeFiles/cmTC_5d006.dir/testCXXCompiler.cxx.obj
FAILED: CMakeFiles/cmTC_5d006.dir/testCXXCompiler.cxx.obj
ms_build\llvm_toolchain\bin\clang.exe /std:c++14 -D_CRT_SECURE_NO_WARNINGS --driver-mode=cl -fms-compatibility-version=19.10 -m32 /MP /Zc:wchar_t -nostdinc /imsvc external/ms_build/msvc_base/MSVC/14.28.29333/atlmfc/include /imsvc external/ms_build/msvc_base/MSVC/14.28.29333/include /imsvc external/ms_build/winsdk/Include/10.0.18362.0/ucrt /imsvc external/ms_build/winsdk/Include/10.0.18362.0/shared /imsvc external/ms_build/winsdk/Include/10.0.18362.0/um /imsvc external/ms_build/winsdk/Include/10.0.18362.0/winrt -g -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -MD -MT CMakeFiles/cmTC_5d006.dir/testCXXCompiler.cxx.obj -MF CMakeFiles\cmTC_5d006.dir\testCXXCompiler.cxx.obj.d -o CMakeFiles/cmTC_5d006.dir/testCXXCompiler.cxx.obj -c testCXXCompiler.cxx
clang: warning: unknown argument ignored in clang-cl: '-g' [-Wunknown-argument]
clang: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang: error: no such file or directory: 'CMakeFiles/cmTC_5d006.dir/testCXXCompiler.cxx.obj'
clang: error: no such file or directory: 'CMakeFiles\cmTC_5d006.dir\testCXXCompiler.cxx.obj.d'
ninja: build stopped: subcommand failed.
Clang version:
clang version 11.0.1
Target: i686-pc-windows-gnu
Thread model: posix
CMake version: 3.19.3
Toolchain used: https://github.com/llvm-mirror/llvm/blob/master/cmake/platforms/WinMsvc.cmake
What I am trying to accomplish: Using a GNU-like command-line interface that uses custom location of the MSVC SDK and a custom clang compiler.
What I have tried to far: Switch to MSVC with --target but it seems to generate the same effect.
Why do I want to accomplish this? The reason is simple, I do not want the user to install MSVC build tools + there is a custom compiler so not every compiler will work. So vcvarsall.bat won't be needed at all.
Question: Is there any way to accomplish the following issue with CMake? It seems that -MF is the culprit here but I have tried to remove it but it does not appear in the compiler arguments. Currently I am investigating to migrate from Waf to CMake but this one issue has to be fixable. If there is any additional information required, I will provide it.
Thanks.