MacOS 10.13.3未知CMake编译器标识

时间:2018-04-20 07:59:04

标签: macos compiler-errors cmake

我想通过cmake构建llvm,

我使用cmake -G Xcode ../llvm -DCMAKE_BUILD_TYPE:STRING=MinSizeRel

但我遇到了麻烦。

错误日志是:

CMake Deprecation Warning at CMakeLists.txt:14 (cmake_policy):
  The OLD behavior for policy CMP0051 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is unknown
-- Found assembler: /Library/Developer/CommandLineTools/usr/bin/cc
CMake Error at CMakeLists.txt:45 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:45 (project):
  No CMAKE_CXX_COMPILER could be found.

-- Warning: Did not find file Compiler/-ASM
-- Configuring incomplete, errors occurred!

此外,我还使用xcrun -find cc,结果为/Library/Developer/CommandLineTools/usr/bin/cc

我该怎么办?请帮忙

3 个答案:

答案 0 :(得分:2)

如果您已安装Xcode,请尝试以下操作:

sudo xcode-select --reset

答案 1 :(得分:0)

请试试这个:

  • 使用什么版本的CMake / Xcode?最近的?
  • 请。检查您是否在源代码中没有旧/以前的cmake构建文件夹
  • 如果您升级Xcode,请不要再忘记通过

    安装命令行工具

    sudo xcode-select --install

  • 旁注:CMake选项'CMAKE_BUILD_TYPE'对Xcode生成器没用;此变量仅适用于Makefile构建 - 从命令行中删除它,当配置工作时,通过以下方式触发构建:

    cmake --build。 --config MinSizeRel

答案 2 :(得分:0)

尝试

sudo xcodebuild -license