Skip to content

Commit cfbcdc1

Browse files
committed
added ImGUI example
1 parent 56fccc8 commit cfbcdc1

4 files changed

Lines changed: 424 additions & 1 deletion

File tree

conanfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def requirements(self):
106106
if self.options.use_imgui:
107107
self.requires("imgui/1.90.5")
108108
self.requires("implot/0.16")
109+
self.requires("glfw/3.4")
109110

110111
# 4. call for conan install
111112
def build_requirements(self):

src/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ IF(CPP_STARTER_USE_SLINT)
5454
ADD_SUBDIRECTORY(slint)
5555
ENDIF()
5656

57-
FIND_PACKAGE(docopt REQUIRED)
57+
# imgui example
58+
IF(CPP_STARTER_USE_IMGUI)
59+
MESSAGE("Using imgui")
60+
ADD_SUBDIRECTORY(imgui)
61+
ENDIF()
62+
5863
FIND_PACKAGE(spdlog REQUIRED)
5964
FIND_PACKAGE(fmt REQUIRED)
6065
# Generic test that uses conan libs

src/imgui/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FIND_PACKAGE(ImGui REQUIRED)
2+
FIND_PACKAGE(ImPlot REQUIRED)
3+
FIND_PACKAGE(glfw3 REQUIRED)
4+
FIND_PACKAGE(OpenGL REQUIRED)
5+
6+
# Retrieve the imgui package include directory.
7+
# Conan's CMakeDeps sets INTERFACE_INCLUDE_DIRECTORIES to a real path at configure time,
8+
# so GET_TARGET_PROPERTY works here without config-specific suffixes like _DEBUG/_RELEASE.
9+
GET_TARGET_PROPERTY(_imgui_incdirs imgui::imgui INTERFACE_INCLUDE_DIRECTORIES)
10+
LIST(GET _imgui_incdirs 0 IMGUI_INCLUDE_DIR)
11+
12+
# Backend sources were copied from res/bindings -> include/backends by conanfile.py generate()
13+
ADD_EXECUTABLE(test_imgui
14+
main.cpp
15+
${IMGUI_INCLUDE_DIR}/backends/imgui_impl_glfw.cpp
16+
${IMGUI_INCLUDE_DIR}/backends/imgui_impl_opengl3.cpp
17+
)
18+
19+
TARGET_LINK_LIBRARIES(test_imgui PRIVATE
20+
imgui::imgui
21+
implot::implot
22+
glfw
23+
OpenGL::GL
24+
)
25+
26+
# On Windows and Linux, copy runtime DLLs/SOs next to the binary
27+
IF(WIN32)
28+
ADD_CUSTOM_COMMAND(TARGET test_imgui POST_BUILD
29+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
30+
$<TARGET_RUNTIME_DLLS:test_imgui>
31+
$<TARGET_FILE_DIR:test_imgui>
32+
COMMAND_EXPAND_LISTS
33+
)
34+
ENDIF()

0 commit comments

Comments
 (0)