forked from lesharris/dorito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
240 lines (211 loc) · 6.92 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
cmake_minimum_required(VERSION 3.13...3.22)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
endif ()
project(
Dorito
VERSION 0.5.0
HOMEPAGE_URL https://lesharris.com/dorito
LANGUAGES C CXX
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_CXX_STANDARD 20)
include(${CMAKE_SOURCE_DIR}/cmake/AddIconToBinary.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/AddFonts.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/AddPNG.cmake)
# Dependencies
# Fetch deps
find_package(raylib 4.2.0 QUIET)
if (NOT raylib_FOUND)
include(FetchContent)
FetchContent_Declare(
raylib
URL https://github.com/raysan5/raylib/archive/refs/tags/4.2.0.zip
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED)
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR} EXCLUDE_FROM_ALL)
endif ()
endif ()
find_package(zep QUIET)
if (NOT zep_FOUND)
include(FetchContent)
FetchContent_Declare(
zep
URL https://github.com/Rezonality/zep/archive/refs/heads/master.zip
)
FetchContent_GetProperties(zep)
if (NOT zep_POPULATED)
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(zep)
set(BUILD_IMGUI ON CACHE BOOL "" FORCE)
set(BUILD_DEMOS OFF CACHE BOOL "" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_EXTENSIONS OFF CACHE BOOL "" FORCE)
add_subdirectory(${zep_SOURCE_DIR} ${zep_BINARY_DIR} EXCLUDE_FROM_ALL)
endif ()
endif ()
# vcpkg deps
find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(EnTT CONFIG REQUIRED)
find_package(unofficial-nativefiledialog CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
# Source Files
set(SOURCE_FILES
src/main.cpp
src/core/Dorito.cpp
src/core/Dorito.h
src/common/common.h
src/core/events/EventManager.h
src/core/events/Event.h
src/core/events/Events.h
src/core/input/Input.cpp
src/core/input/Input.h
src/core/input/Keys.h
src/core/input/InputActions.h
src/core/input/Mapping.h
src/core/layers/GameLayerStack.cpp
src/core/layers/GameLayerStack.h
src/core/layers/GameLayer.h
src/layers/Emu.cpp
src/layers/Emu.h
src/layers/UI.cpp
src/layers/UI.h
src/external/imgui_extra/imgui_impl_glfw.cpp
src/external/imgui/backends/imgui_impl_opengl3.cpp
src/external/imgui/imgui_demo.cpp
src/external/imgui/imgui_draw.cpp
src/external/imgui/imgui_tables.cpp
src/external/imgui/imgui_widgets.cpp
src/external/imgui/imgui.cpp
src/external/imgui_extra/imgui_memory_editor.h
src/external/zep/ZepEditor.cpp
src/external/zep/ZepEditor.h
src/external/zep/mode_repl.cpp
src/external/zep/mode_repl.h
src/external/octo_compiler.h
src/external/octo_compiler.c
src/common/common.cpp
src/cpu/Chip8.cpp
src/cpu/Chip8.h
src/cpu/Memory.cpp
src/cpu/Memory.h
src/system/Bus.cpp
src/system/Bus.h
src/display/Display.cpp
src/display/Display.h
src/common/Preferences.cpp
src/common/Preferences.h
src/code/ZepSyntaxOcto.cpp
src/code/ZepSyntaxOcto.h
src/widgets/EditorWidget.cpp
src/widgets/EditorWidget.h
src/widgets/Widget.h
src/widgets/MainMenuWidget.cpp
src/widgets/MainMenuWidget.h
src/widgets/RegistersWidget.cpp
src/widgets/RegistersWidget.h
src/widgets/DisassemblyWidget.cpp
src/widgets/DisassemblyWidget.h
src/widgets/AudioWidget.cpp
src/widgets/AudioWidget.h
src/widgets/ColorEditorWidget.cpp
src/widgets/ColorEditorWidget.h
src/widgets/MemoryEditorWidget.cpp
src/widgets/MemoryEditorWidget.h
src/widgets/ViewportWidget.cpp
src/widgets/ViewportWidget.h
src/widgets/SoundEditorWidget.cpp
src/widgets/SoundEditorWidget.h
src/widgets/SpriteEditorWidget.cpp
src/widgets/SpriteEditorWidget.h
src/widgets/MonitorsWidget.cpp
src/widgets/MonitorsWidget.h
src/widgets/BreakpointsWidget.cpp
src/widgets/BreakpointsWidget.h
src/external/IconsFontAwesome5.h
src/external/imgui-knobs.cpp)
if (APPLE)
set(SOURCE_FILES ${SOURCE_FILES}
src/external/mac/FolderManager.mm
src/external/mac/FolderManager.h)
endif ()
if(MSVC)
set(SOURCE_FILES ${SOURCE_FILES}
platform/WinMainStub.cpp)
set(WINDOWS 1)
endif()
# App Icon
AddIconToBinary(SOURCE_FILES ICONS ${CMAKE_SOURCE_DIR}/platform/dorito.ico ${CMAKE_SOURCE_DIR}/platform/dorito.icns)
# Dorito 🎉
if (MSVC)
add_executable(${PROJECT_NAME} WIN32 ${SOURCE_FILES})
elseif (APPLE)
AddFont(SOURCE_FILES FONT ${CMAKE_SOURCE_DIR}/assets/fonts/CascadiaMono.ttf)
AddFont(SOURCE_FILES FONT ${CMAKE_SOURCE_DIR}/assets/fonts/fa-solid-900.ttf)
AddPNG(SOURCE_FILES PNG ${CMAKE_SOURCE_DIR}/assets/dorito.png)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${SOURCE_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/platform/Info.plist.in"
)
#AddPlist(SOURCE_FILES PLIST ${CMAKE_SOURCE_DIR}/platform/Info.plist)
else ()
# To do - Add a desktop file for an icon and install stuff?
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
endif ()
# Compile Options
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /utf-8)
endif ()
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else ()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
endif ()
# Generated Files
configure_file("src/common/config.h.in" "src/common/config.h")
# Include directories and libraries
target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/external
${PROJECT_SOURCE_DIR}/src/external/imgui
${PROJECT_SOURCE_DIR}/src/external/imgui/backends
${zep_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE
fmt::fmt
raylib
spdlog::spdlog
EnTT::EnTT
unofficial::nativefiledialog::nfd
nlohmann_json::nlohmann_json
Zep::Zep)
if (APPLE)
target_link_libraries(${PROJECT_NAME} PRIVATE "-framework IOKit")
target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa")
target_link_libraries(${PROJECT_NAME} PRIVATE "-framework OpenGL")
install(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION . COMPONENT app)
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}")
set(CPACK_COMPONENTS_ALL app)
set(CPACK_GENERATOR "DragNDrop")
include(CPack)
endif ()
if (MSVC)
install(TARGETS ${PROJECT_NAME} DESTINATION . COMPONENT app)
install(FILES
$<TARGET_FILE:spdlog::spdlog>
$<TARGET_FILE:fmt::fmt>
DESTINATION . COMPONENT app)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/assets DESTINATION . COMPONENT app)
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}")
set(CPACK_COMPONENTS_ALL app)
set(CPACK_GENERATOR "ZIP")
include(CPack)
endif()