-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
58 lines (47 loc) · 2.16 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
cmake_minimum_required(VERSION 3.15)
project(fantasy_console)
set(CMAKE_CXX_STANDARD 17)
if (EMSCRIPTEN)
set(PLATFORM Web)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
add_definitions(-DPLATFORM_WEB)
add_definitions(-DUSE_WASM)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --bind --memory-init-file 0 -s INITIAL_MEMORY=64MB -s SAFE_HEAP=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_GLFW=3 -s USE_WEBGL2=1 -s FORCE_FILESYSTEM=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ASSERTIONS=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --use-preload-plugins")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --embed-file examples@/")
set(CMAKE_EXECUTABLE_SUFFIX ".js")
file(COPY examples DESTINATION ${CMAKE_BINARY_DIR}/)
file(COPY examples/index.html DESTINATION ${CMAKE_BINARY_DIR}/)
else ()
file(COPY examples/ DESTINATION ${CMAKE_BINARY_DIR})
endif ()
file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS src/*.hpp)
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
add_subdirectory(vendor/duktape)
add_subdirectory(vendor/raylib)
target_include_directories(${PROJECT_NAME} PUBLIC SYSTEM vendor/duktape)
target_include_directories(${PROJECT_NAME} PUBLIC SYSTEM vendor/raylib/src)
target_link_libraries(${PROJECT_NAME} duktape raylib)
function(create_zip output_file input_files working_dir)
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${output_file}" --format=zip -- ${input_files}
WORKING_DIRECTORY "${working_dir}"
OUTPUT "${output_file}"
DEPENDS ${input_files}
COMMENT "Zipping to ${output_file}."
)
endfunction()
if (FALSE)
if (EMSCRIPTEN)
list(APPEND BundleFiles "${CMAKE_BINARY_DIR}/index.html" "${CMAKE_BINARY_DIR}/fantasy_console.wasm" "${CMAKE_BINARY_DIR}/fantasy_console.js")
create_zip("${CMAKE_BINARY_DIR}/web_bundle.zip" "${BundleFiles}" ${CMAKE_BINARY_DIR})
add_custom_target("make_web_bundle" ALL DEPENDS "${CMAKE_BINARY_DIR}/web_bundle.zip")
endif()
endif()