mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-08-16 03:24:05 +00:00
(#11010) croncpp: add recipe
* croncpp: add recipe * remove build() Co-authored-by: Uilian Ries <uilianries@gmail.com> Co-authored-by: Uilian Ries <uilianries@gmail.com>
This commit is contained in:
9
recipes/croncpp/all/CMakeLists.txt
Normal file
9
recipes/croncpp/all/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(conan_wrapper CXX)
|
||||
|
||||
include(conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
add_subdirectory(source_subfolder)
|
4
recipes/croncpp/all/conandata.yml
Normal file
4
recipes/croncpp/all/conandata.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
sources:
|
||||
"cci.20220503":
|
||||
url: "https://github.com/mariusbancila/croncpp/archive/5c28f410db1af9507ef8469c9796a7070e5e8e2e.tar.gz"
|
||||
sha256: "cabc480c78ebf12b11bd9fcd705a7ecb1c85ac88a8c9debe8de67f30abd808a8"
|
45
recipes/croncpp/all/conanfile.py
Normal file
45
recipes/croncpp/all/conanfile.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import os
|
||||
import functools
|
||||
from conans import ConanFile, CMake, tools
|
||||
|
||||
required_conan_version = ">=1.33.0"
|
||||
|
||||
class CroncppConan(ConanFile):
|
||||
name = "croncpp"
|
||||
description = "A C++11/14/17 header-only cross-platform library for handling CRON expressions"
|
||||
topics = ("cron", "header-only")
|
||||
license = "MIT"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://github.com/mariusbancila/croncpp/"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake",
|
||||
|
||||
@property
|
||||
def _source_subfolder(self):
|
||||
return "source_subfolder"
|
||||
|
||||
def export_sources(self):
|
||||
self.copy("CMakeLists.txt")
|
||||
|
||||
def package_id(self):
|
||||
self.info.header_only()
|
||||
|
||||
def validate(self):
|
||||
if self.settings.compiler.get_safe("cppstd"):
|
||||
tools.check_min_cppstd(self, "11")
|
||||
|
||||
def source(self):
|
||||
tools.get(**self.conan_data["sources"][self.version],
|
||||
destination=self._source_subfolder, strip_root=True)
|
||||
|
||||
@functools.lru_cache(1)
|
||||
def _configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
return cmake
|
||||
|
||||
def package(self):
|
||||
self.copy("LICENSE*", "licenses", self._source_subfolder)
|
||||
cmake = self._configure_cmake()
|
||||
cmake.install()
|
||||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
|
11
recipes/croncpp/all/test_package/CMakeLists.txt
Normal file
11
recipes/croncpp/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(test_package CXX)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
find_package(croncpp REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
||||
target_link_libraries(${PROJECT_NAME} croncpp::croncpp)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
|
16
recipes/croncpp/all/test_package/conanfile.py
Normal file
16
recipes/croncpp/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
class CroncppConan(ConanFile):
|
||||
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):
|
||||
bin_path = os.path.join("bin", "test_package")
|
||||
self.run(bin_path, run_environment=True)
|
18
recipes/croncpp/all/test_package/test_package.cpp
Normal file
18
recipes/croncpp/all/test_package/test_package.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
#include "croncpp.h"
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
try {
|
||||
auto cron = cron::make_cron("* 0/5 * * * ?");
|
||||
|
||||
auto now = std::time(0);
|
||||
auto next = cron::cron_next(cron, now);
|
||||
std::cout << (next - now) << "[sec]" << std::endl;
|
||||
return 0;
|
||||
} catch (cron::bad_cronexpr const& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
3
recipes/croncpp/config.yml
Normal file
3
recipes/croncpp/config.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
versions:
|
||||
"cci.20220503":
|
||||
folder: "all"
|
Reference in New Issue
Block a user