From 29254747279e6bc178dd16e917c236486160cfed Mon Sep 17 00:00:00 2001 From: Ubaid Date: Thu, 25 Aug 2022 17:08:31 +0530 Subject: [PATCH] WASM: Optionally include ZLIB --- CMakeLists.txt | 11 ++++++++--- src/lpython/CMakeLists.txt | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb67b4dcd3..b8c70a06fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ set(LPYTHON_BUILD_TO_WASM no if (LPYTHON_BUILD_TO_WASM) set(HAVE_BUILD_TO_WASM yes) SET(WITH_WHEREAMI no) + SET(WITH_ZLIB no) add_definitions("-DHAVE_BUILD_TO_WASM=1") endif() @@ -103,9 +104,13 @@ if (WITH_WHEREAMI) add_definitions("-DHAVE_WHEREAMI=1") endif() -# Find ZLIB with our custom finder before including LLVM since the finder for LLVM -# might search for ZLIB again and find the shared libraries instead of the static ones -find_package(StaticZLIB REQUIRED) +if (WITH_ZLIB) + add_definitions("-DHAVE_ZLIB=1") + + # Find ZLIB with our custom finder before including LLVM since the finder for LLVM + # might search for ZLIB again and find the shared libraries instead of the static ones + find_package(StaticZLIB REQUIRED) +endif() # LLVM set(WITH_LLVM no CACHE BOOL "Build with LLVM support") diff --git a/src/lpython/CMakeLists.txt b/src/lpython/CMakeLists.txt index 41a32fb485..df49f1d44c 100644 --- a/src/lpython/CMakeLists.txt +++ b/src/lpython/CMakeLists.txt @@ -22,7 +22,12 @@ if (WITH_XEUS) ) endif() add_library(lpython_lib ${SRC}) -target_link_libraries(lpython_lib asr lpython_runtime_static ZLIB::ZLIB) +target_link_libraries(lpython_lib asr lpython_runtime_static) + +if (WITH_ZLIB) + target_link_libraries(lpython_lib ZLIB::ZLIB) +endif() + target_include_directories(lpython_lib BEFORE PUBLIC ${lpython_SOURCE_DIR}/src) target_include_directories(lpython_lib BEFORE PUBLIC ${lpython_BINARY_DIR}/src) if (WITH_XEUS)