1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-21 14:00:51 +03:00

cmake: restore non-Windows socket lib detection (#815)

I mistakenly pruned some non-Windows logic, also missing the fact that
our local `check_function_exists_may_need_library()` set the `NEED_*`
variables. Oddly, only `src` imported this function, yet also `examples`
and `tests` called it indirectly. The referenced `HAVE_SOCKET` /
`HAVE_INET_ADDR` variables might be coming from an upstream CMake
project? Leaving those there also, just in case.

Regression from 31fb8860db
This commit is contained in:
Viktor Szakats
2023-03-07 19:30:51 +01:00
committed by GitHub
parent 31fb8860db
commit 05c7d128c8
2 changed files with 13 additions and 1 deletions

View File

@@ -33,6 +33,9 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
include(CheckFunctionExistsMayNeedLibrary)
cmake_minimum_required(VERSION 3.1)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
@@ -79,8 +82,18 @@ install(
include(max_warnings)
include(FeatureSummary)
# Add socket libraries
if(WIN32)
list(APPEND LIBRARIES ws2_32)
else()
check_function_exists_may_need_library(socket HAVE_SOCKET socket)
if(NEED_LIB_SOCKET)
list(APPEND LIBRARIES socket)
endif()
check_function_exists_may_need_library(inet_addr HAVE_INET_ADDR nsl)
if(NEED_LIB_NSL)
list(APPEND LIBRARIES nsl)
endif()
endif()
add_subdirectory(src)

View File

@@ -35,7 +35,6 @@
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckFunctionExistsMayNeedLibrary)
include(CheckIncludeFiles)
include(CheckTypeSize)
include(CheckSymbolExists)