-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (61 loc) · 2.31 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.5)
# Include local settings if available
if(EXISTS "${CMAKE_SOURCE_DIR}/LocalSettings.cmake")
include("${CMAKE_SOURCE_DIR}/LocalSettings.cmake")
endif()
# Define project
get_filename_component(ABSOLUTE_PATH_TO_EMCC "./emsdk/upstream/emscripten/emcc" ABSOLUTE)
set(CMAKE_C_COMPILER ${ABSOLUTE_PATH_TO_EMCC})
get_filename_component(ABSOLUTE_PATH_TO_EMPP "./emsdk/upstream/emscripten/em++" ABSOLUTE)
set(CMAKE_CXX_COMPILER ${ABSOLUTE_PATH_TO_EMPP})
project(gba)
############## GBA ##############
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(VBA_NEXT_DIR ./vba-next)
set(VBA_WSM_DIR ./vba-wsm)
add_definitions(-DUSE_KEYBOARD -DFRONTEND_SUPPORTS_RGB565 -DHAVE_STDINT_H -DINLINE=inline -DLSB_FIRST -DUSE_STATIC_WRAM -DUSE_CHEATS=1)
add_executable(vba-wsm
${VBA_WSM_DIR}/main.cpp
${VBA_WSM_DIR}/ui.h
${VBA_NEXT_DIR}/src/gba.cpp
${VBA_NEXT_DIR}/src/memory.cpp
${VBA_NEXT_DIR}/src/sound.cpp
${VBA_NEXT_DIR}/src/system.cpp
${VBA_NEXT_DIR}/libretro/libretro.cpp
)
target_compile_options(vba-wsm PRIVATE -flto -O3)
target_include_directories(vba-wsm PRIVATE
${VBA_NEXT_DIR}/src ${VBA_NEXT_DIR}/libretro ${VBA_NEXT_DIR}/libretro-common/include
${SDL2_INCLUDE_DIRS}
)
target_link_libraries(vba-wsm PRIVATE
${SDL2_LIBRARIES}
)
target_link_options(vba-wsm PRIVATE -flto -O3 --emit-symbol-map -sEXPORTED_FUNCTIONS=['_emuGetSymbol','_main','_emuRunFrame','_emuSetSampleRate','_emuLoadROM','_emuResetCpu','_emuAddCheat'] -sEXPORT_ALL=1 -sTOTAL_MEMORY=134217728 -sLLD_REPORT_UNDEFINED)
############## Svelte ##############
# Find npm
find_program(NPM npm)
if (NOT NPM)
message(FATAL_ERROR "npm not found")
endif()
# Install npm dependencies
execute_process(
COMMAND ${NPM} i
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
# Build svelte app
add_custom_target(
svelte ALL
COMMAND ${NPM} run build
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
# Move wasm to svelte app
add_custom_command(
TARGET vba-wsm POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/vba-wsm.wasm
${CMAKE_CURRENT_BINARY_DIR}/vba-wsm.js
${CMAKE_CURRENT_BINARY_DIR}/vba-wsm.js.symbols
${CMAKE_CURRENT_SOURCE_DIR}/public
)
add_dependencies(svelte vba-wsm)