2021-09-23 17:58:28 -07:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2017-10-09 12:48:44 +02:00
|
|
|
project(imgui CXX)
|
|
|
|
|
2017-10-14 22:26:06 -07:00
|
|
|
set(CMAKE_DEBUG_POSTFIX d)
|
|
|
|
|
2021-09-23 17:58:28 -07:00
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
enable_language(OBJCXX)
|
|
|
|
endif()
|
|
|
|
|
2020-06-23 22:56:15 +02:00
|
|
|
add_library(${PROJECT_NAME} "")
|
|
|
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
|
|
|
target_include_directories(
|
2020-12-26 12:45:14 -08:00
|
|
|
${PROJECT_NAME}
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
|
|
$<INSTALL_INTERFACE:include>
|
2017-10-09 12:48:44 +02:00
|
|
|
)
|
|
|
|
|
2020-06-23 22:56:15 +02:00
|
|
|
target_sources(
|
2020-12-26 12:45:14 -08:00
|
|
|
${PROJECT_NAME}
|
|
|
|
PRIVATE
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imgui.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imgui_demo.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imgui_draw.cpp
|
2021-02-16 14:09:36 -05:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imgui_tables.cpp
|
2020-12-26 12:45:14 -08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imgui_widgets.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
|
2017-10-09 12:48:44 +02:00
|
|
|
)
|
|
|
|
|
2022-07-13 22:47:22 +02:00
|
|
|
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
|
|
|
|
|
2020-07-16 01:07:40 +02:00
|
|
|
if(IMGUI_BUILD_ALLEGRO5_BINDING)
|
2023-06-08 09:57:58 -07:00
|
|
|
find_package(unofficial-allegro5 CONFIG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE unofficial-allegro5::allegro unofficial-allegro5::allegro_ttf unofficial-allegro5::allegro_font unofficial-allegro5::allegro_main)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_allegro5.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_DX9_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx9.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_DX10_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx10.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_DX11_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx11.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_DX12_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx12.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_GLFW_BINDING)
|
2023-04-26 09:49:46 +03:00
|
|
|
if(NOT EMSCRIPTEN)
|
|
|
|
find_package(glfw3 CONFIG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC glfw)
|
|
|
|
endif()
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glfw.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_GLUT_BINDING)
|
2020-12-26 12:45:14 -08:00
|
|
|
find_package(GLUT REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC GLUT::GLUT)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glut.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_METAL_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_metal.mm)
|
2021-09-23 17:58:28 -07:00
|
|
|
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_metal.mm PROPERTIES COMPILE_FLAGS -fobjc-weak)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_OPENGL2_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl2.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
2021-08-25 01:28:54 +02:00
|
|
|
if(IMGUI_BUILD_OPENGL3_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_OSX_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_osx.mm)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_BUILD_SDL2_BINDING)
|
2020-12-26 12:45:14 -08:00
|
|
|
find_package(SDL2 CONFIG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2)
|
2023-02-15 18:43:32 +01:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
2017-10-09 12:48:44 +02:00
|
|
|
|
2021-10-13 23:47:17 +02:00
|
|
|
if(IMGUI_BUILD_SDL2_RENDERER_BINDING)
|
|
|
|
find_package(SDL2 CONFIG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2)
|
2023-06-07 20:53:30 +02:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdlrenderer2.cpp)
|
2021-10-13 23:47:17 +02:00
|
|
|
endif()
|
|
|
|
|
2020-07-16 01:07:40 +02:00
|
|
|
if(IMGUI_BUILD_VULKAN_BINDING)
|
|
|
|
find_package(Vulkan REQUIRED)
|
2020-12-26 12:45:14 -08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Vulkan::Vulkan)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_vulkan.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
2020-05-01 13:57:38 +08:00
|
|
|
|
2020-07-16 01:07:40 +02:00
|
|
|
if(IMGUI_BUILD_WIN32_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_win32.cpp)
|
2020-07-16 01:07:40 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IMGUI_FREETYPE)
|
2020-12-26 12:45:14 -08:00
|
|
|
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)
|
2021-03-01 17:40:09 +01:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_ENABLE_FREETYPE)
|
|
|
|
endif()
|
|
|
|
|
2023-09-06 07:34:32 +02:00
|
|
|
if(IMGUI_FREETYPE_LUNASVG)
|
|
|
|
find_package(unofficial-lunasvg CONFIG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC unofficial::lunasvg::lunasvg)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_ENABLE_FREETYPE_LUNASVG)
|
|
|
|
endif()
|
|
|
|
|
2021-03-01 17:40:09 +01:00
|
|
|
if(IMGUI_USE_WCHAR32)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC IMGUI_USE_WCHAR32)
|
2020-06-23 22:56:15 +02:00
|
|
|
endif()
|
2018-01-04 14:46:21 +03:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
list(REMOVE_DUPLICATES BINDINGS_SOURCES)
|
|
|
|
|
2020-06-23 22:56:15 +02:00
|
|
|
install(
|
2020-12-26 12:45:14 -08:00
|
|
|
TARGETS ${PROJECT_NAME}
|
|
|
|
EXPORT ${PROJECT_NAME}_target
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin
|
2017-10-09 12:48:44 +02:00
|
|
|
)
|
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
foreach(BINDING_TARGET ${BINDING_TARGETS})
|
|
|
|
install(
|
|
|
|
TARGETS ${BINDING_TARGET}
|
|
|
|
EXPORT ${PROJECT_NAME}_target
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
|
2017-10-09 12:48:44 +02:00
|
|
|
if(NOT IMGUI_SKIP_HEADERS)
|
2020-06-23 22:56:15 +02:00
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imgui.h
|
2020-07-31 13:39:26 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imgui_internal.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imstb_textedit.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imstb_rectpack.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/imstb_truetype.h
|
2020-06-23 22:56:15 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.h
|
2017-10-09 12:48:44 +02:00
|
|
|
DESTINATION include
|
|
|
|
)
|
2020-06-23 22:56:15 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_ALLEGRO5_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_allegro5.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_DX9_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx9.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_DX10_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx10.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_DX11_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx11.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_DX12_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_dx12.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_GLFW_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glfw.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_GLUT_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_glut.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_METAL_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_metal.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_OPENGL2_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl2.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2021-08-25 01:28:54 +02:00
|
|
|
if(IMGUI_BUILD_OPENGL3_BINDING)
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3.h
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_opengl3_loader.h
|
|
|
|
DESTINATION
|
|
|
|
include
|
|
|
|
)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_OSX_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_osx.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_SDL2_BINDING)
|
2023-02-15 18:43:32 +01:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdl2.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2021-10-13 23:47:17 +02:00
|
|
|
if(IMGUI_BUILD_SDL2_RENDERER_BINDING)
|
2023-06-07 20:53:30 +02:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_sdlrenderer2.h DESTINATION include)
|
2021-10-13 23:47:17 +02:00
|
|
|
endif()
|
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_VULKAN_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_vulkan.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-07-16 01:07:40 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_BUILD_WIN32_BINDING)
|
2021-02-17 04:33:33 +03:00
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/backends/imgui_impl_win32.h DESTINATION include)
|
2020-12-26 12:45:14 -08:00
|
|
|
endif()
|
2020-06-23 22:56:15 +02:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
if(IMGUI_FREETYPE)
|
|
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.h DESTINATION include)
|
|
|
|
endif()
|
2017-10-09 12:48:44 +02:00
|
|
|
endif()
|
2020-05-01 13:57:38 +08:00
|
|
|
|
2020-12-26 12:45:14 -08:00
|
|
|
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)
|
|
|
|
|
2020-06-23 22:56:15 +02:00
|
|
|
install(
|
2020-12-26 12:45:14 -08:00
|
|
|
EXPORT ${PROJECT_NAME}_target
|
|
|
|
NAMESPACE ${PROJECT_NAME}::
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
DESTINATION share/${PROJECT_NAME}
|
2020-07-02 01:58:37 +02:00
|
|
|
)
|