Tal
Tal

Reputation: 125

cmake error building llvm/clang under macOS

I am getting the following message when I run cmake for llvm/clang:

-- 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!

Here is the command I am using:

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

A few months ago, I successfully built llvm/clang 5.0. But today, I did a “git pull” on the various directories and subdirectories to pickup the latest changes.

Also, I updated my cmake to 3.8.2. But that didn’t help.

Per a request by a commenter here is the output without the no-dev option:

-- 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)

Upvotes: 1

Views: 2655

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 65928

For use IN_LIST operator in if() expression, policy CMP0057 should be enabled. As you can see from the warning message, it is not your case.

The policy can be enabled via cmake_policy(SET) command. Also, cmake_minimum_required called with sufficient version ("3.3" in given case) automatically enables the policy.

Note, that even you use CMake of higher version, it doesn't enables the policy: CMake respects version given in cmake_minimum_required.

Upvotes: 5

Related Questions