[imgui] Fix find dependencies (#15063)

This commit is contained in:
Jack·Boos·Yu 2020-12-26 12:45:14 -08:00 committed by GitHub
parent 866bd364ae
commit 08b6c85897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 171 additions and 116 deletions

View File

@ -6,135 +6,141 @@ set(CMAKE_DEBUG_POSTFIX d)
add_library(${PROJECT_NAME} "")
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(
${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_sources(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_demo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_widgets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_demo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_widgets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
)
if(IMGUI_USE_WCHAR32)
FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h IMCONFIG)
STRING(REGEX REPLACE "//#define IMGUI_USE_WCHAR32" "#define IMGUI_USE_WCHAR32" IMCONFIG "${IMCONFIG}")
FILE(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h "${IMCONFIG}")
FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h IMCONFIG)
STRING(REGEX REPLACE "//#define IMGUI_USE_WCHAR32" "#define IMGUI_USE_WCHAR32" IMCONFIG "${IMCONFIG}")
FILE(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h "${IMCONFIG}")
endif()
if(IMGUI_BUILD_ALLEGRO5_BINDING)
find_path(ALLEGRO5_INCLUDE_DIRS allegro5/allegro.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${ALLEGRO5_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_allegro5.cpp)
find_path(ALLEGRO5_INCLUDE_DIRS allegro5/allegro.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${ALLEGRO5_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_allegro5.cpp)
endif()
if(IMGUI_BUILD_DX9_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx9.cpp)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx9.cpp)
endif()
if(IMGUI_BUILD_DX10_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx10.cpp)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx10.cpp)
endif()
if(IMGUI_BUILD_DX11_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx11.cpp)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx11.cpp)
endif()
if(IMGUI_BUILD_DX12_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx12.cpp)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx12.cpp)
endif()
if(IMGUI_BUILD_GLFW_BINDING)
find_package(glfw3 REQUIRED)
get_target_property(GLFW3_INCLUDE_DIRS glfw INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLFW3_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glfw.cpp)
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC glfw)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glfw.cpp)
endif()
if(IMGUI_BUILD_GLUT_BINDING)
find_path(GLUT_INCLUDE_DIRS GL/freeglut.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLUT_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glut.cpp)
find_package(GLUT REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC GLUT::GLUT)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glut.cpp)
endif()
if(IMGUI_BUILD_METAL_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_metal.mm)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_metal.mm)
endif()
if(IMGUI_BUILD_OPENGL2_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl2.cpp)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl2.cpp)
endif()
if(IMGUI_BUILD_OPENGL3_GLEW_BINDING)
find_package(glew REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLEW_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
find_package(GLEW REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC GLEW::GLEW)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()
if(IMGUI_BUILD_OPENGL3_GLAD_BINDING)
find_package(glad REQUIRED)
get_target_property(GLAD_INCLUDE_DIRS glad::glad INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLAD_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
find_package(glad CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC glad::glad)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()
if(IMGUI_BUILD_OPENGL3_GL3W_BINDING)
find_package(gl3w REQUIRED)
get_target_property(GL3W_INCLUDE_DIRS unofficial::gl3w::gl3w INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GL3W_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
find_package(gl3w CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC unofficial::gl3w::gl3w)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()
if(IMGUI_BUILD_OPENGL3_GLBINDING_BINDING)
find_package(glbinding REQUIRED)
get_target_property(GLBINDING_INCLUDE_DIRS glbinding::glbinding INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLBINDING_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
find_package(glbinding CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC glbinding::glbinding)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()
if(IMGUI_BUILD_OSX_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_osx.mm)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_osx.mm)
endif()
if(IMGUI_BUILD_SDL2_BINDING)
find_package(SDL2 CONFIG REQUIRED)
find_path(SDL2_INCLUDE_DIRS SDL2/SDL.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}/SDL2)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_sdl.cpp)
find_package(SDL2 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_sdl.cpp)
endif()
if(IMGUI_BUILD_VULKAN_BINDING)
find_package(Vulkan REQUIRED)
get_target_property(VULKAN_INCLUDE_DIRS Vulkan::Vulkan INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${VULKAN_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_vulkan.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC Vulkan::Vulkan)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_vulkan.cpp)
endif()
if(IMGUI_BUILD_WIN32_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_win32.cpp)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_win32.cpp)
endif()
if(IMGUI_FREETYPE)
find_package(Freetype REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp)
find_package(freetype CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC freetype)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp)
endif()
list(REMOVE_DUPLICATES BINDINGS_SOURCES)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_target
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_target
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
foreach(BINDING_TARGET ${BINDING_TARGETS})
install(
TARGETS ${BINDING_TARGET}
EXPORT ${PROJECT_NAME}_target
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
endforeach()
if(NOT IMGUI_SKIP_HEADERS)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/imgui.h
@ -147,75 +153,80 @@ if(NOT IMGUI_SKIP_HEADERS)
DESTINATION include
)
if(IMGUI_BUILD_ALLEGRO5_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_allegro5.h DESTINATION include)
endif()
if(IMGUI_BUILD_ALLEGRO5_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_allegro5.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX9_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx9.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX9_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx9.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX10_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx10.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX10_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx10.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX11_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx11.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX11_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx11.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX12_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx12.h DESTINATION include)
endif()
if(IMGUI_BUILD_DX12_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx12.h DESTINATION include)
endif()
if(IMGUI_BUILD_GLFW_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glfw.h DESTINATION include)
endif()
if(IMGUI_BUILD_GLFW_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glfw.h DESTINATION include)
endif()
if(IMGUI_BUILD_GLUT_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glut.h DESTINATION include)
endif()
if(IMGUI_BUILD_GLUT_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glut.h DESTINATION include)
endif()
if(IMGUI_COPY_MARMALADE_BINDING)
file(GLOB MARMALADE_BINDING_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_marmalade.*)
install(FILES ${MARMALADE_BINDING_SRCS} DESTINATION include/bindings)
endif()
if(IMGUI_COPY_MARMALADE_BINDING)
file(GLOB MARMALADE_BINDING_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_marmalade.*)
install(FILES ${MARMALADE_BINDING_SRCS} DESTINATION include/bindings)
endif()
if(IMGUI_BUILD_METAL_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_metal.h DESTINATION include)
endif()
if(IMGUI_BUILD_METAL_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_metal.h DESTINATION include)
endif()
if(IMGUI_BUILD_OPENGL2_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl2.h DESTINATION include)
endif()
if(IMGUI_BUILD_OPENGL2_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl2.h DESTINATION include)
endif()
if(IMGUI_BUILD_OPENGL3_GLEW_BINDING OR IMGUI_BUILD_OPENGL3_GLAD_BINDING OR IMGUI_BUILD_OPENGL3_GL3W_BINDING OR IMGUI_BUILD_OPENGL3_GLBINDING_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.h DESTINATION include)
endif()
if(IMGUI_BUILD_OPENGL3_GLEW_BINDING OR IMGUI_BUILD_OPENGL3_GLAD_BINDING OR IMGUI_BUILD_OPENGL3_GL3W_BINDING OR IMGUI_BUILD_OPENGL3_GLBINDING_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.h DESTINATION include)
endif()
if(IMGUI_BUILD_OSX_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_osx.h DESTINATION include)
endif()
if(IMGUI_BUILD_OSX_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_osx.h DESTINATION include)
endif()
if(IMGUI_BUILD_SDL2_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_sdl.h DESTINATION include)
endif()
if(IMGUI_BUILD_SDL2_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_sdl.h DESTINATION include)
endif()
if(IMGUI_BUILD_VULKAN_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_vulkan.h DESTINATION include)
endif()
if(IMGUI_BUILD_VULKAN_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_vulkan.h DESTINATION include)
endif()
if(IMGUI_BUILD_WIN32_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_win32.h DESTINATION include)
endif()
if(IMGUI_BUILD_WIN32_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_win32.h DESTINATION include)
endif()
if(IMGUI_FREETYPE)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.h DESTINATION include)
endif()
if(IMGUI_FREETYPE)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.h DESTINATION include)
endif()
endif()
include(CMakePackageConfigHelpers)
configure_package_config_file(imgui-config.cmake.in imgui-config.cmake INSTALL_DESTINATION share/imgui)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/imgui-config.cmake DESTINATION share/imgui)
install(
EXPORT ${PROJECT_NAME}_target
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}-config.cmake
DESTINATION share/${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_target
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}-targets.cmake
DESTINATION share/${PROJECT_NAME}
)

