pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
604 stars 91 forks source link

New back-end default #85

Closed Guillaume227 closed 6 months ago

Guillaume227 commented 6 months ago

I just pulled latest master and am facing the cmake error below. It was building fine just before the update without me having to specify any back-end explicitly. Is there anything to know about backend default change across the update?

CMake Error at extern/imlibs/hello_imgui/hello_imgui_cmake/hello_imgui_build_lib.cmake:193 (message):

                      HelloImGui: no backend selected, and could not find Glfw via find_package(glfw3).

                  HelloImGui: no backend selected!
                      In order to select your own backend, use one of the cmake options below:
                      -DHELLOIMGUI_USE_GLFW_OPENGL3=ON      # Glfw3 + OpenGL3
                      -DHELLOIMGUI_USE_SDL_OPENGL3=ON       # SDL2 + OpenGL3
                      -DHELLOIMGUI_USE_GLFW_METAL           # Glfw3 + Metal
                      -DHELLOIMGUI_USE_SDL_METAL=ON         # SDL2 + Metal
                      -DHELLOIMGUI_USE_GLFW_VULKAN=ON       # Glfw3 + Vulkan
                      -DHELLOIMGUI_USE_SDL_VULKAN           # SDL2 + Vulkan
                      ...

              you can install glfw via your package manager (apt, pacman, etc).
              For example, on Ubuntu, you can run:
                  sudo apt install libglfw3-dev
              on macOS you can run:
                  brew install glfw3
Guillaume227 commented 6 months ago

update: after running

sudo apt install libglfw3-dev

as the useful error message suggests, cmake step succeeds and I see: -- HelloImGui: using HELLOIMGUI_USE_GLFW_OPENGL3 as default default backend (glfw was found via find_package(glfw3))

But I am still curious why I had to do update anything in my environment following that hello_imgui version pull.

pthom commented 6 months ago

Hello,

Sorry for the inconvenience. This originates from a discussion with a Linux distribution maintainer who criticized the fact that HelloImGui could download and build Glfw and/or Sdl when the tradition on Linux is to use shared libraries everywhere.

It is still possible to get the old behaviour, but on Linux this is an opt-in:

#------------------------------------------------------------------------------
# Automatic download of Glfw3 and SDL2 (provided as a convenience)
# (disabled by default on Linux, which prefers to use the system libraries,
# enabled by default on other platforms)
# Note: SDL and Glfw3 will be downloaded if:
#   - HELLOIMGUI_DOWNLOAD_GLFW_IF_NEEDED or HELLOIMGUI_DOWNLOAD_SDL_IF_NEEDED is ON
#   - HELLOIMGUI_USE_SDL_XXXX or HELLOIMGUI_USE_GLFW_XXXX is ON
#   - find_package(glfw3 or SDL2) fails. If a system library is found, or a user library provided
#     in a path added to CMAKE_PREFIX_PATH, it will be used instead
#   - In the case of Glfw3, if a target named glfw is already defined, it will be used instead
#------------------------------------------------------------------------------
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
    set(autodownload_default OFF)
else()
    set(autodownload_default ON)
endif()
option(HELLOIMGUI_DOWNLOAD_GLFW_IF_NEEDED "Download and build GLFW if needed" ${autodownload_default})
option(HELLOIMGUI_DOWNLOAD_SDL_IF_NEEDED "Download and build GLFW if needed" ${autodownload_default})

Happy new year!

Guillaume227 commented 6 months ago

Thanks for the explanation and happy new year to you!!