Last active
March 24, 2025 19:46
-
-
Save nezvers/0de6e56187aae5604d17ce3934d741ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.28) | |
| include(FetchContent) | |
| set(ProjectName RaylibTemplate) | |
| project(${ProjectName} LANGUAGES C CXX) | |
| # Raylib _______________________________________ | |
| FetchContent_Declare( | |
| raylib | |
| DOWNLOAD_EXTRACT_TIMESTAMP OFF | |
| URL https://github.com/raysan5/raylib/archive/refs/tags/5.5.zip | |
| ) | |
| #FetchContent_GetProperties(raylib) | |
| set(FETCHCONTENT_QUIET NO) | |
| set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples | |
| set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games | |
| FetchContent_MakeAvailable(raylib) | |
| # Dear Imgui _____________________________________ | |
| FetchContent_Declare( | |
| imgui | |
| DOWNLOAD_EXTRACT_TIMESTAMP OFF | |
| URL https://github.com/ocornut/imgui/archive/refs/tags/v1.91.9b-docking.zip | |
| ) | |
| FetchContent_MakeAvailable(imgui) | |
| add_library(imgui STATIC | |
| ${imgui_SOURCE_DIR}/imgui.cpp | |
| ${imgui_SOURCE_DIR}/imgui_demo.cpp | |
| ${imgui_SOURCE_DIR}/imgui_draw.cpp | |
| ${imgui_SOURCE_DIR}/imgui_tables.cpp | |
| ${imgui_SOURCE_DIR}/imgui_widgets.cpp | |
| ) | |
| target_include_directories(imgui INTERFACE ${imgui_SOURCE_DIR}) | |
| # RlImGui __________________________________________ | |
| FetchContent_Declare( | |
| rlimgui | |
| GIT_REPOSITORY "https://github.com/raylib-extras/rlImGui.git" | |
| GIT_TAG main | |
| CONFIGURE_COMMAND "" | |
| BUILD_COMMAND "" | |
| ) | |
| FetchContent_GetProperties(rlimgui) | |
| if(NOT rlimgui_POPULATED) | |
| FetchContent_Populate(rlimgui) | |
| endif() | |
| add_library(rlimgui STATIC ${rlimgui_SOURCE_DIR}/rlImGui.cpp) | |
| target_link_libraries(rlimgui raylib imgui) | |
| target_include_directories(rlimgui INTERFACE ${rlimgui_SOURCE_DIR}) | |
| # MAIN _______________________________________________ | |
| include_directories(${CMAKE_SOURCE_DIR}/include) | |
| file(GLOB APP_SOURCE_FILES src/*.cpp src/*.hpp src/*.c src/*.h) | |
| add_executable(${ProjectName} ${APP_SOURCE_FILES}) | |
| target_link_libraries(${ProjectName} raylib imgui rlimgui) | |
| # Setting ASSETS_PATH | |
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | |
| target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets/") # Set the asset path macro to the absolute path on the dev machine | |
| else() | |
| target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="./assets") # Set the asset path macro in release mode to a relative path that assumes the assets folder is in the same directory as the game executable | |
| endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment