Skip to content

Commit

Permalink
(#15293) Add spix/0.5
Browse files Browse the repository at this point in the history
* Add version 0.5

* Bump dependencies

* Always use c++17 for test_package (test_v1_package was not working)

* Add version in config.yml

* Review: replace deps_cpp_info by dependencies

* Review: replace info.settings by settings

* Review: Set AnyRpc target name with CMakeDeps

* Review: lint test_package recipes imports

* trigger ci

* Revert "trigger ci"

This reverts commit 2f87f79.

* Fix KB-H041

* Apply suggestions from code review

* use rm_Safe

* fix typos

---------

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
  • Loading branch information
fdgStilla and prince-chrismc authored Feb 11, 2023
1 parent 33f83eb commit 56030ac
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 59 deletions.
7 changes: 7 additions & 0 deletions recipes/spix/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ sources:
"0.4":
url: "https://github.com/faaxm/spix/archive/refs/tags/v0.4.tar.gz"
sha256: "e787c08840c37e5b153c0139f3bb613a2729ae8f6ccd0fb450fef92971cd8b53"
"0.5":
url: "https://github.com/faaxm/spix/archive/refs/tags/v0.5.tar.gz"
sha256: "d3fd9bb069aef6ff6c93c69524ed3603afd24e6b52e4bb8d093c80cec255d4dc"
patches:
"0.4":
- patch_file: "patches/0001-use-conan-libs-0.4.patch"
patch_description: "Link to conan libs"
patch_type: "conan"
"0.5":
- patch_file: "patches/0001-use-conan-libs-0.5.patch"
patch_description: "Link to conan libs"
patch_type: "conan"
46 changes: 27 additions & 19 deletions recipes/spix/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os


required_conan_version = ">=1.52.0"
required_conan_version = ">=1.53.0"


class SpixConan(ConanFile):
Expand All @@ -29,16 +29,26 @@ class SpixConan(ConanFile):

@property
def _minimum_cpp_standard(self):
return 14
return 14 if self.version == "0.4" else 17

@property
def _compilers_minimum_version(self):
return {
"Visual Studio": "14",
"gcc": "5",
"clang": "3.4",
"apple-clang": "10"
}
if self.version == "0.4":
return {
"Visual Studio": "14",
"msvc": "190",
"gcc": "5",
"clang": "3.4",
"apple-clang": "10"
}
else:
return {
"Visual Studio": "15.7",
"msvc": "192", # FIXME: 15.7 is actually 1914 but needs to be tested
"gcc": "7",
"clang": "5",
"apple-clang": "10",
}

def export_sources(self):
export_conandata_patches(self)
Expand All @@ -49,24 +59,20 @@ def config_options(self):

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

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

def requirements(self):
self.requires("anyrpc/1.0.2")
self.requires("qt/6.3.1")
self.requires("expat/2.4.9")
self.requires("qt/6.4.2")

def validate(self):
if self.info.settings.compiler.cppstd:
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._minimum_cpp_standard)
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:
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support."
)
Expand All @@ -77,7 +83,7 @@ def validate(self):
raise ConanInvalidConfiguration(f"{self.ref} requires qt:gui and qt:qtdeclarative to get the Quick module")

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

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -87,11 +93,13 @@ def generate(self):
tc.generate()

deps = CMakeDeps(self)
deps.set_property("anyrpc", "cmake_file_name", "AnyRPC")
deps.set_property("anyrpc", "cmake_target_name", "AnyRPC::anyrpc")
deps.generate()

def _patch_sources(self):
apply_conandata_patches(self)
if Version(self.deps_cpp_info["qt"].version).major == 6:
if self.version == "0.4" and Version(self.dependencies["qt"].ref.version).major == 6:
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set(CMAKE_CXX_STANDARD 14)", "set(CMAKE_CXX_STANDARD 17)")

def build(self):
Expand Down
25 changes: 0 additions & 25 deletions recipes/spix/all/patches/0001-use-conan-libs-0.4.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,3 @@
set(CMAKE_CXX_STANDARD 14)

# Hide symbols unless explicitly flagged with SPIX_EXPORT
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 723de5e..f234bec 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -8,7 +8,7 @@ include(CMakePackageConfigHelpers)
# Dependencies
#
find_package(Threads REQUIRED)
-find_package(AnyRPC REQUIRED)
+find_package(anyrpc REQUIRED)
find_package(Qt${SPIX_QT_MAJOR}
COMPONENTS
Core
@@ -128,7 +128,7 @@ target_link_libraries(Spix
Qt${SPIX_QT_MAJOR}::Gui
Qt${SPIX_QT_MAJOR}::Quick
PRIVATE
- AnyRPC::anyrpc
+ anyrpc::anyrpc
)

#
--
2.36.1.windows.1

10 changes: 10 additions & 0 deletions recipes/spix/all/patches/0001-use-conan-libs-0.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,6 @@ option(SPIX_BUILD_EXAMPLES "Build Spix examples." ON)
option(SPIX_BUILD_TESTS "Build Spix unit tests." OFF)
set(SPIX_QT_MAJOR "6" CACHE STRING "Major Qt version to build Spix against")

-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
set(CMAKE_CXX_STANDARD 17)

# Hide symbols unless explicitly flagged with SPIX_EXPORT
2 changes: 1 addition & 1 deletion recipes/spix/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ find_package(Spix REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_spix.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE Spix::Spix)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
7 changes: 0 additions & 7 deletions recipes/spix/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
from conan.tools.files import replace_in_file
from conan.tools.scm import Version
import os


Expand All @@ -17,12 +15,7 @@ def requirements(self):
def layout(self):
cmake_layout(self)

def _patch_sources(self):
if Version(self.deps_cpp_info["qt"].version).major == 6:
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "cxx_std_14", "cxx_std_17")

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand Down
7 changes: 0 additions & 7 deletions recipes/spix/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
from conan.tools.files import replace_in_file
from conan.tools.scm import Version
import os


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

def _patch_sources(self):
if Version(self.deps_cpp_info["qt"].version).major == 6:
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "cxx_std_14", "cxx_std_17")

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand Down
2 changes: 2 additions & 0 deletions recipes/spix/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"0.4":
folder: all
"0.5":
folder: all

0 comments on commit 56030ac

Please sign in to comment.