From d67657d9700d9238c0533449f144504337a085aa Mon Sep 17 00:00:00 2001 From: caseymcc Date: Sun, 19 Aug 2018 09:41:03 -0500 Subject: [PATCH] hunterize imgui --- CMakeLists.txt | 106 ++++++++++++++++++++++++++++++++++++++++ cmake/Config.cmake.in | 6 +++ examples/CMakeLists.txt | 1 + 3 files changed, 113 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/Config.cmake.in create mode 100644 examples/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..f59af0dd9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,106 @@ +cmake_minimum_required(VERSION 3.1) + +project(imgui) +set(IMGUI_VERSION "1.62") + +option(IMGUI_BUILD_EXAMPLES "Build imgui examples" OFF) + +# Introduce variables: +# * CMAKE_INSTALL_LIBDIR +# * CMAKE_INSTALL_BINDIR +# * CMAKE_INSTALL_INCLUDEDIR +include(GNUInstallDirs) +set(IMGUI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +set(IMGUI_HEADERS + imconfig.h + imgui.h + imgui_internal.h + stb_rect_pack.h + stb_textedit.h + stb_truetype.h +) + +set(IMGUI_SOURCE + imgui.cpp + imgui_demo.cpp + imgui_draw.cpp +) + +add_library(imgui INTERFACE) + +target_include_directories(imgui INTERFACE + $) + +set(IMGUI_BUILD_SOURCE) +set(IMGUI_INTERFACE_SOURCE) +foreach(SOURCE_FILE ${IMGUI_SOURCE}) + set(IMGUI_BUILD_SOURCE ${IMGUI_BUILD_SOURCE} ${IMGUI_SOURCE_DIR}/${SOURCE_FILE}) + set(IMGUI_INTERFACE_SOURCE ${IMGUI_INTERFACE_SOURCE} ${CMAKE_INSTALL_INCLUDEDIR}/${SOURCE_FILE}) +endforeach() + +target_sources(imgui INTERFACE + $ + $ +) + +if(IMGUI_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + +#Install imgui + +#install config path +set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") +set(INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") +set(VERSION_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}ConfigVersion.cmake") +set(PROJECT_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}Config.cmake") +set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") +set(NAMESPACE "${PROJECT_NAME}::") + +#install header files +install(FILES ${IMGUI_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${IMGUI_SOURCE} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +#build and install project config +include(CMakePackageConfigHelpers) +configure_package_config_file( + "cmake/Config.cmake.in" + "${PROJECT_CONFIG}" + INSTALL_DESTINATION "${INSTALL_CONFIGDIR}" + PATH_VARS CMAKE_INSTALL_INCLUDEDIR +) + +#build config version into bin directory +write_basic_package_version_file( + "${VERSION_CONFIG}" + VERSION ${IMGUI_VERSION} + COMPATIBILITY AnyNewerVersion + +) + +#install target +install( + TARGETS imgui + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +#install files +install( + FILES + "${VERSION_CONFIG}" + "${PROJECT_CONFIG}" + DESTINATION ${INSTALL_CONFIGDIR} +) + +install( + EXPORT "${TARGETS_EXPORT_NAME}" + NAMESPACE "${NAMESPACE}" + DESTINATION "${INSTALL_CONFIGDIR}" +) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in new file mode 100644 index 000000000..a9ffb7271 --- /dev/null +++ b/cmake/Config.cmake.in @@ -0,0 +1,6 @@ +set(IMGUI_VERSION "@IMGUI_VERSION@") + +@PACKAGE_INIT@ +include("${CMAKE_CURRENT_LIST_DIR}/imguiTargets.cmake") + +check_required_components(imgui) \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..0cb6ec3d3 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1 @@ +#needs implementation \ No newline at end of file