| 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/game" |
| 16 | "include/render" |
| 17 | "include/render/gl" |
| 18 | "include/render/objects" |
| 19 | "include/render/shaders" |
| 20 | "include/runtime" |
| 21 | "include/sdl2" |
| 22 | ) |
| 23 |
|
| 24 |
|
| 25 | # Compile settings |
| 26 | set(CMAKE_CXX_STANDARD 20) |
| 27 | set(COMPILE_OPTIONS "-O3 -Wall -Wextra -pedantic") |
| 28 |
|
| 29 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 30 | add_compile_options (-fdiagnostics-color=always) |
| 31 | elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") |
| 32 | add_compile_options (-fcolor-diagnostics) |
| 33 | endif () |
| 34 |
|
| 35 |
|
| 36 | # Add source files |
| 37 | include_directories(${INCLUDE_DIR}) |
| 38 |
|
| 39 | set(LIB_SOURCES |
| 40 | "${LIB_SOURCE_DIR}/gl3w/src/gl3w.c" |
| 41 | "${LIB_SOURCE_DIR}/imgui/imgui.cpp" |
| 42 | "${LIB_SOURCE_DIR}/imgui/imgui_demo.cpp" |
| 43 | "${LIB_SOURCE_DIR}/imgui/imgui_draw.cpp" |
| 44 | "${LIB_SOURCE_DIR}/imgui/imgui_tables.cpp" |
| 45 | "${LIB_SOURCE_DIR}/imgui/imgui_widgets.cpp" |
| 46 | "${LIB_SOURCE_DIR}/imgui/backends/imgui_impl_sdl2.cpp" |
| 47 | "${LIB_SOURCE_DIR}/imgui/backends/imgui_impl_opengl3.cpp" |
| 48 | ) |
| 49 |
|
| 50 | set(PROGRAM_SOURCES |
| 51 | "${SOURCE_DIR}/main.cpp" |
| 52 | "${SOURCE_DIR}/Engine.cpp" |
| 53 | "${SOURCE_DIR}/game/Mandelbrot.cpp" |
| 54 | "${SOURCE_DIR}/render/Renderer.cpp" |
| 55 | "${SOURCE_DIR}/render/gl/GLProgram.cpp" |
| 56 | "${SOURCE_DIR}/render/gl/GLUniformUploader.cpp" |
| 57 | "${SOURCE_DIR}/render/gl/GLComputeShader.cpp" |
| 58 | "${SOURCE_DIR}/render/gl/GLShader.cpp" |
| 59 | "${SOURCE_DIR}/render/gl/GLRenderObject.cpp" |
| 60 | "${SOURCE_DIR}/render/gl/GLTexture.cpp" |
| 61 | "${SOURCE_DIR}/render/objects/GLRenderObjectFractal.cpp" |
| 62 | "${SOURCE_DIR}/render/objects/GLRenderObjectRainbowTriangle.cpp" |
| 63 | "${SOURCE_DIR}/render/objects/GLRenderObjectImGui.cpp" |
| 64 | "${SOURCE_DIR}/runtime/ThreadLooping.cpp" |
| 65 | "${SOURCE_DIR}/sdl2/EventHandlerSDL2.cpp" |
| 66 | "${SOURCE_DIR}/sdl2/TimerSDL2.cpp" |
| 67 | "${SOURCE_DIR}/sdl2/WindowSDL2.cpp" |
| 68 | "${SOURCE_DIR}/util/Fault.cpp" |
| 69 | "${SOURCE_DIR}/util/Logger.cpp" |
| 70 | ) |
| 71 |
|
| 72 |
|
| 73 | # Link libraries |
| 74 | find_package(cpptrace REQUIRED) |
| 75 | link_libraries("fmt" "cpptrace::cpptrace" "SDL2" "GL") |
| 76 |
|
| 77 |
|
| 78 | # Output |
| 79 | add_executable("zydeco" ${LIB_SOURCES} ${PROGRAM_SOURCES}) |
| 80 |
|