From 1f68a41e38079373d763478ec56cc2eeafb26906 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Sun, 1 Sep 2019 09:40:27 -0400 Subject: [PATCH] bug: do not redefine targets in config file. If the config file is included twice (via `find_dependency()` or `find_package()`) some of the targets could get redefined, breaking the configuration. --- cmake/config.cmake.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in index 2dd920197..295501e56 100644 --- a/cmake/config.cmake.in +++ b/cmake/config.cmake.in @@ -38,7 +38,10 @@ foreach (_target type_expr) set(scoped_name "googleapis-c++::${_target}_protos") set(imported_name "googleapis_cpp_${_target}_protos") - add_library(${scoped_name} IMPORTED INTERFACE) - set_target_properties(${scoped_name} - PROPERTIES INTERFACE_LINK_LIBRARIES ${imported_name}) + if (NOT TARGET ${scoped_name}) + add_library(${scoped_name} IMPORTED INTERFACE) + set_target_properties(${scoped_name} + PROPERTIES INTERFACE_LINK_LIBRARIES + ${imported_name}) + endif () endforeach ()