From 06a0874647461f9e2b443f60724d6174949fb205 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Sun, 26 May 2024 11:23:24 -0400 Subject: [PATCH] build: Prevent the redefinition of `stdlib_pch` target in release builds ``` -- Precompiled headers were enabled CMake Error at build-support/macros-and-definitions.cmake:1272 (add_library): add_library cannot create ALIAS target "stdlib_pch" because another target with the same name already exists. Call Stack (most recent call first): CMakeLists.txt:149 (process_options) ``` Signed-off-by: Rui Chen --- build-support/macros-and-definitions.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index ee77503a6..97797231f 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -1297,7 +1297,11 @@ macro(process_options) stdlib_pch${build_profile_suffix} PUBLIC "${precompiled_header_libraries}" ) - add_library(stdlib_pch ALIAS stdlib_pch${build_profile_suffix}) + + # Alias may collide with actual pch in builds without suffix (e.g. release) + if(NOT TARGET stdlib_pch) + add_library(stdlib_pch ALIAS stdlib_pch${build_profile_suffix}) + endif() add_executable( stdlib_pch_exec ${PROJECT_SOURCE_DIR}/build-support/empty-main.cc