diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt new file mode 100644 index 0000000000000..91645488f141a --- /dev/null +++ b/recipes/imgui/all/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.4) +project(imgui CXX) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +if (WIN32 AND MSVC AND BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif(WIN32 AND MSVC AND BUILD_SHARED_LIBS) + +set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) +set(MISC_DIR ${SOURCE_DIR}/misc) +set(EXTRA_FONTS_DIR ${MISC_DIR}/fonts) + +file(GLOB SOURCE_FILES ${SOURCE_DIR}/*.cpp) +file(GLOB HEADER_FILES ${SOURCE_DIR}/*.h) +file(GLOB EXTRA_FONTS_FILES ${EXTRA_FONTS_DIR}/*.ttf) +if (MSVC) + file(GLOB EXTRA_NATVIS_FILES ${MISC_DIR}/natvis/*.natvis) +endif() + +set(BINARY_TO_COMPRESSED_BIN binary_to_compressed_c) + +add_executable(${BINARY_TO_COMPRESSED_BIN} ${EXTRA_FONTS_DIR}/binary_to_compressed_c.cpp) + +add_library(${PROJECT_NAME} ${SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} PRIVATE ${SOURCE_DIR}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${CONAN_LIBS}) + +include(GNUInstallDirs) + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS ${BINARY_TO_COMPRESSED_BIN} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES ${HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES ${EXTRA_FONTS_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/res/fonts + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +if (MSVC) + install(FILES ${EXTRA_NATVIS_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/res/natvis + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +endif() \ No newline at end of file diff --git a/recipes/imgui/all/conandata.yml b/recipes/imgui/all/conandata.yml new file mode 100644 index 0000000000000..ed5862c06718d --- /dev/null +++ b/recipes/imgui/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.74": + url: "https://github.com/ocornut/imgui/archive/v1.74.tar.gz" + sha256: "2f5f2b789edb00260aa71f03189da5f21cf4b5617c4fbba709e9fbcfc76a2f1e" diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py new file mode 100644 index 0000000000000..0ca2628b24531 --- /dev/null +++ b/recipes/imgui/all/conanfile.py @@ -0,0 +1,55 @@ +import os +from conans import ConanFile, CMake, tools + + +class IMGUIConan(ConanFile): + name = "imgui" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ocornut/imgui" + description = "Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies" + topics = ("conan", "imgui", "gui", "graphical") + license = "MIT" + + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = self.name + "-" + self.version + os.rename(extracted_dir, self._source_subfolder) + + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) + self.copy(pattern="examples/imgui_impl_*", dst="res/bindings", src=self._source_subfolder, keep_path=False) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ae0b79dd1b232 --- /dev/null +++ b/recipes/imgui/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +project(test_package) +cmake_minimum_required(VERSION 2.8.11) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +file(GLOB SOURCE_FILES *.cpp) + +add_executable(${PROJECT_NAME} ${SOURCE_FILES}) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) \ No newline at end of file diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py new file mode 100644 index 0000000000000..12acc7a675c1d --- /dev/null +++ b/recipes/imgui/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) \ No newline at end of file diff --git a/recipes/imgui/all/test_package/test_package.cpp b/recipes/imgui/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..238e292da6a14 --- /dev/null +++ b/recipes/imgui/all/test_package/test_package.cpp @@ -0,0 +1,33 @@ +#include +#include + +int main(int, char**) +{ + ImGuiContext* context =ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + + // Build atlas + unsigned char* tex_pixels = NULL; + int tex_w, tex_h; + io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h); + + for (int n = 0; n < 50; n++) + { + printf("NewFrame() %d\n", n); + io.DisplaySize = ImVec2(1920, 1080); + io.DeltaTime = 1.0f / 60.0f; + ImGui::NewFrame(); + + static float f = 0.0f; + ImGui::Text("Hello, world!"); + ImGui::SliderFloat("float", &f, 0.0f, 1.0f); + ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); + ImGui::ShowDemoWindow(NULL); + + ImGui::Render(); + } + + printf("DestroyContext()\n"); + ImGui::DestroyContext(context); + return 0; +} \ No newline at end of file diff --git a/recipes/imgui/config.yml b/recipes/imgui/config.yml new file mode 100644 index 0000000000000..23858765f665c --- /dev/null +++ b/recipes/imgui/config.yml @@ -0,0 +1,3 @@ +versions: + "1.74": + folder: all \ No newline at end of file