-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
244 lines (179 loc) · 6.04 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
cmake_minimum_required(VERSION 3.9)
if (${TARGET_EMSCRIPTEN})
set(CMAKE_TOOLCHAIN_FILE ${EMSCRIPTEN_PATH}/cmake/Modules/Platform/Emscripten.cmake)
endif()
project(wrike-imgui)
if (${TARGET_EMSCRIPTEN})
elseif(${TARGET_OSX})
elseif(${TARGET_SDL})
else()
message(FATAL_ERROR "No target specified")
endif()
if (${TARGET_EMSCRIPTEN})
elseif(${TARGET_OSX})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include_directories("/usr/include")
elseif(${TARGET_SDL})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
set(CURL_LIBRARY "-lcurl")
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(CURL REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${OPENGL_INCLUDE_DIRS})
include_directories(${CURL_INCLUDE_DIR})
include_directories("/usr/include")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/out)
set(CMAKE_BUILD_TYPE_INIT "Debug")
set(CMAKE_CXX_STANDARD 11)
include_directories(libc)
include_directories(external)
set(EXTERNAL_SOURCES
external/imgui.cpp
external/imgui_widgets.cpp
external/imgui_draw.cpp
external/imgui.h
external/imgui_internal.h
external/imconfig.h
external/jsmn.c
external/jsmn.h
external/xxhash.c
external/xxhash.h
external/html_entities.c
external/html_entities.h
)
set(SOURCE_FILES
src/json.cpp
src/json.h
src/hash_map.h
src/id_hash_map.h
src/folder_tree.cpp
src/folder_tree.h
src/temporary_storage.cpp
src/temporary_storage.h
src/rich_text.cpp
src/rich_text.h
src/header.cpp
src/header.h
src/ui.cpp
src/ui.h
src/task_list.cpp
src/task_list.h
src/task_view.cpp
src/task_view.h
src/render_rich_text.cpp
src/render_rich_text.h
src/base32.c
src/base32.h
# src/sdf.cpp
# src/sdf.h
src/common.cpp
src/common.h
src/lazy_array.h
src/platform.h
src/account.cpp
src/account.h
src/users.cpp
src/users.h
src/workflows.cpp
src/workflows.h
src/custom_fields.cpp
src/custom_fields.h
src/inbox.cpp
src/inbox.h
src/main.cpp
src/main.h
)
if (${DEBUG})
add_definitions(-DDEBUG=1)
add_definitions(-DDEBUG_MEMORY=1)
set(SOURCE_FILES ${SOURCE_FILES} src/tracing.cpp src/tracing.h)
endif()
if (${TARGET_EMSCRIPTEN})
add_definitions(-DEMSCRIPTEN=1)
set(SOURCE_FILES ${SOURCE_FILES} src/platform_emscripten.cpp)
elseif(${TARGET_OSX})
set(SOURCE_FILES ${SOURCE_FILES} src/platform_osx.mm)
elseif(${TARGET_SDL})
add_definitions(-DEMSCRIPTEN=0)
set(SOURCE_FILES ${SOURCE_FILES} src/platform_sdl.cpp)
set(EXTERNAL_SOURCES ${EXTERNAL_SOURCES}
external/lodepng.c
external/lodepng.h
)
endif()
add_library(external ${EXTERNAL_SOURCES})
add_definitions(-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS)
add_definitions(-DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0)
add_definitions(-DIMGUI_DISABLE_DEMO_WINDOWS)
add_definitions(-DJSMN_PARENT_LINKS)
add_definitions(-DLODEPNG_NO_COMPILE_ENCODER)
add_definitions(-DLODEPNG_NO_COMPILE_ERROR_TEXT)
add_definitions(-fno-exceptions)
add_definitions(-fno-rtti)
add_custom_command(
OUTPUT out/resources.js
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "python ${EMSCRIPTEN_PATH}/tools/file_packager.py out/resources.data --preload resources > out/resources.js"
COMMENT "Packaging resources"
)
set(LINK_LIBRARIES external)
if (${TARGET_EMSCRIPTEN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1 -s FORCE_FILESYSTEM=1 -s TOTAL_MEMORY=64MB -s ASSERTIONS=1" )
if (${DEBUG})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g4 -s ASSERTIONS=1")
endif()
if (${ENABLE_SANITIZER})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CXX_FLAGS} --bind --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/out/resources.js" )
add_definitions("-DEXPORT=__attribute__((used))")
elseif(${TARGET_OSX})
if (${ENABLE_SANITIZER})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
endif()
add_definitions(-DEXPORT= )
set(LINK_LIBRARIES ${LINK_LIBRARIES}
"-framework Foundation"
"-framework Cocoa"
"-framework Metal"
"-framework MetalKit"
"-framework QuartzCore"
objc)
elseif(${TARGET_SDL})
if (${ENABLE_SANITIZER})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
endif()
set(LINK_LIBRARIES ${LINK_LIBRARIES} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${CURL_LIBRARIES})
add_definitions(-DEXPORT= )
endif()
if (${DEBUG})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os")
endif()
# Jesus that hurt me so many times already
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -Wall")
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT error)
add_executable(wrike-imgui ${SOURCE_FILES})
if(lto_supported)
message(STATUS "IPO / LTO enabled")
#set_property(TARGET wrike-imgui PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: <${error}>")
endif()
target_link_libraries(wrike-imgui ${LINK_LIBRARIES})
add_custom_target(
resources DEPENDS out/resources.js
)
add_custom_command(COMMAND python
${CMAKE_CURRENT_SOURCE_DIR}/generate_out.py
${CMAKE_CURRENT_SOURCE_DIR}/out/shell.html
${CMAKE_CURRENT_SOURCE_DIR}/out/wrike.html
${CMAKE_CURRENT_SOURCE_DIR}/out/wrike-imgui.js
OUTPUT wrike-imgui.js
DEPENDS wrike-imgui
COMMENT "Updating build time")