Skip to content

Commit

Permalink
src/CMakeLists.txt: fix static build with a zlib and mbedtls
Browse files Browse the repository at this point in the history
Static build with a zlib-enabled mbedtls fails on:

[100%] Linking C executable example
/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: /home/buildroot/autobuild/instance-3/output-1/host/arm-buildroot-uclinux-uclibcgnueabi/sysroot/usr/lib/libmbedtls.a(ssl_tls.c.o): in function `mbedtls_ssl_transform_free.part.24':
ssl_tls.c:(.text+0xbc6): undefined reference to `deflateEnd'

As mbedtls does not provide a pkg-config file, search for zlib and link
with it if necessary

Fixes:
 - http://autobuild.buildroot.org/results/5891d12e90182460cde1ddfa0ca75e9fd55e3dff

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  • Loading branch information
ffontaine committed Dec 1, 2020
1 parent 92b6cd4 commit 0c2d854
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ else()
endif()
find_package(WolfSSL)
find_package(MbedTLS)
find_package(ZLIB)

if(UHTTPD_USE_OPENSSL)
if (NOT OPENSSL_FOUND)
Expand Down Expand Up @@ -97,7 +98,11 @@ else()
elseif(UHTTPD_USE_MBEDTLS)
set(SSL_NAME "MbedTLS(PolarSSL)")
set(SSL_INC ${MBEDTLS_INCLUDE_DIR})
set(SSL_LIB ${MBEDTLS_LIBRARIES})
if(ZLIB_FOUND)
set(SSL_LIB ${MBEDTLS_LIBRARIES} ${ZLIB_LIBRARIES})
else()
set(SSL_LIB ${MBEDTLS_LIBRARIES})
endif()
set(UHTTPD_HAVE_MBEDTLS_CONFIG 1)
endif()

Expand Down

0 comments on commit 0c2d854

Please sign in to comment.