|  | 
|  | 1 | +cmake_minimum_required(VERSION 3.1) | 
|  | 2 | + | 
|  | 3 | +# Fetching version from header file | 
|  | 4 | +file(STRINGS ../imgui.h ImGui_VERSION_NUM_HEADER_STRING | 
|  | 5 | +    REGEX "#define[ \t]+IMGUI_VERSION_NUM[ \t]+([0-9]+)" | 
|  | 6 | +    LIMIT_COUNT 1) | 
|  | 7 | +string(REGEX REPLACE "#define[ \t]+IMGUI_VERSION_NUM[ \t]+([0-9]+)" "\\1" | 
|  | 8 | +    IMGUI_VERSION_NUM "${ImGui_VERSION_NUM_HEADER_STRING}") | 
|  | 9 | +math(EXPR IMGUI_VERSION_MAJOR "${IMGUI_VERSION_NUM} / 10000") | 
|  | 10 | +math(EXPR IMGUI_VERSION_MINOR "(${IMGUI_VERSION_NUM} % 10000) / 100") | 
|  | 11 | +math(EXPR IMGUI_VERSION_PATCH "${IMGUI_VERSION_NUM} % 100") | 
|  | 12 | + | 
|  | 13 | +project(imgui_examples | 
|  | 14 | +    VERSION "${IMGUI_VERSION_MAJOR}.${IMGUI_VERSION_MINOR}.${IMGUI_VERSION_PATCH}" | 
|  | 15 | +    LANGUAGES CXX) | 
|  | 16 | + | 
|  | 17 | +get_filename_component(ImGui_SRCDIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) | 
|  | 18 | + | 
|  | 19 | +include("${CMAKE_CURRENT_LIST_DIR}/ImGuiModule.cmake") | 
|  | 20 | + | 
|  | 21 | +set(ImGui_OPTIONS) | 
|  | 22 | + | 
|  | 23 | +imgui_option(USER_CONFIG "Dear ImGui user config for include" "" STRING) | 
|  | 24 | +imgui_option(EXAMPLES    "Dear ImGui example applications" ON) | 
|  | 25 | +imgui_option(BACKENDS    "Dear ImGui platform and render backends" ON) | 
|  | 26 | +imgui_option(MISC        "Dear ImGui misc features" ON) | 
|  | 27 | +imgui_option(3RDPARTY    "Dear ImGui example dependencies" ON) | 
|  | 28 | +imgui_option(OPENGL_LOADER | 
|  | 29 | +    "Dear ImGui OpenGL loader (IMGL3W, GL3W, GLEW, GLAD or CUSTOM)" | 
|  | 30 | +    "IMGL3W" | 
|  | 31 | +    STRINGS "IMGL3W" "GL3W" "GLEW" "GLAD" "CUSTOM") | 
|  | 32 | +imgui_option(FREETYPE    "Dear ImGui will build font atlases using FreeType instead of stb_truetype" OFF) | 
|  | 33 | +imgui_option(TOOLS       "Dear ImGui auxiliary applications" OFF) | 
|  | 34 | +imgui_option(PACKAGE     "Dear ImGui packaging" OFF) | 
|  | 35 | + | 
|  | 36 | +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ImGuiOptions.cmake" | 
|  | 37 | +    CONTENT "${ImGui_OPTIONS_CMAKE}") | 
|  | 38 | + | 
|  | 39 | +include("${CMAKE_CURRENT_LIST_DIR}/ImGuiTargets.cmake") | 
|  | 40 | + | 
|  | 41 | +set(ImGui_DIR "${CMAKE_CURRENT_LIST_DIR}") | 
|  | 42 | + | 
|  | 43 | +imgui_example(example_null | 
|  | 44 | +    TARGETS Core) | 
|  | 45 | + | 
|  | 46 | +imgui_example(example_sdl3_opengl3 | 
|  | 47 | +    BACKENDS ImplSDL3 ImplOpenGL3) | 
|  | 48 | + | 
|  | 49 | +imgui_example(example_glfw_opengl3 | 
|  | 50 | +    BACKENDS ImplGlfw ImplOpenGL3) | 
|  | 51 | + | 
|  | 52 | +if(NOT EMSCRIPTEN) | 
|  | 53 | +    imgui_example(example_glut_opengl2 | 
|  | 54 | +        BACKENDS ImplGLUT ImplOpenGL2) | 
|  | 55 | + | 
|  | 56 | +    imgui_example(example_sdl2_opengl2 | 
|  | 57 | +        BACKENDS ImplSDL2 ImplOpenGL2) | 
|  | 58 | + | 
|  | 59 | +    imgui_example(example_sdl2_opengl3 | 
|  | 60 | +        BACKENDS ImplSDL2 ImplOpenGL3) | 
|  | 61 | + | 
|  | 62 | +    imgui_example(example_sdl2_vulkan | 
|  | 63 | +        BACKENDS ImplSDL2 ImplVulkan) | 
|  | 64 | + | 
|  | 65 | +    imgui_example(example_sdl3_vulkan | 
|  | 66 | +        BACKENDS ImplSDL3 ImplVulkan) | 
|  | 67 | + | 
|  | 68 | +    imgui_example(example_glfw_opengl2 | 
|  | 69 | +        BACKENDS ImplGlfw ImplOpenGL2) | 
|  | 70 | + | 
|  | 71 | +    imgui_example(example_glfw_vulkan | 
|  | 72 | +        BACKENDS ImplGlfw ImplVulkan) | 
|  | 73 | +endif() | 
|  | 74 | + | 
|  | 75 | +if(NOT "${CMAKE_CURRENT_LIST_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") | 
|  | 76 | +    foreach(FILE ImGuiConfig.cmake ImGuiModule.cmake ImGuiTargets.cmake) | 
|  | 77 | +        configure_file(${FILE} ${FILE} COPYONLY) | 
|  | 78 | +    endforeach() | 
|  | 79 | +endif() | 
|  | 80 | + | 
|  | 81 | +install(FILES ImGuiConfig.cmake ImGuiModule.cmake ImGuiTargets.cmake | 
|  | 82 | +    "${CMAKE_CURRENT_BINARY_DIR}/ImGuiOptions.cmake" | 
|  | 83 | +    DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/imgui) | 
|  | 84 | + | 
|  | 85 | +if(ImGui_PACKAGE) | 
|  | 86 | +    if(NOT DEFINED CPACK_PACKAGE_NAME) | 
|  | 87 | +        set(CPACK_PACKAGE_NAME "dear-imgui") | 
|  | 88 | +    endif() | 
|  | 89 | +    include(CPack) | 
|  | 90 | +endif() | 
0 commit comments