Skip to content

Commit db561f5

Browse files
authored
[cmake] FindBrotli: do not add Brotli:: targets if they already exist (#2249)
Not checking for this is terrible practice.
1 parent 35c52c1 commit db561f5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmake/FindBrotli.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ foreach(_listvar "common;common" "decoder;dec" "encoder;enc")
8686
# Check if the target was already found by Pkgconf
8787
if(TARGET PkgConfig::Brotli_${_component_name}${_brotli_stat_str})
8888
# ALIAS since we don't want the PkgConfig namespace on the Cmake library (for end-users)
89-
add_library(Brotli::${_component_name} ALIAS PkgConfig::Brotli_${_component_name}${_brotli_stat_str})
89+
if (NOT TARGET Brotli::${_component_name})
90+
add_library(Brotli::${_component_name} ALIAS PkgConfig::Brotli_${_component_name}${_brotli_stat_str})
91+
endif()
9092

9193
# Tells HANDLE_COMPONENTS we found the component
9294
set(Brotli_${_component_name}_FOUND TRUE)
@@ -139,7 +141,10 @@ foreach(_listvar "common;common" "decoder;dec" "encoder;enc")
139141
# Tells HANDLE_COMPONENTS we found the component
140142
set(Brotli_${_component_name}_FOUND TRUE)
141143

142-
add_library("Brotli::${_component_name}" UNKNOWN IMPORTED)
144+
if (NOT TARGET Brotli::${_component_name})
145+
add_library("Brotli::${_component_name}" UNKNOWN IMPORTED)
146+
endif()
147+
143148
# Attach the literal library and include dir to the IMPORTED target for the end-user
144149
set_target_properties("Brotli::${_component_name}" PROPERTIES
145150
INTERFACE_INCLUDE_DIRECTORIES "${Brotli_INCLUDE_DIR}"

0 commit comments

Comments
 (0)