86 lines
2.1 KiB
CMake
86 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
set(NAME "GameOfLifeEditor")
|
|
project(${NAME} CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
if(WIN32)
|
|
set(IMGUI_BACKEND "imgui_impl_dx11.cpp") # DirectX 11 for Windows
|
|
elseif(APPLE)
|
|
set(IMGUI_BACKEND "imgui_impl_metal.mm") # Metal for macOS
|
|
elseif(UNIX)
|
|
set(IMGUI_BACKEND "imgui_impl_opengl3.cpp") # OpenGL for Linux
|
|
endif()
|
|
|
|
# includes
|
|
include_directories(./includes)
|
|
|
|
# raylib
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
raylib
|
|
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
|
GIT_TAG 5.5
|
|
GIT_SHALLOW 1
|
|
)
|
|
FetchContent_GetProperties(raylib)
|
|
if (NOT raylib_POPULATED)
|
|
set(FETCHCONTENT_QUIET NO)
|
|
FetchContent_Populate(raylib)
|
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
|
|
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
|
|
endif()
|
|
|
|
# imgui
|
|
FetchContent_Declare(
|
|
imgui
|
|
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
|
GIT_TAG docking
|
|
)
|
|
|
|
FetchContent_MakeAvailable(imgui)
|
|
|
|
set(imgui_SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/imgui-src)
|
|
|
|
# rlimgui
|
|
FetchContent_Declare(
|
|
rlImGui
|
|
GIT_REPOSITORY https://github.com/raylib-extras/rlImGui.git
|
|
GIT_TAG main
|
|
)
|
|
FetchContent_MakeAvailable(rlImGui)
|
|
set(rlImGui_SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/rlimgui-src)
|
|
|
|
|
|
# nlohmann::json
|
|
FetchContent_Declare(
|
|
json
|
|
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
|
GIT_TAG v3.11.3
|
|
)
|
|
FetchContent_MakeAvailable(json)
|
|
|
|
include_directories(${imgui_SOURCE_DIR} ${rlImGui_SOURCE_DIR})
|
|
|
|
set(SRC_CXX_FILES "./src/main.cpp"
|
|
"./src/rules.cpp"
|
|
"./src/world.cpp"
|
|
"./src/render.cpp"
|
|
"${rlImGui_SOURCE_DIR}/rlImGui.cpp"
|
|
"${imgui_SOURCE_DIR}/imgui.cpp"
|
|
"${imgui_SOURCE_DIR}/imgui_draw.cpp"
|
|
"${imgui_SOURCE_DIR}/imgui_widgets.cpp"
|
|
"${imgui_SOURCE_DIR}/imgui_tables.cpp"
|
|
"${imgui_SOURCE_DIR}/backends/${IMGUI_BACKEND}"
|
|
)
|
|
|
|
# Setup the example
|
|
add_executable(${NAME} ${SRC_CXX_FILES})
|
|
|
|
# Link raylib and raylib-cpp
|
|
target_link_libraries(${NAME} PUBLIC raylib nlohmann_json::nlohmann_json)
|