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

Add RuntimeQml Package #13407

Merged
merged 20 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 17 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
33 changes: 33 additions & 0 deletions recipes/runtimeqml/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.21.1)

project(runtimeqml LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")

find_package(Qt5 CONFIG)
find_package(Qt6 CONFIG)
if (Qt6_FOUND)
add_library(${PROJECT_NAME} runtimeqml.hpp runtimeqml.cpp)
elseif(Qt5_FOUND)
add_library(${PROJECT_NAME} runtimeqml.h runtimeqml.cpp)
else()
message(FATAL_ERROR "Qt was not found")
endif()

target_link_libraries(${PROJECT_NAME} PUBLIC qt::qt)
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${HEADERS}" C_VISIBILITY_PRESET hidden)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
7 changes: 7 additions & 0 deletions recipes/runtimeqml/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"cci.20220923":
url: /~https://github.com/GIPdA/runtimeqml/archive/3ae5dadcf6548a2e59e83c21d84fd50575df79bf.zip
sha256: "18bf63ab2692e6cb8ed6e0dbfcd2390dc65769eaed43b66c4da9dd7a55598603"
"cci.20211220":
url: /~https://github.com/GIPdA/runtimeqml/archive/ac0cbfc49ae215dd0df5ac8ecb79ca7008de5486.zip
sha256: "57c6d50f0fd281c0984daae65f3559942f58d11de8ff406c150d54fd7ff0d076"
100 changes: 100 additions & 0 deletions recipes/runtimeqml/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.microsoft import is_msvc, check_min_vs
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.files import get, copy
from conan.errors import ConanInvalidConfiguration

required_conan_version = ">=1.50.0"

class RuntimeQml(ConanFile):
name = "runtimeqml"
homepage = "/~https://github.com/GIPdA/runtimeqml"
description = "Enables hot-reloading qml files"
topics = ("qt", "hot-reload", "qml", "gui")
url = "/~https://github.com/conan-io/conan-center-index"
license = "BSD-3-Clause"
settings = "os", "arch", "compiler", "build_type"

options = {
"shared": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": False,
"fPIC": True
}

@property
def _minimum_cpp_standard(self):
return 17

@property
def _compilers_minimum_version(self):
return {
"gcc": "7",
"clang": "7",
"apple-clang": "10",
}

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
try:
del self.options.fPIC
except Exception:
pass

def layout(self):
cmake_layout(self)

def requirements(self):
if Version(self.version) <= "cci.20211220":
Copy link
Contributor

Choose a reason for hiding this comment

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

This works 😱 did not even know

Copy link
Member

Choose a reason for hiding this comment

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

as we don't use that weird american format, is much easier compare using year first. After all, it's only char value comparison

Copy link
Contributor

Choose a reason for hiding this comment

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

weird american format

Heck at least I get two birthday 😆 🍰

self.requires("qt/5.15.5")
else:
self.requires("qt/6.3.1")

def validate(self):
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, self._minimum_cpp_standard)
check_min_vs(self, 191)
if not is_msvc(self):
minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False)
if minimum_version and Version(self.info.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support."
)
qt = self.dependencies["qt"]
if not qt.options.qtdeclarative:
raise ConanInvalidConfiguration(f"{self.ref} requires option qt:qtdeclarative=True")

def source(self):
get(self, **self.conan_data["sources"][str(self.version)],
destination=self.source_folder, strip_root=True)

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

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

def package(self):
self.copy(pattern="LICENSE", src=self.source_folder,
dst="licenses", keep_path=False)
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["runtimeqml"]
8 changes: 8 additions & 0 deletions recipes/runtimeqml/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package CXX)

find_package(runtimeqml REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE runtimeqml::runtimeqml)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
25 changes: 25 additions & 0 deletions recipes/runtimeqml/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

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 can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
12 changes: 12 additions & 0 deletions recipes/runtimeqml/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <QApplication>
#include <QQmlApplicationEngine>

#include <runtimeqml.hpp>

int main(int argc, char* argv[]) {
QApplication app(argc, argv);
QQmlApplicationEngine engine;

RuntimeQml* rt = new RuntimeQml(&engine);
return app.exec();
}
8 changes: 8 additions & 0 deletions recipes/runtimeqml/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

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

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
18 changes: 18 additions & 0 deletions recipes/runtimeqml/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.cmake import CMake
import os

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

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

def test(self):
if not cross_building(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
5 changes: 5 additions & 0 deletions recipes/runtimeqml/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions:
"cci.20220923":
folder: "all"
"cci.20211220":
folder: "all"