在macOS下构建llvm / clang的cmake错误

时间:2017-06-11 04:55:34

标签: c++ macos cmake clang llvm

当我为llvm / clang运行cmake时,我收到以下消息:

-- Performing Test COMPILER_RT_TARGET_HAS_ATOMICS - Success
CMake Error at cmake/modules/AddLLVM.cmake:589 (if):
  if given arguments:

    "LTO" "IN_LIST" "LLVM_DISTRIBUTION_COMPONENTS" "OR" "NOT" "LLVM_DISTRIBUTION_COMPONENTS"

  Unknown arguments specified
Call Stack (most recent call first):
  tools/lto/CMakeLists.txt:19 (add_llvm_library)


-- Configuring incomplete, errors occurred!

这是我正在使用的命令:

  

cmake -G" Unix Makefiles" -DCMAKE_BUILD_TYPE =释放   -DLLVM_ENABLE_LTO = On -Wno-dev ..

几个月前,我成功构建了llvm / clang 5.0。但今天,我在各个目录和子目录上做了一个“ git pull ”来获取最新的更改。

另外,我将我的cmake更新为3.8.2。但这没有帮助。

根据评论者的请求,这里是没有no-dev选项的输出:

-- Performing Test COMPILER_RT_TARGET_HAS_ATOMICS - Success
CMake Warning (dev) at cmake/modules/AddLLVM.cmake:589 (if):
  Policy CMP0057 is not set: Support new IN_LIST if() operator.  Run "cmake
  --help-policy CMP0057" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  IN_LIST will be interpreted as an operator when the policy is set to NEW.
  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  tools/lto/CMakeLists.txt:19 (add_llvm_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at cmake/modules/AddLLVM.cmake:589 (if):
  if given arguments:

    "LTO" "IN_LIST" "LLVM_DISTRIBUTION_COMPONENTS" "OR" "NOT" "LLVM_DISTRIBUTION_COMPONENTS"

  Unknown arguments specified
Call Stack (most recent call first):
  tools/lto/CMakeLists.txt:19 (add_llvm_library)

1 个答案:

答案 0 :(得分:4)

要在if()表达式中使用 IN_LIST 运算符,应启用策略CMP0057。正如您从警告消息中看到的那样,情况并非如此。

可以通过cmake_policy(SET)命令启用该策略。此外,cmake_minimum_required调用足够的版本(在给定的情况下为“3.3”)会自动启用该策略。

请注意,即使您使用较高版本的CMake,它也不会启用该策略:CMake尊重cmake_minimum_required中给出的版本。