Added Cmake Backends

This commit is contained in:
Pinwhell 2024-09-17 04:58:28 -04:00
parent 63cd4d95a3
commit 2f28247606
2 changed files with 36 additions and 0 deletions

View File

@ -2,14 +2,22 @@ cmake_minimum_required(VERSION 3.15)
project(imgui)
option(IMGUI_IMPL_WIN32 "Enable ImGui Win32 implementation" ON)
option(IMGUI_IMPL_OPENGL2 "Enable ImGui OpenGL2 implementation" OFF)
option(IMGUI_IMPL_OPENGL3 "Enable ImGui OpenGL3 implementation" OFF)
option(IMGUI_ENABLE_PLAYGROUND "Enable playground subdirectory" OFF)
set(IMGUI_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_library(imgui-core STATIC)
target_sources(imgui-core PUBLIC imgui.cpp imgui_demo.cpp imgui_draw.cpp imgui_tables.cpp imgui_widgets.cpp)
target_include_directories(imgui-core PUBLIC ${IMGUI_INC_DIR})
add_subdirectory(misc)
add_subdirectory(backends)
# Playground is a private space where dev might test/experiment/freestyle stuffs
if(IMGUI_ENABLE_PLAYGROUND)
if(EXISTS playground)
add_subdirectory(playground)
endif()
endif()

28
backends/CMakeLists.txt Normal file
View File

@ -0,0 +1,28 @@
if(IMGUI_IMPL_OPENGL2 OR IMGUI_IMPL_OPENGL3)
find_package(OpenGL)
endif()
if(IMGUI_IMPL_WIN32)
add_library(imgui-impl-win32 STATIC)
target_sources(imgui-impl-win32 PUBLIC imgui_impl_win32.cpp)
target_include_directories(imgui-impl-win32 PUBLIC ${IMGUI_INC_DIR})
endif()
if(OpenGL_FOUND)
if(IMGUI_IMPL_OPENGL2)
add_library(imgui-impl-opengl2 STATIC)
target_sources(imgui-impl-opengl2 PUBLIC imgui_impl_opengl2.cpp)
target_include_directories(imgui-impl-opengl2 PUBLIC ${IMGUI_INC_DIR})
target_link_libraries(imgui-impl-opengl2 OpenGL::GL)
endif()
if(IMGUI_IMPL_OPENGL3)
add_library(imgui-impl-opengl3 STATIC)
target_sources(imgui-impl-opengl3 PUBLIC imgui_impl_opengl3.cpp)
target_include_directories(imgui-impl-opengl3 PUBLIC ${IMGUI_INC_DIR})
target_link_libraries(imgui-impl-opengl3 OpenGL::GL)
endif()
endif()