Skip to content

Feat/conan qt6.8.3 #12153

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
42 changes: 42 additions & 0 deletions .github/workflows/conan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build with conan

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build-linux:
name: Build on Linux
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Conan
uses: conan-io/setup-conan@v1

- name: Add local recipe repository & set conan config
shell: bash
run: |
conan config install ./vendor/.config/global.conf
conan remote add local ./vendor/

- name: Install dependencies with conan
shell: bash
run: |
conan install . --output-folder=build --build=missing

- name: Build the client
shell: bash
run: |
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DWITH_APPIMAGEUPDATER=OFF
cmake --build .



1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CMakeLists.txt.user*
.vs/
CMakeSettings.json
CMakeUserPresets.json
*~
*.autosave
doc/_build/*
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(QT 6.7 NAMES Qt6 COMPONENTS Core REQUIRED)

find_package(Qt6 COMPONENTS Core Concurrent Network Widgets Xml Quick QuickWidgets QuickControls2 REQUIRED)
find_package(Qt6LinguistTools REQUIRED)
get_target_property (QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
find_package(Qt6 CONFIG REQUIRED COMPONENTS LinguistTools)

get_target_property (QT_QMAKE_EXECUTABLE Qt6::qmake IMPORTED_LOCATION)
message(STATUS "Using Qt ${QT_VERSION} (${QT_QMAKE_EXECUTABLE})")

get_target_property (QT_QTPATH_EXECUTABLE Qt6::qtpaths IMPORTED_LOCATION)
message(STATUS "Using Qt ${QT_VERSION} (${QT_QTPATH_EXECUTABLE})")

if (UNIX AND NOT APPLE)
find_package(Qt6 REQUIRED COMPONENTS DBus)
endif()
Expand Down
30 changes: 30 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[requires]
extra-cmake-modules/6.2.0
zlib/1.3.1
sqlite3/3.49.1
qt/6.8.3
nlohmann_json/3.11.3
kdsingleapplication/1.1.0
qtkeychain/0.15.0
libregraphapi/1.0.4

# this is a painful
# libcrashreporter_qt/0.1.0

# Sparkle ?
# AppImageUpdate ?

[tool_requires]
cmake/3.30.0

[generators]
CMakeDeps
CMakeToolchain

[options]
qt/*:shared=True
qt/*:qtdeclarative=True
qt/*:qttools=True
qt/*:gui=True
qt/*:widgets=True
qt/*:with_dbus=True
2 changes: 2 additions & 0 deletions vendor/.config/global.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tools.system.package_manager:mode = install
tools.system.package_manager:sudo = True
10 changes: 10 additions & 0 deletions vendor/recipes/kdsingleapplication/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sources:
"1.1.0":
url:
- "https://github.com/KDAB/KDSingleApplication/archive/refs/tags/v1.1.0.zip"
sha256: "5024fb8f7dcf7e42a1dd3218bd1f1f0be038abe91d35fd8aa594efaa6d58eae8"
patches:
"1.1.0":
- patch_file: "patches/fbff57202b91c6214360803b7397cf7d607c2fbf.patch"
patch_description: "fix Qt6 link target"
patch_type: "conan"
73 changes: 73 additions & 0 deletions vendor/recipes/kdsingleapplication/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from conan import ConanFile
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, export_conandata_patches, get, replace_in_file
import os

required_conan_version = ">=2.0.9"

class KDSingleApplicationConan(ConanFile):
name = "kdsingleapplication"
description = "KDAB's helper class for single-instance policy applications."
topics = ("qt", "kdab")
license = "MIT"
homepage = "https://github.com/KDAB/KDSingleApplication"
url = "https://github.com/conan-io/conan-center-index"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": True,
"fPIC": True,
}

implements = ["auto_shared_fpic"]

def export_sources(self):
export_conandata_patches(self)

def layout(self):
cmake_layout(self, src_folder="src")

def validate(self):
check_min_cppstd(self, 17)

def requirements(self):
self.requires("qt/[>=6.7 <7]", transitive_headers=True, transitive_libs=True)

def build_requirements(self):
self.tool_requires("qt/<host_version>")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set(CMAKE_CXX_STANDARD 14)", "")

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["KDSingleApplication_QT6"] = True
tc.cache_variables["BUILD_TRANSLATIONS"] = False
tc.generate()

deps = CMakeDeps(self)
deps.generate()

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

def package(self):
copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "KDSingleApplication-qt6")
self.cpp_info.set_property("cmake_target_name", "KDAB::kdsingleapplication")
self.cpp_info.set_property("cmake_target_aliases", ["kdsingleapplication"])
self.cpp_info.filenames["cmake_find_package"] = "KDSingleApplication-qt6"

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From fbff57202b91c6214360803b7397cf7d607c2fbf Mon Sep 17 00:00:00 2001
From: re2zero <[email protected]>
Date: Wed, 25 Sep 2024 09:13:15 +0800
Subject: [PATCH] fix: Fix build configure

It miss the Qt MAJOR version if build with Qt5.

Log: Fix build configure.
---
examples/widgetsingleapplication/CMakeLists.txt | 2 +-
src/CMakeLists.txt | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/widgetsingleapplication/CMakeLists.txt b/examples/widgetsingleapplication/CMakeLists.txt
index 3e4a0a9..21ffb26 100644
--- a/examples/widgetsingleapplication/CMakeLists.txt
+++ b/examples/widgetsingleapplication/CMakeLists.txt
@@ -12,5 +12,5 @@ add_executable(
${widgetsingleapplication_SRCS}
)
target_link_libraries(
- widgetsingleapplication Qt::Widgets kdsingleapplication
+ widgetsingleapplication Qt${QT_VERSION_MAJOR}::Widgets kdsingleapplication
)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 01a804d..794f425 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -40,8 +40,8 @@ if(WIN32)
endif()
target_link_libraries(
kdsingleapplication
- PUBLIC Qt::Core
- PRIVATE Qt::Network
+ PUBLIC Qt${QT_VERSION_MAJOR}::Core
+ PRIVATE Qt${QT_VERSION_MAJOR}::Network
)

install(
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)

find_package(KDSingleApplication-qt6 CONFIG REQUIRED)

add_executable(example src/example.cpp)
target_link_libraries(example KDAB::kdsingleapplication)
26 changes: 26 additions & 0 deletions vendor/recipes/kdsingleapplication/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run


class KDSingleApplicationTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires(self.tested_reference_str)

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

def layout(self):
cmake_layout(self)

def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "kdsingleapplication_version.h"
#include <iostream>

int main()
{
std::cout << KDSINGLEAPPLICATION_VERSION_STRING << std::endl;
}
3 changes: 3 additions & 0 deletions vendor/recipes/kdsingleapplication/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.1.0":
folder: all
4 changes: 4 additions & 0 deletions vendor/recipes/libcrashreporter_qt/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.1.0":
url: "https://github.com/DeepDiver1975/libcrashreporter-qt/releases/download/v0.1.0/libcrashreporter-qt-0.1.0.tar.gz"
sha256: "abdc6d2df3db8d3baecb9480ad9325f7775d4f7f31f4ee86104b8c02542a99d2"
65 changes: 65 additions & 0 deletions vendor/recipes/libcrashreporter_qt/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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 copy, get, replace_in_file, rmdir
import os


required_conan_version = ">=2.0.9"
class LibCrashReporterQtConan(ConanFile):
name = "libcrashreporter_qt"
description = "libcrashreporter-qt is supposed to provide an easy integration of Google Breakpad crash reporting into a Qt application."
topics = ("qt", "breadpad")
license = "LGPL-2.1-or-later"
homepage = "https://github.com/DeepDiver1975/libcrashreporter-qt"
url = "https://github.com/conan-io/conan-center-index"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

implements = ["auto_shared_fpic"]

def layout(self):
cmake_layout(self)

def validate(self):
check_min_cppstd(self, 17)

def requirements(self):
self.requires("qt/[>=6.7 <7]", transitive_headers=True, transitive_libs=True)

def build_requirements(self):
self.tool_requires("qt/<host_version>")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=False)
# replace_in_file(self, os.path.join(self.source_folder, "client", "CMakeLists.txt"), "CXX_STANDARD 14", "")

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

deps = CMakeDeps(self)
deps.generate()

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

def package(self):
copy(self, "LICENSE.LGPL2.1", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["CrashReporterQt"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)

find_package(libregraphapi)
find_package(Qt6)

add_executable(example src/example.cpp)
target_link_libraries(example LibreGraphAPI)
#target_link_libraries(... libregraphapi::libregraphapi qt::qt)
27 changes: 27 additions & 0 deletions vendor/recipes/libcrashreporter_qt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run


class qtkeychainTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires(self.tested_reference_str)
self.requires("qt/[>=6.7 <7]")

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

def layout(self):
cmake_layout(self)

def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "OpenAPI/LibreGraphAPI/OAIDrive.h"

int main()
{
auto d = OpenAPI::OAIDrive();
}
3 changes: 3 additions & 0 deletions vendor/recipes/libcrashreporter_qt/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.1.0":
folder: all
4 changes: 4 additions & 0 deletions vendor/recipes/libregraphapi/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.0.4":
url: "https://github.com/owncloud/libre-graph-api-cpp-qt-client/archive/refs/tags/v1.0.4.zip"
sha256: "7aeb1500f546ac885c7170861d878b037ff5cfcc7f0c28ab774329bb8b4208b8"
Loading
Loading