Skip to content

Commit

Permalink
prepare for cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
xakod committed May 8, 2023
1 parent 9c5dd33 commit 046cd85
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 57 deletions.
4 changes: 2 additions & 2 deletions recipes/libdnet/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"1.16.4":
url: "https://github.com/ofalk/libdnet/archive/refs/tags/libdnet-1.16.4.tar.gz"
sha256: "7df1f0a3db9cf03b48cf50ab273fd6a20c1be99eb9344b9663fe3fd9ed9dab65"
url: "https://github.com/Jihadist/libdnet/archive/19c7040bc92ddf04139a6b566d811d8cd9c3d736.tar.gz"
sha256: "f3dd8f65dfb6ac4249e4160cf46063e422ff7e83638188832b5313c73301fda3"
62 changes: 16 additions & 46 deletions recipes/libdnet/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.env import VirtualBuildEnv
from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps
from conan.tools.microsoft import is_msvc
from conan.tools.layout import basic_layout
from conan.tools.files import copy, get, rmdir
import os


required_conan_version = ">=1.54.0"
required_conan_version = ">=1.56.0"


class LibDNetConan(ConanFile):
name = "libdnet"
class dnetConan(ConanFile):
name = "dnet"
description = "Provides a simplified, portable interface to several low-level networking routines."
homepage = "https://github.com/ofalk/libdnet"
topics = ("libdnet", "libdumbnet")
topics = ("dnet", "libdnet", "libdumbnet")
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
options = {
Expand All @@ -30,10 +24,6 @@ class LibDNetConan(ConanFile):
}
settings = "os", "arch", "compiler", "build_type"

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)


def layout(self):
cmake_layout(self, src_folder="src")
Expand All @@ -47,27 +37,9 @@ def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def validate(self):
if is_msvc(self):
raise ConanInvalidConfiguration("libdnet has not supported Visual Studio yet")
# windows build requires winpcap (looks like we can use npcap)


def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

# def requirements(self):
# self.requires("libcheck/0.15.2")

# def build_requirements(self):
# if not self.conf.get("tools.gnu:pkg_config", check_type=str):
# self.tool_requires("pkgconf/1.9.3")
# self.tool_requires("libtool/2.4.7")
# if self._settings_build.os == "Windows":
# self.win_bash = True
# if not self.conf.get("tools.microsoft.bash:path", check_type=str):
# self.tool_requires("msys2/cci.latest")

def generate(self):
tc = CMakeToolchain(self)

Expand All @@ -83,18 +55,16 @@ def build(self):

def package(self):
copy(self,"COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
autotools.install()

copy(self, "config.h", src=os.path.join(self.build_folder, "include"), dst=os.path.join(self.package_folder, "include"))

rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
fix_apple_shared_install_name(self)

def package_id(self):
del self.info.options.default
cmake = CMake(self)
cmake.configure()
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.components["dnet"].libs = ["dnet"]
self.cpp_info.components["dnet"].names["pkg_config"] = "libdnet"
self.cpp_info.libs.append("dnet")
self.cpp_info.includedirs = ["include"]

self.cpp_info.includedirs.extend(["include/dnet"])

if self.settings.os == 'Windows':
self.cpp_info.system_libs = ['Iphlpapi', 'wsock32']
4 changes: 2 additions & 2 deletions recipes/libdnet/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

find_package(libdnet REQUIRED CONFIG)
find_package(dnet REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE libdnet::libdnet)
target_link_libraries(${PROJECT_NAME} PRIVATE dnet::dnet)
11 changes: 4 additions & 7 deletions recipes/libdnet/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#include <config.h>
#include <dnet/dnet.h>
#include <dnet/config.h>
#include <dnet/err.h>

#include <sys/types.h>

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <dnet.h>

void addr_usage(void)
{
Expand All @@ -29,7 +26,7 @@ int main(int argc, char *argv[])

len = addr.addr_bits / 8;

if (write(STDOUT_FILENO, addr.addr_data8, len) != len)
if (write(1, addr.addr_data8, len) != len)
err(1, "write");
}
return 0;
Expand Down

0 comments on commit 046cd85

Please sign in to comment.