Skip to content

Instantly share code, notes, and snippets.

@jeffamstutz
Created February 8, 2021 14:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffamstutz/992723dfabac4e3ffff265eb71a24cd9 to your computer and use it in GitHub Desktop.
Save jeffamstutz/992723dfabac4e3ffff265eb71a24cd9 to your computer and use it in GitHub Desktop.
CMake FetchContent to get ImGui
FetchContent_Populate(imgui
URL https://github.com/ocornut/imgui/archive/docking.zip
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui
)
set(OpenGL_GL_PREFERENCE "LEGACY")
find_package(OpenGL 2 REQUIRED)
find_package(glfw3 REQUIRED)
add_library(imgui_glfw STATIC
imgui/imgui.cpp
imgui/imgui_draw.cpp
imgui/imgui_demo.cpp
imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp
imgui/backends/imgui_impl_glfw.cpp
imgui/backends/imgui_impl_opengl2.cpp
)
target_link_libraries(imgui_glfw PUBLIC glfw ${OPENGL_LIBRARIES})
target_include_directories(imgui_glfw
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/imgui
${CMAKE_CURRENT_LIST_DIR}/imgui/backends
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment