Skip to content

Commit

Permalink
Check for pthread.h in CMake if no package could be found
Browse files Browse the repository at this point in the history
When having `winpthreads-devel` from conda installed,
`find_package(PThreads)` does not succeed although `pthread.h` is
present.

Co-authored-by: Tobias Diez <[email protected]>
  • Loading branch information
albinahlback and tobiasdiez committed Jan 13, 2025
1 parent 54bfda0 commit 6945188
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6945188

Please sign in to comment.