Skip to content

Commit

Permalink
modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm committed Jan 30, 2022
1 parent 9cb4e25 commit 1d02a40
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
36 changes: 18 additions & 18 deletions recipes/tl-expected/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -12,38 +11,39 @@ 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("*",
src=os.path.join(self._source_subfolder, "include"),
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")
8 changes: 4 additions & 4 deletions recipes/tl-expected/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 3 additions & 3 deletions recipes/tl-expected/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@


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)
cmake.configure()
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)

0 comments on commit 1d02a40

Please sign in to comment.