]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Always add pthread flags into CMAKE_REQUIRED_LIBRARIES
authorLasse Collin <lasse.collin@tukaani.org>
Tue, 25 Jun 2024 12:51:48 +0000 (15:51 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 6 Sep 2024 16:25:03 +0000 (19:25 +0300)
It was weird to add CMAKE_THREAD_LIBS_INIT in CMAKE_REQUIRED_LIBRARIES
only if CLOCK_MONOTONIC is available. Alternative would be to remove
the thread libs from CMAKE_REQUIRED_LIBRARIES after the check for
pthread_condattr_setclock() but keeping the libs should be fine too.
Then it's ready in case more pthread functions were wanted some day.

(cherry picked from commit e620f35097c0ad20cd76d8258750aa706758ced9)

CMakeLists.txt

index 95589b8d377b5a646fd67ca502f4d594ac024473..f7ebb0241d187c2c455d22dc68ddd942449bf1c2 100644 (file)
@@ -638,11 +638,13 @@ if(ENABLE_THREADS)
             target_link_libraries(liblzma PRIVATE Threads::Threads)
             add_compile_definitions(MYTHREAD_POSIX)
 
+            # Make the thread libs available in later checks. In practice
+            # only pthread_condattr_setclock check should need this.
+            list(INSERT CMAKE_REQUIRED_LIBRARIES 0 "${CMAKE_THREAD_LIBS_INIT}")
+
             # Check if pthread_condattr_setclock() exists to
             # use CLOCK_MONOTONIC.
             if(HAVE_CLOCK_MONOTONIC)
-                list(INSERT CMAKE_REQUIRED_LIBRARIES 0
-                     "${CMAKE_THREAD_LIBS_INIT}")
                 check_symbol_exists(pthread_condattr_setclock pthread.h
                                     HAVE_PTHREAD_CONDATTR_SETCLOCK)
                 tuklib_add_definition_if(ALL HAVE_PTHREAD_CONDATTR_SETCLOCK)