| 1 | Patch submitted upstream: https://github.com/OpenBoardView/OpenBoardView/pull/233
|
| 2 |
|
| 3 | diff --git a/CMakeModules/FindImGui.cmake b/CMakeModules/FindImGui.cmake
|
| 4 | new file mode 100644
|
| 5 | index 0000000..4d1fa42
|
| 6 | |
| 7 | |
| 8 | @@ -0,0 +1,36 @@
|
| 9 | +# Copyright (C) 2018, 2022 Maxim Cournoyer
|
| 10 | +# Redistribution and use of this file is allowed according to the terms of the MIT license.
|
| 11 | +# For details see the LICENSE file distributed with OpenBoardView.
|
| 12 | +# Note:
|
| 13 | +# Searching headers and libraries is very simple and is NOT as powerful as scripts
|
| 14 | +# distributed with CMake, because LuaDist defines directories to search for.
|
| 15 | +# Everyone is encouraged to contact the author with improvements. Maybe this file
|
| 16 | +# becomes part of CMake distribution sometimes.
|
| 17 | +
|
| 18 | +# - Find ImGui
|
| 19 | +# Find the native imgui headers and libraries.
|
| 20 | +#
|
| 21 | +# IMGUI_INCLUDE_DIRS - where to find imgui/imgui.h, etc.
|
| 22 | +# IMGUI_LIBRARIES - List of libraries when using imgui.
|
| 23 | +# IMGUI_FOUND - True if imgui is found.
|
| 24 | +
|
| 25 | +# Look for the header file.
|
| 26 | +FIND_PATH(IMGUI_INCLUDE_DIR NAMES imgui.h PATH_SUFFIXES imgui)
|
| 27 | +
|
| 28 | +# Look for the library.
|
| 29 | +FIND_LIBRARY(IMGUI_LIBRARY NAMES ImGui imgui)
|
| 30 | +
|
| 31 | +# Handle the QUIETLY and REQUIRED arguments and set IMGUI_FOUND to TRUE if all listed variables are TRUE.
|
| 32 | +INCLUDE(FindPackageHandleStandardArgs)
|
| 33 | +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ImGui DEFAULT_MSG IMGUI_LIBRARY IMGUI_INCLUDE_DIR)
|
| 34 | +
|
| 35 | +# Copy the results to the output variables.
|
| 36 | +IF(IMGUI_FOUND)
|
| 37 | + SET(IMGUI_LIBRARIES ${IMGUI_LIBRARY})
|
| 38 | + SET(IMGUI_INCLUDE_DIRS ${IMGUI_INCLUDE_DIR})
|
| 39 | +ELSE()
|
| 40 | + SET(IMGUI_LIBRARIES)
|
| 41 | + SET(IMGUI_INCLUDE_DIRS)
|
| 42 | +ENDIF()
|
| 43 | +
|
| 44 | +MARK_AS_ADVANCED(IMGUI_INCLUDE_DIRS IMGUI_LIBRARIES)
|
| 45 | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
| 46 | index b359dde..f11fbab 100644
|
| 47 | |
| 48 | |
| 49 | @@ -96,12 +96,16 @@ endif()
|
| 50 | # note: in the future there may be integrated CMake support into imgui
|
| 51 | # see: https://github.com/ocornut/imgui/pull/1713
|
| 52 | # for now do it manually, after SDL2 because we use the includes for the sdl_opengl examples
|
| 53 | -execute_process(
|
| 54 | +find_package(ImGui) # search ImGui from system
|
| 55 | +if(NOT IMGUI_FOUND) # else fallback to bundled copy
|
| 56 | + execute_process(
|
| 57 | COMMAND git submodule update --init src/imgui
|
| 58 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
| 59 | -)
|
| 60 | + )
|
| 61 |
|
| 62 | -set(SOURCES
|
| 63 | + set(IMGUI_LIBRARIES imgui)
|
| 64 | +
|
| 65 | + set(SOURCES
|
| 66 | imgui/imgui.cpp
|
| 67 | imgui/imgui_draw.cpp
|
| 68 | imgui/imgui_tables.cpp
|
| 69 | @@ -109,34 +113,29 @@ set(SOURCES
|
| 70 | imgui/misc/cpp/imgui_stdlib.cpp
|
| 71 | imgui/backends/imgui_impl_sdl2.cpp)
|
| 72 |
|
| 73 | + if(ENABLE_GL3)
|
| 74 | + LIST(APPEND SOURCES imgui/backends/imgui_impl_opengl3.cpp)
|
| 75 | + endif()
|
| 76 |
|
| 77 | -if(ENABLE_GL3)
|
| 78 | - LIST(APPEND SOURCES
|
| 79 | - imgui/backends/imgui_impl_opengl3.cpp
|
| 80 | - )
|
| 81 | + add_library(imgui STATIC ${SOURCES})
|
| 82 | + target_compile_definitions(imgui PUBLIC "-DImDrawIdx=unsigned int") # short is not enough for us
|
| 83 | + # Configure GL3 renderer to be GLES2 compatible if GLES2 is enabled
|
| 84 | + if(ENABLE_GLES2)
|
| 85 | + target_compile_definitions(imgui PUBLIC "-DIMGUI_IMPL_OPENGL_ES2")
|
| 86 | + endif()
|
| 87 | + target_include_directories(imgui PUBLIC
|
| 88 | + ${CMAKE_CURRENT_SOURCE_DIR}/imgui
|
| 89 | + ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples
|
| 90 | + ${CMAKE_CURRENT_SOURCE_DIR}/imgui/misc/cpp
|
| 91 | + )
|
| 92 | +
|
| 93 | + if(MINGW)
|
| 94 | + target_link_libraries(imgui SDL2::SDL2-static)
|
| 95 | + else()
|
| 96 | + target_link_libraries(imgui SDL2::SDL2)
|
| 97 | + endif()
|
| 98 | endif()
|
| 99 |
|
| 100 | -add_library(imgui STATIC ${SOURCES})
|
| 101 | -target_compile_definitions(imgui PUBLIC "-DImDrawIdx=unsigned int") # short is not enough for us
|
| 102 | -# Configure GL3 renderer to be GLES2 compatible if GLES2 is enabled
|
| 103 | -if(ENABLE_GLES2)
|
| 104 | - target_compile_definitions(imgui PUBLIC "-DIMGUI_IMPL_OPENGL_ES2")
|
| 105 | -endif()
|
| 106 | -target_include_directories(imgui PUBLIC
|
| 107 | - ${CMAKE_CURRENT_SOURCE_DIR}/imgui
|
| 108 | - ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples
|
| 109 | - ${CMAKE_CURRENT_SOURCE_DIR}/imgui/misc/cpp
|
| 110 | -)
|
| 111 | -
|
| 112 | -if(MINGW)
|
| 113 | -target_link_libraries(imgui
|
| 114 | - SDL2::SDL2-static
|
| 115 | -)
|
| 116 | -else()
|
| 117 | -target_link_libraries(imgui
|
| 118 | - SDL2::SDL2
|
| 119 | -)
|
| 120 | -endif()
|
| 121 |
|
| 122 | #install(TARGETS imgui DESTINATION ${INSTALL_ARCHIVE_DIR}) # No need to install a static lib
|
| 123 |
|
| 124 | diff --git a/src/openboardview/CMakeLists.txt b/src/openboardview/CMakeLists.txt
|
| 125 | index 470a145..649a373 100644
|
| 126 | |
| 127 | |
| 128 | @@ -181,7 +181,7 @@ target_include_directories(${PROJECT_NAME_LOWER} PRIVATE
|
| 129 | )
|
| 130 |
|
| 131 | target_link_libraries(${PROJECT_NAME_LOWER}
|
| 132 | - imgui
|
| 133 | + ${IMGUI_LIBRARIES}
|
| 134 | SQLite::SQLite3
|
| 135 | mpc
|
| 136 | opengl_target
|