Skip to content

cmake: make Threads package optional - #354

Open
ryanofsky wants to merge 1 commit into
bitcoin-core:masterfrom
ryanofsky:pr/cmake-threads
Open

cmake: make Threads package optional#354
ryanofsky wants to merge 1 commit into
bitcoin-core:masterfrom
ryanofsky:pr/cmake-threads

Conversation

@ryanofsky

Copy link
Copy Markdown
Collaborator

Make find_package(Threads) optional because there are platforms where this package may not be required, and because find_package(Threads REQUIRED) errors obscure more detailed error messages and make issues harder to debug.

There errors can happen on different platforms with different cmake policy settings. See commit message for details.

Make find_package(Threads) optional because there are platforms where
this package may not be required, and because find_package(Threads
REQUIRED) errors obscure more detailed error messages and makes issues
harder to debug.

For example with CMP0155 enabled which turns CMAKE_CXX_SCAN_FOR_MODULES
on, find_package(Threads) fails on freebsd and openbsd CI jobs which
lack a clang-scan-deps tool. Also when CMP0137 is disabled or
CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES is set to true
find_package(Threadss) fails in the llvm CI job. This change lets builds
in both of those cases succeed.

The freebsd CMP0155 error looks like:

 + cmake /home/runner/work/libmultiprocess/libmultiprocess -G Ninja
-- The CXX compiler identification is Clang 16.0.6
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
CMake Error at /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:41 (find_package)

Inside the CMakeConfigureLog.yaml file there are "/bin/sh:
CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND: not found" errors.
@DrahtBot

DrahtBot commented Aug 20, 2026

Copy link
Copy Markdown

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

@maflcko

maflcko commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

~0: Same here. This won't happen in reality on current master, so better to leave in #209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants