From 6be35093e1a39c6d090ac1c8ba079e6f30ae9a84 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Mon, 12 Feb 2024 03:20:02 +0100 Subject: [PATCH] Define string_theory target only if it doesn't exist yet This fixes errors when another project does find_package(string_theory) more than once, usually indirectly through another dependency. This happened for MoulKI for example, which depends on string_theory both directly and indirectly through libHSPlasma. --- cmake/string_theory-config.cmake.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/string_theory-config.cmake.in b/cmake/string_theory-config.cmake.in index 8ce2b49..a98a789 100644 --- a/cmake/string_theory-config.cmake.in +++ b/cmake/string_theory-config.cmake.in @@ -26,5 +26,7 @@ set(STRING_THEORY_LIBRARIES string_theory::string_theory) # Backwards-compatibility target. CMake <3.11 doesn't allow ALIAS libraries to # imported targets, so this is another IMPORTED target. -add_library(string_theory INTERFACE IMPORTED) -target_link_libraries(string_theory INTERFACE string_theory::string_theory) +if(NOT TARGET string_theory) + add_library(string_theory INTERFACE IMPORTED) + target_link_libraries(string_theory INTERFACE string_theory::string_theory) +endif()