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

qwt: Update to work with Qt 5 or 6 #21391

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions recipes/qwt/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ sources:
sha256: "3e9632a9be6a883db5c496e42ce74cbbf8da02cc3328faa89e2c43e434a2eb76"
patches:
"6.2.0":
- patch_file: "patches/cmake-support.patch"
- patch_file: "patches/0001-cmake-support.patch"
patch_source: "https://github.com/MehdiChinoune/qwt/blob/cmake/CMakeLists.txt"
- patch_file: "patches/cmake-support-patch.patch"
- patch_file: "patches/0002-cmake-support-patch.patch"
- patch_file: "patches/0003-Fix-Build-error-with-Qt6-which-requires-CPP-17.patch"
patch_source: "https://github.com/ashley-b/qwt/commit/75aa20749186a263fd6942a764731826d5bac137"
14 changes: 7 additions & 7 deletions recipes/qwt/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class QwtConan(ConanFile):
name = "qwt"
license = "LGPL-2.1-or-later"
license = "LGPL-2.1+ WITH Qwt-exception-1.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://qwt.sourceforge.io/"
topics = ("chart", "data-visualization", "graph", "plot", "qt")
Expand Down Expand Up @@ -66,6 +66,9 @@ def requirements(self):
self.requires("qt/[~5.15]", transitive_headers=True, transitive_libs=True)

def validate(self):
qt_version = Version(self.dependencies["qt"].ref.version)
if not 5 <= qt_version.major <= 6:
raise ConanInvalidConfiguration(f"{self.name} doesn't support Qt/{qt_version}. Allowed Qt version are 5 or 6")
if hasattr(self, "settings_build") and cross_building(self):
raise ConanInvalidConfiguration("Qwt recipe does not support cross-compilation yet")
qt_options = self.dependencies["qt"].options
Expand All @@ -86,14 +89,11 @@ def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
if self._is_legacy_one_profile:
env = VirtualRunEnv(self)
env.generate(scope="build")
else:
env = VirtualBuildEnv(self)
env.generate()
VirtualBuildEnv(self).generate()
VirtualRunEnv(self).generate(scope="build")

tc = CMakeToolchain(self)
tc.variables["QWT_QT_VERSION_MAJOR"] = Version(self.dependencies["qt"].ref.version).major
tc.variables["QWT_DLL"] = self.options.shared
tc.variables["QWT_STATIC"] = not self.options.shared
tc.variables["QWT_PLOT"] = self.options.plot
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
From fc8e1ba33ca4db5a9b07072734025dcd9ad53d58 Mon Sep 17 00:00:00 2001
From: Ashley Brighthope <[email protected]>
Date: Mon, 6 Mar 2023 19:19:40 +1100
Subject: [PATCH] Fix: Build error with Qt6, which requires C++17

Removed enforced C++ version of 11 to be a minimum version of C++ 11
---
CMakeLists.txt | 4 ----
designer/CMakeLists.txt | 6 ++++++
src/CMakeLists.txt | 6 ++++++
3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b42d510..469fa28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,10 +7,6 @@ project(Qwt
LANGUAGES CXX
)

-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
-set(CMAKE_CXX_EXTENSIONS OFF)
-
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /permissive-")
else()
diff --git a/designer/CMakeLists.txt b/designer/CMakeLists.txt
index aa81efd..98db4b3 100644
--- a/designer/CMakeLists.txt
+++ b/designer/CMakeLists.txt
@@ -18,6 +18,12 @@ else()
target_link_libraries(qwt_designer_plugin PRIVATE qwt)
endif()

+if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
+ target_compile_features(qwt_designer_plugin PUBLIC cxx_std_17)
+else()
+ target_compile_features(qwt_designer_plugin PUBLIC cxx_std_11)
+endif()
+
target_link_libraries(qwt_designer_plugin PUBLIC Qt${QT_VERSION_MAJOR}::Designer)

set_target_properties(qwt_designer_plugin PROPERTIES
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d25655a..2714b4f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -285,6 +285,12 @@ endif()

add_library(qwt_objects OBJECT ${SOURCES} ${HEADERS})

+if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
+ target_compile_features(qwt_objects PUBLIC cxx_std_17)
+else()
+ target_compile_features(qwt_objects PUBLIC cxx_std_11)
+endif()
+
target_include_directories(qwt_objects INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/classincludes>
--
2.43.0

18 changes: 15 additions & 3 deletions recipes/qwt/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(qwt REQUIRED CONFIG)
find_package(Qt5 REQUIRED Core CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE qwt::qwt Qt5::Core)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

if(QT_VERSION VERSION_GREATER_EQUAL "6.0.0")
find_package(Qt6 REQUIRED COMPONENTS Core CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
elseif(QT_VERSION VERSION_GREATER_EQUAL "5.0.0")
find_package(Qt5 COMPONENTS Core REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
else()
message(FATAL_ERROR "Qt < 5 is not supported by this recipe")
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE qwt::qwt)

if(NOT WIN32)
# Must compile with "-fPIC" since Qt was built with -reduce-relocations.
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
Expand Down
9 changes: 7 additions & 2 deletions recipes/qwt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
Expand All @@ -15,6 +15,11 @@ def layout(self):
def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["QT_VERSION"] = self.dependencies["qt"].ref.version
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
Expand Down
1 change: 1 addition & 0 deletions recipes/qwt/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TestPackageConan(ConanFile):

def build(self):
cmake = CMake(self)
cmake.definitions["QT_VERSION"] = self.deps_cpp_info["qt"].version
cmake.configure()
cmake.build()

Expand Down