Skip to content

Commit

Permalink
CMake: Move check for pthread_setname_np to IIOD
Browse files Browse the repository at this point in the history
This function is not used in libiio, but is used by IIOD.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed May 11, 2021
1 parent 945f08e commit bc4385e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 2 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions iiod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit bc4385e

Please sign in to comment.