1 | # CMake info |
2 | cmake_minimum_required(VERSION 3.22) |
3 |
|
4 | project("zydeco") |
5 |
|
6 |
|
7 | # Locations |
8 | set(SOURCE_DIR "src") |
9 | set(LIB_SOURCE_DIR "lib") |
10 | set(INCLUDE_DIR |
11 | "lib/imgui" |
12 | "lib/gl3w/include" |
13 | "include" |
14 | "include/events" |
15 | "include/render" |
16 | "include/render/gl" |
17 | "include/render/objects" |
18 | "include/render/shaders" |
19 | "include/runtime" |
20 | "include/sdl2" |
21 | ) |
22 |
|
23 |
|
24 | # Compile settings |
25 | set(CMAKE_CXX_STANDARD 20) |
26 | set(COMPILE_OPTIONS "-O3 -Wall -Wextra -pedantic") |
27 |
|
28 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
29 | add_compile_options (-fdiagnostics-color=always) |
30 | elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") |
31 | add_compile_options (-fcolor-diagnostics) |
32 | endif () |
33 |
|
34 |
|
35 | # Add source files |
36 | include_directories(${INCLUDE_DIR}) |
37 |
|
38 | set(LIB_SOURCES |
39 | "${LIB_SOURCE_DIR}/gl3w/src/gl3w.c" |
40 | "${LIB_SOURCE_DIR}/imgui/imgui.cpp" |
41 | "${LIB_SOURCE_DIR}/imgui/imgui_demo.cpp" |
42 | "${LIB_SOURCE_DIR}/imgui/imgui_draw.cpp" |
43 | "${LIB_SOURCE_DIR}/imgui/imgui_tables.cpp" |
44 | "${LIB_SOURCE_DIR}/imgui/imgui_widgets.cpp" |
45 | "${LIB_SOURCE_DIR}/imgui/backends/imgui_impl_sdl2.cpp" |
46 | "${LIB_SOURCE_DIR}/imgui/backends/imgui_impl_opengl3.cpp" |
47 | ) |
48 |
|
49 | set(PROGRAM_SOURCES |
50 | "${SOURCE_DIR}/main.cpp" |
51 | "${SOURCE_DIR}/Engine.cpp" |
52 | "${SOURCE_DIR}/render/Renderer.cpp" |
53 | "${SOURCE_DIR}/render/gl/GLProgram.cpp" |
54 | "${SOURCE_DIR}/render/gl/GLShader.cpp" |
55 | "${SOURCE_DIR}/render/gl/GLRenderObject.cpp" |
56 | "${SOURCE_DIR}/render/objects/GLRenderObjectBackground.cpp" |
57 | "${SOURCE_DIR}/render/objects/GLRenderObjectRainbowTriangle.cpp" |
58 | "${SOURCE_DIR}/render/objects/GLRenderObjectImGui.cpp" |
59 | "${SOURCE_DIR}/runtime/ThreadLooping.cpp" |
60 | "${SOURCE_DIR}/sdl2/EventHandlerSDL2.cpp" |
61 | "${SOURCE_DIR}/sdl2/TimerSDL2.cpp" |
62 | "${SOURCE_DIR}/sdl2/WindowSDL2.cpp" |
63 | "${SOURCE_DIR}/util/Fault.cpp" |
64 | "${SOURCE_DIR}/util/Logger.cpp" |
65 | ) |
66 |
|
67 |
|
68 | # Link libraries |
69 | find_package(cpptrace REQUIRED) |
70 | link_libraries("fmt" "cpptrace::cpptrace" "SDL2" "GL" "stb") |
71 |
|
72 |
|
73 | # Output |
74 | add_executable("zydeco" ${LIB_SOURCES} ${PROGRAM_SOURCES}) |
75 |
|