view Deprecated/Resources/CodeGeneration/testWasmIntegrated/CMakeLists.txt @ 1491:c5627b8493f3

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Jun 2020 17:17:24 +0200
parents f6a2d46d2b76
children
line wrap: on
line source

cmake_minimum_required(VERSION 2.8)

project(testWasmIntegratedCpp)

set(WASM_FLAGS "-s WASM=1 -O0 -g0")
set(WASM_MODULE_NAME "TestWasmIntegratedModule" CACHE STRING "Name of the WebAssembly module")
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 ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmDelayedCallExecutor.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js  -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${CMAKE_CURRENT_LIST_DIR}/DefaultLibrary.js -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0 -s EXPORT_NAME='\"${WASM_MODULE_NAME}\"' -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912 -s TOTAL_STACK=128000000")  # 512MB + resize

add_definitions(-DORTHANC_ENABLE_WASM=1)

set(testWasmIntegratedCpp_Codegen_Deps
  ${CMAKE_CURRENT_LIST_DIR}/testWasmIntegratedCpp_api.yaml 
  ${CMAKE_CURRENT_LIST_DIR}/../template.in.h.j2
  ${CMAKE_CURRENT_LIST_DIR}/../template.in.ts.j2
) 

set(jsoncppRootDir ${CMAKE_CURRENT_LIST_DIR}/jsoncpp-1.8.4)

add_custom_command(
    OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/TestStoneCodeGen_generated.hpp ${CMAKE_CURRENT_BINARY_DIR}/TestStoneCodeGen_generated.ts
    COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/../stonegentool.py -o ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR}/../test_data/testTestStoneCodeGen.yaml
    DEPENDS ${testCppHandler_Codegen_Deps} ${CMAKE_CURRENT_LIST_DIR}/../test_data/testTestStoneCodeGen.yaml 
)

add_executable(testWasmIntegratedCpp
  main.cpp
  ${CMAKE_CURRENT_BINARY_DIR}/TestStoneCodeGen_generated.hpp
  ${jsoncppRootDir}/jsoncpp.cpp
  ${testCppHandler_Codegen_Deps})

target_include_directories(testWasmIntegratedCpp  PUBLIC ${CMAKE_BINARY_DIR})
target_include_directories(testWasmIntegratedCpp  PUBLIC ${jsoncppRootDir})

set_property(TARGET testWasmIntegratedCpp PROPERTY CXX_STANDARD 11)