CMake: cleanup, use find_package for pthreads
authorCampbell Barton <ideasman42@gmail.com>
Sat, 15 Nov 2014 15:46:30 +0000 (16:46 +0100)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 15 Nov 2014 15:46:30 +0000 (16:46 +0100)
CMakeLists.txt

index 7b2e5b95663d6eb548fcd3f5aa1d20e38c251d2f..34657888cc0ef0ba9ea8c7524ac939336f1c11f4 100644 (file)
@@ -1070,7 +1070,14 @@ if(UNIX AND NOT APPLE)
        endif()
 
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
-       list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm -lpthread)
+       list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm)
+
+       find_package(Threads REQUIRED)
+       list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT})
+
+       if(CMAKE_DL_LIBS)
+               list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS})
+       endif()
 
        if(CMAKE_SYSTEM_NAME MATCHES "Linux")
                if(NOT WITH_PYTHON_MODULE)
@@ -1080,11 +1087,6 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
-       set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -pthread")
-       if(CMAKE_DL_LIBS)
-               list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS})
-       endif()
-
        # lfs on glibc, all compilers should use
        add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)