mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-08 07:56:16 -05:00
ad85ca0977
* gnu/packages/patches/openboardview-use-system-imgui.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/electronics.scm (openboardview)[source]: Delete "imgui" subdirectory from snippet and apply patch. [inputs]{imgui}: New input.
170 lines
5.5 KiB
Diff
170 lines
5.5 KiB
Diff
Patch submitted upstream: https://github.com/OpenBoardView/OpenBoardView/pull/233
|
|
|
|
diff --git a/CMakeModules/FindImGui.cmake b/CMakeModules/FindImGui.cmake
|
|
new file mode 100644
|
|
index 0000000..4d1fa42
|
|
--- /dev/null
|
|
+++ b/CMakeModules/FindImGui.cmake
|
|
@@ -0,0 +1,36 @@
|
|
+# Copyright (C) 2018, 2022 Maxim Cournoyer
|
|
+# Redistribution and use of this file is allowed according to the terms of the MIT license.
|
|
+# For details see the LICENSE file distributed with OpenBoardView.
|
|
+# Note:
|
|
+# Searching headers and libraries is very simple and is NOT as powerful as scripts
|
|
+# distributed with CMake, because LuaDist defines directories to search for.
|
|
+# Everyone is encouraged to contact the author with improvements. Maybe this file
|
|
+# becomes part of CMake distribution sometimes.
|
|
+
|
|
+# - Find ImGui
|
|
+# Find the native imgui headers and libraries.
|
|
+#
|
|
+# IMGUI_INCLUDE_DIRS - where to find imgui/imgui.h, etc.
|
|
+# IMGUI_LIBRARIES - List of libraries when using imgui.
|
|
+# IMGUI_FOUND - True if imgui is found.
|
|
+
|
|
+# Look for the header file.
|
|
+FIND_PATH(IMGUI_INCLUDE_DIR NAMES imgui.h PATH_SUFFIXES imgui)
|
|
+
|
|
+# Look for the library.
|
|
+FIND_LIBRARY(IMGUI_LIBRARY NAMES ImGui imgui)
|
|
+
|
|
+# Handle the QUIETLY and REQUIRED arguments and set IMGUI_FOUND to TRUE if all listed variables are TRUE.
|
|
+INCLUDE(FindPackageHandleStandardArgs)
|
|
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ImGui DEFAULT_MSG IMGUI_LIBRARY IMGUI_INCLUDE_DIR)
|
|
+
|
|
+# Copy the results to the output variables.
|
|
+IF(IMGUI_FOUND)
|
|
+ SET(IMGUI_LIBRARIES ${IMGUI_LIBRARY})
|
|
+ SET(IMGUI_INCLUDE_DIRS ${IMGUI_INCLUDE_DIR})
|
|
+ELSE()
|
|
+ SET(IMGUI_LIBRARIES)
|
|
+ SET(IMGUI_INCLUDE_DIRS)
|
|
+ENDIF()
|
|
+
|
|
+MARK_AS_ADVANCED(IMGUI_INCLUDE_DIRS IMGUI_LIBRARIES)
|
|
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
|
index 301f933..24bf263 100644
|
|
--- a/src/CMakeLists.txt
|
|
+++ b/src/CMakeLists.txt
|
|
@@ -76,28 +76,30 @@ endif()
|
|
# note: in the future there may be integrated CMake support into imgui
|
|
# see: https://github.com/ocornut/imgui/pull/1713
|
|
# for now do it manually, after glad and SDL2 because we use the includes for the sdl_opengl examples
|
|
-execute_process(
|
|
+find_package(ImGui) # search ImGui from system
|
|
+if(NOT IMGUI_FOUND) # else fallback to bundled copy
|
|
+ execute_process(
|
|
COMMAND git submodule update --init src/imgui
|
|
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
-)
|
|
-add_definitions("-DImDrawIdx=unsigned int") # short is not enough for us
|
|
-add_definitions("-DIMGUI_IMPL_OPENGL_LOADER_GLAD") # We use glad
|
|
-# Configure GL3 renderer to be GLES2 compatible if GLES2 is enabled
|
|
-if(ENABLE_GLES2)
|
|
- add_definitions("-DIMGUI_IMPL_OPENGL_ES2")
|
|
-endif()
|
|
-
|
|
-# workaround for OpenGL include for OpenGL2, need to be glad rather than gl itself
|
|
-file(READ "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_opengl2.cpp" input)
|
|
-string(REPLACE "OpenGL/gl.h" "glad/glad.h" input "${input}")
|
|
-string(REPLACE "GL/gl.h" "glad/glad.h" input "${input}")
|
|
-file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_opengl2.cpp" "${input}")
|
|
-
|
|
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/imgui
|
|
- ${GLAD_INCLUDE_DIRS}
|
|
-)
|
|
-
|
|
-set(SOURCES
|
|
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
|
+ add_definitions("-DImDrawIdx=unsigned int") # short is not enough for us
|
|
+ add_definitions("-DIMGUI_IMPL_OPENGL_LOADER_GLAD") # We use glad
|
|
+ # Configure GL3 renderer to be GLES2 compatible if GLES2 is enabled
|
|
+ if(ENABLE_GLES2)
|
|
+ add_definitions("-DIMGUI_IMPL_OPENGL_ES2")
|
|
+ endif()
|
|
+
|
|
+ # workaround for OpenGL include for OpenGL2, need to be glad rather than gl itself
|
|
+ file(READ "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_opengl2.cpp" input)
|
|
+ string(REPLACE "OpenGL/gl.h" "glad/glad.h" input "${input}")
|
|
+ string(REPLACE "GL/gl.h" "glad/glad.h" input "${input}")
|
|
+ file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_opengl2.cpp" "${input}")
|
|
+
|
|
+ set(IMGUI_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/imgui
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples)
|
|
+
|
|
+ set(IMGUI_LIBRARIES imgui)
|
|
+
|
|
+ set(SOURCES
|
|
imgui/imgui.cpp
|
|
imgui/imgui_draw.cpp
|
|
imgui/imgui_tables.cpp
|
|
@@ -106,33 +108,35 @@ set(SOURCES
|
|
imgui/backends/imgui_impl_sdl.cpp)
|
|
|
|
|
|
-if(ENABLE_GL1)
|
|
+ if(ENABLE_GL1)
|
|
LIST(APPEND SOURCES
|
|
- imgui/backends/imgui_impl_opengl2.cpp
|
|
- )
|
|
-endif()
|
|
-if(ENABLE_GL3)
|
|
+ imgui/backends/imgui_impl_opengl2.cpp
|
|
+ )
|
|
+ endif()
|
|
+ if(ENABLE_GL3)
|
|
LIST(APPEND SOURCES
|
|
- imgui/backends/imgui_impl_opengl3.cpp
|
|
- )
|
|
-endif()
|
|
+ imgui/backends/imgui_impl_opengl3.cpp
|
|
+ )
|
|
+ endif()
|
|
|
|
-add_library(imgui STATIC ${SOURCES})
|
|
-target_link_libraries(imgui
|
|
+ add_library(imgui STATIC ${SOURCES})
|
|
+ target_link_libraries(imgui
|
|
${GLAD_LIBRARIES}
|
|
-)
|
|
-if(MINGW)
|
|
-target_link_libraries(imgui
|
|
- SDL2::SDL2-static
|
|
-)
|
|
-else()
|
|
-target_link_libraries(imgui
|
|
- SDL2::SDL2
|
|
-)
|
|
+ )
|
|
+ if(MINGW)
|
|
+ target_link_libraries(imgui
|
|
+ SDL2::SDL2-static
|
|
+ )
|
|
+ else()
|
|
+ target_link_libraries(imgui
|
|
+ SDL2::SDL2
|
|
+ )
|
|
+ endif()
|
|
endif()
|
|
|
|
-set(IMGUI_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/imgui ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples)
|
|
-
|
|
+include_directories(
|
|
+ ${IMGUI_INCLUDE_DIRS}
|
|
+ ${GLAD_INCLUDE_DIRS})
|
|
|
|
#install(TARGETS imgui DESTINATION ${INSTALL_ARCHIVE_DIR}) # No need to install a static lib
|
|
|
|
diff --git a/src/openboardview/CMakeLists.txt b/src/openboardview/CMakeLists.txt
|
|
index d049ef9..bb56f70 100644
|
|
--- a/src/openboardview/CMakeLists.txt
|
|
+++ b/src/openboardview/CMakeLists.txt
|
|
@@ -129,7 +129,7 @@ elseif(APPLE)
|
|
endif()
|
|
|
|
target_link_libraries(${PROJECT_NAME_LOWER}
|
|
- imgui
|
|
+ ${IMGUI_LIBRARIES}
|
|
SQLite::SQLite3
|
|
${GLAD_LIBRARIES}
|
|
${COCOA_LIBRARY}
|