From 0092dc16ac1b896ca93c59fad802dfeb741fd8a4 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 10 Aug 2018 16:47:17 -0700 Subject: [PATCH] msys2: don't try to link msys librt and libpthread In cmake on Win32, don't try to find librt or libpthread using find_library(), and on mingw just include -lpthread. For some reason the msys versions of librt and libpthread were being picked up when find_library() was being used. --- CMakeLists.txt | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2032a09f..cf745f98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,16 +253,23 @@ add_definitions(-DPKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam" -DPACKAGE=) if(ENABLE_LINK) # IPC linking code needs sem_timedwait which can be either in librt or pthreads - find_library(RT_LIB rt) - if(RT_LIB) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${RT_LIB}) - set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${RT_LIB}) + if(NOT WIN32) + find_library(RT_LIB rt) + if(RT_LIB) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${RT_LIB}) + set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${RT_LIB}) + endif() endif() - find_library(PTHREAD_LIB pthread) - if(PTHREAD_LIB) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PTHREAD_LIB}) - set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${PTHREAD_LIB}) + if(NOT WIN32) + find_library(PTHREAD_LIB pthread) + if(PTHREAD_LIB) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PTHREAD_LIB}) + set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${PTHREAD_LIB}) + endif() + elseif(MINGW) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lpthread) + set(VBAMCORE_LIBS ${VBAMCORE_LIBS} -lpthread) endif() include(CheckFunctionExists)