cmake: use imported targets for OpenSSL and zlib

Imported targets are highly preferred over the individual variables
for includes and libs because they will be used in a coherent way
and any spelling mistakes or unavailability won't go unnoticed.

Also it will prevent bugs like conan-io/conan-center-index#16900
or using mismatching header/libs combinations.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Gregor Jasny
2023-04-05 16:36:19 +02:00
committed by Jakub Jelen
parent 486d2289fa
commit 6ad455a8ac
7 changed files with 8 additions and 56 deletions

View File

@@ -6,9 +6,7 @@ endif (BSD OR SOLARIS OR OSX)
set(TORTURE_LIBRARY torture)
include_directories(${OPENSSL_INCLUDE_DIR}
${CMOCKA_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
include_directories(${CMOCKA_INCLUDE_DIR}
${libssh_BINARY_DIR}/include
${libssh_BINARY_DIR}
${libssh_SOURCE_DIR}/src

View File

@@ -44,7 +44,7 @@ else ()
${libssh_SOURCE_DIR}/src/md_crypto.c
)
set(override_libs
${OPENSSL_CRYPTO_LIBRARIES}
OpenSSL::Crypto
)
endif (WITH_GCRYPT)

View File

@@ -5,7 +5,6 @@ if (WITH_SERVER AND UNIX AND NOT WIN32)
include_directories(${libssh_SOURCE_DIR}/include
${libssh_BINARY_DIR}/include
${CMOCKA_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
${libssh_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR})

View File

@@ -1,7 +1,5 @@
project(unittests C)
include_directories(${OPENSSL_INCLUDE_DIR})
set(LIBSSH_UNIT_TESTS
torture_bignum
torture_buffer