Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 2 additions & 81 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cmake_minimum_required(VERSION 3.28)
project(netkit LANGUAGES C CXX)
project(netkit LANGUAGES CXX)

option(NETKIT_ENABLE_WOLFSSL "Enable WolfSSL support in netkit" ON)
option(NETKIT_ENABLE_TESTS "Enable building tests" OFF)
option(NETKIT_ENABLE_C_BINDINGS "Enable experimental C bindings for netkit" OFF)
option(NETKIT_ENABLE_C_TESTS "Enable C building tests" OFF)
option(NETKIT_ENABLE_WINDOWS_CERTSTORE "Enable getting CA certificates from the Windows store" ON)
option(NETKIT_ENABLE_FALLBACK_CA "Enable fallback CA certficate (required for DevkitPro)" ON)
option(NETKIT_ENABLE_SOCK_CUSTOM_RESOLVER "Enable using netkit's DNS resolver instead of the system resolver" OFF)
Expand Down Expand Up @@ -304,83 +302,6 @@ if (NETKIT_ENABLE_TESTS)
catch_discover_tests(netkit-tests)
endif()

if (NETKIT_ENABLE_C_BINDINGS)
message(STATUS "C bindings enabled")
add_library(netkit-c ${NETKIT_LIB_TYPE}
src/c/sock/addr.cpp
src/c/sock/sync_sock.cpp
src/c/sock/ssl_sync_sock.cpp
src/c/network/utility.cpp
)

set_target_properties(netkit-c PROPERTIES
EXPORT_NAME netkit-c
POSITION_INDEPENDENT_CODE ON
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
VERSION 0.1.0
SOVERSION 1
)

if (NETKIT_BUILD_SHARED)
target_compile_definitions(netkit-c PUBLIC NETKIT_C_SHARED)
endif()

if (WIN32 AND NETKIT_BUILD_SHARED)
target_compile_definitions(netkit-c
PRIVATE NETKIT_C_BUILD_DLL
)
endif()

target_link_libraries(netkit-c
PUBLIC netkit
)

target_include_directories(netkit-c
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/netkit-c/
DESTINATION include/netkit-c
FILES_MATCHING
PATTERN "*.h"
)

install(TARGETS netkit-c
EXPORT netkitTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

if (NETKIT_ENABLE_C_TESTS)
message(STATUS "C API tests enabled")

add_executable(netkit-c-tests
tests/c/test_sock_addr.c
tests/c/test_network_utility.c
tests/c/test_main.c
)

add_dependencies(netkit-c-tests
netkit
netkit-c
)

target_link_libraries(netkit-c-tests
PRIVATE netkit netkit-c
)

add_test(NAME netkit-c-tests COMMAND netkit-c-tests)
else()
message(STATUS "C API tests disabled")
endif()
else()
message(STATUS "C bindings disabled")
endif()

if (NETKIT_BUILD_EXAMPLES)
add_subdirectory(examples/cpp)
add_subdirectory(examples)
endif()
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ The other alternative is to use the latest release, which doesn't have a changin

## Features

- OS-independent socket abstractions, both synchronous and asynchronous
- Higher-level socket abstractions
- OS-independent socket abstractions, both synchronous and asynchronous using C++20 coroutines
- Higher-level socket abstractions, including TCP, UDP and UDS
- HTTP/1.0 and HTTP/1.1 body parser, including headers and body.
- IPv4 and IPv6 support
- TCP and UDP support
Expand All @@ -24,18 +24,11 @@ The other alternative is to use the latest release, which doesn't have a changin
- Network interface enumeration
- Exceptions for errors
- Inheritable classes for easy extension
- Designed for C++23, with optional C bindings for use in non-C++ projects and interoperability with other programming languages entirely
- Designed for C++23
- Support for Windows, Linux, macOS and other Unix-compatible systems.
- Support for DevkitPro (Wii and GameCube)
- Permissive MIT license, allowing use in both open source and proprietary software.

Still missing:

- Asynchronous I/O for non-Linux platforms
- Threaded fallback is available
- Schannel support for Windows (waste of time I reckon)
- WebSocket abstraction

## Dependencies

- WolfSSL (optional)
Expand All @@ -48,8 +41,6 @@ netkit's CMakeLists.txt offers multiple options:

- NETKIT_ENABLE_WOLFSSL: Enable WolfSSL-backed SSL/TLS
- NETKIT_ENABLE_TESTS: Enable Catch2 tests for the main C++ library
- NETKIT_ENABLE_C_BINDINGS: Enable C bindings for netkit
- NETKIT_ENABLE_C_TESTS: Enable tests for netkit C bindings
- NETKIT_ENABLE_WINDOWS_CERTSTORE: Enable getting CA certificates from the Windows store
- NETKIT_ENABLE_FALLBACK_CA: Enable fallback hardcoded CA certificate (required for DevkitPro with TLS enabled)
- NETKIT_WOLFSSL_DEBUG: Enable debugging for WolfSSL and netkit WolfSSL functions
Expand All @@ -59,7 +50,7 @@ netkit's CMakeLists.txt offers multiple options:

```bash
mkdir -p build/; cd build/
cmake .. -DCMAKE_BUILD_TYPE=Release # if using devkitpro, -DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO}/cmake/Wii.cmake
cmake .. -DCMAKE_BUILD_TYPE=Release # if using devkitpro, -DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO:-/opt/devkitpro}/cmake/Wii.cmake
cmake --build .
cmake --install .
```
Expand All @@ -84,9 +75,7 @@ target_link_libraries(netkit-example PRIVATE
...
```

If you wish to use the C bindings, link with `netkit::netkit-c` instead.

See `examples/c/` and `examples/cpp/` for further examples of how to use the library.
See `examples/` for further examples of how to use the library.

Netkit can also be statically linked, and for users of DevkitPro it will be automatically.

Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/CMakeLists.txt → examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file(GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
file(GLOB children RELATIVE cpp *)
foreach(child ${children})
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${child})
add_subdirectory(${child})
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 0 additions & 15 deletions examples/c/socket/CMakeLists.txt

This file was deleted.

67 changes: 0 additions & 67 deletions examples/c/socket/main.c

This file was deleted.

22 changes: 0 additions & 22 deletions examples/c/socket_ssl/CMakeLists.txt

This file was deleted.

108 changes: 0 additions & 108 deletions examples/c/socket_ssl/main.c

This file was deleted.

1 change: 0 additions & 1 deletion examples/cpp/socket_server/.gitignore

This file was deleted.

Loading
Loading