Skip to content

Commit

Permalink
CMake: check if -lsocket is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
DerDakon committed Jul 5, 2020
1 parent 55f8044 commit a5208f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CMakeDependentOption)
include(GNUInstallDirs)

# Find library needed for connect. Taken from FindX11.cmake
check_function_exists("connect" CMAKE_HAVE_CONNECT)
if(NOT CMAKE_HAVE_CONNECT)
check_library_exists("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT)
if (CMAKE_LIB_SOCKET_HAS_CONNECT)
set(CMAKE_SOCKET_LIB socket)
endif ()
endif()

find_package(owfat REQUIRED)

if (COMMAND cmake_policy)
Expand Down
4 changes: 4 additions & 0 deletions cmake/Modules/Findowfat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if(OWFAT_FOUND)
set_target_properties(owfat::owfat PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${OWFAT_LIBRARY}")
if (CMAKE_SOCKET_LIB)
set_target_properties(owfat::owfat PROPERTIES
INTERFACE_LINK_LIBRARIES "${CMAKE_SOCKET_LIB}")
endif ()
endif ()
set(OWFAT_INCLUDE_DIRS ${OWFAT_INCLUDE_DIR})
endif()

0 comments on commit a5208f2

Please sign in to comment.