From: Charles Giessen Date: Wed, 3 Nov 2021 20:28:03 +0000 (-0600) Subject: Use the CMake Threads package X-Git-Tag: upstream/1.3.208~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3b4b13a8eff80bea67b2536128ce1a41e4cd9ad;p=platform%2Fupstream%2FVulkan-Loader.git Use the CMake Threads package Instead of manually linking to pthreads, use find_package(Threads) to get the platform specific name for the threading library and link to it. Use the THREADS_PREFER_PTHREAD_FLAG to ensure we prefer pthreads before anything else. Note that this commit is a part of a series of commits and not intended to work by itself. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe08902..e3c7c94c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,9 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(PythonInterp 3 QUIET) +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) + option(BUILD_TESTS "Build Tests" OFF) if(BUILD_TESTS) diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index acea3da5..f867a9a1 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -289,7 +289,7 @@ else() VERSION ${LOADER_GENERATED_HEADER_VERSION}) target_link_libraries(vulkan ${CMAKE_DL_LIBS} m) if (NOT ANDROID) - target_link_libraries(vulkan pthread) + target_link_libraries(vulkan Threads::Threads) endif() # Used to make alloca() and secure_getenv() available target_compile_definitions(vulkan PRIVATE _GNU_SOURCE)