Skip to content

Commit

Permalink
Quick and dirty patch to allow imgui and magnum integration build fro…
Browse files Browse the repository at this point in the history
…m source along project files
  • Loading branch information
pgrodek committed Apr 8, 2020
1 parent d2f9067 commit d5e3dad
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Magnum/ImGuiIntegration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#

find_package(Magnum REQUIRED GL)
find_package(ImGui REQUIRED Sources)
#find_package(ImGui REQUIRED)

if(BUILD_STATIC)
set(MAGNUM_IMGUIINTEGRATION_BUILD_STATIC 1)
Expand Down Expand Up @@ -65,12 +65,10 @@ set_target_properties(MagnumImGuiIntegration PROPERTIES
FOLDER "Magnum/ImGuiIntegration")
if(NOT BUILD_STATIC)
set_target_properties(MagnumImGuiIntegration PROPERTIES VERSION ${MAGNUM_LIBRARY_VERSION} SOVERSION ${MAGNUM_LIBRARY_SOVERSION})
elseif(BUILD_STATIC_PIC)
set_target_properties(MagnumImGuiIntegration PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
set_target_properties(MagnumImGuiIntegration PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(MagnumImGuiIntegration
PUBLIC Magnum::GL ImGui::ImGui
PRIVATE ImGui::Sources)
PUBLIC Magnum::GL imgui::imgui)

if(BUILD_TESTS)
add_subdirectory(Test)
Expand Down

1 comment on commit d5e3dad

@mosra
Copy link

@mosra mosra commented on d5e3dad Apr 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Just noticed your fork -- I assume you add imgui as a subdirectory, right? Would the following patch to FindImGui.cmake cover your use case?

diff --git a/modules/FindImGui.cmake b/modules/FindImGui.cmake
index 6038724..cf544f0 100644
--- a/modules/FindImGui.cmake
+++ b/modules/FindImGui.cmake
@@ -69,8 +69,10 @@ endif()
 # Vcpkg distributes imgui as a library with a config file, so try that first --
 # but only if IMGUI_DIR wasn't explicitly passed, in which case we'll look
 # there instead
-find_package(imgui CONFIG QUIET)
-if(imgui_FOUND AND NOT IMGUI_DIR)
+if(NOT TARGET imgui::imgui)
+    find_package(imgui CONFIG QUIET)
+endif()
+if(TARGET imgui::imgui AND NOT IMGUI_DIR)
     if(NOT TARGET ImGui::ImGui)
         add_library(ImGui::ImGui INTERFACE IMPORTED)
         # TODO: remove once 1.71 is obsolete

Please sign in to comment.