]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Link Threads::Threads as PRIVATE to liblzma
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 15 Jun 2024 20:34:29 +0000 (23:34 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 6 Sep 2024 16:07:09 +0000 (19:07 +0300)
This way pthread options aren't passed to the linker when linking
against shared liblzma but they are still passed when linking against
static liblzma. (Also, one never needs the include path of the
threading library to use liblzma since liblzma's API headers
don't #include <pthread.h>. But <pthread.h> tends to be in the
default include path so here this change makes no difference.)

One cannot mix target_link_libraries() calls that use the scope
(PRIVATE, PUBLIC, or INTERFACE) keyword and calls that don't use it.
The calls without the keyword are like PUBLIC except perhaps when
they aren't, or something like that... It seems best to always
specify a scope keyword as the meanings of those three keywords
at least are clear.

(cherry picked from commit ac05f1b0d7cda1e7ae79775a8dfecc54601d7f1c)

CMakeLists.txt

index fb701ec338f65737fc425a7b4c763bc98e5b3fdd..d60649d66df285397bd90fd2ff9a3ba9a5e299af 100644 (file)
@@ -629,7 +629,7 @@ if(ENABLE_THREADS)
             # liblzma-config.cmake later.
             set(USE_POSIX_THREADS ON)
 
-            target_link_libraries(liblzma Threads::Threads)
+            target_link_libraries(liblzma PRIVATE Threads::Threads)
             add_compile_definitions(MYTHREAD_POSIX)
 
             # Check if pthread_condattr_setclock() exists to