From 105dabe0222cbb4a8005b8460c925465daa8318e Mon Sep 17 00:00:00 2001 From: hnOsmium0001 Date: Tue, 13 Jul 2021 17:20:43 -0700 Subject: [PATCH 1/4] Add implot --- recipes/implot/all/CMakeLists.txt | 27 ++++++++ recipes/implot/all/conandata.yml | 4 ++ recipes/implot/all/conanfile.py | 62 +++++++++++++++++++ .../implot/all/test_package/CMakeLists.txt | 14 +++++ recipes/implot/all/test_package/conanfile.py | 16 +++++ .../implot/all/test_package/test_package.cpp | 6 ++ recipes/implot/config.yml | 3 + 7 files changed, 132 insertions(+) create mode 100644 recipes/implot/all/CMakeLists.txt create mode 100644 recipes/implot/all/conandata.yml create mode 100644 recipes/implot/all/conanfile.py create mode 100644 recipes/implot/all/test_package/CMakeLists.txt create mode 100644 recipes/implot/all/test_package/conanfile.py create mode 100644 recipes/implot/all/test_package/test_package.cpp create mode 100644 recipes/implot/config.yml diff --git a/recipes/implot/all/CMakeLists.txt b/recipes/implot/all/CMakeLists.txt new file mode 100644 index 0000000000000..4a06ba1470e36 --- /dev/null +++ b/recipes/implot/all/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.4) +project(implot CXX) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +set(SOURCE_DIR source_subfolder) +file(GLOB SOURCE_FILES ${SOURCE_DIR}/*.cpp) +file(GLOB HEADER_FILES ${SOURCE_DIR}/*.h) + +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(FILES ${HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) diff --git a/recipes/implot/all/conandata.yml b/recipes/implot/all/conandata.yml new file mode 100644 index 0000000000000..45ea42e9671bc --- /dev/null +++ b/recipes/implot/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.11": + url: "https://github.com/epezent/implot/archive/v0.11.tar.gz" + sha256: "1ec4c8501f70901132a9f14409c956b508a8ea3fe457e8518325b156dceada00" diff --git a/recipes/implot/all/conanfile.py b/recipes/implot/all/conanfile.py new file mode 100644 index 0000000000000..724f41544f2e9 --- /dev/null +++ b/recipes/implot/all/conanfile.py @@ -0,0 +1,62 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" + +class ImGuizmoConan(ConanFile): + name = "implot" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/epezent/implot" + description = "Advanced 2D Plotting for Dear ImGui" + topics = ("conan", "imgui", "plot", "graphics") + license = "MIT" + settings = "os", "arch", "compiler", "build_type" + + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + requires = "imgui/1.83" + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["implot"] diff --git a/recipes/implot/all/test_package/CMakeLists.txt b/recipes/implot/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c046975767154 --- /dev/null +++ b/recipes/implot/all/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(imgui REQUIRED) +find_package(implot REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} imgui::imgui) +target_link_libraries(${PROJECT_NAME} implot::implot) diff --git a/recipes/implot/all/test_package/conanfile.py b/recipes/implot/all/test_package/conanfile.py new file mode 100644 index 0000000000000..23ba95e79f465 --- /dev/null +++ b/recipes/implot/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", "cmake_find_package" + + 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) diff --git a/recipes/implot/all/test_package/test_package.cpp b/recipes/implot/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3e66b8ef948f6 --- /dev/null +++ b/recipes/implot/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + ImPlot::GetCurrentContext(); + return 0; +} diff --git a/recipes/implot/config.yml b/recipes/implot/config.yml new file mode 100644 index 0000000000000..5c1dd2fc635b0 --- /dev/null +++ b/recipes/implot/config.yml @@ -0,0 +1,3 @@ +versions: + "0.11": + folder: "all" From af8932ed9494ec85125c3819f6e4b1d1ed69d064 Mon Sep 17 00:00:00 2001 From: hnOsmium0001 Date: Tue, 13 Jul 2021 20:54:02 -0700 Subject: [PATCH 2/4] Add imgui to implot cpp_info.requires --- recipes/implot/all/conanfile.py | 1 + recipes/implot/all/test_package/CMakeLists.txt | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/implot/all/conanfile.py b/recipes/implot/all/conanfile.py index 724f41544f2e9..f11cd0d283e53 100644 --- a/recipes/implot/all/conanfile.py +++ b/recipes/implot/all/conanfile.py @@ -60,3 +60,4 @@ def package(self): def package_info(self): self.cpp_info.libs = ["implot"] + self.cpp_info.requires = ["imgui::imgui"] diff --git a/recipes/implot/all/test_package/CMakeLists.txt b/recipes/implot/all/test_package/CMakeLists.txt index c046975767154..3b7083d5edf30 100644 --- a/recipes/implot/all/test_package/CMakeLists.txt +++ b/recipes/implot/all/test_package/CMakeLists.txt @@ -6,9 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -find_package(imgui REQUIRED) find_package(implot REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} imgui::imgui) target_link_libraries(${PROJECT_NAME} implot::implot) From 808967afda15a91bdff717ce732a59e66418b526 Mon Sep 17 00:00:00 2001 From: hnOsmium0001 Date: Wed, 14 Jul 2021 08:47:32 -0700 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Anonymous Maarten --- recipes/implot/all/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/implot/all/conanfile.py b/recipes/implot/all/conanfile.py index f11cd0d283e53..47136a6ab392d 100644 --- a/recipes/implot/all/conanfile.py +++ b/recipes/implot/all/conanfile.py @@ -3,7 +3,7 @@ required_conan_version = ">=1.33.0" -class ImGuizmoConan(ConanFile): +class ImplotConan(ConanFile): name = "implot" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/epezent/implot" @@ -60,4 +60,3 @@ def package(self): def package_info(self): self.cpp_info.libs = ["implot"] - self.cpp_info.requires = ["imgui::imgui"] From 4a908a147972875377bf497c790f1f6a2ffdd96b Mon Sep 17 00:00:00 2001 From: hnOsmium0001 Date: Wed, 14 Jul 2021 08:49:42 -0700 Subject: [PATCH 4/4] Remove tests for find_package --- recipes/implot/all/test_package/CMakeLists.txt | 4 +--- recipes/implot/all/test_package/conanfile.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/implot/all/test_package/CMakeLists.txt b/recipes/implot/all/test_package/CMakeLists.txt index 3b7083d5edf30..02f4ef746eac3 100644 --- a/recipes/implot/all/test_package/CMakeLists.txt +++ b/recipes/implot/all/test_package/CMakeLists.txt @@ -6,7 +6,5 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -find_package(implot REQUIRED) - add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} implot::implot) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/implot/all/test_package/conanfile.py b/recipes/implot/all/test_package/conanfile.py index 23ba95e79f465..4903f1a7e8fa0 100644 --- a/recipes/implot/all/test_package/conanfile.py +++ b/recipes/implot/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "cmake" def build(self): cmake = CMake(self)