diff options
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 125 |
1 files changed, 60 insertions, 65 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 621f8b35..93ecb5e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,6 @@ set(LIBSSH_PUBLIC_INCLUDE_DIRS ${libssh_SOURCE_DIR}/include) set(LIBSSH_PRIVATE_INCLUDE_DIRS - ${libssh_BINARY_DIR}/include ${libssh_BINARY_DIR} ) @@ -9,24 +8,9 @@ set(LIBSSH_LINK_LIBRARIES ${LIBSSH_REQUIRED_LIBRARIES} ) -if (WIN32) - set(LIBSSH_LINK_LIBRARIES - ${LIBSSH_LINK_LIBRARIES} - ws2_32 - ) -endif (WIN32) - -if (OPENSSL_CRYPTO_LIBRARY) - set(LIBSSH_PRIVATE_INCLUDE_DIRS - ${LIBSSH_PRIVATE_INCLUDE_DIRS} - ${OPENSSL_INCLUDE_DIR} - ) - - set(LIBSSH_LINK_LIBRARIES - ${LIBSSH_LINK_LIBRARIES} - ${OPENSSL_CRYPTO_LIBRARY} - ) -endif (OPENSSL_CRYPTO_LIBRARY) +if (TARGET OpenSSL::Crypto) + list(APPEND LIBSSH_LINK_LIBRARIES OpenSSL::Crypto) +endif () if (MBEDTLS_CRYPTO_LIBRARY) set(LIBSSH_PRIVATE_INCLUDE_DIRS @@ -51,15 +35,7 @@ if (GCRYPT_LIBRARIES) endif() if (WITH_ZLIB) - set(LIBSSH_PRIVATE_INCLUDE_DIRS - ${LIBSSH_PRIVATE_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIR} - ) - - set(LIBSSH_LINK_LIBRARIES - ${LIBSSH_LINK_LIBRARIES} - ${ZLIB_LIBRARY} - ) + list(APPEND LIBSSH_LINK_LIBRARIES ZLIB::ZLIB) endif (WITH_ZLIB) if (WITH_GSSAPI AND GSSAPI_FOUND) @@ -93,6 +69,16 @@ if (MINGW AND Threads_FOUND) ) endif() +# The ws2_32 needs to be last for mingw to build +# https://gitlab.com/libssh/libssh-mirror/-/issues/84 +if (WIN32) + set(LIBSSH_LINK_LIBRARIES + ${LIBSSH_LINK_LIBRARIES} + iphlpapi + ws2_32 + ) +endif (WIN32) + if (BUILD_STATIC_LIB) set(LIBSSH_STATIC_LIBRARY ssh_static @@ -112,6 +98,7 @@ set(libssh_SRCS config.c connect.c connector.c + crypto_common.c curve25519.c dh.c ecdh.c @@ -140,6 +127,7 @@ set(libssh_SRCS socket.c string.c threads.c + ttyopts.c wrapper.c external/bcrypt_pbkdf.c external/blowfish.c @@ -181,6 +169,8 @@ if (WITH_GCRYPT) gcrypt_missing.c pki_gcrypt.c ecdh_gcrypt.c + getrandom_gcrypt.c + md_gcrypt.c dh_key.c pki_ed25519.c external/ed25519.c @@ -204,52 +194,51 @@ elseif (WITH_MBEDTLS) mbedcrypto_missing.c pki_mbedcrypto.c ecdh_mbedcrypto.c + getrandom_mbedcrypto.c + md_mbedcrypto.c dh_key.c pki_ed25519.c external/ed25519.c external/fe25519.c external/ge25519.c external/sc25519.c - external/chacha.c - external/poly1305.c - chachapoly.c ) + if (NOT (HAVE_MBEDTLS_CHACHA20_H AND HAVE_MBEDTLS_POLY1305_H)) + set(libssh_SRCS + ${libssh_SRCS} + external/chacha.c + external/poly1305.c + chachapoly.c + ) + endif() + else (WITH_GCRYPT) set(libssh_SRCS ${libssh_SRCS} threads/libcrypto.c pki_crypto.c ecdh_crypto.c + getrandom_crypto.c + md_crypto.c libcrypto.c dh_crypto.c ) - if (NOT HAVE_OPENSSL_ED25519) - set(libssh_SRCS - ${libssh_SRCS} - pki_ed25519.c - external/ed25519.c - external/fe25519.c - external/ge25519.c - external/sc25519.c - ) - endif (NOT HAVE_OPENSSL_ED25519) - if (NOT (HAVE_OPENSSL_EVP_CHACHA20 AND HAVE_OPENSSL_EVP_POLY1305)) + if (NOT HAVE_OPENSSL_EVP_CHACHA20) set(libssh_SRCS ${libssh_SRCS} external/chacha.c external/poly1305.c chachapoly.c ) - endif (NOT (HAVE_OPENSSL_EVP_CHACHA20 AND HAVE_OPENSSL_EVP_POLY1305)) - if(OPENSSL_VERSION VERSION_LESS "1.1.0") - set(libssh_SRCS ${libssh_SRCS} libcrypto-compat.c) - endif() + endif (NOT HAVE_OPENSSL_EVP_CHACHA20) endif (WITH_GCRYPT) if (WITH_SFTP) set(libssh_SRCS ${libssh_SRCS} sftp.c + sftp_common.c + sftp_aio.c ) if (WITH_SERVER) @@ -291,12 +280,12 @@ if (WITH_GSSAPI AND GSSAPI_FOUND) endif (WITH_GSSAPI AND GSSAPI_FOUND) if (NOT WITH_NACL) - if (NOT HAVE_OPENSSL_ED25519) + if (NOT HAVE_LIBCRYPTO) set(libssh_SRCS ${libssh_SRCS} external/curve25519_ref.c ) - endif (NOT HAVE_OPENSSL_ED25519) + endif() endif (NOT WITH_NACL) # Set the path to the default map file @@ -335,11 +324,14 @@ endif (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT AND ABIMAP_FOUND) add_library(ssh ${libssh_SRCS}) target_compile_options(ssh PRIVATE - ${DEFAULT_C_COMPILE_FLAGS} - -D_GNU_SOURCE) + ${DEFAULT_C_COMPILE_FLAGS}) +if (CYGWIN) + target_compile_definitions(ssh PRIVATE _GNU_SOURCE) +endif () target_include_directories(ssh PUBLIC $<BUILD_INTERFACE:${libssh_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${libssh_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> PRIVATE ${LIBSSH_PRIVATE_INCLUDE_DIRS}) @@ -347,7 +339,7 @@ target_link_libraries(ssh PRIVATE ${LIBSSH_LINK_LIBRARIES}) if (WIN32 AND NOT BUILD_SHARED_LIBS) - set_target_properties(ssh PROPERTIES COMPILE_FLAGS "-DLIBSSH_STATIC") + target_compile_definitions(ssh PUBLIC "LIBSSH_STATIC") endif () add_library(ssh::ssh ALIAS ssh) @@ -358,9 +350,7 @@ if (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT) set(MAP_PATH "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dev.map") endif (ABIMAP_FOUND) - set_target_properties(ssh - PROPERTIES LINK_FLAGS - "-Wl,--version-script,\"${MAP_PATH}\"") + target_link_libraries(ssh PRIVATE "-Wl,--version-script,\"${MAP_PATH}\"") endif (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT) set_target_properties(ssh @@ -374,13 +364,17 @@ set_target_properties(ssh ) if (WITH_VISIBILITY_HIDDEN) - set_target_properties(ssh PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") + set_target_properties(ssh PROPERTIES C_VISIBILITY_PRESET hidden) endif (WITH_VISIBILITY_HIDDEN) if (MINGW) - set_target_properties(ssh PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup") - set_target_properties(ssh PROPERTIES COMPILE_FLAGS "-D_POSIX_SOURCE") + target_link_libraries(ssh PRIVATE "-Wl,--enable-stdcall-fixup") + target_compile_definitions(ssh PRIVATE "_POSIX_SOURCE") endif () +if (WITH_COVERAGE) + include(CodeCoverage) + append_coverage_compiler_flags_to_target(ssh) +endif (WITH_COVERAGE) install(TARGETS ssh @@ -397,12 +391,15 @@ if (BUILD_STATIC_LIB) add_library(ssh-static STATIC ${libssh_SRCS}) target_compile_options(ssh-static PRIVATE - ${DEFAULT_C_COMPILE_FLAGS} - -D_GNU_SOURCE) + ${DEFAULT_C_COMPILE_FLAGS}) + if (CYGWIN) + target_compile_definitions(ssh-static PRIVATE _GNU_SOURCE) + endif () target_include_directories(ssh-static PUBLIC $<BUILD_INTERFACE:${libssh_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${libssh_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> PRIVATE ${LIBSSH_PRIVATE_INCLUDE_DIRS}) target_link_libraries(ssh-static @@ -428,13 +425,11 @@ if (BUILD_STATIC_LIB) ) if (WIN32) - set_target_properties( - ssh-static - PROPERTIES - COMPILE_FLAGS - "-DLIBSSH_STATIC" - ) + target_compile_definitions(ssh-static PUBLIC "LIBSSH_STATIC") endif (WIN32) + if (WITH_COVERAGE) + append_coverage_compiler_flags_to_target(ssh-static) + endif (WITH_COVERAGE) endif (BUILD_STATIC_LIB) message(STATUS "Threads_FOUND=${Threads_FOUND}") |