-
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.
* add recipe stub * add names to generators * enable cxx 11 by default * Update recipes/libtins/all/CMakeLists.txt Co-authored-by: Ayaz Salikhov <[email protected]> * Update recipes/libtins/all/test_package/test_package.cpp Co-authored-by: Ayaz Salikhov <[email protected]> * add other options from readme and fix suggesstions * fix build * remove invalid condition * remove with_cxx11 option * Use multi generator to avoid link errors * restore cmake_find_package generator * Update recipes/libtins/all/conanfile.py Co-authored-by: SpaceIm <[email protected]> * Replace OPENSSL with OpenSSL to fix linking issues * Update recipes/libtins/all/conanfile.py Co-authored-by: SpaceIm <[email protected]> * Update recipes/libtins/all/conanfile.py Co-authored-by: SpaceIm <[email protected]> * Update recipes/libtins/all/conanfile.py Co-authored-by: SpaceIm <[email protected]> * remove needless generator Co-authored-by: Ayaz Salikhov <[email protected]> Co-authored-by: SpaceIm <[email protected]>
- Loading branch information
1 parent
30b5395
commit fd9c699
Showing
7 changed files
with
151 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,7 @@ | ||
cmake_minimum_required(VERSION 2.8.1) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory("source_subfolder") |
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: | ||
"4.2": | ||
sha256: a9fed73e13f06b06a4857d342bb30815fa8c359d00bd69547e567eecbbb4c3a1 | ||
url: https://github.com/mfontanini/libtins/archive/v4.2.tar.gz |
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,102 @@ | ||
from conans import tools, CMake, ConanFile | ||
import os | ||
|
||
|
||
class LibTinsConan(ConanFile): | ||
name = "libtins" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/mfontanini/libtins" | ||
description = "High-level, multiplatform C++ network packet sniffing and crafting library." | ||
license = "BSD-2-Clause" | ||
topics = ("pcap", "packets", "network", "packet-analyser", "packet-parsing", "libpcap", "sniffing") | ||
exports_sources = ["CMakeLists.txt"] | ||
generators = "cmake", "cmake_find_package" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_ack_tracker": [True, False], | ||
"with_wpa2": [True, False], | ||
"with_dot11": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_ack_tracker": True, | ||
"with_wpa2": True, | ||
"with_dot11": True, | ||
} | ||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_subfolder" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def requirements(self): | ||
self.requires("libpcap/1.10.0") | ||
if self.options.with_ack_tracker: | ||
self.requires("boost/1.75.0") | ||
if self.options.with_wpa2: | ||
self.requires("openssl/1.1.1i") | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_dir = self.name + "-" + self.version | ||
os.rename(extracted_dir, self._source_subfolder) | ||
|
||
def _patch_sources(self): | ||
# Workaround for casing issues in cmake_find_package generator of openssl recipe | ||
top_cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") | ||
src_cmakelists = os.path.join(self._source_subfolder, "src", "CMakeLists.txt") | ||
tools.replace_in_file(top_cmakelists, "OPENSSL_FOUND", "OpenSSL_FOUND") | ||
tools.replace_in_file(src_cmakelists, "OPENSSL_INCLUDE_DIR", "OpenSSL_INCLUDE_DIR") | ||
tools.replace_in_file(src_cmakelists, "OPENSSL_LIBRARIES", "OpenSSL_LIBRARIES") | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
self._cmake.definitions["LIBTINS_BUILD_EXAMPLES"] = False | ||
self._cmake.definitions["LIBTINS_BUILD_TESTS"] = False | ||
|
||
self._cmake.definitions["LIBTINS_BUILD_SHARED"] = self.options.shared | ||
self._cmake.definitions["LIBTINS_ENABLE_CXX11"] = tools.valid_min_cppstd(self, 11) | ||
self._cmake.definitions["LIBTINS_ENABLE_ACK_TRACKER"] = self.options.with_ack_tracker | ||
self._cmake.definitions["LIBTINS_ENABLE_WPA2"] = self.options.with_wpa2 | ||
self._cmake.definitions["LIBTINS_ENABLE_DOT11"] = self.options.with_dot11 | ||
|
||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def build(self): | ||
self._patch_sources() | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy(os.path.join(self._source_subfolder, "LICENSE"), dst="licenses") | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
|
||
def package_info(self): | ||
# FIXME: official CMake imported target is not namespaced | ||
self.cpp_info.names["cmake_find_package"] = "libtins" | ||
self.cpp_info.names["cmake_find_package_multi"] = "libtins" | ||
self.cpp_info.names["pkg_config"] = "libtins" | ||
self.cpp_info.libs = tools.collect_libs(self) | ||
if self.settings.os == "Windows" and not self.options.shared: | ||
self.cpp_info.defines.append("TINS_STATIC") |
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.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(test_package test_package.cpp) | ||
target_link_libraries(test_package ${CONAN_LIBS}) |
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,17 @@ | ||
from conans import tools, ConanFile, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
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) |
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,10 @@ | ||
#include <tins/tins.h> | ||
|
||
using namespace Tins; | ||
|
||
int main() { | ||
SnifferConfiguration config; | ||
config.set_filter("port 80"); | ||
config.set_promisc_mode(true); | ||
config.set_snap_len(400); | ||
} |
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: | ||
"4.2": | ||
folder: all |