diff --git a/recipes/tl-expected/all/conanfile.py b/recipes/tl-expected/all/conanfile.py index 854f1db3cd6ee..ae5a9295b9686 100644 --- a/recipes/tl-expected/all/conanfile.py +++ b/recipes/tl-expected/all/conanfile.py @@ -1,8 +1,7 @@ -from conans import ConanFile, CMake, tools -from fnmatch import fnmatch +from conans import ConanFile, tools import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.43.0" class TlExpectedConan(ConanFile): @@ -12,25 +11,23 @@ class TlExpectedConan(ConanFile): description = "C++11/14/17 std::expected with functional-style extensions" topics = ("cpp11", "cpp14", "cpp17", "expected") license = "CC0-1.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True @property def _source_subfolder(self): return "source_subfolder" - @property - def _archive_dir(self): - # the archive expands to a directory named expected-[COMMIT SHA1]; - # we'd like to put this under a stable name - expected_dirs = [ - de for de in os.scandir(self.source_folder) - if de.is_dir() and fnmatch(de.name, "expected-*") - ] - return expected_dirs[0].name + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def package_id(self): + self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self._archive_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): self.copy("*", @@ -38,12 +35,15 @@ def package(self): dst="include") self.copy("COPYING", src=self._source_subfolder, dst="licenses") - def package_id(self): - self.info.header_only() - def package_info(self): + self.cpp_info.set_property("cmake_file_name", "tl-expected") + self.cpp_info.set_property("cmake_target_name", "tl::expected") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "tl-expected" self.cpp_info.filenames["cmake_find_package_multi"] = "tl-expected" self.cpp_info.names["cmake_find_package"] = "tl" self.cpp_info.names["cmake_find_package_multi"] = "tl" - self.cpp_info.components["expected"].name = "expected" + self.cpp_info.components["expected"].names["cmake_find_package"] = "expected" + self.cpp_info.components["expected"].names["cmake_find_package_multi"] = "expected" + self.cpp_info.components["expected"].set_property("cmake_target_name", "tl::expected") diff --git a/recipes/tl-expected/all/test_package/CMakeLists.txt b/recipes/tl-expected/all/test_package/CMakeLists.txt index c5b259b4d6df1..b623fbd9b8f68 100644 --- a/recipes/tl-expected/all/test_package/CMakeLists.txt +++ b/recipes/tl-expected/all/test_package/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.1) project(test_package) -set(CMAKE_CXX_STANDARD 11) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -find_package(tl-expected REQUIRED) +find_package(tl-expected REQUIRED CONFIG) -add_executable(${PROJECT_NAME} example.cpp) +add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} tl::expected) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/recipes/tl-expected/all/test_package/conanfile.py b/recipes/tl-expected/all/test_package/conanfile.py index 48d0e219e961e..fa561bdd6d36a 100644 --- a/recipes/tl-expected/all/test_package/conanfile.py +++ b/recipes/tl-expected/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class ExpectedTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/tl-expected/all/test_package/example.cpp b/recipes/tl-expected/all/test_package/test_package.cpp similarity index 100% rename from recipes/tl-expected/all/test_package/example.cpp rename to recipes/tl-expected/all/test_package/test_package.cpp