diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d5332d1a..4d40eea6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ endif() # Set the project root directory. set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF) + option(ENABLE_PROGRAMS "Build mbed TLS programs." ON) option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF) @@ -179,6 +181,14 @@ endif() include_directories(include/) include_directories(library/) +if(ENABLE_ZLIB_SUPPORT) + find_package(ZLIB) + + if(ZLIB_FOUND) + include_directories(${ZLIB_INCLUDE_DIR}) + endif(ZLIB_FOUND) +endif(ENABLE_ZLIB_SUPPORT) + add_subdirectory(include) add_subdirectory(3rdparty) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 8db082862..a602a6bfd 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -148,6 +148,10 @@ if(HAIKU) set(libs ${libs} network) endif(HAIKU) +if(ENABLE_ZLIB_SUPPORT) + set(libs ${libs} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB_SUPPORT) + if(LINK_WITH_PTHREAD) set(libs ${libs} pthread) endif() diff --git a/programs/Makefile b/programs/Makefile index c5ac76749..65a31b1b8 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -44,6 +44,11 @@ EXEXT= SHARED_SUFFIX= endif +# Zlib shared library extensions: +ifdef ZLIB +LOCAL_LDFLAGS += -lz +endif + APPS = \ aes/aescrypt2$(EXEXT) \ aes/crypt_and_hash$(EXEXT) \ diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 59f8d54f1..0d2b9460a 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -2,6 +2,10 @@ set(libs mbedtls ) +if(ENABLE_ZLIB_SUPPORT) + set(libs ${libs} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB_SUPPORT) + add_executable(selftest selftest.c) target_link_libraries(selftest ${libs}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a1194e520..ecc33eec0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,6 +9,10 @@ if(NOT DEFINED MBEDTLS_DIR) set(MBEDTLS_DIR ${CMAKE_SOURCE_DIR}) endif() +if(ENABLE_ZLIB_SUPPORT) + set(libs ${libs} ${ZLIB_LIBRARIES}) +endif(ENABLE_ZLIB_SUPPORT) + find_package(PythonInterp) if(NOT PYTHONINTERP_FOUND) message(FATAL_ERROR "Cannot build test suites without Python 2 or 3") diff --git a/tests/Makefile b/tests/Makefile index 3203b883e..cca7c1cf0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -55,6 +55,11 @@ SHARED_SUFFIX= PYTHON ?= python2 endif +# Zlib shared library extensions: +ifdef ZLIB +LOCAL_LDFLAGS += -lz +endif + # A test application is built for each suites/test_suite_*.data file. # Application name is same as .data file's base name and can be # constructed by stripping path 'suites/' and extension .data.