From b7e5451ef42b8536db4a8e7637f53279e507c315 Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 20 Aug 2025 18:07:59 +1000 Subject: [PATCH] Try fixing a compilation error when pthread does not exist. --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe03ce64..18e5261b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -458,8 +458,15 @@ if (UNIX) endif() endif() - list(APPEND COMMON_LINK_LIBRARIES pthread) # Some compilers will not link to pthread by default so list it here just in case. - list(APPEND COMMON_LINK_LIBRARIES m) + find_library(LIB_PTHREAD NAMES pthread) + if(LIB_PTHREAD) + list(APPEND COMMON_LINK_LIBRARIES pthread) # Some compilers will not link to pthread by default so list it here just in case. + endif() + + find_library(LIB_M NAMES m) + if(LIB_M) + list(APPEND COMMON_LINK_LIBRARIES m) + endif() # If we're compiling for 32-bit ARM we need to link to -latomic. if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")