Skip to content

Commit

Permalink
qwt: Use Cmake instead of qmake
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanDugueperoux2 committed Sep 6, 2022
1 parent 313420c commit 5711a14
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/qwt/6.2.1/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"6.2.1":
url: "https://github.com/MehdiChinoune/qwt/archive/refs/tags/6.2.0.tar.gz"
sha256: "3e9632a9be6a883db5c496e42ce74cbbf8da02cc3328faa89e2c43e434a2eb76"
89 changes: 89 additions & 0 deletions recipes/qwt/6.2.1/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get

required_conan_version = ">=1.50"

class QwtConan(ConanFile):
name = "qwt"
license = "LGPL-2.1-or-later"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://qwt.sourceforge.io/"
topics = ("conan", "archive", "compression")
description = (
"The Qwt library contains GUI Components and utility classes which are primarily useful for programs "
"with a technical background. Beside a framework for 2D plots it provides scales, sliders, dials, compasses, "
"thermometers, wheels and knobs to control or display values, arrays, or ranges of type double."
)
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"plot": [True, False],
"widgets": [True, False],
"svg": [True, False],
"opengl": [True, False],
"designer": [True, False],
"polar": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"plot": False,
"widgets": False,
"svg": True,
"opengl": False,
"designer": False,
"polar": False,
"qt:qtsvg": True

}

def build_requirements(self):
if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
self.build_requires("jom/1.1.3")

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 requirements(self):
self.requires("qt/5.15.2")

def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)

def generate(self):
tc = CMakeToolchain(self)

tc.variables["QWT_PLOT"] = "ON" if self.options.plot else "OFF"
tc.variables["QWT_WIDGETS"] = "ON" if self.options.widgets else "OFF"
tc.variables["QWT_SVG"] = "ON" if self.options.svg else "OFF"
tc.variables["QWT_OPENGL"] = "ON" if self.options.opengl else "OFF"
tc.variables["QWT_DESIGNER"] = "ON" if self.options.designer else "OFF"
tc.variables["QWT_POLAR"] = "ON" if self.options.polar else "OFF"

tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = CMake(self)
cmake.install()
12 changes: 12 additions & 0 deletions recipes/qwt/6.2.1/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.5)
project(PackageTest CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_executable(example example.cpp)
# Must compile with "-fPIC" since Qt was built with -reduce-relocations.
target_compile_options(example PRIVATE -fPIC)
target_link_libraries(example CONAN_PKG::qt CONAN_PKG::qwt)
set_property(TARGET example PROPERTY CXX_STANDARD 11)

19 changes: 19 additions & 0 deletions recipes/qwt/6.2.1/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from conan import ConanFile
from conans import CMake
from conan.tools.build import cross_building
import os


class QwtTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "example")
self.run(bin_path, run_environment=True)
10 changes: 10 additions & 0 deletions recipes/qwt/6.2.1/test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <QDebug>
#include <QDateTime>

#include <qwt_date.h>

int main()
{
qDebug() << QwtDate::toString(QwtDate::toDateTime(10), "MMM dd hh:mm ", QwtDate::FirstThursday);
return 0;
}
2 changes: 2 additions & 0 deletions recipes/qwt/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ versions:
folder: "all"
"6.2.0":
folder: "all"
"6.2.1":
folder: "6.2.1"

0 comments on commit 5711a14

Please sign in to comment.