Skip to content

Commit

Permalink
Simplify pthreads library detection
Browse files Browse the repository at this point in the history
Use the cmake builtin Threads library detection, and bail out if it
wasn't pthreads. This allows deleting the cmake/FindPTHREAD.cmake file
which complains because pthreads doesn't provide a pkg-config file.

In newer versions of cmake the FindThreads module has the
THREADS_PREFER_PTHREAD_FLAG variable and creates a Threads::Threads
import target. However, in order top remain compatible with older
cmake version this is not used.
  • Loading branch information
jabl committed Sep 13, 2017
1 parent 205df66 commit f739af1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 47 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

find_required_package(GTK)
find_required_package(PTHREAD)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "pthreads thread library not found")
endif()

find_suggested_package(GCRYPT)
find_suggested_package(AVAHI)

Expand Down
38 changes: 0 additions & 38 deletions cmake/FindPTHREAD.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion remmina-plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set(APPICON16_EMBLEMS_DIR "${REMMINA_DATADIR}/icons/hicolor/16x16/emblems")
set(APPICON22_EMBLEMS_DIR "${REMMINA_DATADIR}/icons/hicolor/22x22/emblems")

set(REMMINA_COMMON_INCLUDE_DIRS ${GTK_INCLUDE_DIRS})
set(REMMINA_COMMON_LIBRARIES ${GTK_LIBRARIES} ${PTHREAD_LIBRARY})
set(REMMINA_COMMON_LIBRARIES ${GTK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

find_suggested_package(LIBSSH)
if(LIBSSH_FOUND)
Expand Down
4 changes: 2 additions & 2 deletions remmina-plugins/rdp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
# files in the program, then also delete it here.


set(CMAKE_THREAD_PREFER_PTHREAD)
find_package(Threads)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
find_package(X11)

set(REMMINA_PLUGIN_RDP_SRCS
Expand Down
7 changes: 2 additions & 5 deletions remmina/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,15 @@ find_package(X11)
include_directories(${X11_INCLUDE_DIR})
target_link_libraries(remmina ${X11_LIBRARIES})

target_link_libraries(remmina ${CMAKE_THREAD_LIBS_INIT})

find_suggested_package(LIBSSH)
if(LIBSSH_FOUND)
add_definitions(-DHAVE_LIBSSH)
include_directories(${LIBSSH_INCLUDE_DIRS})
target_link_libraries(remmina ${LIBSSH_LIBRARIES})
endif()

if(PTHREAD_FOUND)
include_directories(${PTHREAD_INCLUDE_DIRS})
target_link_libraries(remmina ${PTHREAD_LIBRARIES})
endif()

if(GCRYPT_FOUND)
include_directories(${GCRYPT_INCLUDE_DIRS})
target_link_libraries(remmina ${GCRYPT_LIBRARIES})
Expand Down

0 comments on commit f739af1

Please sign in to comment.