From 29a02a87c067f05700b174ff4e23ff883dac0f85 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 30 Jun 2023 08:55:53 +0300 Subject: [PATCH 1/3] p-ranav-glob: migrate to Conan v2 --- recipes/p-ranav-glob/all/conanfile.py | 55 ++++++++++++------- .../all/test_package/CMakeLists.txt | 7 +-- .../all/test_package/conanfile.py | 22 ++++++-- 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/recipes/p-ranav-glob/all/conanfile.py b/recipes/p-ranav-glob/all/conanfile.py index 3db82dd1c8225..882ff198b6b6c 100644 --- a/recipes/p-ranav-glob/all/conanfile.py +++ b/recipes/p-ranav-glob/all/conanfile.py @@ -1,23 +1,26 @@ import os -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.33.0" +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version + +required_conan_version = ">=1.52.0" class PRanavGlobConan(ConanFile): name = "p-ranav-glob" + description = "Glob for C++17" license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/p-ranav/glob" - description = "Glob for C++17" topics = ("c++17", "config", "filesystem", "header-only") - settings = "compiler" - no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True @property def _compilers_minimum_version(self): @@ -28,23 +31,33 @@ def _compilers_minimum_version(self): "apple-clang": "11", } - def configure(self): + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 17) + check_min_cppstd(self, 17) minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) if minimum_version: - if tools.Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration("{} requires C++17, which your compiler does not support.".format(self.name)) + if Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.name} requires C++17, which your compiler does not support.") else: - self.output.warn("{} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) - - def package_id(self): - self.info.header_only() + self.output.warning(f"{self.name} requires C++17. Your compiler is unknown. Assuming it supports C++17.") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], strip_root=True) def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "single_include")) + copy(self, "LICENSE", + 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, "single_include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/p-ranav-glob/all/test_package/CMakeLists.txt b/recipes/p-ranav-glob/all/test_package/CMakeLists.txt index 481262167c9f5..5baf64aba53ee 100644 --- a/recipes/p-ranav-glob/all/test_package/CMakeLists.txt +++ b/recipes/p-ranav-glob/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.15) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(p-ranav-glob REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE p-ranav-glob::p-ranav-glob) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/p-ranav-glob/all/test_package/conanfile.py b/recipes/p-ranav-glob/all/test_package/conanfile.py index 4903f1a7e8fa0..ef5d7042163ec 100644 --- a/recipes/p-ranav-glob/all/test_package/conanfile.py +++ b/recipes/p-ranav-glob/all/test_package/conanfile.py @@ -1,9 +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", "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) @@ -11,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - 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") From b761aa14d19cc332d91db5baa485fab65ead3ecc Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 3 Jul 2023 23:11:28 +0200 Subject: [PATCH 2/3] p-ranav-glob: restore test_v1_package --- .../all/test_v1_package/CMakeLists.txt | 8 ++++++++ .../all/test_v1_package/conanfile.py | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 recipes/p-ranav-glob/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/p-ranav-glob/all/test_v1_package/conanfile.py diff --git a/recipes/p-ranav-glob/all/test_v1_package/CMakeLists.txt b/recipes/p-ranav-glob/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/p-ranav-glob/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/p-ranav-glob/all/test_v1_package/conanfile.py b/recipes/p-ranav-glob/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4903f1a7e8fa0 --- /dev/null +++ b/recipes/p-ranav-glob/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From abfedcd330ff090a210d69d5d1976537618dfd91 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 5 Jul 2023 09:16:59 +0200 Subject: [PATCH 3/3] p-ranav-glob: add cmake_find_package_multi generator to test_v1_package --- recipes/p-ranav-glob/all/test_v1_package/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/p-ranav-glob/all/test_v1_package/conanfile.py b/recipes/p-ranav-glob/all/test_v1_package/conanfile.py index 4903f1a7e8fa0..6c9d5dba712c7 100644 --- a/recipes/p-ranav-glob/all/test_v1_package/conanfile.py +++ b/recipes/p-ranav-glob/all/test_v1_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self)