Skip to content

Commit

Permalink
CMake: Link Threads::Threads as PRIVATE to liblzma
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Larhzu committed Jun 17, 2024
1 parent 82986d8 commit ac05f1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,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
Expand Down

0 comments on commit ac05f1b

Please sign in to comment.