-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
cli: new recipe #22673
Merged
Merged
cli: new recipe #22673
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
67e1b31
cli: new recipe
rob-baily b8082df
Ensure files have final endline
rob-baily 77fab22
cli: new recipe
rob-baily 9c5ea58
Ensure files have final endline
rob-baily 2218d6a
Merge branch 'master' of https://github.com/Xcelerator-Group/conan-ce…
rob-baily 7480eab
Remove share folder for package
rob-baily 2478cca
Updated checks for minimum cpp and compiler versions
rob-baily 8a52695
Add import for ConanInvalidConfiguration
rob-baily ff5f8a4
Try Apple clang minimum version 12
rob-baily 8efe249
Try apple-clang compatibility at version 14
rob-baily df2fb5a
Apply suggestions from code review
rob-baily d32684c
Set CMake generated names to lower case
rob-baily 75e8908
add option for boost and asio
uilianries 784e225
Add test_package example using the with_asio option
rob-baily d06fa42
Fix newline at end of file
rob-baily 9e5cb2c
Fix last line for example_complete.cpp
rob-baily 3a7956f
simplify recipe
uilianries File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"2.1.0": | ||
url: "https://github.com/daniele77/cli/archive/refs/tags/v2.1.0.tar.gz" | ||
sha256: "dfc9fc7c72a6cdfdf852d89f151699b57460ff49775a8ff27d2a69477649acf9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.files import get, copy | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
class CLIConan(ConanFile): | ||
name = "cli" | ||
description = "A library for interactive command line interfaces in modern C++" | ||
license = "BSL-1.0" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/daniele77/cli" | ||
topics = "cli-interface", "cpp14", "no-dependencies", "header-only" | ||
package_type = "header-library" | ||
settings = "os", "compiler", "build_type", "arch" | ||
no_copy_source = True | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 14 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "7", | ||
"clang": "6", | ||
"Visual Studio": "16", | ||
"msvc": "192", | ||
"apple-clang": "14", | ||
} | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def package_id(self): | ||
self.info.clear() | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def build(self): | ||
pass | ||
|
||
def package(self): | ||
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
copy(self, "*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) | ||
|
||
def package_info(self): | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("pthread") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package CXX) | ||
|
||
find_package(cli CONFIG REQUIRED) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} cli::cli) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain | ||
from conan.tools.build import can_run | ||
|
||
class cliTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeDeps" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def test(self): | ||
if can_run(self): | ||
cmd = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(cmd, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <cli/cli.h> | ||
#include <cli/clifilesession.h> | ||
|
||
using namespace cli; | ||
using namespace std; | ||
|
||
|
||
int main() | ||
{ | ||
auto rootMenu = make_unique< Menu >( "cli" ); | ||
rootMenu -> Insert( | ||
"hello", | ||
[](std::ostream& out){ out << "Hello, world\n"; }, | ||
"Print hello world" ); | ||
|
||
Cli cli( std::move(rootMenu) ); | ||
cli.ExitAction( [](auto& out){ out << "Goodbye and thanks for all the fish.\n"; } ); | ||
|
||
CliFileSession input(cli); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"2.1.0": | ||
folder: all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's stick with this. It only affects Conan v1 which are on our way to deprecate from CCI, so I don't want to spend much energy on it :)