From 87f347be3f943ee61d5eb8ce88987ca0ae27805f Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sun, 16 Feb 2020 18:52:12 +0100 Subject: [PATCH 1/8] add example CMake configuration --- CMakeLists.txt | 100 ++++++++++++++++++ examples/example_apple_metal/CMakeLists.txt | 18 ++++ examples/example_apple_opengl2/CMakeLists.txt | 11 ++ examples/example_glfw_metal/CMakeLists.txt | 11 ++ examples/example_glfw_opengl2/CMakeLists.txt | 11 ++ examples/example_glfw_opengl3/CMakeLists.txt | 11 ++ examples/example_glut_opengl2/CMakeLists.txt | 11 ++ examples/example_null/CMakeLists.txt | 6 ++ examples/example_sdl2_metal/CMakeLists.txt | 11 ++ examples/example_sdl2_opengl2/CMakeLists.txt | 11 ++ examples/example_sdl2_opengl3/CMakeLists.txt | 11 ++ .../example_win32_directx10/CMakeLists.txt | 11 ++ .../example_win32_directx11/CMakeLists.txt | 11 ++ .../example_win32_directx12/CMakeLists.txt | 11 ++ .../example_win32_directx9/CMakeLists.txt | 11 ++ examples/imgui_impl_dx10.cmake | 26 +++++ examples/imgui_impl_dx11.cmake | 26 +++++ examples/imgui_impl_dx12.cmake | 26 +++++ examples/imgui_impl_dx9.cmake | 19 ++++ examples/imgui_impl_glfw.cmake | 14 +++ examples/imgui_impl_glut.cmake | 26 +++++ examples/imgui_impl_metal.cmake | 19 ++++ examples/imgui_impl_opengl.cmake | 40 +++++++ examples/imgui_impl_osx.cmake | 15 +++ examples/imgui_impl_sdl.cmake | 19 ++++ examples/imgui_impl_win32.cmake | 11 ++ examples/libs/glfw.cmake | 24 +++++ 27 files changed, 521 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 examples/example_apple_metal/CMakeLists.txt create mode 100644 examples/example_apple_opengl2/CMakeLists.txt create mode 100644 examples/example_glfw_metal/CMakeLists.txt create mode 100644 examples/example_glfw_opengl2/CMakeLists.txt create mode 100644 examples/example_glfw_opengl3/CMakeLists.txt create mode 100644 examples/example_glut_opengl2/CMakeLists.txt create mode 100644 examples/example_null/CMakeLists.txt create mode 100644 examples/example_sdl2_metal/CMakeLists.txt create mode 100644 examples/example_sdl2_opengl2/CMakeLists.txt create mode 100644 examples/example_sdl2_opengl3/CMakeLists.txt create mode 100644 examples/example_win32_directx10/CMakeLists.txt create mode 100644 examples/example_win32_directx11/CMakeLists.txt create mode 100644 examples/example_win32_directx12/CMakeLists.txt create mode 100644 examples/example_win32_directx9/CMakeLists.txt create mode 100644 examples/imgui_impl_dx10.cmake create mode 100644 examples/imgui_impl_dx11.cmake create mode 100644 examples/imgui_impl_dx12.cmake create mode 100644 examples/imgui_impl_dx9.cmake create mode 100644 examples/imgui_impl_glfw.cmake create mode 100644 examples/imgui_impl_glut.cmake create mode 100644 examples/imgui_impl_metal.cmake create mode 100644 examples/imgui_impl_opengl.cmake create mode 100644 examples/imgui_impl_osx.cmake create mode 100644 examples/imgui_impl_sdl.cmake create mode 100644 examples/imgui_impl_win32.cmake create mode 100644 examples/libs/glfw.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..e890ed846 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,100 @@ +project (imgui) +cmake_minimum_required (VERSION 3.2) + +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_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_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}) +option (IMGUI_IMPL_DX12 "Build the DirectX 12 implementation (only if supported)" ${WIN32}) + +set (CMAKE_CXX_STANDARD 11) + +if (IMGUI_DEMO) + set (IMGUI_DEMO_SRC imgui_demo.cpp) +endif () + +add_library (imgui STATIC + imgui.cpp + imgui_draw.cpp + imgui_widgets.cpp + ${IMGUI_DEMO_SRC} +) + +target_include_directories (imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +if (IMGUI_EXAMPLES) + # Sets up polyfill libraries for Windows examples (e.g. GLFW) + include (examples/libs/glfw.cmake) +endif () + +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) +endif () +if (IMGUI_IMPL_METAL) + include (examples/imgui_impl_metal.cmake) +endif () +if (IMGUI_IMPL_OSX) + include (examples/imgui_impl_osx.cmake) +endif () +if (IMGUI_IMPL_WIN32) + include (examples/imgui_impl_win32.cmake) +endif () +if (IMGUI_IMPL_GLFW) + include (examples/imgui_impl_glfw.cmake) +endif () +if (IMGUI_IMPL_OPENGL OR IMGUI_IMPL_OPENGL2) + include (examples/imgui_impl_opengl.cmake) +endif () +if (IMGUI_IMPL_GLUT) + include (examples/imgui_impl_glut.cmake) +endif () +if (IMGUI_IMPL_DX9) + include (examples/imgui_impl_dx9.cmake) +endif () +if (IMGUI_IMPL_DX10) + include (examples/imgui_impl_dx10.cmake) +endif () +if (IMGUI_IMPL_DX11) + include (examples/imgui_impl_dx11.cmake) +endif () +if (IMGUI_IMPL_DX12) + include (examples/imgui_impl_dx12.cmake) +endif () + +if (IMGUI_EXAMPLES) + set (IMGUI_EXAMPLE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + #add_subdirectory (examples/example_allegro5) + add_subdirectory (examples/example_apple_metal) + add_subdirectory (examples/example_apple_opengl2) + #add_subdirectory (examples/example_emscripten) + add_subdirectory (examples/example_glfw_metal) + add_subdirectory (examples/example_glfw_opengl2) + add_subdirectory (examples/example_glfw_opengl3) + #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_win32_directx10) + add_subdirectory (examples/example_win32_directx11) + add_subdirectory (examples/example_win32_directx12) + add_subdirectory (examples/example_win32_directx9) +endif () diff --git a/examples/example_apple_metal/CMakeLists.txt b/examples/example_apple_metal/CMakeLists.txt new file mode 100644 index 000000000..67192e0c6 --- /dev/null +++ b/examples/example_apple_metal/CMakeLists.txt @@ -0,0 +1,18 @@ +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 + ) + + target_link_libraries (imgui_example_apple_metal + imgui-metal imgui-osx + ) + + set_target_properties (imgui_example_apple_metal + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_apple_opengl2/CMakeLists.txt b/examples/example_apple_opengl2/CMakeLists.txt new file mode 100644 index 000000000..ad9a2bc34 --- /dev/null +++ b/examples/example_apple_opengl2/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-osx AND TARGET imgui-opengl2) + add_executable (imgui_example_apple_opengl2 main.mm) + + target_link_libraries (imgui_example_apple_opengl2 + imgui-osx imgui-opengl2 + ) + + set_target_properties (imgui_example_apple_opengl2 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_glfw_metal/CMakeLists.txt b/examples/example_glfw_metal/CMakeLists.txt new file mode 100644 index 000000000..f863445a4 --- /dev/null +++ b/examples/example_glfw_metal/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-glfw AND TARGET imgui-metal) + add_executable (imgui_example_glfw_metal main.mm) + + target_link_libraries (imgui_example_glfw_metal + imgui-glfw imgui-metal + ) + + set_target_properties (imgui_example_glfw_metal + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_glfw_opengl2/CMakeLists.txt b/examples/example_glfw_opengl2/CMakeLists.txt new file mode 100644 index 000000000..08f94c53f --- /dev/null +++ b/examples/example_glfw_opengl2/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-glfw AND TARGET imgui-opengl2) + add_executable (imgui_example_glfw_opengl2 main.cpp) + + target_link_libraries (imgui_example_glfw_opengl2 + imgui-glfw imgui-opengl2 + ) + + set_target_properties (imgui_example_glfw_opengl2 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_glfw_opengl3/CMakeLists.txt b/examples/example_glfw_opengl3/CMakeLists.txt new file mode 100644 index 000000000..7c3cbac33 --- /dev/null +++ b/examples/example_glfw_opengl3/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-glfw AND TARGET imgui-opengl) + add_executable (imgui_example_glfw_opengl3 main.cpp) + + target_link_libraries (imgui_example_glfw_opengl3 + imgui-glfw imgui-opengl + ) + + set_target_properties (imgui_example_glfw_opengl3 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_glut_opengl2/CMakeLists.txt b/examples/example_glut_opengl2/CMakeLists.txt new file mode 100644 index 000000000..ce2b6485b --- /dev/null +++ b/examples/example_glut_opengl2/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-glut AND TARGET imgui-opengl2) + add_executable (imgui_example_glut_opengl2 main.cpp) + + target_link_libraries (imgui_example_glut_opengl2 + imgui-glut imgui-opengl2 + ) + + set_target_properties (imgui_example_glut_opengl2 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_null/CMakeLists.txt b/examples/example_null/CMakeLists.txt new file mode 100644 index 000000000..0c94135bf --- /dev/null +++ b/examples/example_null/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable (imgui_example_null main.cpp) +target_link_libraries (imgui_example_null imgui) + +set_target_properties (imgui_example_null + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" +) diff --git a/examples/example_sdl2_metal/CMakeLists.txt b/examples/example_sdl2_metal/CMakeLists.txt new file mode 100644 index 000000000..d85942290 --- /dev/null +++ b/examples/example_sdl2_metal/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-sdl AND TARGET imgui-metal) + add_executable (imgui_example_sdl_metal main.mm) + + target_link_libraries (imgui_example_sdl_metal + imgui-sdl imgui-metal + ) + + set_target_properties (imgui_example_sdl_metal + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_sdl2_opengl2/CMakeLists.txt b/examples/example_sdl2_opengl2/CMakeLists.txt new file mode 100644 index 000000000..a94015e69 --- /dev/null +++ b/examples/example_sdl2_opengl2/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-sdl AND TARGET imgui-opengl2) + add_executable (imgui_example_sdl_opengl2 WIN32 main.cpp) + + target_link_libraries (imgui_example_sdl_opengl2 + imgui-sdl imgui-opengl2 + ) + + set_target_properties (imgui_example_sdl_opengl2 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_sdl2_opengl3/CMakeLists.txt b/examples/example_sdl2_opengl3/CMakeLists.txt new file mode 100644 index 000000000..828881f05 --- /dev/null +++ b/examples/example_sdl2_opengl3/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-sdl AND TARGET imgui-opengl) + add_executable (imgui_example_sdl_opengl3 main.cpp) + + target_link_libraries (imgui_example_sdl_opengl3 + imgui-sdl imgui-opengl + ) + + set_target_properties (imgui_example_sdl_opengl3 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_win32_directx10/CMakeLists.txt b/examples/example_win32_directx10/CMakeLists.txt new file mode 100644 index 000000000..8770167fb --- /dev/null +++ b/examples/example_win32_directx10/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-win32 AND TARGET imgui-dx10) + add_executable (imgui_example_win32_directx10 main.cpp) + + target_link_libraries (imgui_example_win32_directx10 + imgui-win32 imgui-dx10 + ) + + set_target_properties (imgui_example_win32_directx10 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_win32_directx11/CMakeLists.txt b/examples/example_win32_directx11/CMakeLists.txt new file mode 100644 index 000000000..a01458926 --- /dev/null +++ b/examples/example_win32_directx11/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-win32 AND TARGET imgui-dx11) + add_executable (imgui_example_win32_directx11 main.cpp) + + target_link_libraries (imgui_example_win32_directx11 + imgui-win32 imgui-dx11 + ) + + set_target_properties (imgui_example_win32_directx11 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_win32_directx12/CMakeLists.txt b/examples/example_win32_directx12/CMakeLists.txt new file mode 100644 index 000000000..1d7839e24 --- /dev/null +++ b/examples/example_win32_directx12/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-win32 AND TARGET imgui-dx12) + add_executable (imgui_example_win32_directx12 main.cpp) + + target_link_libraries (imgui_example_win32_directx12 + imgui-win32 imgui-dx12 + ) + + set_target_properties (imgui_example_win32_directx12 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/example_win32_directx9/CMakeLists.txt b/examples/example_win32_directx9/CMakeLists.txt new file mode 100644 index 000000000..58e34ad10 --- /dev/null +++ b/examples/example_win32_directx9/CMakeLists.txt @@ -0,0 +1,11 @@ +if (TARGET imgui-win32 AND TARGET imgui-dx9) + add_executable (imgui_example_win32_directx9 main.cpp) + + target_link_libraries (imgui_example_win32_directx9 + imgui-win32 imgui-dx9 + ) + + set_target_properties (imgui_example_win32_directx9 + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMGUI_EXAMPLE_OUTPUT_DIR}" + ) +endif () diff --git a/examples/imgui_impl_dx10.cmake b/examples/imgui_impl_dx10.cmake new file mode 100644 index 000000000..7b1efc7ed --- /dev/null +++ b/examples/imgui_impl_dx10.cmake @@ -0,0 +1,26 @@ +if (WIN32) + find_library (D3D10_LIBRARY "d3d10") + if (NOT D3D10_LIBRARY) + message (WARNING "IMGUI_IMPL_DX10 set to ON but d3d10.dll not found") + endif () + + find_library (DXGI_LIBRARY "dxgi") + if (NOT DXGI_LIBRARY) + message (WARNING "IMGUI_IMPL_DX10 set to ON but dxgi.dll not found") + endif () + + if (D3D10_LIBRARY AND DXGI_LIBRARY) + add_library (imgui-dx10 OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_dx10.cpp" + ) + + target_link_libraries (imgui-dx10 PUBLIC + imgui + ${D3D10_LIBRARY} ${DXGI_LIBRARY} + ) + + target_include_directories (imgui-dx10 PUBLIC "${CMAKE_CURRENT_LIST_DIR}") + endif () +else () + message (WARNING "IMGUI_IMPL_DX10 set to ON but platform is not Win32") +endif () diff --git a/examples/imgui_impl_dx11.cmake b/examples/imgui_impl_dx11.cmake new file mode 100644 index 000000000..45cc3c310 --- /dev/null +++ b/examples/imgui_impl_dx11.cmake @@ -0,0 +1,26 @@ +if (WIN32) + find_library (D3D11_LIBRARY "d3d11") + if (NOT D3D11_LIBRARY) + message (WARNING "IMGUI_IMPL_DX11 set to ON but d3d11.dll not found") + endif () + + find_library (DXGI_LIBRARY "dxgi") + if (NOT DXGI_LIBRARY) + message (WARNING "IMGUI_IMPL_DX11 set to ON but dxgi.dll not found") + endif () + + if (D3D11_LIBRARY AND DXGI_LIBRARY) + add_library (imgui-dx11 OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_dx11.cpp" + ) + + target_link_libraries (imgui-dx11 PUBLIC + imgui + ${D3D11_LIBRARY} ${DXGI_LIBRARY} + ) + + target_include_directories (imgui-dx11 PUBLIC "${CMAKE_CURRENT_LIST_DIR}") + endif () +else () + message (WARNING "IMGUI_IMPL_DX11 set to ON but platform is not Win32") +endif () diff --git a/examples/imgui_impl_dx12.cmake b/examples/imgui_impl_dx12.cmake new file mode 100644 index 000000000..2d4bb0dc5 --- /dev/null +++ b/examples/imgui_impl_dx12.cmake @@ -0,0 +1,26 @@ +if (WIN32) + find_library (D3D12_LIBRARY "d3d12") + if (NOT D3D12_LIBRARY) + message (WARNING "IMGUI_IMPL_DX12 set to ON but d3d12.dll not found") + endif () + + find_library (DXGI_LIBRARY "dxgi") + if (NOT DXGI_LIBRARY) + message (WARNING "IMGUI_IMPL_DX12 set to ON but dxgi.dll not found") + endif () + + if (D3D12_LIBRARY AND DXGI_LIBRARY) + add_library (imgui-dx12 OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_dx12.cpp" + ) + + target_link_libraries (imgui-dx12 PUBLIC + imgui + ${D3D12_LIBRARY} ${DXGI_LIBRARY} + ) + + target_include_directories (imgui-dx12 PUBLIC "${CMAKE_CURRENT_LIST_DIR}") + endif () +else () + message (WARNING "IMGUI_IMPL_DX12 set to ON but platform is not Win32") +endif () diff --git a/examples/imgui_impl_dx9.cmake b/examples/imgui_impl_dx9.cmake new file mode 100644 index 000000000..ccae36fe2 --- /dev/null +++ b/examples/imgui_impl_dx9.cmake @@ -0,0 +1,19 @@ +if (WIN32) + find_library (D3D9_LIBRARY "d3d9") + if (D3D9_LIBRARY) + add_library (imgui-dx9 OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_dx9.cpp" + ) + + target_link_libraries (imgui-dx9 PUBLIC + imgui + ${D3D9_LIBRARY} + ) + + target_include_directories (imgui-dx9 PUBLIC "${CMAKE_CURRENT_LIST_DIR}") + else () + message (WARNING "IMGUI_IMPL_DX9 set to ON but d3d9.dll not found") + endif () +else () + message (WARNING "IMGUI_IMPL_DX9 set to ON but platform is not Win32") +endif () diff --git a/examples/imgui_impl_glfw.cmake b/examples/imgui_impl_glfw.cmake new file mode 100644 index 000000000..064a4cff2 --- /dev/null +++ b/examples/imgui_impl_glfw.cmake @@ -0,0 +1,14 @@ +if (NOT TARGET glfw) + find_package (GLFW3 QUIET) +endif () + +if (TARGET glfw OR GLFW3_DIR) + add_library (imgui-glfw OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_glfw.cpp" + ) + + target_link_libraries (imgui-glfw PUBLIC imgui glfw) + target_include_directories (imgui-glfw PUBLIC "${CMAKE_CURRENT_LIST_DIR}") +else () + message (WARNING "IMGUI_IMPL_GLFW set to ON but glfw3 could not be located") +endif () diff --git a/examples/imgui_impl_glut.cmake b/examples/imgui_impl_glut.cmake new file mode 100644 index 000000000..c12743c03 --- /dev/null +++ b/examples/imgui_impl_glut.cmake @@ -0,0 +1,26 @@ +find_package (GLUT QUIET) + +if (GLUT_glut_LIBRARY) + add_library (imgui-glut OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_glut.cpp" + ) + + target_link_libraries (imgui-glut PUBLIC + imgui + "${GLUT_glut_LIBRARY}" + ) + + if (APPLE) + target_link_libraries (imgui-glut PUBLIC + "${GLUT_cocoa_LIBRARY}" + ) + endif () + + target_include_directories (imgui-glut PUBLIC "${CMAKE_CURRENT_LIST_DIR}") + + target_include_directories (imgui-glut SYSTEM PUBLIC + "${GLUT_INCLUDE_DIR}" + ) +else () + message (WARNING "IMGUI_IMPL_GLUT set to ON but GLUT could not be found") +endif () diff --git a/examples/imgui_impl_metal.cmake b/examples/imgui_impl_metal.cmake new file mode 100644 index 000000000..42c32f8b1 --- /dev/null +++ b/examples/imgui_impl_metal.cmake @@ -0,0 +1,19 @@ +if (APPLE) + add_library (imgui-metal OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_metal.mm" + ) + + target_link_libraries (imgui-metal PUBLIC + imgui + "-framework Cocoa" "-framework Metal" "-framework QuartzCore" + ) + + target_include_directories (imgui-metal PUBLIC "${CMAKE_CURRENT_LIST_DIR}") + + set_property ( + TARGET imgui-metal + APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc" + ) +else () + message (WARNING "IMGUI_IMPL_METAL set to ON but platform is not Apple") +endif () diff --git a/examples/imgui_impl_opengl.cmake b/examples/imgui_impl_opengl.cmake new file mode 100644 index 000000000..aab8cb91c --- /dev/null +++ b/examples/imgui_impl_opengl.cmake @@ -0,0 +1,40 @@ +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 () diff --git a/examples/imgui_impl_osx.cmake b/examples/imgui_impl_osx.cmake new file mode 100644 index 000000000..96da237cd --- /dev/null +++ b/examples/imgui_impl_osx.cmake @@ -0,0 +1,15 @@ +if (APPLE) + add_library (imgui-osx OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_osx.mm" + ) + + target_link_libraries (imgui-osx PUBLIC imgui "-framework Cocoa" "-framework AppKit") + target_include_directories (imgui-osx PUBLIC "${CMAKE_CURRENT_LIST_DIR}") + + set_property ( + TARGET imgui-osx + APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc" + ) +else () + message (WARNING "IMGUI_IMPL_OSX set to ON but platform is not Apple") +endif () diff --git a/examples/imgui_impl_sdl.cmake b/examples/imgui_impl_sdl.cmake new file mode 100644 index 000000000..1cb734690 --- /dev/null +++ b/examples/imgui_impl_sdl.cmake @@ -0,0 +1,19 @@ +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 () diff --git a/examples/imgui_impl_win32.cmake b/examples/imgui_impl_win32.cmake new file mode 100644 index 000000000..8c6cac7ff --- /dev/null +++ b/examples/imgui_impl_win32.cmake @@ -0,0 +1,11 @@ +if (WIN32) + add_library (imgui-win32 OBJECT + "${CMAKE_CURRENT_LIST_DIR}/imgui_impl_win32.cpp" + ) + + target_link_libraries (imgui-win32 PUBLIC imgui) + + target_include_directories (imgui-win32 PUBLIC "${CMAKE_CURRENT_LIST_DIR}") +else () + message (WARNING "IMGUI_IMPL_WIN32 set to ON but platform is not Win32") +endif () diff --git a/examples/libs/glfw.cmake b/examples/libs/glfw.cmake new file mode 100644 index 000000000..26f1a2033 --- /dev/null +++ b/examples/libs/glfw.cmake @@ -0,0 +1,24 @@ +# NOTE: These are polyfill libs for developing GLFW windows examples; +# they are NOT intended to be used for production; instead, you +# acquire your own version (either from pre-built binaries or +# from building from source). +# +# More info at https://glfw.org. + +if (WIN32 AND NOT TARGET glfw) + message ( + WARNING + "ImGui polyfill glfw target should not be used for production! " + "If you're seeing this while building ImGui examples, please ignore." + ) + + add_library (glfw STATIC IMPORTED) + + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set_target_properties (glfw PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/glfw/lib-vc2010-64/glfw3.lib") + else () + set_target_properties (glfw PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/glfw/lib-vc2010-32/glfw3.lib") + endif () + + target_include_directories (glfw SYSTEM INTERFACE "${CMAKE_CURRENT_LIST_DIR}/glfw/include") +endif () From a360e5117d6b500caea608d54209f68ca2bc2880 Mon Sep 17 00:00:00 2001 From: pumpkinpal Date: Fri, 15 May 2020 11:39:26 +1000 Subject: [PATCH 2/8] Moved project() below cmake_minimum_version() and specified version and languages used. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e890ed846..aec5eb993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -project (imgui) cmake_minimum_required (VERSION 3.2) +project(imgui VERSION 1.73.0 LANGUAGES CXX C) option (IMGUI_EXAMPLES "Build ImGui examples" ON) option (IMGUI_DEMO "Include the ImGui demo window implementation in library" ON) From b5f0e9b075565c736bc7719200834c8ce4da8b3b Mon Sep 17 00:00:00 2001 From: pumpkinpal Date: Fri, 15 May 2020 11:41:23 +1000 Subject: [PATCH 3/8] Replaced conditional compilation of IMGUI_DEMO_SRC with generator expression. --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aec5eb993..dc4546691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,15 +19,11 @@ option (IMGUI_IMPL_DX12 "Build the DirectX 12 implementation (only if supported) set (CMAKE_CXX_STANDARD 11) -if (IMGUI_DEMO) - set (IMGUI_DEMO_SRC imgui_demo.cpp) -endif () - add_library (imgui STATIC imgui.cpp imgui_draw.cpp imgui_widgets.cpp - ${IMGUI_DEMO_SRC} + $<$:imgui_demo.cpp> ) target_include_directories (imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") From 37f5526bd1c590b0447d32d0b4879bf4f8846aef Mon Sep 17 00:00:00 2001 From: pumpkinpal Date: Fri, 15 May 2020 11:43:21 +1000 Subject: [PATCH 4/8] Switched from setting CXX_STANDARD global to target property. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc4546691..d2c8c5e76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,6 @@ option (IMGUI_IMPL_DX10 "Build the DirectX 10 implementation (only if supported) option (IMGUI_IMPL_DX11 "Build the DirectX 11 implementation (only if supported)" ${WIN32}) option (IMGUI_IMPL_DX12 "Build the DirectX 12 implementation (only if supported)" ${WIN32}) -set (CMAKE_CXX_STANDARD 11) - add_library (imgui STATIC imgui.cpp imgui_draw.cpp @@ -28,6 +26,8 @@ add_library (imgui STATIC target_include_directories (imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") +set_target_properties(imgui PROPERTIES CXX_STANDARD 11) + if (IMGUI_EXAMPLES) # Sets up polyfill libraries for Windows examples (e.g. GLFW) include (examples/libs/glfw.cmake) From ab3e62bcfefd87b9e23b1e7b3ba8143cc32d0b69 Mon Sep 17 00:00:00 2001 From: pumpkinpal Date: Fri, 15 May 2020 11:52:40 +1000 Subject: [PATCH 5/8] Added library alias imgui::imgui and removed 'STATIC' from target. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2c8c5e76..f50a73720 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,13 +17,15 @@ option (IMGUI_IMPL_DX10 "Build the DirectX 10 implementation (only if supported) option (IMGUI_IMPL_DX11 "Build the DirectX 11 implementation (only if supported)" ${WIN32}) option (IMGUI_IMPL_DX12 "Build the DirectX 12 implementation (only if supported)" ${WIN32}) -add_library (imgui STATIC +add_library (imgui imgui.cpp imgui_draw.cpp imgui_widgets.cpp $<$:imgui_demo.cpp> ) +add_library(imgui::imgui ALIAS imgui) + target_include_directories (imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") set_target_properties(imgui PROPERTIES CXX_STANDARD 11) From 2c77f34ba948e12d261183a81458ee8f9b3a5f58 Mon Sep 17 00:00:00 2001 From: Ivan Kulikov Date: Sun, 24 May 2020 11:54:16 +0300 Subject: [PATCH 6/8] update cmake_minimum_required to 3.8.2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f50a73720..7280ea245 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.2) +cmake_minimum_required (VERSION 3.8.2) project(imgui VERSION 1.73.0 LANGUAGES CXX C) option (IMGUI_EXAMPLES "Build ImGui examples" ON) From a67c7cf77e83d883e09b35248ad555eb69a193bb Mon Sep 17 00:00:00 2001 From: Ivan Kulikov Date: Sun, 24 May 2020 11:56:10 +0300 Subject: [PATCH 7/8] Switched from setting set_target_properties to target_compile_features cxx_std_98 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7280ea245..74ebd85c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ add_library(imgui::imgui ALIAS imgui) target_include_directories (imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") -set_target_properties(imgui PROPERTIES CXX_STANDARD 11) +target_compile_features(imgui PRIVATE cxx_std_98) if (IMGUI_EXAMPLES) # Sets up polyfill libraries for Windows examples (e.g. GLFW) From 55402fdcf4a458f2b02bcaa8fc39c780df0bfddc Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 2 May 2025 17:35:03 +0200 Subject: [PATCH 8/8] Update for recent versions. C++11. Backends moved to backends/ folder. Renamed reference to SDL to SDL2. --- CMakeLists.txt | 46 ++++++++++--------- {examples => backends}/imgui_impl_dx10.cmake | 0 {examples => backends}/imgui_impl_dx11.cmake | 0 {examples => backends}/imgui_impl_dx12.cmake | 0 {examples => backends}/imgui_impl_dx9.cmake | 0 {examples => backends}/imgui_impl_glfw.cmake | 0 {examples => backends}/imgui_impl_glut.cmake | 0 {examples => backends}/imgui_impl_metal.cmake | 0 backends/imgui_impl_opengl.cmake | 19 ++++++++ {examples => backends}/imgui_impl_osx.cmake | 0 backends/imgui_impl_sdl2.cmake | 19 ++++++++ {examples => backends}/imgui_impl_win32.cmake | 0 examples/example_apple_metal/CMakeLists.txt | 5 +- examples/example_sdl2_metal/CMakeLists.txt | 10 ++-- examples/example_sdl2_opengl2/CMakeLists.txt | 10 ++-- examples/example_sdl2_opengl3/CMakeLists.txt | 10 ++-- examples/imgui_impl_opengl.cmake | 40 ---------------- examples/imgui_impl_sdl.cmake | 19 -------- 18 files changed, 78 insertions(+), 100 deletions(-) rename {examples => backends}/imgui_impl_dx10.cmake (100%) rename {examples => backends}/imgui_impl_dx11.cmake (100%) rename {examples => backends}/imgui_impl_dx12.cmake (100%) rename {examples => backends}/imgui_impl_dx9.cmake (100%) rename {examples => backends}/imgui_impl_glfw.cmake (100%) rename {examples => backends}/imgui_impl_glut.cmake (100%) rename {examples => backends}/imgui_impl_metal.cmake (100%) create mode 100644 backends/imgui_impl_opengl.cmake rename {examples => backends}/imgui_impl_osx.cmake (100%) create mode 100644 backends/imgui_impl_sdl2.cmake rename {examples => backends}/imgui_impl_win32.cmake (100%) delete mode 100644 examples/imgui_impl_opengl.cmake delete mode 100644 examples/imgui_impl_sdl.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 74ebd85c5..d2727bb69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 $<$: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) diff --git a/examples/imgui_impl_dx10.cmake b/backends/imgui_impl_dx10.cmake similarity index 100% rename from examples/imgui_impl_dx10.cmake rename to backends/imgui_impl_dx10.cmake diff --git a/examples/imgui_impl_dx11.cmake b/backends/imgui_impl_dx11.cmake similarity index 100% rename from examples/imgui_impl_dx11.cmake rename to backends/imgui_impl_dx11.cmake diff --git a/examples/imgui_impl_dx12.cmake b/backends/imgui_impl_dx12.cmake similarity index 100% rename from examples/imgui_impl_dx12.cmake rename to backends/imgui_impl_dx12.cmake diff --git a/examples/imgui_impl_dx9.cmake b/backends/imgui_impl_dx9.cmake similarity index 100% rename from examples/imgui_impl_dx9.cmake rename to backends/imgui_impl_dx9.cmake diff --git a/examples/imgui_impl_glfw.cmake b/backends/imgui_impl_glfw.cmake similarity index 100% rename from examples/imgui_impl_glfw.cmake rename to backends/imgui_impl_glfw.cmake diff --git a/examples/imgui_impl_glut.cmake b/backends/imgui_impl_glut.cmake similarity index 100% rename from examples/imgui_impl_glut.cmake rename to backends/imgui_impl_glut.cmake diff --git a/examples/imgui_impl_metal.cmake b/backends/imgui_impl_metal.cmake similarity index 100% rename from examples/imgui_impl_metal.cmake rename to backends/imgui_impl_metal.cmake diff --git a/backends/imgui_impl_opengl.cmake b/backends/imgui_impl_opengl.cmake new file mode 100644 index 000000000..5ddccc0bf --- /dev/null +++ b/backends/imgui_impl_opengl.cmake @@ -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 () diff --git a/examples/imgui_impl_osx.cmake b/backends/imgui_impl_osx.cmake similarity index 100% rename from examples/imgui_impl_osx.cmake rename to backends/imgui_impl_osx.cmake diff --git a/backends/imgui_impl_sdl2.cmake b/backends/imgui_impl_sdl2.cmake new file mode 100644 index 000000000..54351cc5a --- /dev/null +++ b/backends/imgui_impl_sdl2.cmake @@ -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 () diff --git a/examples/imgui_impl_win32.cmake b/backends/imgui_impl_win32.cmake similarity index 100% rename from examples/imgui_impl_win32.cmake rename to backends/imgui_impl_win32.cmake diff --git a/examples/example_apple_metal/CMakeLists.txt b/examples/example_apple_metal/CMakeLists.txt index 67192e0c6..7621b3816 100644 --- a/examples/example_apple_metal/CMakeLists.txt +++ b/examples/example_apple_metal/CMakeLists.txt @@ -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 diff --git a/examples/example_sdl2_metal/CMakeLists.txt b/examples/example_sdl2_metal/CMakeLists.txt index d85942290..dd08c68cb 100644 --- a/examples/example_sdl2_metal/CMakeLists.txt +++ b/examples/example_sdl2_metal/CMakeLists.txt @@ -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 () diff --git a/examples/example_sdl2_opengl2/CMakeLists.txt b/examples/example_sdl2_opengl2/CMakeLists.txt index a94015e69..9299d5f83 100644 --- a/examples/example_sdl2_opengl2/CMakeLists.txt +++ b/examples/example_sdl2_opengl2/CMakeLists.txt @@ -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 () diff --git a/examples/example_sdl2_opengl3/CMakeLists.txt b/examples/example_sdl2_opengl3/CMakeLists.txt index 828881f05..cdbea86db 100644 --- a/examples/example_sdl2_opengl3/CMakeLists.txt +++ b/examples/example_sdl2_opengl3/CMakeLists.txt @@ -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 () diff --git a/examples/imgui_impl_opengl.cmake b/examples/imgui_impl_opengl.cmake deleted file mode 100644 index aab8cb91c..000000000 --- a/examples/imgui_impl_opengl.cmake +++ /dev/null @@ -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 () diff --git a/examples/imgui_impl_sdl.cmake b/examples/imgui_impl_sdl.cmake deleted file mode 100644 index 1cb734690..000000000 --- a/examples/imgui_impl_sdl.cmake +++ /dev/null @@ -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 ()