]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Use interface library for better FindLibLZMA compatibility.
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 13 Feb 2021 21:31:27 +0000 (23:31 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sat, 13 Feb 2021 21:31:27 +0000 (23:31 +0200)
https://www.mail-archive.com/xz-devel@tukaani.org/msg00446.html

Thanks to Markus Rickert.

CMakeLists.txt

index 47ce5f56341bf9f1dc5bd6c59626e5c3369ddaf3..88bec28e9fad0c879b60af54026a528b0fe2f58b 100644 (file)
@@ -454,9 +454,16 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/liblzma-config.cmake"
 "include(CMakeFindDependencyMacro)
 set(THREADS_PREFER_PTHREAD_FLAG TRUE)
 find_dependency(Threads)
+
 include(\"\${CMAKE_CURRENT_LIST_DIR}/liblzma-targets.cmake\")
-# Be compatible with the spelling used by the FindLibLZMA module:
-add_library(LibLZMA::LibLZMA ALIAS 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)
 ")
 
 # Set CMAKE_INSTALL_LIBDIR and friends.