diff --git a/source/loader/CMakeLists.txt b/source/loader/CMakeLists.txt index b1a3e8bb91..db796612ea 100644 --- a/source/loader/CMakeLists.txt +++ b/source/loader/CMakeLists.txt @@ -48,6 +48,14 @@ if (UNIX) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) target_link_libraries(ur_loader PRIVATE Threads::Threads) + # Older gcc versions need -pthread, not just -lpthread + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.1) + if(CMAKE_USE_PTHREADS_INIT) + target_link_libraries(ur_loader PRIVATE "-pthread") + endif() + endif() + endif() endif() if(WIN32)