mirror of
https://github.com/libssh2/libssh2.git
synced 2026-10-24 03:48:58 +03:00
cmake: rename two variables and initialize them
- `LIBRARIES` -> `LIBSSH2_LIBS` - `SOCKET_LIBRARIES` -> `LIBSSH2_LIBS_SOCKET` Also initialize them before use. Cherry-picked from #1445 Closes #1464
This commit is contained in:
@@ -96,17 +96,20 @@ install(
|
||||
|
||||
include(PickyWarnings)
|
||||
|
||||
set(LIBSSH2_LIBS_SOCKET "")
|
||||
set(LIBSSH2_LIBS "")
|
||||
|
||||
# Add socket libraries
|
||||
if(WIN32)
|
||||
list(APPEND SOCKET_LIBRARIES "ws2_32")
|
||||
list(APPEND LIBSSH2_LIBS_SOCKET "ws2_32")
|
||||
else()
|
||||
check_function_exists_may_need_library("socket" HAVE_SOCKET "socket")
|
||||
if(NEED_LIB_SOCKET)
|
||||
list(APPEND SOCKET_LIBRARIES "socket")
|
||||
list(APPEND LIBSSH2_LIBS_SOCKET "socket")
|
||||
endif()
|
||||
check_function_exists_may_need_library("inet_addr" HAVE_INET_ADDR "nsl")
|
||||
if(NEED_LIB_NSL)
|
||||
list(APPEND SOCKET_LIBRARIES "nsl")
|
||||
list(APPEND LIBSSH2_LIBS_SOCKET "nsl")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -270,7 +273,7 @@ endif()
|
||||
# dependencies which might not have been built yet.
|
||||
if(NOT WIN32)
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${SOCKET_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBS_SOCKET})
|
||||
check_nonblocking_socket_support()
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
@@ -302,14 +305,14 @@ if(CRYPTO_BACKEND STREQUAL "OpenSSL" OR NOT CRYPTO_BACKEND)
|
||||
set(CRYPTO_BACKEND "OpenSSL")
|
||||
set(CRYPTO_BACKEND_DEFINE "LIBSSH2_OPENSSL")
|
||||
set(CRYPTO_BACKEND_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
|
||||
list(APPEND LIBRARIES OpenSSL::SSL)
|
||||
list(APPEND LIBSSH2_LIBS OpenSSL::SSL)
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lcrypto")
|
||||
list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE "libcrypto")
|
||||
|
||||
if(WIN32)
|
||||
# Statically linking to OpenSSL requires crypt32 for some Windows APIs.
|
||||
# This should really be handled by FindOpenSSL.cmake.
|
||||
list(APPEND LIBRARIES "crypt32" "bcrypt")
|
||||
list(APPEND LIBSSH2_LIBS "crypt32" "bcrypt")
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lcrypt32" "-lbcrypt")
|
||||
|
||||
#set(CMAKE_FIND_DEBUG_MODE ON)
|
||||
@@ -333,7 +336,7 @@ if(CRYPTO_BACKEND STREQUAL "OpenSSL" OR NOT CRYPTO_BACKEND)
|
||||
find_package(ZLIB)
|
||||
|
||||
if(ZLIB_FOUND)
|
||||
list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${ZLIB_LIBRARIES})
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lz")
|
||||
endif()
|
||||
endif()
|
||||
@@ -347,12 +350,12 @@ if(CRYPTO_BACKEND STREQUAL "wolfSSL" OR NOT CRYPTO_BACKEND)
|
||||
set(CRYPTO_BACKEND "wolfSSL")
|
||||
set(CRYPTO_BACKEND_DEFINE "LIBSSH2_WOLFSSL")
|
||||
set(CRYPTO_BACKEND_INCLUDE_DIR ${WOLFSSL_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${WOLFSSL_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${WOLFSSL_LIBRARIES})
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lwolfssl")
|
||||
list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE "wolfssl")
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND LIBRARIES "crypt32")
|
||||
list(APPEND LIBSSH2_LIBS "crypt32")
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lcrypt32")
|
||||
endif()
|
||||
|
||||
@@ -360,7 +363,7 @@ if(CRYPTO_BACKEND STREQUAL "wolfSSL" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
if(ZLIB_FOUND)
|
||||
list(APPEND CRYPTO_BACKEND_INCLUDE_DIR ${ZLIB_INCLUDE_DIR}) # Public wolfSSL headers require zlib headers
|
||||
list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${ZLIB_LIBRARIES})
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lz")
|
||||
endif()
|
||||
endif()
|
||||
@@ -374,7 +377,7 @@ if(CRYPTO_BACKEND STREQUAL "Libgcrypt" OR NOT CRYPTO_BACKEND)
|
||||
set(CRYPTO_BACKEND "Libgcrypt")
|
||||
set(CRYPTO_BACKEND_DEFINE "LIBSSH2_LIBGCRYPT")
|
||||
set(CRYPTO_BACKEND_INCLUDE_DIR ${LIBGCRYPT_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${LIBGCRYPT_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${LIBGCRYPT_LIBRARIES})
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lgcrypt")
|
||||
list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE "libgcrypt")
|
||||
endif()
|
||||
@@ -388,7 +391,7 @@ if(CRYPTO_BACKEND STREQUAL "mbedTLS" OR NOT CRYPTO_BACKEND)
|
||||
set(CRYPTO_BACKEND "mbedTLS")
|
||||
set(CRYPTO_BACKEND_DEFINE "LIBSSH2_MBEDTLS")
|
||||
set(CRYPTO_BACKEND_INCLUDE_DIR ${MBEDTLS_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${MBEDTLS_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${MBEDTLS_LIBRARIES})
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lmbedcrypto")
|
||||
list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE "mbedcrypto")
|
||||
link_directories(${MBEDTLS_LIBRARY_DIR})
|
||||
@@ -402,7 +405,7 @@ if(CRYPTO_BACKEND STREQUAL "WinCNG" OR NOT CRYPTO_BACKEND)
|
||||
set(CRYPTO_BACKEND "WinCNG")
|
||||
set(CRYPTO_BACKEND_DEFINE "LIBSSH2_WINCNG")
|
||||
set(CRYPTO_BACKEND_INCLUDE_DIR "")
|
||||
list(APPEND LIBRARIES "crypt32" "bcrypt")
|
||||
list(APPEND LIBSSH2_LIBS "crypt32" "bcrypt")
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lcrypt32" "-lbcrypt")
|
||||
|
||||
option(ENABLE_ECDSA_WINCNG "Enable WinCNG ECDSA support (requires Windows 10 or later)" OFF)
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
include(CopyRuntimeDependencies)
|
||||
|
||||
list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${LIBSSH2_LIBS_SOCKET})
|
||||
|
||||
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
# Get 'noinst_PROGRAMS' variable
|
||||
@@ -51,7 +51,7 @@ foreach(_example IN LISTS noinst_PROGRAMS)
|
||||
target_include_directories(${_example} PRIVATE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../src"
|
||||
"../src")
|
||||
target_link_libraries(${_example} ${LIB_SELECTED} ${LIBRARIES})
|
||||
target_link_libraries(${_example} ${LIB_SELECTED} ${LIBSSH2_LIBS})
|
||||
set_target_properties(${_example} PROPERTIES UNITY_BUILD OFF)
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ if(ENABLE_ZLIB_COMPRESSION)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
list(APPEND libssh2_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${ZLIB_LIBRARIES})
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lz")
|
||||
list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE "zlib")
|
||||
if(ZLIB_FOUND)
|
||||
@@ -71,7 +71,7 @@ if(ENABLE_ZLIB_COMPRESSION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${LIBSSH2_LIBS_SOCKET})
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lws2_32")
|
||||
@@ -113,7 +113,7 @@ if(BUILD_STATIC_LIBS)
|
||||
add_library(${LIB_STATIC} STATIC ${_sources})
|
||||
add_library(${PROJECT_NAME}::${LIB_STATIC} ALIAS ${LIB_STATIC})
|
||||
target_compile_definitions(${LIB_STATIC} PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} ${_libssh2_definitions})
|
||||
target_link_libraries(${LIB_STATIC} PRIVATE ${LIBRARIES})
|
||||
target_link_libraries(${LIB_STATIC} PRIVATE ${LIBSSH2_LIBS})
|
||||
set_target_properties(${LIB_STATIC} PROPERTIES
|
||||
PREFIX "" OUTPUT_NAME "libssh2" SOVERSION "${_libssh2_soversion}" VERSION "${_libssh2_libversion}"
|
||||
SUFFIX "${STATIC_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
@@ -136,7 +136,7 @@ if(BUILD_SHARED_LIBS)
|
||||
endif()
|
||||
target_compile_definitions(${LIB_SHARED} PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} ${_libssh2_definitions} ${LIB_SHARED_DEFINITIONS})
|
||||
target_compile_options(${LIB_SHARED} PRIVATE ${LIB_SHARED_C_FLAGS})
|
||||
target_link_libraries(${LIB_SHARED} PRIVATE ${LIBRARIES})
|
||||
target_link_libraries(${LIB_SHARED} PRIVATE ${LIBSSH2_LIBS})
|
||||
set_target_properties(${LIB_SHARED} PROPERTIES
|
||||
PREFIX "" OUTPUT_NAME "libssh2" SOVERSION "${_libssh2_soversion}" VERSION "${_libssh2_libversion}"
|
||||
IMPORT_PREFIX "" IMPORT_SUFFIX "${IMPORT_LIB_SUFFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}"
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
include(CopyRuntimeDependencies)
|
||||
|
||||
list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
|
||||
list(APPEND LIBSSH2_LIBS ${LIBSSH2_LIBS_SOCKET})
|
||||
|
||||
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
||||
# Get 'DOCKER_TESTS', 'DOCKER_TESTS_STATIC', 'STANDALONE_TESTS', 'STANDALONE_TESTS_STATIC', 'SSHD_TESTS',
|
||||
@@ -104,9 +104,9 @@ foreach(_test IN LISTS DOCKER_TESTS STANDALONE_TESTS SSHD_TESTS)
|
||||
# build a single test with gcov
|
||||
if(GCOV_PATH AND _test STREQUAL "test_auth_keyboard_info_request" AND TARGET ${LIB_STATIC})
|
||||
target_compile_options(${_test} BEFORE PRIVATE ${_gcov_cflags})
|
||||
target_link_libraries(${_test} runner ${_lib_for_tests} ${LIBRARIES} "gcov")
|
||||
target_link_libraries(${_test} runner ${_lib_for_tests} ${LIBSSH2_LIBS} "gcov")
|
||||
else()
|
||||
target_link_libraries(${_test} runner ${_lib_for_tests} ${LIBRARIES})
|
||||
target_link_libraries(${_test} runner ${_lib_for_tests} ${LIBSSH2_LIBS})
|
||||
endif()
|
||||
|
||||
list(APPEND TEST_TARGETS ${_test})
|
||||
|
||||
Reference in New Issue
Block a user