-
-
Notifications
You must be signed in to change notification settings - Fork 325
/
CMakeLists.txt
76 lines (55 loc) · 2 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
cmake_minimum_required(VERSION 3.12)
project(FastNoiseLitePreview VERSION 1.1.1)
SET(CMAKE_CXX_STANDARD 17)
include(FetchContent)
FetchContent_Declare(
imgui_application
GIT_REPOSITORY https://github.com/auburn/imgui_application
GIT_TAG 00c4079834123e27850c6ec818b21fdf2797e5b5
)
FetchContent_MakeAvailable(imgui_application)
FetchContent_Declare(
emscripten-browser-file
GIT_REPOSITORY https://github.com/Armchair-Software/emscripten-browser-file
GIT_TAG 2ff8f8f791c0e7177b40e621ee3f758e03b31bf5
)
FetchContent_MakeAvailable(emscripten-browser-file)
# ----------------------------------------------------------
add_executable(${CMAKE_PROJECT_NAME}
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
${IMGUI_APPLICATION_INCLUDE_DIRECTORIES}
${emscripten-browser-file_SOURCE_DIR}
../Cpp
)
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC
FNL_VERSION="v${CMAKE_PROJECT_VERSION}"
)
if(EMSCRIPTEN)
# IMPORTANT NOTE: due to `target_link_options` deduplication,
# we use "-sWASM=1 -sUSE_SDL=2 ..." which works well, instead of
# "-s WASM=1 -s USE_SDL=2 ..." (with spaces), which becomes
# "-s WASM=1 USE_SDL=2 ..." (duplicated but necessary '-s' removed).
target_link_options(${CMAKE_PROJECT_NAME} PRIVATE
-sWASM=1
-sUSE_SDL=2
-sUSE_WEBGL2=1
#-sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 # Only target for WebGL2 (drop support for WebGL1 to save code size)
-sEXPORTED_RUNTIME_METHODS=[ccall]
-sEXPORTED_FUNCTIONS=[_main,_malloc,_free]
-sALLOW_MEMORY_GROWTH=1
-sDISABLE_EXCEPTION_CATCHING=1 -sNO_EXIT_RUNTIME=0 -sASSERTIONS=1
-sNO_FILESYSTEM=1
-sSINGLE_FILE
--shell-file ${IMGUI_APPLICATION_SHELL_MINIMAL}
)
target_link_libraries(${CMAKE_PROJECT_NAME}
imgui_application
)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
else()
target_link_libraries(${CMAKE_PROJECT_NAME}
imgui_application GL
)
endif()