aboutsummaryrefslogtreecommitdiff
path: root/ports/ogre/fix-findimgui.patch
blob: 8e812d92652dbf791e7948930ef3cb6ebb88fb74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
diff --git a/Components/Overlay/CMakeLists.txt b/Components/Overlay/CMakeLists.txt
index df8f32af4..42be1e8f2 100644
--- a/Components/Overlay/CMakeLists.txt
+++ b/Components/Overlay/CMakeLists.txt
@@ -19,21 +19,8 @@ list(APPEND HEADER_FILES
 file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
 
 if(OGRE_BUILD_COMPONENT_OVERLAY_IMGUI)
-  set(IMGUI_DIR "${PROJECT_BINARY_DIR}/imgui-1.77" CACHE PATH "")
-  if(NOT EXISTS ${IMGUI_DIR})
-    message(STATUS "Dowloading imgui")
-    file(DOWNLOAD
-        https://github.com/ocornut/imgui/archive/v1.77.tar.gz
-        ${PROJECT_BINARY_DIR}/imgui.tar.gz)
-    execute_process(COMMAND ${CMAKE_COMMAND}
-        -E tar xf imgui.tar.gz WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
-  endif()
-  list(APPEND SOURCE_FILES
-    ${IMGUI_DIR}/imgui.cpp
-    ${IMGUI_DIR}/imgui_draw.cpp
-    ${IMGUI_DIR}/imgui_widgets.cpp
-    ${IMGUI_DIR}/imgui_demo.cpp
-    ${IMGUI_DIR}/misc/freetype/imgui_freetype.cpp)
+    find_package(imgui CONFIG REQUIRED)
+    find_path(IMGUI_INCLUDE_DIR imgui.h)
 else()
     list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/OgreImGuiOverlay.cpp")
 endif()
@@ -41,13 +28,17 @@ endif()
 # setup target
 add_library(OgreOverlay ${OGRE_COMP_LIB_TYPE} ${HEADER_FILES} ${SOURCE_FILES})
 set_target_properties(OgreOverlay PROPERTIES VERSION ${OGRE_SOVERSION} SOVERSION ${OGRE_SOVERSION})
-target_link_libraries(OgreOverlay PUBLIC OgreMain PRIVATE ${FREETYPE_LIBRARIES} ZLIB::ZLIB)
+if(OGRE_BUILD_COMPONENT_OVERLAY_IMGUI)
+    target_link_libraries(OgreOverlay PUBLIC OgreMain PRIVATE freetype ZLIB::ZLIB imgui::imgui)
+else()
+    target_link_libraries(OgreOverlay PUBLIC OgreMain PRIVATE freetype ZLIB::ZLIB)
+endif()
 target_include_directories(OgreOverlay PUBLIC 
   "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
   $<INSTALL_INTERFACE:include/OGRE/Overlay>
   PRIVATE ${FREETYPE_INCLUDE_DIRS})
 
-if(OGRE_BUILD_COMPONENT_OVERLAY_IMGUI)
+if(0)
   target_include_directories(OgreOverlay PUBLIC
     PUBLIC "$<BUILD_INTERFACE:${IMGUI_DIR}>"
     PRIVATE "$<BUILD_INTERFACE:${IMGUI_DIR}/misc/freetype>")
diff --git "a/Components/Bites/CMakeLists.txt" "b/Components/Bites/CMakeLists.txt"
index 5d58a8d74..fe41e4a28 100644
--- "a/Components/Bites/CMakeLists.txt"
+++ "b/Components/Bites/CMakeLists.txt"
@@ -152,6 +152,11 @@ elseif(NOT EMSCRIPTEN)
   message(WARNING "SDL2 not found - no input handling and reduced window creation capabilites")
 endif()
 
+if(OGRE_BUILD_COMPONENT_OVERLAY_IMGUI)
+  find_package(imgui CONFIG REQUIRED)
+  target_link_libraries(OgreBites PRIVATE imgui::imgui)
+endif()
+
 generate_export_header(OgreBites 
     EXPORT_MACRO_NAME _OgreBitesExport
     EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/OgreBitesPrerequisites.h)