From: Yann Collet Date: Mon, 11 Mar 2024 23:11:15 +0000 (-0700) Subject: cmake refactor: move HP-UX specific logic into its own function X-Git-Tag: v1.5.6^2~39^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6039f3d5fa607555fc193042671a05bf5029bad;p=thirdparty%2Fzstd.git cmake refactor: move HP-UX specific logic into its own function reduce visual clutter of corner case configuration. --- diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 50b1bb95c..399b818fc 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -114,20 +114,25 @@ endif () #----------------------------------------------------------------------------- # External dependencies #----------------------------------------------------------------------------- +# Define a function to handle special thread settings for HP-UX +# See https://github.com/facebook/zstd/pull/3862 for details. +function(setup_hpux_threads) + find_package(Threads) + if (NOT Threads_FOUND) + set(CMAKE_USE_PTHREADS_INIT 1 PARENT_SCOPE) + set(CMAKE_THREAD_LIBS_INIT -lpthread PARENT_SCOPE) + set(CMAKE_HAVE_THREADS_LIBRARY 1 PARENT_SCOPE) + set(Threads_FOUND TRUE PARENT_SCOPE) + endif() +endfunction() + if (ZSTD_MULTITHREAD_SUPPORT AND UNIX) if (CMAKE_SYSTEM_NAME MATCHES "HP-UX") - find_package(Threads) - if (NOT Threads_FOUND) - set(CMAKE_USE_PTHREADS_INIT 1) - set(CMAKE_THREAD_LIBS_INIT -lpthread) - set(CMAKE_HAVE_THREADS_LIBRARY 1) - set(Threads_FOUND TRUE) - endif () - else () + setup_hpux_threads() + else() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) - endif () - + endif() if (CMAKE_USE_PTHREADS_INIT) set(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}") else()