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

Options to build IMGUI with other implementations #1

Open
francescobrischetto opened this issue May 10, 2022 · 6 comments
Open

Options to build IMGUI with other implementations #1

francescobrischetto opened this issue May 10, 2022 · 6 comments

Comments

@francescobrischetto
Copy link

Hi,
I'm new to cmake and IMGUI, but I need to build the library for glfw and opengl3. I saw that you didn't provide cmake flags for it. How can I modify it?

@mariocjun
Copy link

Hi, I'm new to cmake and IMGUI, but I need to build the library for glfw and opengl3. I saw that you didn't provide cmake flags for it. How can I modify it?

please!

@grahamreeds
Copy link

@francescobrischetto @mariocjun @giladreich I added a backend for Vulcan. May not work as I am having trouble getting it to work though everything looks like it should (it compiles fine).

@giladreich
Copy link
Owner

Hi folks, thanks for this issue. I still didn't get around adding more Backends & Platforms. Please feel free to create a PR if you got something already. There are some TODOs in the CMake files and it needs some validation / dependent cmake options, depending on the Backend or Platform, since some Backends may use multiple Platforms.

@grahamreeds
Copy link

@giladreich In your post (https://greich.com/projects/ImGui-CMake-Installer/) you mention that passing cmake .. -DIMGUI_IMPL_DX11=ON would build the example.

My CMakeFu isn't that great but I can't see how that could possibly work with the CMakeFile as it is.

@giladreich
Copy link
Owner

@giladreich In your post (https://greich.com/projects/ImGui-CMake-Installer/) you mention that passing cmake .. -DIMGUI_IMPL_DX11=ON would build the example.

My CMakeFu isn't that great but I can't see how that could possibly work with the CMakeFile as it is.

@grahamreeds sorry for the confusion. Please refer to the README in this repository as the source of true. I forgot updating my blog since I refactored this CMake module.

@giladreich
Copy link
Owner

I had some progress on this during the weekend, but it requires noticeably changing the way import targets were done. I'll try to finish it and setup CI/CD for Windows, macOS and Linux to build and distribute the library for all platforms. Then I'll draft tarballs in the releases. That way if people would prefer to not build from source, they can import the package to their projects for whatever platforms or renderers they select. Sample code:

cmake_minimum_required(VERSION 3.18)
project(imgui_app LANGUAGES CXX)
find_package(ImGui CONFIG REQUIRED
  COMPONENTS
    glfw_shared
    opengl2_shared
  PATHS "$ENV{IMGUI_SDK}"
)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME}
  PRIVATE
    ImGui::core_shared
    ImGui::glfw_shared
    ImGui::opengl2_shared
)

This also works:

target_link_libraries(${PROJECT_NAME}
  PRIVATE
    ImGui::glfw_shared
    ImGui::opengl2_shared
)

because backends will automatically import the ImGui::core_shared into the target. Technically one could also get into their app all backends if they wish, as long as they got all of them installed:

find_package(ImGui CONFIG REQUIRED
  COMPONENTS
    glfw_shared
    glfw_static
    glut_shared
    glut_static
    sdl2_shared
    sdl2_static
    sdl3_shared
    sdl3_static
    opengl2_shared
    opengl2_static
    opengl3_shared
    opengl3_static
    sdlrenderer2_shared
    sdlrenderer2_static
    sdlrenderer3_shared
    sdlrenderer3_static
    vulkan_shared
    vulkan_static
  PATHS "$ENV{IMGUI_SDK}"
)

ImGuiConfig.cmake will verify that and error out for missing components or environment variables. I still need to finish some CPack stuff and then CI/CD before it will be finished. Perhaps next weekend I will find time for this.
FYI: @grahamreeds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants