解决LLVM项目中CMake 报错 “if given arguments *** Unknown arguments specified”
报错信息如下:
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:27 (add_llvm_library)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at cmake/modules/AddLLVM.cmake:691 (if):
if given arguments:
"LTO" "IN_LIST" "LLVM_DISTRIBUTION_COMPONENTS" "OR" "(" "in_llvm_libs" "AND" "llvm-libraries" "IN_LIST" "LLVM_DISTRIBUTION_COMPONENTS" ")" "OR" "NOT" "LLVM_DISTRIBUTION_COMPONENTS"
Unknown arguments specified
Call Stack (most recent call first):
tools/lto/CMakeLists.txt:27 (add_llvm_library)
这样的cmake报错信息,是由于我将multicompiler的代码合并到llvm-9.0版本中,创建cmake工程的时候报的。
经过一番捣鼓,发现是cmake中cmake-min-version
设置的问题,导致multicompiler的compiler-rt
项目cmake报错。修改llvm/projects/compiler-rt/CMakeLists.txt
文件中cmake-min-version
为3.4.3(我系统中安装的cmake是这个版本,版本过低是报这种错误的主要原因),使得compiler-rt
项目中的cmake-min-version
版本好和LLVM项目的版本号一致。
修改如下;
18 # The CompilerRT build system requires CMake version 2.8.8 or higher in order
19 # to use its support for building convenience "libraries" as a collection of
20 # .o files. This is particularly useful in producing larger, more complex
21 # runtime libraries.
22 if (NOT MSVC)
23 --- cmake_minimum_required(VERSION 2.8.8)
23 +++ cmake_minimum_required(VERSION 3.4.3)
24 else()
25 # Version 2.8.12.1 is required to build with Visual Studio 2013.
26 --- cmake_minimum_required(VERSION 2.8.12.1)
26 +++ cmake_minimum_required(VERSION 3.4.3)
27 endif()