View File

@ -1,6 +1,6 @@
Source: imgui
Version: 1.79
Port-Version: 3
Port-Version: 4
Homepage: https://github.com/ocornut/imgui
Description: Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies.

View File

@ -0,0 +1,43 @@
cmake_policy(SET CMP0012 NEW)
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
if (@IMGUI_BUILD_GLFW_BINDING@)
find_dependency(glfw3 CONFIG)
endif()
if (@IMGUI_BUILD_OPENGL3_GLEW_BINDING@)
find_dependency(GLEW)
endif()
if (@IMGUI_BUILD_OPENGL3_GLAD_BINDING@)
find_dependency(glad CONFIG)
endif()
if (@IMGUI_BUILD_OPENGL3_GL3W_BINDING@)
find_dependency(gl3w CONFIG)
endif()
if (@IMGUI_BUILD_GLUT_BINDING@)
find_dependency(GLUT)
endif()
if (@IMGUI_BUILD_OPENGL3_GLBINDING_BINDING@)
find_dependency(glbinding CONFIG)
endif()
if (@IMGUI_BUILD_SDL2_BINDING@)
find_dependency(SDL2 CONFIG)
endif()
if (@IMGUI_BUILD_VULKAN_BINDING@)
find_dependency(Vulkan)
endif()
if (@IMGUI_FREETYPE@)
find_dependency(freetype CONFIG)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/imgui-targets.cmake")

View File

@ -18,6 +18,7 @@ else()
)
endif()
file(COPY ${CMAKE_CURRENT_LIST_DIR}/imgui-config.cmake.in DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
if(("metal-binding" IN_LIST FEATURES OR "osx-binding" IN_LIST FEATURES) AND (NOT VCPKG_TARGET_IS_OSX))