From 949f2d0d3ad68ceadd10034081e444211243d56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Wed, 8 Jan 2020 23:41:06 +0100 Subject: [PATCH 1/8] Import bincrafters/conan-imgui --- recipes/imgui/all/CMakeLists.txt | 49 ++++++++++++++++ recipes/imgui/all/conandata.yml | 4 ++ recipes/imgui/all/conanfile.py | 56 +++++++++++++++++++ recipes/imgui/all/test_package/CMakeLists.txt | 12 ++++ recipes/imgui/all/test_package/conanfile.py | 22 ++++++++ .../imgui/all/test_package/test_package.cpp | 33 +++++++++++ recipes/imgui/config.yml | 3 + 7 files changed, 179 insertions(+) create mode 100644 recipes/imgui/all/CMakeLists.txt create mode 100644 recipes/imgui/all/conandata.yml create mode 100644 recipes/imgui/all/conanfile.py create mode 100644 recipes/imgui/all/test_package/CMakeLists.txt create mode 100644 recipes/imgui/all/test_package/conanfile.py create mode 100644 recipes/imgui/all/test_package/test_package.cpp create mode 100644 recipes/imgui/config.yml diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt new file mode 100644 index 0000000000000..a10c473502113 --- /dev/null +++ b/recipes/imgui/all/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 2.8.11) +project(imgui CXX) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_VERBOSE_MAKEFILE TRUE) +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}/misc/fonts + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +if (MSVC) + install(FILES ${EXTRA_NATVIS_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/misc/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..be61eb75cb3fa --- /dev/null +++ b/recipes/imgui/all/conanfile.py @@ -0,0 +1,56 @@ +import os +from conans import ConanFile, CMake, tools + + +class IMGUIConan(ConanFile): + name = "imgui" + url = "https://github.com/bincrafters/conan-imgui" + 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="misc/bindings", src=self._source_subfolder, keep_path=False) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.srcdirs = ["misc"] + self.cpp_info.libs = tools.collect_libs(self) \ No newline at end of file diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..74e8133d6577c --- /dev/null +++ b/recipes/imgui/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +project(test_package) +cmake_minimum_required(VERSION 2.8.11) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +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..544de40c916ba --- /dev/null +++ b/recipes/imgui/all/test_package/conanfile.py @@ -0,0 +1,22 @@ +from conans import ConanFile, CMake, tools, RunEnvironment +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): + with tools.environment_append(RunEnvironment(self).vars): + bin_path = os.path.join("bin", "test_package") + if self.settings.os == "Windows": + self.run(bin_path) + elif self.settings.os == "Macos": + self.run("DYLD_LIBRARY_PATH=%s %s" % (os.environ.get('DYLD_LIBRARY_PATH', ''), bin_path)) + else: + self.run("LD_LIBRARY_PATH=%s %s" % (os.environ.get('LD_LIBRARY_PATH', ''), bin_path)) \ 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 From 3d4c4458bf72b922795b0324dd6baddba48ca491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Thu, 9 Jan 2020 00:04:41 +0100 Subject: [PATCH 2/8] RunEnvironment is no longer needed --- recipes/imgui/all/test_package/conanfile.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py index 544de40c916ba..12acc7a675c1d 100644 --- a/recipes/imgui/all/test_package/conanfile.py +++ b/recipes/imgui/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake, tools, RunEnvironment +from conans import ConanFile, CMake, tools import os class TestPackageConan(ConanFile): @@ -12,11 +12,5 @@ def build(self): def test(self): if not tools.cross_building(self.settings): - with tools.environment_append(RunEnvironment(self).vars): - bin_path = os.path.join("bin", "test_package") - if self.settings.os == "Windows": - self.run(bin_path) - elif self.settings.os == "Macos": - self.run("DYLD_LIBRARY_PATH=%s %s" % (os.environ.get('DYLD_LIBRARY_PATH', ''), bin_path)) - else: - self.run("LD_LIBRARY_PATH=%s %s" % (os.environ.get('LD_LIBRARY_PATH', ''), bin_path)) \ No newline at end of file + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) \ No newline at end of file From 0c371398e9825bbdb0ee9394530f78f05344e281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Thu, 9 Jan 2020 00:05:57 +0100 Subject: [PATCH 3/8] Change url --- recipes/imgui/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index be61eb75cb3fa..5d386ee751631 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -4,7 +4,7 @@ class IMGUIConan(ConanFile): name = "imgui" - url = "https://github.com/bincrafters/conan-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") From c2a8d3c4940077b4b4a3e75a8173caeeee9dbd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Thu, 9 Jan 2020 00:06:43 +0100 Subject: [PATCH 4/8] Avoid KB-H013 by switching /misc for /res folders --- recipes/imgui/all/CMakeLists.txt | 4 ++-- recipes/imgui/all/conanfile.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index a10c473502113..131cc86f81180 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -40,10 +40,10 @@ 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}/misc/fonts + 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}/misc/natvis + 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/conanfile.py b/recipes/imgui/all/conanfile.py index 5d386ee751631..a3a8a24aca37c 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -47,10 +47,9 @@ def build(self): def package(self): self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - self.copy(pattern="examples/imgui_impl_*", dst="misc/bindings", src=self._source_subfolder, keep_path=False) + 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.srcdirs = ["misc"] self.cpp_info.libs = tools.collect_libs(self) \ No newline at end of file From 999231101020682d66e291f350544ac6a2078726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Thu, 9 Jan 2020 00:16:00 +0100 Subject: [PATCH 5/8] Control verbosity from conan --- recipes/imgui/all/CMakeLists.txt | 1 - recipes/imgui/all/conanfile.py | 1 + recipes/imgui/all/test_package/CMakeLists.txt | 2 -- recipes/imgui/all/test_package/conanfile.py | 1 + 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index 131cc86f81180..a12333911cc0a 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -4,7 +4,6 @@ project(imgui CXX) include(conanbuildinfo.cmake) conan_basic_setup() -set(CMAKE_VERBOSE_MAKEFILE TRUE) if (WIN32 AND MSVC AND BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif(WIN32 AND MSVC AND BUILD_SHARED_LIBS) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index a3a8a24aca37c..e409854ae1625 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -38,6 +38,7 @@ def source(self): def _configure_cmake(self): cmake = CMake(self) + cmake.verbose = True cmake.configure() return cmake diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt index 74e8133d6577c..ae0b79dd1b232 100644 --- a/recipes/imgui/all/test_package/CMakeLists.txt +++ b/recipes/imgui/all/test_package/CMakeLists.txt @@ -1,8 +1,6 @@ project(test_package) cmake_minimum_required(VERSION 2.8.11) -set(CMAKE_VERBOSE_MAKEFILE TRUE) - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py index 12acc7a675c1d..c5832c202327c 100644 --- a/recipes/imgui/all/test_package/conanfile.py +++ b/recipes/imgui/all/test_package/conanfile.py @@ -7,6 +7,7 @@ class TestPackageConan(ConanFile): def build(self): cmake = CMake(self) + cmake.verbose = True cmake.configure() cmake.build() From 1a8557debac7dfe9b4c26b640a6780ce215cdacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Thu, 9 Jan 2020 16:09:55 +0100 Subject: [PATCH 6/8] Remove verbose Co-Authored-By: Uilian Ries --- recipes/imgui/all/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index e409854ae1625..0ca2628b24531 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -38,7 +38,6 @@ def source(self): def _configure_cmake(self): cmake = CMake(self) - cmake.verbose = True cmake.configure() return cmake @@ -53,4 +52,4 @@ def package(self): cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) \ No newline at end of file + self.cpp_info.libs = tools.collect_libs(self) From 5704f1d0bab3130399180782af13214d1bd8ac37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Thu, 9 Jan 2020 21:26:58 +0100 Subject: [PATCH 7/8] Remove verbose in test_package --- recipes/imgui/all/test_package/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py index c5832c202327c..12acc7a675c1d 100644 --- a/recipes/imgui/all/test_package/conanfile.py +++ b/recipes/imgui/all/test_package/conanfile.py @@ -7,7 +7,6 @@ class TestPackageConan(ConanFile): def build(self): cmake = CMake(self) - cmake.verbose = True cmake.configure() cmake.build() From 688d04de4b4f2a8af6bd376ee56064988b7dd30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Farr=C3=A9?= Date: Wed, 15 Jan 2020 21:37:53 +0100 Subject: [PATCH 8/8] Bump cmake minimum required to version 3.4 --- recipes/imgui/all/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index a12333911cc0a..91645488f141a 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.4) project(imgui CXX) include(conanbuildinfo.cmake)