(#14650) qcustomplot: Use newer Conan functions and update Qt versions

Include GNUInstallDirs in CMakeLists.txt.
Use rm_safe.
Use export_conandata_patches.
Make test_type explicit.
This commit is contained in:
Jordan Williams
2022-12-13 17:08:03 -06:00
committed by GitHub
parent 26afe9ae18
commit d20b69e9a6
4 changed files with 17 additions and 31 deletions

View File

@@ -31,7 +31,7 @@ if(QCUSTOMPLOT_USE_OPENGL)
# QCustomPlot does not use the QOpenGLFunctions class, and instead needs to link directly
# to OpenGL32.lib on Windows, regardless of whether qt:opengl is 'dynamic' or 'desktop'
if(WIN32)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
find_package(OpenGL REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL)
endif()
@@ -51,6 +51,7 @@ else()
message(FATAL_ERROR "Qt < 5 not yet supported in this recipe")
endif()
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@@ -2,21 +2,20 @@ from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file
from conan.tools.files import apply_conandata_patches, copy, get, export_conandata_patches, replace_in_file
from conan.tools.scm import Version
import os
required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2"
required_conan_version = ">=1.53.0"
class QcustomplotConan(ConanFile):
class QCustomPlotConan(ConanFile):
name = "qcustomplot"
description = "QCustomPlot is a Qt C++ widget for plotting and data visualization."
license = "GPL-3.0-only"
topics = ("qcustomplot", "qt", "chart", "plot", "data-visualization")
topics = ("chart", "data-visualization", "graph", "plot", "qt")
homepage = "https://www.qcustomplot.com"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
@@ -31,8 +30,7 @@ class QcustomplotConan(ConanFile):
def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
for p in self.conan_data.get("patches", {}).get(self.version, []):
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder)
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
@@ -40,16 +38,16 @@ class QcustomplotConan(ConanFile):
def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")
# FIXME: we shouldn't have to force shared in qt, but config file
# generated by conan in qt static is likely broken, or maybe env vars.
self.options["qt"].shared = True
def requirements(self):
if Version(self.version) >= "2.0.0":
self.requires("qt/6.3.0")
self.requires("qt/6.4.1")
else:
self.requires("qt/5.15.3")
self.requires("qt/5.15.7")
if self.options.with_opengl and self.settings.os == "Windows":
self.requires("opengl/system")
@@ -58,9 +56,9 @@ class QcustomplotConan(ConanFile):
min_cppstd = "11" if Version(self.dependencies["qt"].ref.version) < "6.0.0" else "17"
check_min_cppstd(self, min_cppstd)
if not (self.dependencies["qt"].options.gui and self.dependencies["qt"].options.widgets):
raise ConanInvalidConfiguration("qcustomplot requires qt gui and widgets")
raise ConanInvalidConfiguration(f"{self.ref} requires qt gui and widgets")
if self.info.options.with_opengl and self.dependencies["qt"].options.opengl == "no":
raise ConanInvalidConfiguration("qcustomplot with opengl requires Qt with opengl enabled")
raise ConanInvalidConfiguration(f"{self.ref} with opengl requires Qt with opengl enabled")
def layout(self):
cmake_layout(self, src_folder="src")

View File

@@ -7,6 +7,7 @@ import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)

View File

@@ -1,22 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)
cmake_minimum_required(VERSION 3.1)
project(test_package)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
find_package(qcustomplot REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE qcustomplot::qcustomplot)
if(QT_VERSION VERSION_GREATER_EQUAL "6.0.0")
find_package(Qt6 COMPONENTS Core Widgets REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
elseif(QT_VERSION VERSION_GREATER_EQUAL "5.0.0")
find_package(Qt5 COMPONENTS Core Widgets REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Widgets)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
else()
message(FATAL_ERROR "Qt < 5 not yet supported in this recipe")
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)