Issue 147190
Summary llvm-bolt configure failed because CMP0002 with cmake version >= 4.0 using BOLT-PGO.cmake
Labels BOLT
Assignees
Reporter pure-purpose
    As described in [CMake docs](https://cmake.org/cmake/help/latest/policy/CMP0002.html):
> Targets names created with [add_executable()](https://cmake.org/cmake/help/latest/command/add_executable.html#command:add_executable), [add_library()](https://cmake.org/cmake/help/latest/command/add_library.html#command:add_library), or [add_custom_target()](https://cmake.org/cmake/help/latest/command/add_custom_target.html#command:add_custom_target) are logical build target names. Logical target names must be globally unique

> Warning The OLD behavior of this policy was removed in CMake version 4.0. This policy must be set to NEW by a call to [cmake_minimum_required()](https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#command:cmake_minimum_required) or [cmake_policy()](https://cmake.org/cmake/help/latest/command/cmake_policy.html#command:cmake_policy).

So when I use BOLT-PGO.cmake to configure llvm with -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt", it failed with CMP0002. “compiler-rt" and "bolt" are mutually exclusive.
```
CMake Error at /usr/share/cmake/Modules/ExternalProject.cmake:2994 (add_custom_target):
  add_custom_target cannot create target "builtins" because another target
  with the same name already exists.  The existing target is a custom target
  created in source directory
  "/home/xxx/workspace/llvm-project-20.1.7.src/compiler-rt/lib/builtins".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  cmake/modules/LLVMExternalProjectUtils.cmake:367 (ExternalProject_Add)
  runtimes/CMakeLists.txt:90 (llvm_ExternalProject_Add)
  runtimes/CMakeLists.txt:166 (builtin_default_target)


CMake Error at cmake/modules/LLVMExternalProjectUtils.cmake:457 (add_custom_target):
  add_custom_target cannot create target "compiler-rt" because another target
  with the same name already exists.  The existing target is a custom target
  created in source directory
  "/home/xxx/workspace/llvm-project-20.1.7.src/compiler-rt".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  runtimes/CMakeLists.txt:261 (llvm_ExternalProject_Add)
  runtimes/CMakeLists.txt:554 (runtime_default_target)


CMake Error at cmake/modules/LLVMExternalProjectUtils.cmake:457 (add_custom_target):
  add_custom_target cannot create target "install-compiler-rt" because
  another target with the same name already exists.  The existing target is a
  custom target created in source directory
  "/home/xxx/workspace/llvm-project-20.1.7.src/compiler-rt".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  runtimes/CMakeLists.txt:261 (llvm_ExternalProject_Add)
  runtimes/CMakeLists.txt:554 (runtime_default_target)


CMake Error at cmake/modules/LLVMExternalProjectUtils.cmake:457 (add_custom_target):
  add_custom_target cannot create target "install-compiler-rt-stripped"
  because another target with the same name already exists.  The existing
  target is a custom target created in source directory
  "/home/xxx/workspace/llvm-project-20.1.7.src/compiler-rt".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  runtimes/CMakeLists.txt:261 (llvm_ExternalProject_Add)
  runtimes/CMakeLists.txt:554 (runtime_default_target)


CMake Error at cmake/modules/LLVMExternalProjectUtils.cmake:457 (add_custom_target):
  add_custom_target cannot create target "check-compiler-rt" because another
  target with the same name already exists.  The existing target is a custom
  target created in source directory
  "/home/xxx/workspace/llvm-project-20.1.7.src/compiler-rt/test".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  runtimes/CMakeLists.txt:261 (llvm_ExternalProject_Add)
  runtimes/CMakeLists.txt:554 (runtime_default_target)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to