mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Update for recent versions. C++11. Backends moved to backends/ folder. Renamed reference to SDL to SDL2.
This commit is contained in:
parent
a67c7cf77e
commit
55402fdcf4
18 changed files with 78 additions and 100 deletions
|
|
@ -1,17 +1,18 @@
|
|||
cmake_minimum_required (VERSION 3.8.2)
|
||||
cmake_minimum_required (VERSION 3.10)
|
||||
project(imgui VERSION 1.73.0 LANGUAGES CXX C)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
|
||||
option (IMGUI_EXAMPLES "Build ImGui examples" ON)
|
||||
option (IMGUI_DEMO "Include the ImGui demo window implementation in library" ON)
|
||||
|
||||
option (IMGUI_IMPL_SDL "Build the SDL implementation (only if supported)" ON)
|
||||
option (IMGUI_IMPL_SDL2 "Build the SDL implementation (only if supported)" ON)
|
||||
option (IMGUI_IMPL_METAL "Build the Metal implementation (only if supported)" ${APPLE})
|
||||
option (IMGUI_IMPL_OSX "Build the OSX implementation (only if supported)" ${APPLE})
|
||||
option (IMGUI_IMPL_WIN32 "Build the Win32 (native winapi) implementation (only if supported)" ${WIN32})
|
||||
option (IMGUI_IMPL_GLFW "Build the GLFW implementation (only if supported)" ON)
|
||||
option (IMGUI_IMPL_GLUT "Build the GLUT implementation (only if supported)" ON)
|
||||
option (IMGUI_IMPL_OPENGL "Build the OpenGL implementation (only if supported)" ON)
|
||||
option (IMGUI_IMPL_OPENGL2 "Build the OpenGL 2 (legacy) implementation (only if supported)" ${IMGUI_IMPL_OPENGL})
|
||||
option (IMGUI_IMPL_OPENGL "Build the OpenGL3 implementation (only if supported)" ON)
|
||||
option (IMGUI_IMPL_OPENGL2 "Build the OpenGL2 (legacy) implementation (only if supported)" ${IMGUI_IMPL_OPENGL})
|
||||
option (IMGUI_IMPL_DX9 "Build the DirectX 9 implementation (only if supported)" ${WIN32})
|
||||
option (IMGUI_IMPL_DX10 "Build the DirectX 10 implementation (only if supported)" ${WIN32})
|
||||
option (IMGUI_IMPL_DX11 "Build the DirectX 11 implementation (only if supported)" ${WIN32})
|
||||
|
|
@ -20,6 +21,7 @@ option (IMGUI_IMPL_DX12 "Build the DirectX 12 implementation (only if supported)
|
|||
add_library (imgui
|
||||
imgui.cpp
|
||||
imgui_draw.cpp
|
||||
imgui_tables.cpp
|
||||
imgui_widgets.cpp
|
||||
$<$<BOOL:IMGUI_DEMO>:imgui_demo.cpp>
|
||||
)
|
||||
|
|
@ -28,7 +30,7 @@ add_library(imgui::imgui ALIAS imgui)
|
|||
|
||||
target_include_directories (imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
target_compile_features(imgui PRIVATE cxx_std_98)
|
||||
target_compile_features(imgui PRIVATE cxx_std_11)
|
||||
|
||||
if (IMGUI_EXAMPLES)
|
||||
# Sets up polyfill libraries for Windows examples (e.g. GLFW)
|
||||
|
|
@ -39,38 +41,38 @@ if (NOT IMGUI_DEMO)
|
|||
target_compile_definitions (imgui PUBLIC -DIMGUI_DISABLE_DEMO_WINDOWS=1)
|
||||
endif ()
|
||||
|
||||
if (IMGUI_IMPL_SDL)
|
||||
include (examples/imgui_impl_sdl.cmake)
|
||||
if (IMGUI_IMPL_SDL2)
|
||||
include (backends/imgui_impl_sdl2.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_METAL)
|
||||
include (examples/imgui_impl_metal.cmake)
|
||||
include (backends/imgui_impl_metal.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_OSX)
|
||||
include (examples/imgui_impl_osx.cmake)
|
||||
include (backends/imgui_impl_osx.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_WIN32)
|
||||
include (examples/imgui_impl_win32.cmake)
|
||||
include (backends/imgui_impl_win32.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_GLFW)
|
||||
include (examples/imgui_impl_glfw.cmake)
|
||||
include (backends/imgui_impl_glfw.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_OPENGL OR IMGUI_IMPL_OPENGL2)
|
||||
include (examples/imgui_impl_opengl.cmake)
|
||||
include (backends/imgui_impl_opengl.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_GLUT)
|
||||
include (examples/imgui_impl_glut.cmake)
|
||||
include (backends/imgui_impl_glut.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_DX9)
|
||||
include (examples/imgui_impl_dx9.cmake)
|
||||
include (backends/imgui_impl_dx9.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_DX10)
|
||||
include (examples/imgui_impl_dx10.cmake)
|
||||
include (backends/imgui_impl_dx10.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_DX11)
|
||||
include (examples/imgui_impl_dx11.cmake)
|
||||
include (backends/imgui_impl_dx11.cmake)
|
||||
endif ()
|
||||
if (IMGUI_IMPL_DX12)
|
||||
include (examples/imgui_impl_dx12.cmake)
|
||||
include (backends/imgui_impl_dx12.cmake)
|
||||
endif ()
|
||||
|
||||
if (IMGUI_EXAMPLES)
|
||||
|
|
@ -86,11 +88,11 @@ if (IMGUI_EXAMPLES)
|
|||
#add_subdirectory (examples/example_glfw_vulkan)
|
||||
add_subdirectory (examples/example_glut_opengl2)
|
||||
add_subdirectory (examples/example_null)
|
||||
#add_subdirectory (examples/example_sdl_directx11)
|
||||
add_subdirectory (examples/example_sdl_metal)
|
||||
add_subdirectory (examples/example_sdl_opengl2)
|
||||
add_subdirectory (examples/example_sdl_opengl3)
|
||||
#add_subdirectory (examples/example_sdl_vulkan)
|
||||
#add_subdirectory (examples/example_sdl2_directx11)
|
||||
add_subdirectory (examples/example_sdl2_metal)
|
||||
add_subdirectory (examples/example_sdl2_opengl2)
|
||||
add_subdirectory (examples/example_sdl2_opengl3)
|
||||
#add_subdirectory (examples/example_sdl2_vulkan)
|
||||
add_subdirectory (examples/example_win32_directx10)
|
||||
add_subdirectory (examples/example_win32_directx11)
|
||||
add_subdirectory (examples/example_win32_directx12)
|
||||
|
|
|
|||
19
backends/imgui_impl_opengl.cmake
Normal file
19
backends/imgui_impl_opengl.cmake
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
find_package (OpenGL QUIET)
|
||||
|
||||
if (OPENGL_gl_LIBRARY)
|
||||
if (IMGUI_IMPL_OPENGL2)
|
||||
add_library (imgui-opengl2 OBJECT
|
||||
"${CMAKE_CURRENT_LIST_DIR}/imgui_impl_opengl2.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries (imgui-opengl2 PUBLIC
|
||||
imgui
|
||||
"${OPENGL_gl_LIBRARY}"
|
||||
)
|
||||
|
||||
target_include_directories (imgui-opengl2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
target_include_directories (imgui-opengl2 SYSTEM PUBLIC "${OPENGL_INCLUDE_DIR}")
|
||||
endif ()
|
||||
else ()
|
||||
message (WARNING "IMGUI_IMPL_OPENGL and/or IMGUI_IMPL_OPENGL2 set to ON but OpenGL could not be found")
|
||||
endif ()
|
||||
19
backends/imgui_impl_sdl2.cmake
Normal file
19
backends/imgui_impl_sdl2.cmake
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
find_package (SDL2 QUIET)
|
||||
|
||||
if (SDL2_DIR)
|
||||
add_library (imgui-sdl2 OBJECT
|
||||
"${CMAKE_CURRENT_LIST_DIR}/imgui_impl_sdl2.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries (imgui-sdl2 PUBLIC imgui sdl2)
|
||||
target_include_directories (imgui-sdl2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
# Fixes a strange inclusion problem on MacOS due to an unconventional
|
||||
# SDL installation with Homebrew. Innocuous if SDL is being pulled in
|
||||
# from somewhere else.
|
||||
if (APPLE)
|
||||
target_include_directories (imgui-sdl2 SYSTEM PUBLIC "/usr/local/include/SDL2")
|
||||
endif ()
|
||||
else ()
|
||||
message (WARNING "IMGUI_IMPL_SDL2 set to ON but SDL2 not found on system or in project")
|
||||
endif ()
|
||||
|
|
@ -2,10 +2,7 @@ if (TARGET imgui-metal AND TARGET imgui-osx)
|
|||
# TODO proper bundling of assets for macOS and iOS
|
||||
|
||||
add_executable (imgui_example_apple_metal
|
||||
Shared/main.m
|
||||
Shared/AppDelegate.m
|
||||
Shared/Renderer.mm
|
||||
Shared/ViewController.mm
|
||||
main.mm
|
||||
)
|
||||
|
||||
target_link_libraries (imgui_example_apple_metal
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
if (TARGET imgui-sdl AND TARGET imgui-metal)
|
||||
add_executable (imgui_example_sdl_metal main.mm)
|
||||
if (TARGET imgui-sdl2 AND TARGET imgui-metal)
|
||||
add_executable (imgui_example_sdl2_metal main.mm)
|
||||
|
||||
target_link_libraries (imgui_example_sdl_metal
|
||||
imgui-sdl imgui-metal
|
||||
target_link_libraries (imgui_example_sdl2_metal
|
||||
imgui-sdl2 imgui-metal
|
||||
)
|
||||
|
||||
set_target_properties (imgui_example_sdl_metal
|
||||
set_target_properties (imgui_example_sdl2_metal
|
||||
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
|
||||
)
|
||||
endif ()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
if (TARGET imgui-sdl AND TARGET imgui-opengl2)
|
||||
add_executable (imgui_example_sdl_opengl2 WIN32 main.cpp)
|
||||
if (TARGET imgui-sdl2 AND TARGET imgui-opengl2)
|
||||
add_executable (imgui_example_sdl2_opengl2 WIN32 main.cpp)
|
||||
|
||||
target_link_libraries (imgui_example_sdl_opengl2
|
||||
imgui-sdl imgui-opengl2
|
||||
target_link_libraries (imgui_example_sdl2_opengl2
|
||||
imgui-sdl2 imgui-opengl2
|
||||
)
|
||||
|
||||
set_target_properties (imgui_example_sdl_opengl2
|
||||
set_target_properties (imgui_example_sdl2_opengl2
|
||||
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
|
||||
)
|
||||
endif ()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
if (TARGET imgui-sdl AND TARGET imgui-opengl)
|
||||
add_executable (imgui_example_sdl_opengl3 main.cpp)
|
||||
if (TARGET imgui-sdl2 AND TARGET imgui-opengl)
|
||||
add_executable (imgui_example_sdl2_opengl3 main.cpp)
|
||||
|
||||
target_link_libraries (imgui_example_sdl_opengl3
|
||||
imgui-sdl imgui-opengl
|
||||
target_link_libraries (imgui_example_sdl2_opengl3
|
||||
imgui-sdl2 imgui-opengl
|
||||
)
|
||||
|
||||
set_target_properties (imgui_example_sdl_opengl3
|
||||
set_target_properties (imgui_example_sdl2_opengl3
|
||||
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
|
||||
)
|
||||
endif ()
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
find_package (OpenGL QUIET)
|
||||
|
||||
if (OPENGL_gl_LIBRARY)
|
||||
if (IMGUI_IMPL_OPENGL2)
|
||||
add_library (imgui-opengl2 OBJECT
|
||||
"${CMAKE_CURRENT_LIST_DIR}/imgui_impl_opengl2.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries (imgui-opengl2 PUBLIC
|
||||
imgui
|
||||
"${OPENGL_gl_LIBRARY}"
|
||||
)
|
||||
|
||||
target_include_directories (imgui-opengl2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
target_include_directories (imgui-opengl2 SYSTEM PUBLIC "${OPENGL_INCLUDE_DIR}")
|
||||
endif ()
|
||||
|
||||
if (IMGUI_IMPL_OPENGL)
|
||||
find_package (GLEW)
|
||||
|
||||
if (GLEW_DIR)
|
||||
add_library (imgui-opengl OBJECT
|
||||
"${CMAKE_CURRENT_LIST_DIR}/imgui_impl_opengl3.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries (imgui-opengl PUBLIC
|
||||
imgui
|
||||
"${OPENGL_gl_LIBRARY}"
|
||||
glew
|
||||
)
|
||||
|
||||
target_include_directories (imgui-opengl PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
target_include_directories (imgui-opengl SYSTEM PUBLIC "${OPENGL_INCLUDE_DIR}")
|
||||
else ()
|
||||
message (WARNING "IMGUI_IMPL_OPENGL set to ON but GLEW could not be found")
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
message (WARNING "IMGUI_IMPL_OPENGL and/or IMGUI_IMPL_OPENGL2 set to ON but OpenGL could not be found")
|
||||
endif ()
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
find_package (SDL2 QUIET)
|
||||
|
||||
if (SDL2_DIR)
|
||||
add_library (imgui-sdl OBJECT
|
||||
"${CMAKE_CURRENT_LIST_DIR}/imgui_impl_sdl.cpp"
|
||||
)
|
||||
|
||||
target_link_libraries (imgui-sdl PUBLIC imgui sdl2)
|
||||
target_include_directories (imgui-sdl PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
# Fixes a strange inclusion problem on MacOS due to an unconventional
|
||||
# SDL installation with Homebrew. Innocuous if SDL is being pulled in
|
||||
# from somewhere else.
|
||||
if (APPLE)
|
||||
target_include_directories (imgui-sdl SYSTEM PUBLIC "/usr/local/include/SDL2")
|
||||
endif ()
|
||||
else ()
|
||||
message (WARNING "IMGUI_IMPL_SDL set to ON but SDL2 not found on system or in project")
|
||||
endif ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue