imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Add simple cmake

Open yh-sb opened this issue 2 years ago • 5 comments

I have looked into pull requests which add cmake to imgui project. Trying to cover both, imgui backends and examples, they just stuck in review state.

Let's go another way: add simple cmake for imgui itself. I tried to create a simple and easy to use CMakeLists.txt.

Here is how imgui integration will look into some project:

set(IMGUI_BACKEND_GLFW ON CACHE BOOL "")
set(IMGUI_BACKEND_OPENGL3 ON CACHE BOOL "")
add_subdirectory(third_party/imgui)
...
target_link_libraries(some_project_name PRIVATE imgui)

Tested on Windows and Linux.

@ocornut, if you are not ok with keeping cmake file in imgui root, then we can move it to /cmake directory.

yh-sb avatar Oct 02 '21 15:10 yh-sb

The vcpkg port of ImGui uses CMake for building and also includes support for backends. Maybe it is worth just adapting the "recipe" from there, given there will be little to no change needed? Also remember vcpkg is widely used so the cmake "recipe" is already tested on different environments.

TerensTare avatar Dec 16 '21 08:12 TerensTare

I am probably doing something wrong, I dropped this CMakeLists.txt file at the root of the project and cmake gives me this:

   ninja: error: build.ninja:143: bad $-escape (literal $ must be written as $$)
    LINK_LIBRARIES = $<0:d3d10.lib  -ld3dcompiler.lib>  $<0:d3d11.lib  -ld...
                     ^ near here

AdelKS avatar Dec 17 '21 18:12 AdelKS

@AdelKS, If I understand you correctly, it seems that you placed this CMakeLists.txt to the root of your top-level project. But it is intended to be in the root of imgui library, not in root of top-level project. After that, in top-level CMakeLists.txt paste the code from the first comment in this pull request.

yh-sb avatar Dec 23 '21 22:12 yh-sb

Hi @ocornut , Any reason to not add this feature? If so, I will close this PR.

yh-sb avatar Apr 06 '24 07:04 yh-sb

I prefer to keep them open as useful reference but haven’t had time to wade through the million of cmake suggestions.

ocornut avatar Apr 06 '24 09:04 ocornut