-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (73 loc) · 2.21 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
cmake_minimum_required(VERSION 3.11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project (Memory)
# Source code
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.h)
add_executable (${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic)
add_subdirectory(lib/asw)
# Find libs
if(NOT EMSCRIPTEN)
find_library(SDL_LIBRARY NAMES SDL2 REQUIRED)
find_library(SDL_MIXER_LIBRARY NAMES SDL2_mixer REQUIRED)
find_library(SDL_IMAGE_LIBRARY NAMES SDL2_image REQUIRED)
find_library(SDL_TTF_LIBRARY NAMES SDL2_ttf REQUIRED)
find_library(SDL_GFX_LIBRARY NAMES SDL2_gfx REQUIRED)
find_library(SDL_MAIN_LIBRARY NAMES SDL2main REQUIRED)
endif(NOT EMSCRIPTEN)
# Link Libs
# Emscripten support
if(EMSCRIPTEN)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "index")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_compile_options(
${PROJECT_NAME}
PRIVATE
-sUSE_SDL=2
-sUSE_SDL_IMAGE=2
-sUSE_SDL_TTF=2
-sUSE_SDL_MIXER=2
-sUSE_SDL_GFX=2
-sSDL2_IMAGE_FORMATS=["png"]
)
target_link_libraries(
${PROJECT_NAME}
-sWASM=1
-sUSE_SDL=2
-sUSE_SDL_IMAGE=2
-sUSE_SDL_TTF=2
-sUSE_SDL_MIXER=2
-sUSE_SDL_GFX=2
-sSDL2_IMAGE_FORMATS=["png"]
-sDEMANGLE_SUPPORT=1
-sTOTAL_MEMORY=512MB
asw
)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
LINK_FLAGS
"--preload-file ${CMAKE_CURRENT_LIST_DIR}/assets@/assets --use-preload-plugins --shell-file ${CMAKE_CURRENT_LIST_DIR}/index.html"
)
# Run of the mill executable
else(EMSCRIPTEN)
if(MINGW)
target_link_libraries(${PROJECT_NAME} -lmingw32)
endif(MINGW)
target_link_libraries(
${PROJECT_NAME}
-lm
${SDL_MAIN_LIBRARY}
${SDL_LIBRARY}
${SDL_MIXER_LIBRARY}
${SDL_IMAGE_LIBRARY}
${SDL_TTF_LIBRARY}
${SDL_GFX_LIBRARY}
asw
)
endif(EMSCRIPTEN)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets/ DESTINATION ${CMAKE_BINARY_DIR}/build/assets/)