From 5e805590f775b05a542ec95516dcb7309a1dc1a8 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:30:17 +0100 Subject: [PATCH] conan v2 support --- recipes/taocpp-tuple/all/conanfile.py | 33 +++++++++++-------- .../all/test_package/CMakeLists.txt | 9 ++--- .../all/test_package/conanfile.py | 19 ++++++++--- .../all/test_v1_package/CMakeLists.txt | 8 +++++ .../all/test_v1_package/conanfile.py | 17 ++++++++++ 5 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 recipes/taocpp-tuple/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/taocpp-tuple/all/test_v1_package/conanfile.py diff --git a/recipes/taocpp-tuple/all/conanfile.py b/recipes/taocpp-tuple/all/conanfile.py index 901f53a0bfa763..49ba6fed4d4b0d 100644 --- a/recipes/taocpp-tuple/all/conanfile.py +++ b/recipes/taocpp-tuple/all/conanfile.py @@ -1,7 +1,10 @@ -from conans import ConanFile, tools +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 import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class TaoCPPTupleConan(ConanFile): @@ -14,28 +17,32 @@ class TaoCPPTupleConan(ConanFile): no_copy_source = True settings = "os", "arch", "compiler", "build_type" - @property - def _source_subfolder(self): - return "source_subfolder" + 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"): - tools.check_min_cppstd(self, 11) - - def package_id(self): - self.info.header_only() + check_min_cppstd(self, 11) 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], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "taocpp-tuple") self.cpp_info.set_property("cmake_target_name", "taocpp::tuple") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "taocpp-tuple" diff --git a/recipes/taocpp-tuple/all/test_package/CMakeLists.txt b/recipes/taocpp-tuple/all/test_package/CMakeLists.txt index d9a490f809bbc6..7758d52fe5e896 100644 --- a/recipes/taocpp-tuple/all/test_package/CMakeLists.txt +++ b/recipes/taocpp-tuple/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(taocpp-tuple REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} taocpp::tuple) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE taocpp::tuple) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/taocpp-tuple/all/test_package/conanfile.py b/recipes/taocpp-tuple/all/test_package/conanfile.py index 38f4483872d47f..0a6bc68712d901 100644 --- a/recipes/taocpp-tuple/all/test_package/conanfile.py +++ b/recipes/taocpp-tuple/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, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) 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.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/taocpp-tuple/all/test_v1_package/CMakeLists.txt b/recipes/taocpp-tuple/all/test_v1_package/CMakeLists.txt new file mode 100644 index 00000000000000..0d20897301b68b --- /dev/null +++ b/recipes/taocpp-tuple/all/test_v1_package/CMakeLists.txt @@ -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) diff --git a/recipes/taocpp-tuple/all/test_v1_package/conanfile.py b/recipes/taocpp-tuple/all/test_v1_package/conanfile.py new file mode 100644 index 00000000000000..38f4483872d47f --- /dev/null +++ b/recipes/taocpp-tuple/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +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 tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True)