CMake将Visual C ++参数传递给clang而不是被驱逐的GCC参数

时间:2016-11-18 10:39:35

标签: c++ gcc cmake clang mingw

我正在尝试使用mingw最新工具链和clang编译器(来自CLion IDE)在命令行选项中使用明确指定的编译器在win10下构建项目:

-DCMAKE_C_COMPILER=C:/dev/tools/LLVM/bin/clang.exe
-DCMAKE_CXX_COMPILER=C:/dev/tools/LLVM/bin/clang++.exe

cmake正确识别clang,但在测试期间编译尝试传递cl(Visual C ++编译器)标志:

C:\dev\tools\CLion.RC\bin\cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=C:/dev/tools/LLVM/bin/clang.exe -DCMAKE_CXX_COMPILER=C:/dev/tools/LLVM/bin/clang++.exe -G "CodeBlocks - MinGW Makefiles" C:\Users\amigo421\ClionProjects\hr2

-- The C compiler identification is unknown
-- The CXX compiler identification is Clang 3.9.0
-- Check for working C compiler: C:/dev/tools/LLVM/bin/clang.exe
-- Check for working C compiler: C:/dev/tools/LLVM/bin/clang.exe -- broken CMake Error at
C:/dev/tools/CLion.RC/bin/cmake/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61
(message):   The C compiler "C:/dev/tools/LLVM/bin/clang.exe" is not
able to compile a   simple test program.

  It fails with the following output:

  C:\dev\tools\LLVM\bin\clang.exe /DWIN32 /D_WINDOWS /W3 -o  
CMakeFiles\cmTC_397ea.dir\testCCompiler.c.obj -c  
C:\Users\amigo421\ClionProjects\hr2\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c


  **clang.exe: error: no such file or directory: '/DWIN32'**

  **clang.exe: error: no such file or directory: '/D_WINDOWS'**

  **clang.exe: error: no such file or directory: '/W3'**

  CMakeFiles\cmTC_397ea.dir\build.make:64: recipe for target  
'CMakeFiles/cmTC_397ea.dir/testCCompiler.c.obj' failed

  mingw32-make.exe[1]: ***
[CMakeFiles/cmTC_397ea.dir/testCCompiler.c.obj]   Error 1

  mingw32-make.exe[1]: Leaving directory  
'C:/Users/amigo421/ClionProjects/hr2/cmake-build-debug/CMakeFiles/CMakeTmp'

你看到cmake传递了visual c ++标志,我不打算使用clang-cl。 我想cmake应该在命令行中使用GCC(MinGW)参数

任何想法如何解决这个问题

0 个答案:

没有答案