pthom/hello_imgui

Problems with implot from vcpkg

sabudilovskiy opened this issue · 1 comments

Hi, I tried to use your project together with implot, supplied from vcpkg. I came across the fact that implot pulls its imgui from vcpkg, which does not have backend files, even if you throw it into hello_imgui, it will not work, well, there is a slightly different name for the target, but this is solved by alias. I don't understand well what you can try to do in such a situation. Hypothetically, if the backends you use were in separate targets (with separate settings), then you could use the package from vcpkg, turn off the imgui build along with hello_imgui and it would work.

Hello,

Using imgui and/or implot from vcpkg is not recommended. HelloImGui provides its own copy of ImGui (on the docking branch).

You have two solutions:

  1. Add ImPlot manually (as a submodule for example):
add_library(implot implot/implot.cpp implot/implot.h etc...)
target_link_library(implot PUBLIC imgui)
  1. If you really want to use vcpkg for implot

In this case, both ImGui and ImPlot will need to come from vcpkg.

See instructions here (following a recent commit):

hello_imgui/CMakeLists.txt

Lines 245 to 290 in 2fa9569

# -----------------------------------------------------------------------------
# How to build offline with vcpkg
# -----------------------------------------------------------------------------
# By default, hello_imgui will download and build the required libraries automatically,
# if they cannot be found via cmake's find_package:
# glfw3, lunasvg, freetype
# To build offline, you can for example pre-install the required libraries with vcpkg,
# but you can also install them via a system package manager, or add them manually as targets.
#
# see below an example with vcpkg
#
# Install requirements via vcpkg
# --------------------------------------------
#
# git clone https://github.com/microsoft/vcpkg
# ./vcpkg/bootstrap-vcpkg.sh
# ./vcpkg/vcpkg install glfw3 freetype lunasvg
# export CMAKE_TOOLCHAIN_FILE=$(pwd)/vcpkg/scripts/buildsystems/vcpkg.cmake
# mkdir build && cd build
# cmake ..
#
# Note: under windows, you could specify a static triplet (x64-windows-static):
# ./vcpkg/vcpkg install freetype:x64-windows-static glfw3:x64-windows-static lunasvg:x64-windows-static
#
# -----------------------------------------------------------------------------
# How to use ImGui from vcpkg (*not* recommended)
# -----------------------------------------------------------------------------
# HelloImGui provides its own copy of imgui, as a submodule (on the branch "docking")
# it is possible, but not recommended, to use imgui from vcpkg via the option
# HELLOIMGUI_USE_IMGUI_CMAKE_PACKAGE
# In this case, you will need to install vcpkg, and install imgui with the correct options.
# (see below an example with vcpkg)
# (this method is not recommended, since ImGui voluntarily to not provide cmake tooling)
#
# git clone https://github.com/microsoft/vcpkg
# ./vcpkg/bootstrap-vcpkg.sh
# ./vcpkg/vcpkg install glfw3 freetype lunasvg
# # install imgui from vcpkg, with the correct options
# ./vcpkg/vcpkg install "imgui[docking-experimental,freetype-lunasvg,glfw-binding,opengl3-binding]"
#
# export CMAKE_TOOLCHAIN_FILE=$(pwd)/vcpkg/scripts/buildsystems/vcpkg.cmake
# mkdir build && cd build
# cmake .. -DHELLOIMGUI_USE_IMGUI_CMAKE_PACKAGE=ON
#
option(HELLOIMGUI_USE_IMGUI_CMAKE_PACKAGE "Use imgui from cmake package (provided by vcpkg for example) * Must be on docking branch*" OFF)