# ============================================================================== # Find imgui # ============================================================================== # Builds Dear ImGui from the bundled sources in deps/imgui/. # # Targets provided: # imgui::imgui - The Dear ImGui library target # # Variables set: # imgui_FOUND - TRUE if imgui is available # imgui_LIBRARIES - The imgui library target (imgui::imgui) # imgui_INCLUDE_DIR - Include directories for imgui # # Configuration (set before find_package): # IMGUI_BACKEND_PLATFORM - Platform backend (default: glfw) # IMGUI_BACKEND_RENDERER - Renderer backend (default: opengl3) # IMGUI_BUILD_DEMO - Include demo sources (default: ON) # ============================================================================== if (DEFINED _FINDIMGUI_INCLUDED) return() endif() set(_FINDIMGUI_INCLUDED TRUE) set(IMGUI_BACKEND_PLATFORM "glfw" CACHE STRING "Dear ImGui platform backend") set(IMGUI_BACKEND_RENDERER "opengl3" CACHE STRING "Dear ImGui renderer backend") option(IMGUI_BUILD_DEMO "Include Dear ImGui demo window sources" ON) set(_imgui_source_dir "${CMAKE_CURRENT_LIST_DIR}/imgui") if (NOT EXISTS "${_imgui_source_dir}/imgui.cpp") message(FATAL_ERROR "imgui sources not found at '${_imgui_source_dir}'") endif() # On Emscripten, GLFW is provided by compiler flags (-sUSE_GLFW=3), not a CMake target. # Create a stub interface target so imgui's CMakeLists skips find_package(glfw3). if (IS_EMSCRIPTEN AND NOT TARGET glfw) add_library(glfw INTERFACE) endif() add_subdirectory("${_imgui_source_dir}" "${CMAKE_BINARY_DIR}/_deps/imgui-build" EXCLUDE_FROM_ALL) if (NOT TARGET imgui::imgui) message(FATAL_ERROR "imgui: target imgui::imgui was not created") endif() set(imgui_FOUND TRUE) set(imgui_LIBRARIES imgui::imgui) get_target_property(_imgui_inc imgui INTERFACE_INCLUDE_DIRECTORIES) set(imgui_INCLUDE_DIR "${_imgui_inc}") # Mark imgui includes as SYSTEM to suppress warnings from its headers if (_imgui_inc AND TARGET imgui) set_target_properties(imgui PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_imgui_inc}" ) endif() set(IMGUI_LICENSE_FILE "${_imgui_source_dir}/LICENSE.txt" CACHE FILEPATH "Path to Dear ImGui license file")