CPM.cmake icon indicating copy to clipboard operation
CPM.cmake copied to clipboard

Help adding ImGui using CPM

Open cyric2020 opened this issue 3 years ago • 2 comments

Hello, I have tried using cpm to add the ImGui module to my c++ project.

Different methods I've tried.

CPMAddPackage(
  NAME imgui
  GITHUB_REPOSITORY ocornut/imgui
  GIT_TAG v1.88
)
CPMAddPackage(
  NAME imgui
  GITHUB_REPOSITORY ocornut/imgui
  VERSION 1.88
)
CPMAddPackage("https://github.com/ocornut/imgui/archive/refs/tags/v1.88.zip")

Thanks for any support you can give me :)

cyric2020 avatar Jul 04 '22 06:07 cyric2020

Correct me if I'm wrong, but I'm pretty sure ImGui does not come with any project file using any build system whatsoever. Given that, you'll likely have to create the targets yourself or add the sources to an existing one using the variable imgui_SOURCE_DIR that points to where CPM cloned it.

oddko avatar Jul 05 '22 21:07 oddko

I use this:

CPMAddPackage(gh:ocornut/[email protected])

add_library(imgui STATIC
    ${imgui_SOURCE_DIR}/imgui.cpp
    ${imgui_SOURCE_DIR}/imgui_demo.cpp # optionally comment this out
    ${imgui_SOURCE_DIR}/imgui_draw.cpp
    ${imgui_SOURCE_DIR}/imgui_widgets.cpp
    ${imgui_SOURCE_DIR}/imgui_tables.cpp
)
target_include_directories(imgui INTERFACE ${imgui_SOURCE_DIR})
target_compile_definitions(imgui PUBLIC -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS) # optional imgui setting
set_target_properties(imgui PROPERTIES FOLDER third-party) # optoinal IDE dir

iboB avatar Jul 07 '22 11:07 iboB