aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorBenjamin Buch <bebuch@users.noreply.github.com>2023-06-06 15:32:45 +0200
committerGitHub <noreply@github.com>2023-06-06 21:32:45 +0800
commit0d94ba69220d894d2a86081821d2d7a89df5a10b (patch)
treebbd70c2a038b64a647f76d63c4219fc9b7b420ac /CMakeLists.txt
parentTranslations: Update the Esperanto translation. (diff)
downloadxz-0d94ba69220d894d2a86081821d2d7a89df5a10b.tar.xz
CMake: Protects against double find_package
Boost iostream uses `find_package` in quiet mode and then again uses `find_package` with required. This second call triggers a `add_library cannot create imported target "ZLIB::ZLIB" because another target with the same name already exists.` This can simply be fixed by skipping the alias part on secondary `find_package` runs.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt16
1 files changed, 9 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 55cd358c..458ad49d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -889,13 +889,15 @@ write_basic_package_version_file(
set(LZMA_CONFIG_CONTENTS
"include(\"\${CMAKE_CURRENT_LIST_DIR}/liblzma-targets.cmake\")
-# Be compatible with the spelling used by the FindLibLZMA module. This
-# doesn't use ALIAS because it would make CMake resolve LibLZMA::LibLZMA
-# to liblzma::liblzma instead of keeping the original spelling. Keeping
-# the original spelling is important for good FindLibLZMA compatibility.
-add_library(LibLZMA::LibLZMA INTERFACE IMPORTED)
-set_target_properties(LibLZMA::LibLZMA PROPERTIES
- INTERFACE_LINK_LIBRARIES liblzma::liblzma)
+if(NOT TARGET LibLZMA::LibLZMA)
+ # Be compatible with the spelling used by the FindLibLZMA module. This
+ # doesn't use ALIAS because it would make CMake resolve LibLZMA::LibLZMA
+ # to liblzma::liblzma instead of keeping the original spelling. Keeping
+ # the original spelling is important for good FindLibLZMA compatibility.
+ add_library(LibLZMA::LibLZMA INTERFACE IMPORTED)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ INTERFACE_LINK_LIBRARIES liblzma::liblzma)
+endif()
")
if(ENABLE_THREADS STREQUAL "posix")