diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-03-21 14:19:29 -0400 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-03-21 15:30:55 -0400 |
commit | ad85ca09777052426e801788032beb7592f0f21a (patch) | |
tree | e65705a209fef5a940ea8e496d0af21fe25dab68 | |
parent | 7f981c53df790bf1b5a33da77c0b926f64732576 (diff) | |
download | guix-ad85ca09777052426e801788032beb7592f0f21a.tar.gz |
gnu: openboardview: Unbundle imgui.
* 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.
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/electronics.scm | 10 | ||||
-rw-r--r-- | gnu/packages/patches/openboardview-use-system-imgui.patch | 170 |
3 files changed, 177 insertions, 4 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 423feb2028..ad39e648f7 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1557,6 +1557,7 @@ dist_patch_DATA = \ %D%/packages/patches/onnx-use-system-googletest.patch \ %D%/packages/patches/onnx-shared-libraries.patch \ %D%/packages/patches/onnx-skip-model-downloads.patch \ + %D%/packages/patches/openboardview-use-system-imgui.patch \ %D%/packages/patches/openboardview-use-system-utf8.patch \ %D%/packages/patches/opencascade-oce-glibc-2.26.patch \ %D%/packages/patches/openfoam-4.1-cleanup.patch \ diff --git a/gnu/packages/electronics.scm b/gnu/packages/electronics.scm index 3631d08519..ab72c36563 100644 --- a/gnu/packages/electronics.scm +++ b/gnu/packages/electronics.scm @@ -56,7 +56,8 @@ #:use-module (gnu packages qt) #:use-module (gnu packages sdl) #:use-module (gnu packages sqlite) - #:use-module (gnu packages stb)) + #:use-module (gnu packages stb) + #:use-module (gnu packages toolkits)) (define-public libserialport (package @@ -264,14 +265,14 @@ supported devices, as well as input/output file format support.") (guix build utils))) (snippet '(with-directory-excursion "src" - ;; TODO: Unbundle ImGui. - (define keep (list "." ".." "imgui" "openboardview")) + (define keep (list "." ".." "openboardview")) (for-each (lambda (f) (when (eq? 'directory (stat:type (lstat f))) (delete-file-recursively f))) (scandir "." (negate (cut member <> keep)))))) (patches - (search-patches "openboardview-use-system-utf8.patch")) + (search-patches "openboardview-use-system-imgui.patch" + "openboardview-use-system-utf8.patch")) (sha256 (base32 "1n2yfi8wpky0y231kq2zdgwn7f7kff8m53m904hxi5ppmwhx1d6q")))) @@ -327,6 +328,7 @@ supported devices, as well as input/output file format support.") (inputs (list fontconfig gtk+ + imgui sdl2 sqlite zlib)) diff --git a/gnu/packages/patches/openboardview-use-system-imgui.patch b/gnu/packages/patches/openboardview-use-system-imgui.patch new file mode 100644 index 0000000000..7345f1fe99 --- /dev/null +++ b/gnu/packages/patches/openboardview-use-system-imgui.patch @@ -0,0 +1,170 @@ +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} |