Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 36 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ project(vsgImGui
DESCRIPTION "VulkanSceneGraph, ImGui and ImPlot integration library"
LANGUAGES CXX
)

option(VSG_IMGUI_USE_SYSTEM_IMGUI "Use system installed ImGui" OFF)
option(VSG_IMGUI_USE_SYSTEM_IMPLOT "Use system installed ImPlot" OFF)

set(VSGIMGUI_SOVERSION 0)
SET(VSGIMGUI_RELEASE_CANDIDATE 0)

Expand All @@ -27,29 +31,43 @@ find_package(vsg 1.0.5)
vsg_setup_dir_vars()
vsg_setup_build_vars()

if ( (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/imgui/imgui.h) OR
(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/implot/implot.h) )
find_package(Git QUIET)
if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI OR NOT VSG_IMGUI_USE_SYSTEM_IMPLOT)
if ( (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/imgui/imgui.h) OR
(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/implot/implot.h) )
find_package(Git QUIET)

execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

vsg_copy_imgui_headers(
FILES
${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui.h
${VSGIMGUI_SOURCE_DIR}/src/imgui/imconfig.h
${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui_internal.h
${VSGIMGUI_SOURCE_DIR}/src/imgui/imstb_textedit.h
${VSGIMGUI_SOURCE_DIR}/src/imgui//misc/cpp/imgui_stdlib.h
${VSGIMGUI_SOURCE_DIR}/src/implot/implot.h
${VSGIMGUI_SOURCE_DIR}/src/implot/implot_internal.h
)
if(VSG_IMGUI_USE_SYSTEM_IMGUI)
find_package(imgui CONFIG REQUIRED)
else()
vsg_copy_imgui_headers(
FILES
${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui.h
${VSGIMGUI_SOURCE_DIR}/src/imgui/imconfig.h
${VSGIMGUI_SOURCE_DIR}/src/imgui/imgui_internal.h
${VSGIMGUI_SOURCE_DIR}/src/imgui/imstb_textedit.h
${VSGIMGUI_SOURCE_DIR}/src/imgui//misc/cpp/imgui_stdlib.h
)
endif()

if(VSG_IMGUI_USE_SYSTEM_IMPLOT)
find_package(implot CONFIG REQUIRED)
else()
vsg_copy_imgui_headers(
FILES
${VSGIMGUI_SOURCE_DIR}/src/implot/implot.h
${VSGIMGUI_SOURCE_DIR}/src/implot/implot_internal.h
)
endif()

vsg_add_target_clang_format(
FILES
Expand Down
2 changes: 1 addition & 1 deletion include/vsgImGui/RenderImGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <vsg/vk/DescriptorPool.h>

#include <vsgImGui/Export.h>
#include <vsgImGui/imgui.h>
#include <imgui.h>

namespace vsgImGui
{
Expand Down
3,724 changes: 0 additions & 3,724 deletions include/vsgImGui/imgui.h

This file was deleted.

1,297 changes: 0 additions & 1,297 deletions include/vsgImGui/implot.h

This file was deleted.

74 changes: 53 additions & 21 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,60 @@ set(EXTRA_INCLUDES)
SET(HEADER_PATH ${VSGIMGUI_SOURCE_DIR}/include/vsgImGui)

set(HEADERS
${HEADER_PATH}/imgui.h
${HEADER_PATH}/SendEventsToImGui.h
${HEADER_PATH}/RenderImGui.h
${HEADER_PATH}/Texture.h
imgui/imconfig.h
imgui/imgui_internal.h
imgui/imstb_rectpack.h
imgui/imstb_textedit.h
imgui/imstb_truetype.h
imgui/misc/cpp/imgui_stdlib.h
implot/implot.h
implot/implot_internal.h
)

set(SOURCES
vsgImGui/RenderImGui.cpp
vsgImGui/SendEventsToImGui.cpp
vsgImGui/Texture.cpp
imgui/imgui.cpp
imgui/imgui_draw.cpp
imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp
imgui/backends/imgui_impl_vulkan.cpp
imgui/misc/cpp/imgui_stdlib.cpp
implot/implot.cpp
implot/implot_items.cpp
)

OPTION(SHOW_DEMO_WINDOW "Toggle the build of the ImGui::ShowDemoWindow(bool*) and ImPlot::ShadowDemoWindow(bool*)" ON)
if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI)
set(HEADERS ${HEADERS}
imgui/imgui.h
imgui/imconfig.h
imgui/imgui_internal.h
imgui/imstb_rectpack.h
imgui/imstb_textedit.h
imgui/imstb_truetype.h
imgui/misc/cpp/imgui_stdlib.h
)

if (SHOW_DEMO_WINDOW)
set(SOURCES ${SOURCES}
imgui/imgui_demo.cpp
implot/implot_demo.cpp
imgui/imgui.cpp
imgui/imgui_draw.cpp
imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp
imgui/backends/imgui_impl_vulkan.cpp
imgui/misc/cpp/imgui_stdlib.cpp
)
endif()

if(NOT VSG_IMGUI_USE_SYSTEM_IMPLOT)
set(HEADERS ${HEADERS}
implot/implot.h
implot/implot_internal.h
)

set(SOURCES ${SOURCES}
implot/implot.cpp
implot/implot_items.cpp
)
endif()

OPTION(SHOW_DEMO_WINDOW "Toggle the build of the ImGui::ShowDemoWindow(bool*) and ImPlot::ShadowDemoWindow(bool*)" ON)

if (SHOW_DEMO_WINDOW)
if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI)
set(HEADERS ${HEADERS} imgui/imgui_demo.cpp)
endif()

if(NOT VSG_IMGUI_USE_SYSTEM_IMPLOT)
set(SOURCES ${SOURCES} implot/implot_demo.cpp)
endif()
else()
set(SOURCES ${SOURCES}
vsgImGui/fallback_demo.cpp
Expand Down Expand Up @@ -69,6 +88,11 @@ target_include_directories(vsgImGui PUBLIC
$<INSTALL_INTERFACE:include>
${EXTRA_INCLUDES}
)
if(NOT VSG_IMGUI_USE_SYSTEM_IMGUI)
target_include_directories(vsgImGui PRIVATE
$<BUILD_INTERFACE:${VSGIMGUI_SOURCE_DIR}/src/imgui/backends>
)
endif()

target_link_libraries(vsgImGui
PUBLIC
Expand All @@ -77,6 +101,14 @@ target_link_libraries(vsgImGui
${EXTRA_LIBRARIES}
)

if(VSG_IMGUI_USE_SYSTEM_IMGUI)
target_link_libraries(vsgImGui PUBLIC imgui::imgui)
endif()

if(VSG_IMGUI_USE_SYSTEM_IMPLOT)
target_link_libraries(vsgImGui PUBLIC implot::implot)
endif()

install(TARGETS vsgImGui ${INSTALL_TARGETS_DEFAULT_FLAGS})

if (BUILD_SHARED_LIBS)
Expand Down
4 changes: 2 additions & 2 deletions src/vsgImGui/RenderImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</editor-fold> */

#include <vsgImGui/RenderImGui.h>
#include <vsgImGui/implot.h>
#include <implot.h>

#include "../imgui/backends/imgui_impl_vulkan.h"
#include <imgui_impl_vulkan.h>

#include <vsg/io/Logger.h>
#include <vsg/vk/State.h>
Expand Down
2 changes: 1 addition & 1 deletion src/vsgImGui/SendEventsToImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</editor-fold> */

#include <vsgImGui/SendEventsToImGui.h>
#include <vsgImGui/imgui.h>
#include <imgui.h>

#include <vsg/ui/KeyEvent.h>
#include <vsg/ui/PointerEvent.h>
Expand Down
7 changes: 7 additions & 0 deletions src/vsgImGuiConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ include(CMakeFindDependencyMacro)

find_dependency(Vulkan)
find_dependency(vsg)
if(@VSG_IMGUI_USE_SYSTEM_IMGUI@)
find_dependency(imgui CONFIG)
endif()

if(@VSG_IMGUI_USE_SYSTEM_IMPLOT@)
find_dependency(implot CONFIG)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/vsgImGuiTargets.cmake")