imgui
imgui copied to clipboard
add basic CMake implementation
Hi,
there are quite a few CMake pull requests, but none of them do what I propose/need.
Description:
This pull requests adds CMake not for examples, but rather for integrating imgui in other CMake projects. Using this it is possible to integrate imgui in another CMake project like this (assuming e.g. imgui is a git submodule):
...
add_subdirectory(deps/imgui)
...
target_link_libraries(mytarget PUBLIC imgui)
It is also possible to depend on a specific backend:
...
set(IMGUI_BACKEND_GLFW ON)
add_subdirectory(deps/imgui)
...
# all necessary headers, glfw, etc. are all linked with it already, as the imgui CMake targets depend on them
target_link_libraries(mytarget PUBLIC imgui_backend_glfw)
...
Incentive:
The benefit of this approach is much easier maintenance compared in case of changes in the names of files, addition of new files, etc. Imgui Module authors can also depend on imgui in their CMake Files without having to provide variables like "imgui location" and such (so in case of new files no changes are necessary usually). Furthermore the dependecies of backends are handled by the build system and people "just using" one of these backends should not need to configure additional libraries or include paths.
Sideeffects:
It does not break any existing features/buildsystems, because there are none I know of and there are no changes to the source files themselves.
Limitations:
I did not yet test all backends (Mac, Windows, Allegro, WGPU are untested), parts of the code are adapted from https://github.com/ocornut/imgui/pull/4614/files
There currently only is support for the CPP Module in misc/.
The examples are not covered with this code, as they can be built using a Makefile already (and are only for demonstration).
@ev1313 Do you need help following up on the feedback?