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

qxlsx/1.4.3: Add qt6 compatibility #11364

Closed
wants to merge 5 commits into from
Closed
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: 6 additions & 0 deletions recipes/qxlsx/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ patches:
base_path: "source_subfolder"
- patch_file: "patches/0002-add-install-target.patch"
base_path: "source_subfolder"
- patch_file: "patches/0003-use-cpp17-with-qt6.patch"
base_path: "source_subfolder"
patch_source: "https://github.com/QtExcel/QXlsx/pull/223"
- patch_file: "patches/0004-defined-cpp-standard-only-if-need.patch"
base_path: "source_subfolder"
patch_source: "https://github.com/QtExcel/QXlsx/pull/226"
14 changes: 5 additions & 9 deletions recipes/qxlsx/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from conan.tools.files import apply_conandata_patches
from conans import CMake, ConanFile, tools
import functools
import os
Expand All @@ -12,7 +13,7 @@ class QXlsxConan(ConanFile):
topics = ("qxlsx", "excel", "xlsx")
homepage = "https://github.com/QtExcel/QXlsx"
url = "https://github.com/conan-io/conan-center-index"

exports_sources = ["CMakeLists.txt", "patches/**"]
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand All @@ -29,11 +30,6 @@ class QXlsxConan(ConanFile):
def _source_subfolder(self):
return "source_subfolder"

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -43,7 +39,7 @@ def configure(self):
del self.options.fPIC

def requirements(self):
self.requires("qt/5.15.3")
self.requires("qt/5.15.4")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
Expand All @@ -52,12 +48,12 @@ def source(self):
@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["QT_VERSION_MAJOR"] = tools.Version(self.deps_cpp_info["qt"].version).major
cmake.configure()
return cmake

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
apply_conandata_patches(self)
cmake = self._configure_cmake()
cmake.build()

Expand Down
32 changes: 32 additions & 0 deletions recipes/qxlsx/all/patches/0003-use-cpp17-with-qt6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
commit e53efc535340dc74120c53b83b6462ae9144e39d
Author: Martin Delille <[email protected]>
Date: Tue Jul 5 10:33:47 2022 +0200

Use c++17 when using Qt 6

diff --git a/QXlsx/CMakeLists.txt b/QXlsx/CMakeLists.txt
index d82b479..527866c 100644
--- a/QXlsx/CMakeLists.txt
+++ b/QXlsx/CMakeLists.txt
@@ -11,14 +11,18 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)

-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
include(GNUInstallDirs)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui REQUIRED)

+if (QT_MAJOR_VERSION EQUAL 6)
+ set(CMAKE_CXX_STANDARD 17)
+else()
+ set(CMAKE_CXX_STANDARD 11)
+endif()
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

if(NOT DEFINED ${QXLSX_PARENTPATH})
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
commit 9072fc1b7160fd67123a39cf9590db5133de51ec
Author: Martin Delille <[email protected]>
Date: Fri Jul 22 10:21:54 2022 +0200

Define cpp standard only if not defined

diff --git a/QXlsx/CMakeLists.txt b/QXlsx/CMakeLists.txt
index 527866c..7e59cc5 100644
--- a/QXlsx/CMakeLists.txt
+++ b/QXlsx/CMakeLists.txt
@@ -16,10 +16,12 @@ include(GNUInstallDirs)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui REQUIRED)

-if (QT_MAJOR_VERSION EQUAL 6)
+if(NOT CMAKE_CXX_STANDARD)
+ if (QT_MAJOR_VERSION EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
-else()
+ else()
set(CMAKE_CXX_STANDARD 11)
+ endif()
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)

2 changes: 1 addition & 1 deletion recipes/qxlsx/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ find_package(QXlsx REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} QXlsx::Core)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prince-chrismc How shall I handle the C++ version conditionnally here ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is the test packge, it's prefect