Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variant-lite: modernize #8778

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions recipes/variant-lite/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sources:
"1.2.2":
url: https://github.com/martinmoene/variant-lite/archive/v1.2.2.tar.gz
sha256: 97334108c3a92f7becc74e2798ab8e0ea57fd67d4ad893ec0b0b8e1c35bb411c
"2.0.0":
url: https://github.com/martinmoene/variant-lite/archive/v2.0.0.tar.gz
sha256: 70c1509e24d03abfd22d2e702ab398238e69658b7b2890ce1d7e9731d6b5a7cb
url: "https://github.com/martinmoene/variant-lite/archive/v2.0.0.tar.gz"
sha256: "70c1509e24d03abfd22d2e702ab398238e69658b7b2890ce1d7e9731d6b5a7cb"
"1.2.2":
url: "https://github.com/martinmoene/variant-lite/archive/v1.2.2.tar.gz"
sha256: "97334108c3a92f7becc74e2798ab8e0ea57fd67d4ad893ec0b0b8e1c35bb411c"
18 changes: 12 additions & 6 deletions recipes/variant-lite/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import os
from conans import ConanFile, tools
import os

required_conan_version = ">=1.43.0"

required_conan_version = ">=1.28.0"

class VariantLiteConan(ConanFile):
name = "variant-lite"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/martinmoene/variant-lite"
description = "variant lite - A C++17-like variant, a type-safe union for C++98, C++11 and later in a single-file header-only library"
topics = ("conan", "cpp98", "cpp11", "cpp14", "cpp17", "variant", "variant-implementations")
topics = ("cpp98", "cpp11", "cpp14", "cpp17", "variant", "variant-implementations")
license = "BSL-1.0"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
Expand All @@ -20,18 +22,22 @@ def package_id(self):
self.info.header_only()

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def package(self):
self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include"))
self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder)

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "variant-lite")
self.cpp_info.set_property("cmake_target_name", "nonstd::variant-lite")

# TODO: to remove in conan v2 once cmake_find_package* generators removed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 If I followed the changes correctly...

The 7 lines below will be replaced with just two?! 🤯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

self.cpp_info.filenames["cmake_find_package"] = "variant-lite"
self.cpp_info.filenames["cmake_find_package_multi"] = "variant-lite"
self.cpp_info.names["cmake_find_package"] = "nonstd"
self.cpp_info.names["cmake_find_package_multi"] = "nonstd"
self.cpp_info.components["variantlite"].names["cmake_find_package"] = "variant-lite"
self.cpp_info.components["variantlite"].names["cmake_find_package_multi"] = "variant-lite"
self.cpp_info.components["variantlite"].set_property("cmake_target_name", "nonstd::variant-lite")
2 changes: 1 addition & 1 deletion recipes/variant-lite/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
conan_basic_setup(TARGETS)

find_package(variant-lite REQUIRED CONFIG)

Expand Down
6 changes: 3 additions & 3 deletions recipes/variant-lite/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
Expand All @@ -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)
4 changes: 2 additions & 2 deletions recipes/variant-lite/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
versions:
"1.2.2":
folder: all
"2.0.0":
folder: all
"1.2.2":
folder: all