Open
Description
As described in CMake docs:
Targets names created with add_executable(), add_library(), or 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() or 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 -S llvm -B build -G Ninja -C clang/cmake/caches/BOLT-PGO.cmake -DBOOTSTRAP_LLVM_ENABLE_LLD=ON\
-DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON\
-DPGO_INSTRUMENT_LTO=Thin\
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;lld;bolt"
omit some output ......
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)