mirror of
https://github.com/BinomialLLC/basis_universal.git
synced 2026-08-23 19:48:09 +00:00
Enable building the encoder with Enscripten to WebAssebly as a Nodejs cli tool.
This commit is contained in:
@@ -33,7 +33,12 @@ if (NOT MSVC)
|
||||
set(GCC_COMPILE_FLAGS "${GCC_COMPILE_FLAGS} -m32")
|
||||
endif()
|
||||
|
||||
if (STATIC)
|
||||
if (EMSCRIPTEN)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS}")
|
||||
elseif (STATIC)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -static-libgcc -static-libstdc++ -static")
|
||||
else()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -Wl,-rpath .")
|
||||
@@ -85,15 +90,16 @@ if (NOT MSVC)
|
||||
target_link_libraries(basisu m pthread)
|
||||
endif()
|
||||
|
||||
install(TARGETS basisu DESTINATION bin)
|
||||
|
||||
if (UNIX)
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
if (APPLE)
|
||||
add_custom_command(TARGET basisu POST_BUILD COMMAND strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu)
|
||||
else()
|
||||
add_custom_command(TARGET basisu POST_BUILD COMMAND strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT EMSCRIPTEN)
|
||||
install(TARGETS basisu DESTINATION bin)
|
||||
|
||||
if (UNIX)
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
if (APPLE)
|
||||
add_custom_command(TARGET basisu POST_BUILD COMMAND strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu)
|
||||
else()
|
||||
add_custom_command(TARGET basisu POST_BUILD COMMAND strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
9
build_emscripten.sh
Executable file
9
build_emscripten.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
if ! emcc --version
|
||||
then
|
||||
echo "Emscripten not found on PATH. Please follow instructions on https://emscripten.org/docs/getting_started/downloads.html"
|
||||
exit
|
||||
fi
|
||||
|
||||
emcmake cmake .
|
||||
emcmake make
|
||||
Reference in New Issue
Block a user