view Platforms/WebAssembly/CMakeLists.txt @ 227:c8f11437a6fd am

getting ready for multiple viewports
author am@osimis.io
date Thu, 14 Jun 2018 13:28:40 +0200
parents c993693e9e63
children
line wrap: on
line source

# Usage (Linux):
# source ~/Downloads/emsdk/emsdk_env.sh && cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake ..

cmake_minimum_required(VERSION 2.8.3)


#####################################################################
## Configuration of the Emscripten compiler for WebAssembly target
#####################################################################

set(WASM_FLAGS "-s WASM=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${CMAKE_SOURCE_DIR}/library.js")

# Handling of memory
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1")  # Resize
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912")  # 512MB
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912")  # 512MB + resize
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824")  # 1GB + resize

# To debug exceptions
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2")


#####################################################################
## Build a static library containing the Orthanc Stone framework
#####################################################################

include(../../Resources/CMake/OrthancStoneParameters.cmake)

SET(ORTHANC_SANDBOXED ON)
SET(ENABLE_SDL OFF)

include(../../Resources/CMake/OrthancStoneConfiguration.cmake)

add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES})






# Regenerate a dummy "library.c" file each time the "library.js" file
# is modified, so as to force a new execution of the linking
add_custom_command(
    OUTPUT "${AUTOGENERATED_DIR}/library.c"
    COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/library.c" ""
    DEPENDS "${CMAKE_SOURCE_DIR}/library.js")