From 3e8615ed0fbdb67402811e7a9203d6c4b20f21da Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 17 Jun 2024 12:43:34 +0300 Subject: [PATCH] (#17841) limereport: add library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * LimeReport * [^] * update recipe * * try to fix test_package * use upstream * * bump to actual upstream * small updates * fix * remove patches * fix shared * fix qt options * Update conanfile.py * Update conanfile.py * Update conanfile.py * Update conanfile.py * Update conanfile.py * Update conanfile.py * rm_safe("fPIC") * Apply suggestions from code review Co-authored-by: Rubén Rincón Blanco * multiple review fixes * libpng bump * Minor fixes * Newline at eof * Recipe cleanup * Simplify test package Signed-off-by: Uilian Ries * remove quickcontrols * Remove CMAKE_VERBOSE_MAKEFILE Signed-off-by: Uilian Ries * Use qt version ranges * Accept Qt5 as minimal version due compatiblity * fix zint as requirement Signed-off-by: Uilian Ries * fix bad indentation Signed-off-by: Uilian Ries * copy all licenses files Signed-off-by: Uilian Ries --------- Signed-off-by: Uilian Ries Co-authored-by: Rubén Rincón Blanco Co-authored-by: Uilian Ries --- recipes/limereport/all/conandata.yml | 4 + recipes/limereport/all/conanfile.py | 119 ++++++++++++++++++ .../all/test_package/CMakeLists.txt | 8 ++ .../limereport/all/test_package/conanfile.py | 30 +++++ .../all/test_package/test_package.cpp | 15 +++ recipes/limereport/config.yml | 3 + 6 files changed, 179 insertions(+) create mode 100644 recipes/limereport/all/conandata.yml create mode 100644 recipes/limereport/all/conanfile.py create mode 100644 recipes/limereport/all/test_package/CMakeLists.txt create mode 100644 recipes/limereport/all/test_package/conanfile.py create mode 100644 recipes/limereport/all/test_package/test_package.cpp create mode 100644 recipes/limereport/config.yml diff --git a/recipes/limereport/all/conandata.yml b/recipes/limereport/all/conandata.yml new file mode 100644 index 0000000000000..a6aa17992b336 --- /dev/null +++ b/recipes/limereport/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.7.4": + url: "https://github.com/fralx/LimeReport/archive/refs/tags/1.7.4.tar.gz" + sha256: 5e16ffa4f1f6c9175ef00be95029d5dda57287236ef8529582e1df1366c8dc30 diff --git a/recipes/limereport/all/conanfile.py b/recipes/limereport/all/conanfile.py new file mode 100644 index 0000000000000..60455f5993eb1 --- /dev/null +++ b/recipes/limereport/all/conanfile.py @@ -0,0 +1,119 @@ +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import copy, get, replace_in_file +from conan.tools.build import check_min_cppstd +from conan import ConanFile +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os + + +class LimereportConan(ConanFile): + name = "limereport" + description = "Report generator for Qt Framework" + homepage = "https://limereport.ru" + topics = ("limereport", "pdf", "report","qt") + license = "LGPL-3.0", "GPL-3.0" + url = "https://github.com/conan-io/conan-center-index" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_zint": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_zint": False, + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16", + "msvc": "192", + "gcc": "8", + "clang": "8", + "apple-clang": "9.1", + } + + @property + def _qt_version_major(self): + return Version(self.dependencies["qt"].ref.version).major + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # QString included in Irglobal.h and Limereport expects be running Qt on customer side + self.requires("qt/[>=5.15 <7]", transitive_headers=True, transitive_libs=True) + if self.options.with_zint: + self.requires("zint/2.10.0") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + if not (self.dependencies["qt"].options.qtdeclarative): + raise ConanInvalidConfiguration(f"{self.ref} requires -o='qt/*:qtdeclarative=True'") + if not (self.dependencies["qt"].options.qtsvg and self.dependencies["qt"].options.qttools): + raise ConanInvalidConfiguration(f"{self.ref} requires -o='qt/*:qtsvg=True' and -o='qt/*:qttools=True'") + if self.options.with_zint and not self.dependencies["zint"].options.with_qt: + raise ConanInvalidConfiguration(f"{self.ref} option with_zint=True requires -o 'zint/*:with_qt=True'") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["LIMEREPORT_STATIC"] = not self.options.shared + if is_msvc(self): + tc.variables["WINDOWS_BUILD"] = True + tc.cache_variables["USE_QT6"] = self._qt_version_major == 6 + tc.cache_variables["ENABLE_ZINT"] = self.options.with_zint + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def _patch_sources(self): + # Avoid using vendozied zint + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "add_subdirectory(3rdparty)", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = [f"limereport-qt{self._qt_version_major}"] + self.cpp_info.requires = ["qt::qtCore", "qt::qtWidgets", "qt::qtQml", "qt::qtXml", "qt::qtSql", + "qt::qtPrintSupport", "qt::qtSvg", "qt::qtUiTools"] + if self.options.with_zint: + self.cpp_info.requires.append("zint::zint") + if self.options.shared: + self.cpp_info.defines.append("LIMEREPORT_IMPORTS") diff --git a/recipes/limereport/all/test_package/CMakeLists.txt b/recipes/limereport/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..08e6667600f91 --- /dev/null +++ b/recipes/limereport/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package CXX) + +find_package(limereport CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} limereport::limereport) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/limereport/all/test_package/conanfile.py b/recipes/limereport/all/test_package/conanfile.py new file mode 100644 index 0000000000000..76ff27872680a --- /dev/null +++ b/recipes/limereport/all/test_package/conanfile.py @@ -0,0 +1,30 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/limereport/all/test_package/test_package.cpp b/recipes/limereport/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..a10ab64ab7245 --- /dev/null +++ b/recipes/limereport/all/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + auto report = new LimeReport::ReportEngine(); + + std::cout << "limereport: " << report->reportName().toStdString() << std::endl; + std::cout << "LIMEREPORT_VERSION_STR: " << LIMEREPORT_VERSION_STR << std::endl; + + delete report; + return EXIT_SUCCESS; +} diff --git a/recipes/limereport/config.yml b/recipes/limereport/config.yml new file mode 100644 index 0000000000000..41f47d462d189 --- /dev/null +++ b/recipes/limereport/config.yml @@ -0,0 +1,3 @@ +versions: + "1.7.4": + folder: "all"