cross-compile-macosx-clang-windows-msvc icon indicating copy to clipboard operation
cross-compile-macosx-clang-windows-msvc copied to clipboard

clang: error: no such file or directory: '/MT'

Open fzy139 opened this issue 3 years ago • 1 comments

Hi,

I am trying the cmake example to build my cmake project under macOS. This error occurs when runing cmake .. cmake -DCMAKE_TOOLCHAIN_FILE=Modules/Windows64.cmake; .

The output is

-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
System is unknown to cmake, create:
Platform/LlvmWindowsCrossCompile to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/LlvmWindowsCrossCompile to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
System is unknown to cmake, create:
Platform/LlvmWindowsCrossCompile to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - broken
CMake Error at /usr/local/Cellar/cmake/3.19.5/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler

    "/Library/Developer/CommandLineTools/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/kf/Codes/test/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make cmTC_56ce6/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_56ce6.dir/build.make CMakeFiles/cmTC_56ce6.dir/build
    Building C object CMakeFiles/cmTC_56ce6.dir/testCCompiler.c.obj
    /Library/Developer/CommandLineTools/usr/bin/cc   -m64 /MT  -o CMakeFiles/cmTC_56ce6.dir/testCCompiler.c.obj -c /Users/kf/Codes/test/build/CMakeFiles/CMakeTmp/testCCompiler.c
    clang: error: no such file or directory: '/MT'
    make[1]: *** [CMakeFiles/cmTC_56ce6.dir/testCCompiler.c.obj] Error 1
    make: *** [cmTC_56ce6/fast] Error 2

macOS 10.15.7 cmake 3.19.5

fzy139 avatar Jun 30 '21 13:06 fzy139

I had this cmake module originally working against clang 6.0.0.... looks like clang/LLVM is up to version 12 now

I found this: https://stackoverflow.com/questions/52760801/cmake-building-for-windows-clang-cl-using-ninja-generator

To compile with clang-cl, it is necessary to run cmake with MSVC environment loaded
 (use vcvarsall.bat). Otherwise it tries to use GCC compatibility options. 
It is enough to install just the Build Tools.

But yeah, it's broken for me here too, and I haven't had a chance to fix it.
I welcome any patches!

subatomicglue avatar Nov 12 '21 18:11 subatomicglue