]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Use CMAKE_THREAD_LIBS_INIT in liblzma.pc only with pthreads
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 16 Jun 2024 16:37:36 +0000 (19:37 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 17 Jun 2024 15:20:21 +0000 (18:20 +0300)
This shouldn't make much difference in practice as on Windows
no flags are needed anyway and unitialized variable (when threading
is disabled) expands to empty. But it's clearer this way.

CMakeLists.txt

index d77d5fd07f3402911d62d4df44a336e224f06252..ff34acdbd03adcbadebb2313bb714a8d77c792b3 100644 (file)
@@ -1428,7 +1428,13 @@ else()
     set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
 endif()
 
-set(PTHREAD_CFLAGS "${CMAKE_THREAD_LIBS_INIT}")
+# Threads::Threads is linked in only when using POSIX threads.
+# Use an empty value if using Windows threads or if threading is disabled.
+set(PTHREAD_CFLAGS)
+if(USE_POSIX_THREADS)
+    set(PTHREAD_CFLAGS "${CMAKE_THREAD_LIBS_INIT}")
+endif()
+
 configure_file(src/liblzma/liblzma.pc.in liblzma.pc @ONLY)
 
 # Install the library binary. The INCLUDES specifies the include path that