Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limereport: add library #17841

Merged
merged 32 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/limereport/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.7.4":
url: "https://github.com/fralx/LimeReport/archive/refs/tags/1.7.4.tar.gz"
sha256: 5e16ffa4f1f6c9175ef00be95029d5dda57287236ef8529582e1df1366c8dc30
119 changes: 119 additions & 0 deletions recipes/limereport/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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 = {
xakod marked this conversation as resolved.
Show resolved Hide resolved
"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")
8 changes: 8 additions & 0 deletions recipes/limereport/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
30 changes: 30 additions & 0 deletions recipes/limereport/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
15 changes: 15 additions & 0 deletions recipes/limereport/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <cstdlib>
#include <iostream>
#include <limereport/LimeReport>
#include <limereport/config.h>

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;
}
3 changes: 3 additions & 0 deletions recipes/limereport/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.7.4":
folder: "all"
Loading