From bc4385e623142726542f91ca83abf3e46dd170d5 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Fri, 7 May 2021 09:48:10 +0100 Subject: [PATCH] CMake: Move check for pthread_setname_np to IIOD This function is not used in libiio, but is used by IIOD. Signed-off-by: Paul Cercueil --- CMakeLists.txt | 9 ++------- iiod/CMakeLists.txt | 7 +++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eac89549..9b4393efe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,13 +135,6 @@ check_symbol_exists(strndup "string.h" HAS_STRNDUP) check_symbol_exists(strerror_r "string.h" HAS_STRERROR_R) check_symbol_exists(newlocale "locale.h" HAS_NEWLOCALE) -if (NOT WIN32) - find_library(PTHREAD_LIBRARIES pthread) - set(CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARIES}) - check_symbol_exists(pthread_setname_np "pthread.h" HAS_PTHREAD_SETNAME_NP) - set(CMAKE_REQUIRED_LIBRARIES) -endif() - option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) if (ENABLE_IPV6) check_symbol_exists(in6addr_any "netinet/in.h" HAVE_IPV6) @@ -398,6 +391,8 @@ endif() if (NEED_THREADS) if (NOT WIN32) + find_library(PTHREAD_LIBRARIES pthread) + if (PTHREAD_LIBRARIES) list(APPEND LIBS_TO_LINK ${PTHREAD_LIBRARIES}) else() diff --git a/iiod/CMakeLists.txt b/iiod/CMakeLists.txt index 49049b488..9a0b6ff27 100644 --- a/iiod/CMakeLists.txt +++ b/iiod/CMakeLists.txt @@ -12,6 +12,13 @@ add_flex_bison_dependency(lexer parser) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARIES}) +set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +check_symbol_exists(pthread_setname_np "pthread.h" HAS_PTHREAD_SETNAME_NP) +set(CMAKE_REQUIRED_LIBRARIES) +set(CMAKE_REQUIRED_DEFINITIONS) + if (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCC) # flex sometimes generates code which generate sign comparison errors set_source_files_properties(${FLEX_lexer_OUTPUTS} PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")