Skip to content

Commit c8bce83

Browse files
committed
add example CMake configuration
1 parent f339b24 commit c8bce83

File tree

17 files changed

+309
-0
lines changed

17 files changed

+309
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build/

CMakeLists.txt

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
project (imgui)
2+
cmake_minimum_required (VERSION 3.2)
3+
4+
option (IMGUI_EXAMPLES "Build ImGui examples" ON)
5+
option (IMGUI_DEMO "Include the ImGui demo window implementation in library" ON)
6+
7+
option (IMGUI_IMPL_SDL "Build the SDL implementation (only if supported)" ON)
8+
option (IMGUI_IMPL_METAL "Build the Metal implementation (only if supported)" ON)
9+
option (IMGUI_IMPL_OSX "Build the OSX implementation (only if supported)" ON)
10+
option (IMGUI_IMPL_GLFW "Build the GLFW implementation (only if supported)" ON)
11+
option (IMGUI_IMPL_GLUT "Build the GLUT implementation (only if supported)" ON)
12+
option (IMGUI_IMPL_OPENGL "Build the OpenGL implementation (only if supported)" ON)
13+
option (IMGUI_IMPL_OPENGL2 "Build the OpenGL 2 (legacy) implementation (only if supported)" ${IMGUI_IMPL_OPENGL})
14+
15+
set (CMAKE_CXX_STANDARD 11)
16+
17+
if (IMGUI_DEMO)
18+
set (IMGUI_DEMO_SRC imgui_demo.cpp)
19+
endif ()
20+
21+
add_library (imgui STATIC
22+
imgui.cpp
23+
imgui_draw.cpp
24+
imgui_widgets.cpp
25+
${IMGUI_DEMO_SRC}
26+
)
27+
28+
target_include_directories (imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
29+
30+
if (NOT IMGUI_DEMO)
31+
target_compile_definitions (imgui PUBLIC -DIMGUI_DISABLE_DEMO_WINDOWS=1)
32+
endif ()
33+
34+
if (IMGUI_IMPL_SDL)
35+
include (examples/imgui_impl_sdl.cmake)
36+
endif ()
37+
if (IMGUI_IMPL_METAL)
38+
include (examples/imgui_impl_metal.cmake)
39+
endif ()
40+
if (IMGUI_IMPL_OSX)
41+
include (examples/imgui_impl_osx.cmake)
42+
endif ()
43+
if (IMGUI_IMPL_GLFW)
44+
include (examples/imgui_impl_glfw.cmake)
45+
endif ()
46+
if (IMGUI_IMPL_OPENGL OR IMGUI_IMPL_OPENGL2)
47+
include (examples/imgui_impl_opengl.cmake)
48+
endif ()
49+
if (IMGUI_IMPL_GLUT)
50+
include (examples/imgui_impl_glut.cmake)
51+
endif ()
52+
53+
if (IMGUI_EXAMPLES)
54+
set (IMGUI_EXAMPLE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
55+
56+
#add_subdirectory (examples/example_allegro5)
57+
add_subdirectory (examples/example_apple_metal)
58+
#add_subdirectory (examples/example_apple_opengl2)
59+
#add_subdirectory (examples/example_emscripten)
60+
add_subdirectory (examples/example_glfw_metal)
61+
add_subdirectory (examples/example_glfw_opengl2)
62+
add_subdirectory (examples/example_glfw_opengl3)
63+
#add_subdirectory (examples/example_glfw_vulkan)
64+
add_subdirectory (examples/example_glut_opengl2)
65+
#add_subdirectory (examples/example_marmalade)
66+
add_subdirectory (examples/example_null)
67+
#add_subdirectory (examples/example_sdl_directx11)
68+
add_subdirectory (examples/example_sdl_metal)
69+
add_subdirectory (examples/example_sdl_opengl2)
70+
add_subdirectory (examples/example_sdl_opengl3)
71+
#add_subdirectory (examples/example_sdl_vulkan)
72+
#add_subdirectory (examples/example_win32_directx10)
73+
#add_subdirectory (examples/example_win32_directx11)
74+
#add_subdirectory (examples/example_win32_directx12)
75+
#add_subdirectory (examples/example_win32_directx9)
76+
endif ()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if (TARGET imgui-metal AND TARGET imgui-osx)
2+
# TODO proper bundling of assets for macOS and iOS
3+
4+
add_executable (imgui_example_apple_metal
5+
Shared/main.m
6+
Shared/AppDelegate.m
7+
Shared/Renderer.mm
8+
Shared/ViewController.mm
9+
)
10+
11+
target_link_libraries (imgui_example_apple_metal
12+
imgui-metal imgui-osx
13+
)
14+
15+
set_target_properties (imgui_example_apple_metal
16+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
17+
)
18+
endif ()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (TARGET imgui-glfw AND TARGET imgui-metal)
2+
add_executable (imgui_example_glfw_metal main.mm)
3+
4+
target_link_libraries (imgui_example_glfw_metal
5+
imgui-glfw imgui-metal
6+
)
7+
8+
set_target_properties (imgui_example_glfw_metal
9+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
10+
)
11+
endif ()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (TARGET imgui-glfw AND TARGET imgui-opengl2)
2+
add_executable (imgui_example_glfw_opengl2 main.cpp)
3+
4+
target_link_libraries (imgui_example_glfw_opengl2
5+
imgui-glfw imgui-opengl2
6+
)
7+
8+
set_target_properties (imgui_example_glfw_opengl2
9+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
10+
)
11+
endif ()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (TARGET imgui-glfw AND TARGET imgui-opengl)
2+
add_executable (imgui_example_glfw_opengl3 main.cpp)
3+
4+
target_link_libraries (imgui_example_glfw_opengl3
5+
imgui-glfw imgui-opengl
6+
)
7+
8+
set_target_properties (imgui_example_glfw_opengl3
9+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
10+
)
11+
endif ()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (TARGET imgui-glut AND TARGET imgui-opengl2)
2+
add_executable (imgui_example_glut_opengl2 main.cpp)
3+
4+
target_link_libraries (imgui_example_glut_opengl2
5+
imgui-glut imgui-opengl2
6+
)
7+
8+
set_target_properties (imgui_example_glut_opengl2
9+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
10+
)
11+
endif ()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_executable (imgui_example_null main.cpp)
2+
target_link_libraries (imgui_example_null imgui)
3+
4+
set_target_properties (imgui_example_null
5+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
6+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (TARGET imgui-sdl AND TARGET imgui-metal)
2+
add_executable (imgui_example_sdl_metal main.mm)
3+
4+
target_link_libraries (imgui_example_sdl_metal
5+
imgui-sdl imgui-metal
6+
)
7+
8+
set_target_properties (imgui_example_sdl_metal
9+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
10+
)
11+
endif ()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (TARGET imgui-sdl AND TARGET imgui-opengl2)
2+
add_executable (imgui_example_sdl_opengl2 main.cpp)
3+
4+
target_link_libraries (imgui_example_sdl_opengl2
5+
imgui-sdl imgui-opengl2
6+
)
7+
8+
set_target_properties (imgui_example_sdl_opengl2
9+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}"
10+
)
11+
endif ()

0 commit comments

Comments
 (0)