cmake: use Threads::Threads imported target for POSIX Threads

- use `Threads::Threads` imported target, replacing
  `CMAKE_THREAD_LIBS_INIT`. To use the modern form and to allow using
  `THREADS_PREFER_PTHREAD_FLAG` option.

- only add Threads library/options if POSIX Threads was detected (not
  any other threading backend FindThreads may detect, e.g. the HP one.)

- curl-config.in.cmake: detect and define `Threads::Threads`.

Refs:
https://cmake.org/cmake/help/v3.18/module/FindThreads.html
https://cmake.org/cmake/help/v4.3/module/FindThreads.html

Closes #21163
This commit is contained in:
Viktor Szakats 2026-03-28 23:23:01 +01:00
parent ce6c441cf2
commit 2d546d239e
No known key found for this signature in database
2 changed files with 9 additions and 2 deletions

View file

@ -35,6 +35,10 @@ endif()
include(CMakeFindDependencyMacro)
if("@HAVE_THREADS_POSIX@")
find_dependency(Threads) # for Threads::Threads
endif()
if("@USE_OPENSSL@")
if("@OPENSSL_VERSION_MAJOR@")
find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@")