cmake 在 macOS 下构建 llvm/clang 时出错

Tal*_*Tal 1 c++ macos cmake llvm clang

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

\n\n
-- Performing Test COMPILER_RT_TARGET_HAS_ATOMICS - Success\nCMake Error at cmake/modules/AddLLVM.cmake:589 (if):\n  if given arguments:\n\n    "LTO" "IN_LIST" "LLVM_DISTRIBUTION_COMPONENTS" "OR" "NOT" "LLVM_DISTRIBUTION_COMPONENTS"\n\n  Unknown arguments specified\nCall Stack (most recent call first):\n  tools/lto/CMakeLists.txt:19 (add_llvm_library)\n\n\n-- Configuring incomplete, errors occurred!\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我正在使用的命令:

\n\n
\n

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release\n -DLLVM_ENABLE_LTO=On -Wno-dev ..

\n
\n\n

几个月前,我成功构建了 llvm/clang 5.0。但今天,我在各个目录和子目录上执行了 \xe2\x80\x9c git pull \xe2\x80\x9d 来获取最新的更改。

\n\n

另外,我将 cmake 更新到了 3.8.2。但这并没有帮助。

\n\n

根据评论者的请求,这里是不带选项的输出no-dev

\n\n
-- Performing Test COMPILER_RT_TARGET_HAS_ATOMICS - Success\nCMake Warning (dev) at cmake/modules/AddLLVM.cmake:589 (if):\n  Policy CMP0057 is not set: Support new IN_LIST if() operator.  Run "cmake\n  --help-policy CMP0057" for policy details.  Use the cmake_policy command to\n  set the policy and suppress this warning.\n\n  IN_LIST will be interpreted as an operator when the policy is set to NEW.\n  Since the policy is not set the OLD behavior will be used.\nCall Stack (most recent call first):\n  tools/lto/CMakeLists.txt:19 (add_llvm_library)\nThis warning is for project developers.  Use -Wno-dev to suppress it.\n\nCMake Error at cmake/modules/AddLLVM.cmake:589 (if):\n  if given arguments:\n\n    "LTO" "IN_LIST" "LLVM_DISTRIBUTION_COMPONENTS" "OR" "NOT" "LLVM_DISTRIBUTION_COMPONENTS"\n\n  Unknown arguments specified\nCall Stack (most recent call first):\n  tools/lto/CMakeLists.txt:19 (add_llvm_library)\n
Run Code Online (Sandbox Code Playgroud)\n

Tsy*_*rev 5

要在表达式中使用IN_LIST运算符if(),应启用策略CMP0057 。从警告消息中可以看出,这不是您的情况。

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

请注意,即使您使用更高版本的 CMake,它也不会启用该策略:CMake 尊重cmake_minimum_required.