From 74b4e8a75872c75679b9913bbcbd139ed9c0fb0e Mon Sep 17 00:00:00 2001 From: Victor <35421250+Vic-Min@users.noreply.github.com> Date: Wed, 21 Mar 2018 19:44:25 +0300 Subject: [PATCH] =?UTF-8?q?Fixed=20bug=20of=20determining=20availability?= =?UTF-8?q?=20of=20functions=20=E2=80=98pthread=5Fgetconcurrency=E2=80=99,?= =?UTF-8?q?=20=E2=80=98pthread=5Fsetconcurrency=E2=80=99,=20=E2=80=98pthre?= =?UTF-8?q?ad=5Fsetaffinity=5Fnp=E2=80=99=20in=20=E2=80=98pthread=E2=80=99?= =?UTF-8?q?=20library?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CMake cannot find 'pthread_getconcurrency’, ‘pthread_setconcurrency’ and ‘pthread_setaffinity_np' functions in 'pthread' library because when linking internal cmake test did’t specifed ‘-l pthread’. --- src/OpenThreads/pthreads/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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}