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

p-ranav-glob: migrate to Conan v2 #18204

Merged
merged 3 commits into from
Jul 5, 2023
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
55 changes: 34 additions & 21 deletions recipes/p-ranav-glob/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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 = []
7 changes: 3 additions & 4 deletions recipes/p-ranav-glob/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
22 changes: 16 additions & 6 deletions recipes/p-ranav-glob/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
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)
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)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/p-ranav-glob/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/)
16 changes: 16 additions & 0 deletions recipes/p-ranav-glob/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile, CMake, tools
import os

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
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):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)