<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/147190>147190</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
llvm-bolt configure failed because CMP0002 with cmake version >= 4.0 using BOLT-PGO.cmake
</td>
</tr>
<tr>
<th>Labels</th>
<td>
BOLT
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pure-purpose
</td>
</tr>
</table>
<pre>
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)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsmE1v4zYTxz8NfRlYkCnLtg4-2LH14CmcTdCk3aNBUWOLDSV6-ZI4374gJW2VbFKgu8YC7S6QQ8KXP-flN2NPmDHi2CAuSbom6WbEnK2UXp6cxvHJ6ZMyOCpU-bxcGSjRcC0KLEE0QNL11TV7QCgVNyTdELqorD0ZkqwIzQnNec0eMFL62P9OaF6hPBGaS2bRWEL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