diff --git a/src/OpenThreads/pthreads/CMakeLists.txt b/src/OpenThreads/pthreads/CMakeLists.txt index 56213b680..5c2f28121 100644 --- a/src/OpenThreads/pthreads/CMakeLists.txt +++ b/src/OpenThreads/pthreads/CMakeLists.txt @@ -33,6 +33,9 @@ ELSE() ADD_DEFINITIONS(-DHAVE_PTHREAD_CANCEL) ADD_DEFINITIONS(-DHAVE_PTHREAD_SETCANCELSTATE) + SET(CMAKE_REQUIRED_LIBRARIES_SAFE "${CMAKE_REQUIRED_LIBRARIES}") + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + CHECK_FUNCTION_EXISTS(pthread_yield HAVE_PTHREAD_YIELD) IF(HAVE_PTHREAD_YIELD) ADD_DEFINITIONS(-DHAVE_PTHREAD_YIELD) @@ -43,6 +46,7 @@ ELSE() CHECK_LIBRARY_EXISTS(rt sched_yield "" HAVE_SCHED_YIELD) IF(HAVE_SCHED_YIELD) SET(CMAKE_THREAD_LIBS_INIT "${CMAKE_THREAD_LIBS_INIT} -lrt") + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAFE} ${CMAKE_THREAD_LIBS_INIT}) ENDIF() ENDIF() IF(HAVE_SCHED_YIELD) @@ -110,9 +114,6 @@ ELSE() ENDIF() ENDIF() - SET(CMAKE_REQUIRED_LIBRARIES_SAFE "${CMAKE_REQUIRED_LIBRARIES}") - SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) - ADD_LIBRARY(${LIB_NAME} ${OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC} ${TARGET_H}