-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tcpcat 1.0.0 publish * fix linter errors * Simplify recipe and test_package * updated ASIO dependency usage and upstream version number * CI test error fix * updated upstream version to 1.0.2 * added CMakeDeps for find_package to work properly * updated for tcpcat 1.0.3 * updated topics and asio requirement version * updated upstream to 1.0.4 with fixes * updated package folder name * Ensure CXX is valid in Conan 1 * reorder * Update recipes/ydcpp-tcpcat/all/test_package/CMakeLists.txt Co-authored-by: Uilian Ries <uilianries@gmail.com> * Disable msvc shared builds for now until upstream exports some symbols * Add missing m system lib * Simplify --------- Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> Co-authored-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
b68a781
commit eb5a081
Showing
6 changed files
with
147 additions
and
0 deletions.
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: | ||
"1.0.4": | ||
url: "https://github.com/ydcpp/tcpcat/archive/refs/tags/1.0.4.tar.gz" | ||
sha256: "3413e74eab0a1bf7927b747e393b1931e8a516ee769642ce89c558a93e00e38b" |
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,95 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout | ||
from conan.tools.microsoft import is_msvc | ||
from conan.tools.files import copy, get | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
|
||
class TcpcatConan(ConanFile): | ||
name = "ydcpp-tcpcat" | ||
|
||
# Optional metadata | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/ydcpp/tcpcat" | ||
description = "Simple C++ TCP Server and Client library." | ||
topics = ("network", "tcp", "tcp-server", "tcp-client") | ||
|
||
# Binary configuration | ||
package_type = "library" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "7", | ||
"Visual Studio": "16", | ||
"msvc": "192", | ||
"clang": "7", | ||
"apple-clang": "12" | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
self.options.rm_safe("fPIC") | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
# Upstream meant to support Windows Shared builds, but they don't currently export any symbols | ||
# Disable for now until fixed. As this is an upstream issue they want fixed, we don't set | ||
# package_type = "static-library" in the configure() method so that users have a clear message error for now | ||
if is_msvc(self) and self.options.shared: | ||
raise ConanInvalidConfiguration(f"{self.ref} does not currently support Windows shared builds due to an upstream issue") | ||
|
||
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 requirements(self): | ||
self.requires("asio/1.30.2", transitive_headers = True) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) | ||
copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["ydcpp-tcpcat"] | ||
self.cpp_info.set_property("cmake_target_name", "ydcpp-tcpcat") | ||
if self.settings.os in ("Linux", "FreeBSD"): | ||
self.cpp_info.system_libs.append("m") |
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(PackageTest CXX) | ||
|
||
add_executable(test_package test_package.cpp) | ||
|
||
find_package(ydcpp-tcpcat CONFIG REQUIRED) | ||
target_link_libraries(test_package ydcpp-tcpcat) | ||
target_compile_features(test_package PRIVATE cxx_std_17) |
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,26 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, cmake_layout | ||
from conan.tools.build import can_run | ||
|
||
|
||
class tcpcatTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeDeps", "CMakeToolchain" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
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,11 @@ | ||
#include <tcpcat/tcpcat.h> | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
int main() | ||
{ | ||
tcpcat::TcpSession session(nullptr, nullptr, 0); | ||
std::cout << "session id: " << session.GetId() << std::endl; | ||
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: | ||
"1.0.4": | ||
folder: all |