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")