From e3e90509550cd26fe1200e5571362c18e1e360a4 Mon Sep 17 00:00:00 2001 From: Martin Miralles-Cordal Date: Tue, 10 Nov 2020 18:31:53 -0500 Subject: [PATCH] (#3405) add fire-hpp/0.2 * fire-hpp: added initial recipe, prerelease snapshot * fire-hpp: renamed copy of bsl so hook doesn't think it's for the recipe * fire-hpp: added c++11 check, switched test_package to use find_package() * fire-hpp: put CXX_STANDARD setting back into test_package/CMakeLists.txt * fire-hpp: removed copy of BSL, switched to extraction from header file. * fire-hpp: replaced prerelease with 0.2. (yay!) --- recipes/fire-hpp/all/conandata.yml | 4 ++ recipes/fire-hpp/all/conanfile.py | 43 +++++++++++++++++++ .../fire-hpp/all/test_package/CMakeLists.txt | 11 +++++ .../fire-hpp/all/test_package/conanfile.py | 18 ++++++++ .../all/test_package/test_package.cpp | 9 ++++ recipes/fire-hpp/config.yml | 3 ++ 6 files changed, 88 insertions(+) create mode 100644 recipes/fire-hpp/all/conandata.yml create mode 100644 recipes/fire-hpp/all/conanfile.py create mode 100644 recipes/fire-hpp/all/test_package/CMakeLists.txt create mode 100644 recipes/fire-hpp/all/test_package/conanfile.py create mode 100644 recipes/fire-hpp/all/test_package/test_package.cpp create mode 100644 recipes/fire-hpp/config.yml diff --git a/recipes/fire-hpp/all/conandata.yml b/recipes/fire-hpp/all/conandata.yml new file mode 100644 index 0000000000000..0ac5acb1e3d98 --- /dev/null +++ b/recipes/fire-hpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.2": + sha256: 50ac76005e5d45590355a51e5e1b62aba65c56f2003335acce0370da13d77b28 + url: https://github.com/kongaskristjan/fire-hpp/archive/v0.2.tar.gz diff --git a/recipes/fire-hpp/all/conanfile.py b/recipes/fire-hpp/all/conanfile.py new file mode 100644 index 0000000000000..e2770d10a2f50 --- /dev/null +++ b/recipes/fire-hpp/all/conanfile.py @@ -0,0 +1,43 @@ +from conans import ConanFile, CMake, tools +import os + +class FireHppConan(ConanFile): + name = "fire-hpp" + homepage = "https://github.com/kongaskristjan/fire-hpp" + url = "https://github.com/conan-io/conan-center-index" + description = "Fire for C++: Create fully functional CLIs using function signatures" + topics = ("command-line", "argument", "parser") + license = "BSL-1.0" + no_copy_source = True + settings = "os", "arch", "compiler", "build_type" + + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + _cmake = None + + def configure(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = "{}-{}".format(self.name, self.version) + os.rename(extracted_dir, self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["FIRE_EXAMPLES"] = False + self._cmake.definitions["FIRE_UNIT_TESTS"] = False + self._cmake.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) + return self._cmake + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENCE", dst="licenses", src=self._source_subfolder) + tools.rmdir(os.path.join(self.package_folder, "lib")) + + def package_id(self): + self.info.header_only() diff --git a/recipes/fire-hpp/all/test_package/CMakeLists.txt b/recipes/fire-hpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..520f51ea73d4a --- /dev/null +++ b/recipes/fire-hpp/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(fire-hpp REQUIRED) + +add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE fire-hpp::fire-hpp) +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/fire-hpp/all/test_package/conanfile.py b/recipes/fire-hpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b6680c7d91280 --- /dev/null +++ b/recipes/fire-hpp/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + 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") + bin_args = "-x=1 -y=2" + self.run("{} {}".format(bin_path, bin_args), run_environment=True) diff --git a/recipes/fire-hpp/all/test_package/test_package.cpp b/recipes/fire-hpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..614e5b1984d23 --- /dev/null +++ b/recipes/fire-hpp/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include +#include + +int fired_main(int x = fire::arg("-x"), int y = fire::arg("-y")) { + std::cout << x + y << std::endl; + return 0; +} + +FIRE(fired_main) diff --git a/recipes/fire-hpp/config.yml b/recipes/fire-hpp/config.yml new file mode 100644 index 0000000000000..7e65100e62b2c --- /dev/null +++ b/recipes/fire-hpp/config.yml @@ -0,0 +1,3 @@ +versions: + "0.2": + folder: all