-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
89 lines (77 loc) · 2.36 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
cmake_minimum_required(VERSION 3.10)
project(cpp)
option(ENABLE_SANITIZERS "Enable Clang's sanitizer options" OFF)
set(CMAKE_INSTALL_PREFIX "..")
set(VCPKG_INCLUDE_DIR ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include)
# See: https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
set(EM_CPP_FLAGS
"-flto"
)
set(EM_LINK_FLAGS
"-sASSERTIONS=0"
"-sINVOKE_RUN=0"
"-sALLOW_MEMORY_GROWTH=1"
# "-sWASM=1"
"-sENVIRONMENT=webview"
"-sFILESYSTEM=0"
# "-sMINIMAL_RUNTIME=1"
"-sMODULARIZE=1"
"-sEXPORT_ES6=1"
# "-sIGNORE_CLOSURE_COMPILER_ERRORS=0"
# "-sWASM_BIGINT=1"
# "-sSTANDALONE_WASM=0"
# "-sBINARYEN_ASYNC_COMPILATION=1"
# "-sDYNAMIC_EXECUTION=0"
"-sPOLYFILL=0"
# "-sSTRICT=0"
"-sIGNORE_MISSING_MAIN=0"
"-sAUTO_JS_LIBRARIES=0"
"-sAUTO_NATIVE_LIBRARIES=0"
"-sAUTO_ARCHIVE_INDEXES=0"
"-sDEFAULT_TO_CXX=0"
"-sUSE_GLFW=0"
"-sALLOW_UNIMPLEMENTED_SYSCALLS=1"
"-sINCOMING_MODULE_JS_API=\"['wasmBinary']\""
"--no-entry"
"--pre-js ${CMAKE_CURRENT_SOURCE_DIR}/src-cpp/src/pre.js"
"--post-js ${CMAKE_CURRENT_SOURCE_DIR}/src-cpp/src/post.js"
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(EM_LINK_FLAGS
${EM_LINK_FLAGS}
"-sUSE_ES6_IMPORT_META=1"
"-gsource-map"
"--source-map-base ./" # Debugging c++ only works in browser with "Experimental DWARF support turned on"
)
if (ENABLE_SANITIZERS)
set(EM_CPP_FLAGS
${EM_CPP_FLAGS}
"-fsanitize=address"
)
set(EM_LINK_FLAGS
${EM_LINK_FLAGS}
"-fsanitize=address"
"-sENVIRONMENT=web,node"
)
endif ()
else ()
set(EM_LINK_FLAGS
${EM_LINK_FLAGS}
"-sUSE_ES6_IMPORT_META=0"
)
endif ()
set(EMSDK_DIR "${CMAKE_SOURCE_DIR}/emsdk")
set(EXPAT_DIR "${CMAKE_SOURCE_DIR}/src-expat/expat")
set(GRAPHVIZ_DIR "${CMAKE_SOURCE_DIR}/third-party/graphviz")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(PACK_MODE "")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PACK_MODE "-d")
endif ()
add_subdirectory(packages/base91/src-cpp)
add_subdirectory(packages/expat/src-cpp)
add_subdirectory(packages/graphviz/src-cpp)
add_subdirectory(packages/llama/src-cpp)
add_subdirectory(packages/zstd/src-cpp)