Update CMakeLists.txt to support Emscripten

This commit is contained in:
Dan Rosser 2024-02-15 22:14:42 +11:00 committed by GitHub
parent 8e42eef495
commit 91201e04f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -421,6 +421,24 @@ if (FMT_TEST)
add_subdirectory(test)
endif ()
if(EMSCRIPTEN)
set(FMT_WASM_SOURCES
${FMT_SOURCES}
${FMT_HEADERS}
)
add_executable(fmt_wasm
${FMT_WASM_SOURCES}
)
target_include_directories(fmt_wasm PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
set_target_properties(fmt_wasm PROPERTIES COMPILE_FLAGS "-Os -s SIDE_MODULE=1 ")
set_target_properties(fmt_wasm PROPERTIES LINK_FLAGS "-Os -s WASM=1 -s SIDE_MODULE=1 -s STANDALONE_WASM --no-entry")
set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
endif()
# Control fuzzing independent of the unit tests.
if (FMT_FUZZ)
add_subdirectory(test/fuzzing)