-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
109 lines (92 loc) · 2.63 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cmake_minimum_required(VERSION 3.20)
project(carimbo LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(SDL2_DIR "${CMAKE_BINARY_DIR}")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten")
find_package(Boost CONFIG REQUIRED)
find_package(OpenSSL CONFIG REQUIRED)
endif()
find_package(Ogg CONFIG REQUIRED)
find_package(PhysFS CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(SPNG CONFIG REQUIRED)
find_package(sol2 CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(OpenAL CONFIG REQUIRED)
find_package(Vorbis CONFIG REQUIRED)
file(GLOB HEADER_FILES "src/*.hpp")
file(GLOB SOURCE_FILES "src/*.cpp")
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_precompile_headers(${PROJECT_NAME} PRIVATE ${HEADER_FILES})
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -pedantic)
endif()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /Od /Zi)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -O0 -g)
endif()
elseif (CMAKE_BUILD_TYPE MATCHES "Release")
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /O2 /GL)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -O2 -flto)
endif()
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES Emscripten)
set(EMSCRIPTEN_OPTIONS
-sEVAL_CTORS=1
-sWASM_BIGINT=1
-sALLOW_MEMORY_GROWTH=1
-sINITIAL_MEMORY=128MB
-lwebsocket.js
-sUSE_SDL=2
-sWEBSOCKET_SUBPROTOCOL=text
-sEXPORTED_RUNTIME_METHODS=['callMain']
)
if (ENABLE_PROFILING)
list(APPEND EMSCRIPTEN_OPTIONS
-O0
-g
-gsource-map
-sDEMANGLE_SUPPORT=1
-sASSERTIONS=1
-sNO_DISABLE_EXCEPTION_CATCHING
--profiling-funcs
-sSAFE_HEAP=0
-sSTACK_OVERFLOW_CHECK=2
)
else()
list(APPEND EMSCRIPTEN_OPTIONS
-O2
)
endif()
target_link_options(${PROJECT_NAME} PRIVATE ${EMSCRIPTEN_OPTIONS})
endif()
option(LOCAL "Use local environment" OFF)
if(LOCAL)
target_compile_definitions(${PROJECT_NAME} PRIVATE LOCAL)
endif()
option(SANDBOX "Use sandbox" OFF)
if(SANDBOX)
target_compile_definitions(${PROJECT_NAME} PRIVATE SANDBOX)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE
physfs-static
SDL2::SDL2-static
SDL2::SDL2main
spng::spng_static
sol2::sol2
nlohmann_json::nlohmann_json
Ogg::ogg
vorbis::vorbis
)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten")
target_link_libraries(${PROJECT_NAME} PRIVATE Boost::boost OpenAL::OpenAL openssl::openssl)
endif()