From 595f0b77b6b20cb61638e3816bdef5dda267e1a6 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 5 Jul 2023 12:27:35 +0200 Subject: [PATCH] (#18237) snowhouse: migrate to Conan v2 * snowhouse: migrate to Conan v2 * snowhouse: restore test_v1_package * snowhouse: add cmake_find_package_multi generator to test_v1_package --- recipes/snowhouse/all/conanfile.py | 44 ++++++++++++++----- .../snowhouse/all/test_package/CMakeLists.txt | 9 ++-- .../snowhouse/all/test_package/conanfile.py | 21 ++++++--- .../all/test_v1_package/CMakeLists.txt | 8 ++++ .../all/test_v1_package/conanfile.py | 17 +++++++ 5 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 recipes/snowhouse/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/snowhouse/all/test_v1_package/conanfile.py diff --git a/recipes/snowhouse/all/conanfile.py b/recipes/snowhouse/all/conanfile.py index 8bca8ddf11dc6d..ec6ca8d6070920 100644 --- a/recipes/snowhouse/all/conanfile.py +++ b/recipes/snowhouse/all/conanfile.py @@ -1,28 +1,50 @@ -from conans import ConanFile, tools import os -required_conan_version = ">=1.33.0" +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout + +required_conan_version = ">=1.52.0" class SnowHouseConan(ConanFile): name = "snowhouse" description = "An assertion library for C++" - topics = ("assertion", "header-only") + license = "BSL-1.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/banditcpp/snowhouse" - license = "BSL-1.0" + topics = ("assertion", "header-only") + + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return 11 + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True) def package(self): - self.copy(pattern="LICENSE_1_0.txt", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE_1_0.txt", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder) + copy(self, "*", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/snowhouse/all/test_package/CMakeLists.txt b/recipes/snowhouse/all/test_package/CMakeLists.txt index 33ae887aa6aea3..2fd896601b32f8 100644 --- a/recipes/snowhouse/all/test_package/CMakeLists.txt +++ b/recipes/snowhouse/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(snowhouse REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE snowhouse::snowhouse) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/snowhouse/all/test_package/conanfile.py b/recipes/snowhouse/all/test_package/conanfile.py index d4128b04507778..fae501d0afb9e4 100644 --- a/recipes/snowhouse/all/test_package/conanfile.py +++ b/recipes/snowhouse/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -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 TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/snowhouse/all/test_v1_package/CMakeLists.txt b/recipes/snowhouse/all/test_v1_package/CMakeLists.txt new file mode 100644 index 00000000000000..91630d79f4abb3 --- /dev/null +++ b/recipes/snowhouse/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +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/) diff --git a/recipes/snowhouse/all/test_v1_package/conanfile.py b/recipes/snowhouse/all/test_v1_package/conanfile.py new file mode 100644 index 00000000000000..49a3a66ea5bad4 --- /dev/null +++ b/recipes/snowhouse/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + 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", "test_package") + self.run(bin_path, run_environment=True)