From 6945188f733f7ca5270f07143ff99591f6d059fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Mon, 13 Jan 2025 16:13:23 +0100 Subject: [PATCH] Check for pthread.h in CMake if no package could be found When having `winpthreads-devel` from conda installed, `find_package(PThreads)` does not succeed although `pthread.h` is present. Co-authored-by: Tobias Diez --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51dc2c3c96..6f0786915e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,14 @@ if(MSVC) set(PThreads_LIBRARIES PThreads4W::PThreads4W) set(PThreads_INCLUDE_DIRS ${PThreads4W_INCLUDE_DIRS}) else() - find_package(PThreads REQUIRED) + find_package(PThreads) + if(NOT PThreads_FOUND) + include(CheckIncludeFile) + check_include_file(pthread.h HAVE_PTHREAD_H) + if(NOT HAVE_PTHREAD_H) + message(FATAL_ERROR "Could not find pthreads.") + endif() + endif() endif() set(FLINT_USES_PTHREAD ON CACHE BOOL "Use POSIX Threads.") else()