Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imgui_stdlib is not being detected #36

Closed
paladium opened this issue Jan 30, 2019 · 8 comments
Closed

imgui_stdlib is not being detected #36

paladium opened this issue Jan 30, 2019 · 8 comments

Comments

@paladium
Copy link

I found myself using imgui_stdlib.h file which contains some overrides for using std libraries with ImGUI. However Magnum does not include those when finding components. A quick fix that worked for me was:

File FindImGui.cmake
Line 101: foreach(_file imgui imgui_widgets imgui_draw imgui_demo **imgui_stdlib**)

Next a new entry will appear in cmake to point to that file. Hope that helps someone.

@mosra mosra added this to the 2019.01 milestone Jan 30, 2019
@mosra mosra added this to TODO in GUI via automation Jan 30, 2019
@mosra
Copy link
Owner

mosra commented Jan 30, 2019

Hi, thanks for the report!

I tried to do this in a way that doesn't make the whole ImGuiIntegration library depend on the imgui_stdlib.cpp file, since this particular STL compatibility is not used there. I came up with the following, currently only in the next branch -- first take the updated FindImGui.cmake from here, then in your CMakeLists add this:

find_package(ImGui REQUIRED SourcesMiscCpp)

...

target_link_libraries(your-app PRIVATE ImGui::SourcesMiscCpp)

After that, you should be able to

#include <misc/cpp/imgui_stdlib.h>

and everything should work as expected. Though I'm not sure if the misc/cpp prefix makes sense, maybe I'll make it so only #include <imgui_stdlib.h> is needed. What do you say? Can you test on your side and confirm it works? Also, suggestions welcome :)

@mosra mosra moved this from TODO to In Progress in GUI Jan 31, 2019
@paladium
Copy link
Author

paladium commented Feb 1, 2019

Yes that works, thanks for the fix. The stdlib for imgui is still in development and has little useful functions at this point, however if it becomes larger, it will make sense to make ImGUIIntegration dependent on that file. At this point, this would work.

@mosra
Copy link
Owner

mosra commented Feb 1, 2019

Thanks for the confirmation! 👍 3a2cb98 is now in master.

I'm not sure if @ocornut wants to depend on STL too much, so I assume it will stay like this for quite a while. But who knows. If it will later make sense to have it directly, then I can make that change, of course :)

@mosra mosra closed this as completed Feb 1, 2019
GUI automation moved this from In Progress to Done Feb 1, 2019
@melix99
Copy link
Contributor

melix99 commented Oct 5, 2019

Unfortunately I'm having problems even using the find_package(ImGui REQUIRED SourcesMiscCpp) inside my CMakeLists: CMake says that it could not find the component SourcesMiscCpp.
I'm using the latest ImGui release, and the path of the misc folder is the same as the one specified in the FindImGui.cmake so... idk what's going on.

I also want to specify that I have magnum-integration as my CMake's subdirectory, and that if I add the SourcesMiscCpp to the find_package inside the CMakeLists of the library, the find_package inside my CMakeLists can find the component for some reason (but it's not the best solution obv).

Any suggestions?

@mosra mosra reopened this Oct 8, 2019
GUI automation moved this from Done to In Progress Oct 8, 2019
@mosra
Copy link
Owner

mosra commented Oct 8, 2019

That's weird ... I just tried to reproduce here (adding the find_package() to the imgui example), but everything works as expected.

  • Are you sure your copy of FindImGui.cmake is the same as the one in the integration repo?
  • If you look into CMakeCache.txt, which of the ImGui_* variables are set to -NOTFOUND?

@melix99
Copy link
Contributor

melix99 commented Oct 8, 2019

Are you sure your copy of FindImGui.cmake is the same as the one in the integration repo?

Yep, I literally copied the modules directory from magnum-integration inside mine.

I just tried to reproduce here (adding the find_package() to the imgui example), but everything works as expected.

I just tried that too and it worked for me either, so I analyzed the differences between the example and my project and found that in my project I have the magnum-integration and imgui subprojects inside a ThirdParty directory with a CMakeLists, but, in the imgui example, I putted magnum-integration and imgui directly in a subdirectory inside the main CMakeLists. In fact I did the same thing in my project and it worked fine. To clarify:

My project:
Main CMakeLists -> ThirdParty subdir -> magnum-integration subdir (with imgui)

Imgui example:
Main CMakeLists -> magnum-integration subdir (with imgui)

This is the CMakeLists inside the ThirdParty dir:

set(WITH_IMGUI ON CACHE BOOL "" FORCE)
set(IMGUI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/imgui/")

add_subdirectory(magnum-integration)

Maybe I did something wrong here?

@mosra
Copy link
Owner

mosra commented Oct 8, 2019

I see the problem now -- find_package(ImGui REQUIRED SourcesMiscCpp) needs the IMGUI_DIR. Because you're setting it in a subdirectory, the parent won't see it, and then FindImGui.cmake will fail to find the sources because it doesn't know where to look. One way to fix this would be to put it into the cache, so parent dir can pick it up from there:

set(IMGUI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/imgui" CACHE STRING "" FORCE)

@melix99
Copy link
Contributor

melix99 commented Oct 8, 2019

Oh ok, that worked. Thanks!

@mosra mosra closed this as completed Oct 8, 2019
GUI automation moved this from In Progress to Done Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
GUI
  
Done
Development

No branches or pull requests

3 participants