Skip to content

Instantly share code, notes, and snippets.

@ebarlas
Created April 5, 2022 00:01
Show Gist options
  • Save ebarlas/8d9a30da7570d6d80a594cef310aa83c to your computer and use it in GitHub Desktop.
Save ebarlas/8d9a30da7570d6d80a594cef310aa83c to your computer and use it in GitHub Desktop.
Emscripten example
cmake_minimum_required(VERSION 3.20)
project(...)
set(CMAKE_CXX_STANDARD 20)
include(FetchContent)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG v2.0.0
)
FetchContent_GetProperties(ftxui)
if (NOT ftxui_POPULATED)
FetchContent_Populate(ftxui)
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif ()
if (EMSCRIPTEN)
string(APPEND CMAKE_CXX_FLAGS " -O2")
string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s ASYNCIFY")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s PROXY_TO_PTHREAD")
target_link_options(component PUBLIC "SHELL: -s TOTAL_MEMORY=33554432")
endif()
add_executable(...)
target_link_libraries(..
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)
foreach(file
"index.html"
"run_webassembly.py")
configure_file(${file} ${file})
endforeach(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment