cmake: fix linking when mbed TLS not in default paths
authorPetr Štetiar <ynezz@true.cz>
Thu, 10 Dec 2020 11:16:01 +0000 (12:16 +0100)
committerPetr Štetiar <ynezz@true.cz>
Thu, 10 Dec 2020 11:18:05 +0000 (12:18 +0100)
Fixes following issue when mbed TLS libs are installed in different
paths:

 /usr/bin/ld: cannot find -lmbedtls
 /usr/bin/ld: cannot find -lmbedcrypto
 /usr/bin/ld: cannot find -lmbedx509

Signed-off-by: Petr Štetiar <ynezz@true.cz>
CMakeLists.txt

index 42c7f1fb00de34c39f0974882e3a91ef699ceb5b..bb2abe5af596ec9f17be06c7bdb9c995db7f1de6 100644 (file)
@@ -10,7 +10,10 @@ SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 IF(MBEDTLS)
   ADD_DEFINITIONS(-DHAVE_MBEDTLS)
   SET(SSL_SRC ustream-mbedtls.c)
-  SET(SSL_LIB mbedtls mbedcrypto mbedx509 m)
+  FIND_LIBRARY(mbedtls_library mbedtls)
+  FIND_LIBRARY(mbedx509_library mbedx509)
+  FIND_LIBRARY(mbedcrypto_library mbedcrypto)
+  SET(SSL_LIB ${mbedtls_library} ${mbedx509_library} ${mbedcrypto_library} m)
 ELSEIF(WOLFSSL)
   ADD_DEFINITIONS(-DHAVE_WOLFSSL)
   FIND_LIBRARY(wolfssl_library wolfssl)