about summary refs log tree commit diff
path: root/cmake/config.cmake.in
diff options
context:
space:
mode:
authorCarlos O'Ryan <coryan@users.noreply.github.com>2019-09-01T13·40-0400
committerCarlos O'Ryan <coryan@users.noreply.github.com>2019-09-01T13·40-0400
commit1f68a41e38079373d763478ec56cc2eeafb26906 (patch)
tree9c5c8d6ba52c73c2602192f82c4fb3c43462a664 /cmake/config.cmake.in
parent51d2b0895c8e301cd132038252734df0ed41afc4 (diff)
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.
Diffstat (limited to 'cmake/config.cmake.in')
-rw-r--r--cmake/config.cmake.in9
1 files changed, 6 insertions, 3 deletions
diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in
index 2dd9201977c0..295501e569b9 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 ()