From d37c9a248432bb9ec56f2bd9025e0b895f46c737 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:47:57 +0000 Subject: [PATCH] [FIXUP] cmake: Ensure C language is disabled for FindThreads Must be squashed with the commit d028a49c35abe55d6f53c2515cab30d30e726b08 "cmake: Build `bitcoin_util` static library". --- cmake/module/AddThreadsIfNeeded.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmake/module/AddThreadsIfNeeded.cmake b/cmake/module/AddThreadsIfNeeded.cmake index d11e9e5205566..2939f1a0c6fcb 100644 --- a/cmake/module/AddThreadsIfNeeded.cmake +++ b/cmake/module/AddThreadsIfNeeded.cmake @@ -7,8 +7,17 @@ function(add_threads_if_needed) # require Threads. Therefore, a proper check will be # appropriate here. + if(CMAKE_C_COMPILER_LOADED) + message(FATAL_ERROR [=[ + To make FindThreads check C++ language features, C language must be + disabled. This is essential, at least, when cross-compiling for MinGW-w64 + because two different threading models are available. + ]=] ) + endif() + set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) + set_target_properties(Threads::Threads PROPERTIES IMPORTED_GLOBAL TRUE) set(thread_local) if(MINGW)