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.
This commit is contained in:
Carlos O'Ryan 2019-09-01 09:40:27 -04:00
parent 51d2b0895c
commit 1f68a41e38
No known key found for this signature in database
GPG key ID: BC4C1DC8B0DEF583

View file

@ -38,7 +38,10 @@ foreach (_target
type_expr)
set(scoped_name "googleapis-c++::${_target}_protos")
set(imported_name "googleapis_cpp_${_target}_protos")
if (NOT TARGET ${scoped_name})
add_library(${scoped_name} IMPORTED INTERFACE)
set_target_properties(${scoped_name}
PROPERTIES INTERFACE_LINK_LIBRARIES ${imported_name})
PROPERTIES INTERFACE_LINK_LIBRARIES
${imported_name})
endif ()
endforeach ()