From 66a2cc8e006b0f24fe07c3f74a411ae91c7a0ef1 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Mon, 19 Feb 2024 14:26:29 +1100 Subject: [PATCH] Emscripten wasm side module library --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bff18ff6e..6a6ca5b407 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -949,6 +949,24 @@ if(PNG_SHARED AND PNG_TOOLS) list(APPEND PNG_BIN_TARGETS png-fix-itxt) endif() +if(EMSCRIPTEN) + set(LIBPNG_WASM_SOURCES + ${pngfix_sources} + ) + add_executable(libpng_wasm + ${LIBPNG_WASM_SOURCES} + ) + target_include_directories(libpng_wasm PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include + ) + target_link_libraries(libpng_wasm ${ZLIB_LIBRARIES} ${M_LIBRARY}) + set_target_properties(libpng_wasm PROPERTIES COMPILE_FLAGS "-Os -fPIC -s SIDE_MODULE=1 ") + set_target_properties(libpng_wasm PROPERTIES LINK_FLAGS "-Os -fPIC -s WASM=1 -s SIDE_MODULE=1 -s STANDALONE_WASM --no-entry") + set(CMAKE_EXECUTABLE_SUFFIX ".wasm") + list(APPEND PNG_BIN_TARGETS libpng_wasm) +endif() + + # Create a symlink from src to dest (if possible), or, alternatively, # copy src to dest if different. function(create_symlink DEST_FILE)