Set cmake policy for CMP0057
authorYonghong Song <yhs@fb.com>
Sun, 26 Mar 2023 19:38:18 +0000 (12:38 -0700)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 22 Feb 2024 14:17:55 +0000 (15:17 +0100)
With latest llvm17, running cmake, we got the following errors:
  -- Found LLVM: /home/yhs/work/llvm-project/llvm/build/install/include 17.0.0git (Use LLVM_ROOT envronment variable for another version of LLVM)
  CMake Warning (dev) at /home/yhs/work/llvm-project/llvm/build/install/lib/cmake/llvm/LLVM-Config.cmake:230 (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):
    cmake/clang_libs.cmake:32 (llvm_map_components_to_libnames)
    src/cc/CMakeLists.txt:132 (include)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Error at /home/yhs/work/llvm-project/llvm/build/install/lib/cmake/llvm/LLVM-Config.cmake:230 (if):
    if given arguments:
      "engine" "IN_LIST" "link_components"
    Unknown arguments specified

Let set cmake policy for CMP0057 explicitly.

Signed-off-by: Yonghong Song <yhs@fb.com>
CMakeLists.txt

index 87f85e0da6782b95b5b901dba42f7c7af6e3d109..0c12bfae383ff8c148087f7f9dce71e633cfdd77 100644 (file)
@@ -6,6 +6,10 @@ if (${CMAKE_VERSION} VERSION_EQUAL 3.12.0 OR ${CMAKE_VERSION} VERSION_GREATER 3.
   cmake_policy(SET CMP0074 NEW)
 endif()
 
+if(${CMAKE_VERSION} VERSION_EQUAL 3.3.0 OR ${CMAKE_VERSION} VERSION_GREATER 3.3.0)
+  cmake_policy(SET CMP0057 NEW)
+endif()
+
 project(bcc)
 if(NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE Release)