mosra / magnum-integration

Integration libraries for the Magnum C++11 graphics engine
https://magnum.graphics/
Other
99 stars 44 forks source link

vcpgk imgui #37

Closed Getshi closed 5 years ago

Getshi commented 5 years ago

I tried switching from manually downloaded/built/linked corrade magnum imgui and magnum-imgui to vcpkg, now that magnum-integration[imgui] is listed.

However, there seem to be problems stemming from the capitalization of the imgui library. vcpkg imgui is lowercase and will then be used via

find_package(imgui CONFIG REQUIRED)
target_link_libraries(main PRIVATE imgui::imgui)

whereas the FindMagnumIntegration.cmake is set up to use ImGui::ImGui.

I tried to no avail modifying the file to the lower case version but something always seemed to go wrong, maybe trying to find imgui headers, which are not set in vcpkg's imguiConfig.cmake.

Maybe the easiest solution for me would be to modify vcpkg's imgui instead, but I think if imgui will stay lowercase then magnum-integration should likely adapt to this.

Any local/temporary fix would be appreciated!

mosra commented 5 years ago

Hi!

This should be correctly handled by the FindImGui.cmake module (we specifically went quite some extra steps to make it work) -- it first tries to look for (lowercase) imgui::imgui and then it exposes that through the (camelcased) ImGui::ImGui, providing the same interface for both source and vcpkg version of it. If it doesn't find it, it falls back to looking for the sources.

If this doesn't work, try checking if you are bundling FindImGui.cmake with your project and if it's available through CMAKE_MODULE_PATH.

Getshi commented 5 years ago

Hi, thanks for the blazing fast reply! I saw that there was something going on about exposing lowercase to uppercase, but didn't think to try to include the FindImGui.cmake since I thought I would only need to access stuff exposed by vcpkg.

If I add the full path to the file (within vcpkg/buildtrees/magnum-integration/src ...) then it doesn't complain (except for shaders not compiling for some reason, maybe since I haven't updated in a while).

Is this the intended solution? Since it doesn't seem as portable due to the hardcoded full path, or is vcpkg expected to be located relative to/inside of the project?

mosra commented 5 years ago

Umm.... I mean taking the FindImGui.cmake directly from the repository and copying it somewhere in a modules directory that your project has, like the one in the bootstrap projects, along with FindSDL2.cmake and others. And then pointing CMAKE_MODULE_PATH there, again like the bootstrap project has:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/modules/")

That way you have it bundled with your project and don't need to hardcode a path to some externally located file. Hope that clears it up :)

Getshi commented 5 years ago

Okay I see, thanks for the clarification. By the way the FindSDL2.cmake seems to not be needed, as vcpkg provides SDL2Config.cmake and sdl2[core] a dependency of magnum.

Anyway, I will mark the issue as closed. Thanks again for the quick help!

mosra commented 5 years ago

You're welcome! :)

Interesting, didn't know about SDL2Config from vcpkg, thank you.

FeraiAli commented 5 years ago

Hello, I would like to ask question, about building from source. The imgui sources are copied from the Dear ImGui repositry as it is. I'm using FindImGui.cmake from the MagnumIntegration/modules. And the main CMakeList.txt file is organized as:

cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
project(imgui_test_project)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/modules/")
set(WITH_SDL2APPLICATION ON CACHE BOOL "Build Sdl2Application library")
set(IMGUI_DIR "${PROJECT_SOURCE_DIR}/core/imgui/")

add_subdirectory(corrade)
add_subdirectory(magnum)
add_subdirectory(magnum_integration)
add_subdirectory(src)

In 'src' CMakeLists.txt when write find_package(MagnumIntegration REQUIRED ImGui) I'm getting error: "Could NOT find MagnumIntegration (missing: ImGui)"

The only thing i found that may be the case is in FindImGui.cmake ImGui_FIND_COMPONENTS is empty.

Couldn't found example with building from source either to see if i'm doing everything fine.

mosra commented 5 years ago

@FeraiAli hi! the ImGuiIntegration is, like Sdl2Application, not enabled by default. So if you set(WITH_IMGUI ON) as well, it should work.

FeraiAli commented 5 years ago

@mosra Thank you, very much. It worked. :))