From cc21e12738bd667bc5087aeac5f32d748021740d Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Wed, 12 Mar 2025 00:30:34 +0100 Subject: [PATCH] Added DirImgui support as well as rlImGui. --- .gitignore | 5 ++++- dependencies.cmake | 52 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7124752..2d2188f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # Build folder -build/** \ No newline at end of file +build/** + +# VSCode +.vscode/** \ No newline at end of file diff --git a/dependencies.cmake b/dependencies.cmake index f24cfd5..bb84036 100644 --- a/dependencies.cmake +++ b/dependencies.cmake @@ -15,4 +15,54 @@ if (NOT raylib_FOUND) # If there's none, fetch and build raylib FetchContent_MakeAvailable(raylib) set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples endif() -endif() \ No newline at end of file +endif() + +# dear imgui +include(FetchContent) +FetchContent_Declare( + imgui_content + DOWNLOAD_EXTRACT_TIMESTAMP OFF + URL https://github.com/ocornut/imgui/archive/refs/tags/v1.91.8.tar.gz +) +FetchContent_Populate(imgui_content) +FetchContent_GetProperties(imgui_content) +project(imgui_library) +set(imgui_SOURCE_FILES + "${imgui_content_SOURCE_DIR}/imgui.cpp" + "${imgui_content_SOURCE_DIR}/imgui_demo.cpp" + "${imgui_content_SOURCE_DIR}/imgui_draw.cpp" + "${imgui_content_SOURCE_DIR}/imgui_tables.cpp" + "${imgui_content_SOURCE_DIR}/imgui_widgets.cpp" + "${imgui_content_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp" +) +add_library(imgui STATIC "${imgui_SOURCE_FILES}") +target_include_directories(imgui PRIVATE "${imgui_content_SOURCE_DIR}") +SET(imgui_INCLUDE_DIRS + "${imgui_content_SOURCE_DIR}" + "${imgui_content_SOURCE_DIR}/misc/cpp" + CACHE INTERNAL "ImGUI Header folder") +set_target_properties(${imgui} + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" +) + +# rlImGui +FetchContent_Declare( + rlimgui_content + GIT_REPOSITORY https://github.com/raylib-extras/rlImGui + GIT_TAG 8d3a31402f6b99ba52925acc96441c2410f6b500 +) +FetchContent_Populate(rlimgui_content) +FetchContent_GetProperties(rlimgui_content) +project(rlimgui) +add_library(rlimgui STATIC "${rlimgui_content_SOURCE_DIR}/rlImGui.cpp") +target_include_directories(rlimgui PRIVATE "${rlimgui_content_SOURCE_DIR}") +target_include_directories(rlimgui PRIVATE "${imgui_INCLUDE_DIRS}") +target_link_libraries(rlimgui raylib imgui) +SET(rlImGui_INCLUDE_DIRS "${rlimgui_content_SOURCE_DIR}" CACHE INTERNAL "rlImGui Header folder") +set_target_properties(${rlimgui} + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" +)