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

qt-advanced-docking-system: migrate to Conan v2 #18794

Open
wants to merge 17 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
7 changes: 0 additions & 7 deletions recipes/qt-advanced-docking-system/all/CMakeLists.txt

This file was deleted.

16 changes: 6 additions & 10 deletions recipes/qt-advanced-docking-system/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
sources:
"3.8.3":
url: "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/archive/refs/tags/3.8.3.tar.gz"
sha256: "bd5a9469b755bedf33baefd0b3dda6d167b7917a2888e2794eed5abee7d78f74"
"3.8.2":
url: "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/archive/refs/tags/3.8.2.tar.gz"
sha256: "e56811228fb4d5f5703c31cd83cb39ab2d5a849f581719d383db72f9322ec7f2"
patches:
"3.8.2":
- patch_file: "patches/fix-cmake-license-install.patch"
base_path: "source_subfolder"
"4.2.0":
url: "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/archive/refs/tags/4.2.0.tar.gz"
sha256: "b6f030a2f9e7797803d8bd283bf01bae76d27a9f11a7cba5263cd775f264ab55"
"3.8.4":
url: "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/archive/refs/tags/3.8.4.tar.gz"
sha256: "9c876a7841ab6a6f05a879beb25dde043d42626b5acfd1b0b54d70055ebf1ebe"
114 changes: 65 additions & 49 deletions recipes/qt-advanced-docking-system/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
from conan import ConanFile
from conan.tools.files import copy, get, apply_conandata_patches, export_conandata_patches, replace_in_file, rmdir
from conans import CMake
import os

required_conan_version = ">=1.52.0"
from conan import ConanFile
from conan.tools.build import check_min_cppstd, can_run
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, replace_in_file, rmdir
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version

required_conan_version = ">=2.0.9"


class QtADS(ConanFile):
name = "qt-advanced-docking-system"
license = "LGPL-2.1"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System"
topics = ("qt", "gui")
description = (
"Qt Advanced Docking System lets you create customizable layouts "
"using a full featured window docking system similar to what is found "
"in many popular integrated development environments (IDEs) such as "
"Visual Studio."
)
settings = "os", "compiler", "build_type", "arch"
license = "LGPL-2.1"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System"
topics = ("qt", "gui")

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
Expand All @@ -26,70 +33,79 @@ class QtADS(ConanFile):
"shared": False,
"fPIC": True,
}
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"

_cmake = None
_qt_version = "5.15.6"
implements = ["auto_shared_fpic"]

@property
def _source_subfolder(self):
return "source_subfolder"

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
export_conandata_patches(self)
def _qt_major(self):
return Version(self.dependencies["qt"].ref.version).major

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
@property
def _min_cppstd(self):
if self._qt_major >= 6:
return 17
else:
return 14

def configure(self):
if self.options.shared:
del self.options.fPIC
def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires(f"qt/{self._qt_version}")
self.requires("qt/[>=6.0 <7]", transitive_headers=True, transitive_libs=True, run=can_run(self))
self.requires("libpng/[>=1.6 <2]")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True,
destination=self._source_subfolder)
def validate(self):
check_min_cppstd(self, self._min_cppstd)

def _configure_cmake(self):
if self._cmake:
return self._cmake
def build_requirements(self):
if not can_run(self):
self.tool_requires("qt/<host_version>")

self._cmake = CMake(self)
self._cmake.definitions["ADS_VERSION"] = self.version
self._cmake.definitions["BUILD_EXAMPLES"] = "OFF"
self._cmake.definitions["BUILD_STATIC"] = not self.options.shared
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

self._cmake.configure()
return self._cmake
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["ADS_VERSION"] = self.version
tc.variables["BUILD_EXAMPLES"] = "OFF"
tc.variables["BUILD_STATIC"] = not self.options.shared
tc.generate()
deps = CMakeDeps(self)
deps.generate()

def _patch_sources(self):
apply_conandata_patches(self)

replace_in_file(self,
f"{self.source_folder}/{self._source_subfolder}/src/ads_globals.cpp",
"#include <qpa/qplatformnativeinterface.h>",
f"#include <{self._qt_version}/QtGui/qpa/qplatformnativeinterface.h>"
qt_version = self.dependencies["qt"].ref.version
replace_in_file(self, os.path.join(self.source_folder, "src", "ads_globals.cpp"),
"#include <qpa/qplatformnativeinterface.h>",
f"#include <{qt_version}/QtGui/qpa/qplatformnativeinterface.h>",
)

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

def package(self):
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.install()
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "license"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
if Version(self.version) >= 4:
name = f"qt{self._qt_major}advanceddocking"
self.cpp_info.includedirs.append(os.path.join("include", name))
lib_name = f"{name}d" if self.settings.build_type == "Debug" else name
else:
lib_name = "qtadvanceddocking"

if self.options.shared:
self.cpp_info.libs = ["qtadvanceddocking"]
self.cpp_info.libs = [lib_name]
else:
self.cpp_info.defines.append("ADS_STATIC")
self.cpp_info.libs = ["qtadvanceddocking_static"]
self.cpp_info.libs = [f"{lib_name}_static"]

if is_msvc(self) and self._qt_major >= 6:
# Qt 6 requires C++17 and a valid __cplusplus value
self.cpp_info.cxxflags.append("/Zc:__cplusplus")

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(qt-advanced-docking-system CONFIG REQUIRED)
find_package(qt-advanced-docking-system REQUIRED CONFIG)

add_executable(example example.cpp)
target_link_libraries(example qt-advanced-docking-system::qt-advanced-docking-system)
target_compile_features(example PRIVATE cxx_std_17)
23 changes: 16 additions & 7 deletions recipes/qt-advanced-docking-system/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


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

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

def layout(self):
cmake_layout(self)

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)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "example")
self.run(bin_path, env="conanrun")
4 changes: 2 additions & 2 deletions recipes/qt-advanced-docking-system/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
versions:
"3.8.3":
"4.2.0":
folder: "all"
"3.8.2":
"3.8.4":
folder: "all"