diff --git a/recipes/qwt/all/conandata.yml b/recipes/qwt/all/conandata.yml new file mode 100644 index 0000000000000..5e6acd7ff338d --- /dev/null +++ b/recipes/qwt/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "6.1.6": + url: "https://sourceforge.net/projects/qwt/files/qwt/6.1.6/qwt-6.1.6.zip" + sha256: "4b2452662ae64656aca92f1bef44a281229f77056689100af62c4b9f24462873" diff --git a/recipes/qwt/all/conanfile.py b/recipes/qwt/all/conanfile.py new file mode 100644 index 0000000000000..016714112ef7e --- /dev/null +++ b/recipes/qwt/all/conanfile.py @@ -0,0 +1,118 @@ +import os +from conans import ConanFile, tools + + +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], + "mathml": [True, False], + "designer": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "plot": True, + "widgets": True, + "opengl": True, + "designer": True, + "mathml": False, + "svg": False + + } + generators = "qmake" + + @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 requirements(self): + self.requires("qt/5.15.2") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _patch_qwt_config_files(self): + # qwtconfig.pri + qwtconfig_path = os.path.join(self.source_folder, self._source_subfolder, "qwtconfig.pri") + qwtconfig = tools.load(qwtconfig_path) + + qwtconfig = "CONFIG += conan_basic_setup\ninclude(../conanbuildinfo.pri)\n" + qwtconfig + qwtconfig += "QWT_CONFIG {}= QwtDll\n".format("+" if self.options.shared else "-") + qwtconfig += "QWT_CONFIG {}= QwtPlot\n".format("+" if self.options.plot else "-") + qwtconfig += "QWT_CONFIG {}= QwtWidgets\n".format("+" if self.options.widgets else "-") + qwtconfig += "QWT_CONFIG {}= QwtSvg\n".format("+" if self.options.svg else "-") + qwtconfig += "QWT_CONFIG {}= QwtOpenGL\n".format("+" if self.options.opengl else "-") + qwtconfig += "QWT_CONFIG {}= QwtMathML\n".format("+" if self.options.mathml else "-") + qwtconfig += "QWT_CONFIG {}= QwtDesigner\n".format("+" if self.options.designer else "-") + tools.save(qwtconfig_path, qwtconfig) + + # qwtbuild.pri + qwtbuild_path = os.path.join(self.source_folder, self._source_subfolder, "qwtbuild.pri") + qwtbuild = tools.load(qwtbuild_path) + # set build type + qwtbuild += "CONFIG -= debug_and_release\n" + qwtbuild += "CONFIG -= build_all\n" + qwtbuild += "CONFIG -= release\n" + qwtbuild += "CONFIG += {}\n".format("debug" if self.settings.build_type == "Debug" else "release") + if self.settings.build_type == "RelWithDebInfo": + qwtbuild += "CONFIG += force_debug_info\n" + tools.save(qwtbuild_path, qwtbuild) + + def build(self): + self._patch_qwt_config_files() + + if self.settings.compiler == "Visual Studio": + vcvars = tools.vcvars_command(self.settings) + self.run("{} && qmake {}".format(vcvars, self._source_subfolder), run_environment=True) + self.run("{} && nmake".format(vcvars)) + else: + self.run("qmake {}".format(self._source_subfolder), run_environment=True) + self.run("make -j {}".format(tools.cpu_count())) + + def package(self): + self.copy("COPYING", src=os.path.join(self._source_subfolder), dst="licenses") + self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "src")) + self.copy("*.dll", dst="bin", keep_path=False) + self.copy("*.lib", dst="lib", keep_path=False) + self.copy("*.so*", dst="lib", keep_path=False, symlinks=True) + self.copy("*.dylib", dst="lib", keep_path=False) + self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.includedirs = ['include'] + if self.settings.build_type == "Debug": + if self.settings.os == "Windows": + self.cpp_info.libs = ["qwtd"] + elif self.settings.os == "Macos": + self.cpp_info.libs = ["qwt_debug"] + else: + self.cpp_info.libs = ["qwt"] + else: + self.cpp_info.libs = ["qwt"] + self.env_info.QT_PLUGIN_PATH.append(os.path.join(self.package_folder, 'bin')) + self.env_info.QT_PLUGIN_PATH.append(os.path.join(self.package_folder, 'lib')) + self.cpp_info.defines = ['HAVE_QWT', 'QWT_DLL'] if self.options.shared else ['HAVE_QWT'] diff --git a/recipes/qwt/all/test_package/CMakeLists.txt b/recipes/qwt/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..79d3544c480ff --- /dev/null +++ b/recipes/qwt/all/test_package/CMakeLists.txt @@ -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) + diff --git a/recipes/qwt/all/test_package/conanfile.py b/recipes/qwt/all/test_package/conanfile.py new file mode 100644 index 0000000000000..47c78f875835e --- /dev/null +++ b/recipes/qwt/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +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 tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/qwt/all/test_package/example.cpp b/recipes/qwt/all/test_package/example.cpp new file mode 100644 index 0000000000000..194d042bbc781 --- /dev/null +++ b/recipes/qwt/all/test_package/example.cpp @@ -0,0 +1,10 @@ +#include +#include + +#include + +int main() +{ + qDebug() << QwtDate::toString(QwtDate::toDateTime(10), "MMM dd hh:mm ", QwtDate::FirstThursday); + return 0; +} diff --git a/recipes/qwt/config.yml b/recipes/qwt/config.yml new file mode 100644 index 0000000000000..25122d605fe76 --- /dev/null +++ b/recipes/qwt/config.yml @@ -0,0 +1,3 @@ +versions: + "6.1.6": + folder: "all"