Skip to content

Commit 1fdf980

Browse files
committed
Removed wepoll from the codebase. bump version to v1.0.6
1 parent 1a13805 commit 1fdf980

6 files changed

Lines changed: 130 additions & 2452 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# unreleased
22
- Removed shared build. There is no exports
3+
- Converted to truly header-only library (INTERFACE target on all platforms)
4+
- Added wepoll dependency via vcpkg on Windows with FetchContent fallback
5+
- Simplified CMake configuration to use single INTERFACE library
6+
- Automatic wepoll fetch and build if not found
37

48
#v1.0.5 - [02/04/2026]
59
- Add CMake package configuration support for find_package()

CMakeLists.txt

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,50 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
55
set(CMAKE_CXX_EXTENSIONS OFF)
66

77
project(slick-socket
8-
VERSION 1.0.5
8+
VERSION 1.0.6
99
LANGUAGES C CXX
1010
)
1111

12+
# Options
13+
option(BUILD_SLICK_SOCKET_EXAMPLES "Build tests" ON)
14+
option(BUILD_SLICK_SOCKET_TESTING "Build tests" ON)
15+
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
16+
17+
if(WIN32)
18+
# Find wepoll (vcpkg installation without CMake config)
19+
find_path(WEPOLL_INCLUDE_DIR wepoll.h)
20+
find_library(WEPOLL_LIBRARY NAMES wepoll)
21+
22+
if(WEPOLL_INCLUDE_DIR AND WEPOLL_LIBRARY)
23+
# Create an imported target for wepoll
24+
add_library(wepoll::wepoll STATIC IMPORTED)
25+
set_target_properties(wepoll::wepoll PROPERTIES
26+
IMPORTED_LOCATION "${WEPOLL_LIBRARY}"
27+
INTERFACE_INCLUDE_DIRECTORIES "${WEPOLL_INCLUDE_DIR}"
28+
)
29+
message(STATUS "wepoll: found at ${WEPOLL_LIBRARY}")
30+
else()
31+
# Fallback: Fetch wepoll from GitHub and build it
32+
message(STATUS "wepoll not found locally, fetching from GitHub...")
33+
include(FetchContent)
34+
FetchContent_Declare(
35+
wepoll
36+
GIT_REPOSITORY https://github.com/piscisaureus/wepoll.git
37+
GIT_TAG v1.5.8
38+
)
39+
FetchContent_MakeAvailable(wepoll)
40+
41+
# Build wepoll as a static library
42+
add_library(wepoll_lib STATIC ${wepoll_SOURCE_DIR}/wepoll.c)
43+
target_include_directories(wepoll_lib PUBLIC ${wepoll_SOURCE_DIR})
44+
45+
# Create the wepoll::wepoll target
46+
add_library(wepoll::wepoll ALIAS wepoll_lib)
47+
48+
message(STATUS "wepoll: fetched and built from GitHub")
49+
endif()
50+
endif()
51+
1252
# MSVC configuration
1353
if(MSVC)
1454
# Enable policy CMP0091 to allow CMAKE_MSVC_RUNTIME_LIBRARY to be controlled by toolchain/user
@@ -32,7 +72,6 @@ if (CMAKE_BUILD_TYPE MATCHES Release)
3272
add_definitions(-DNDEBUG)
3373
endif()
3474

35-
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
3675
if(ENABLE_ASAN)
3776
if(MSVC)
3877
# MSVC AddressSanitizer (requires Visual Studio 2022 17.7+)
@@ -60,43 +99,28 @@ if (MSVC)
6099
set(CMAKE_SUPPRESS_REGENERATION true) # supress zero_check project
61100
endif()
62101

102+
# Create header-only INTERFACE library
103+
add_library(slick-socket INTERFACE)
104+
add_library(slick::socket ALIAS slick-socket)
105+
106+
target_include_directories(slick-socket INTERFACE
107+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
108+
$<INSTALL_INTERFACE:include>
109+
)
110+
111+
# Platform-specific dependencies
63112
if(WIN32)
64-
add_library(slick-socket STATIC src/wepoll.c)
65-
add_library(slick::socket ALIAS slick-socket)
66-
# For backward compatibility
67-
add_library(slick_socket ALIAS slick-socket)
68-
add_library(slick::slick_socket ALIAS slick-socket)
69-
70-
set_target_properties(slick-socket PROPERTIES
71-
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
72-
)
73-
target_include_directories(slick-socket PUBLIC
74-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
75-
$<INSTALL_INTERFACE:include>
76-
)
77-
target_compile_definitions(slick-socket PUBLIC _WIN32_WINNT=0x0601)
78-
target_link_libraries(slick-socket PUBLIC ws2_32)
79-
elseif(UNIX)
80-
add_library(slick-socket INTERFACE)
81-
add_library(slick::socket ALIAS slick-socket)
82-
# For backward compatibility
83-
add_library(slick_socket ALIAS slick-socket)
84-
add_library(slick::slick_socket ALIAS slick-socket)
85-
target_include_directories(slick-socket INTERFACE
86-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
87-
$<INSTALL_INTERFACE:include>
88-
)
113+
target_compile_definitions(slick-socket INTERFACE _WIN32_WINNT=0x0601)
114+
target_link_libraries(slick-socket INTERFACE ws2_32 wepoll::wepoll)
89115
endif()
90116

91117
set_target_properties(slick-socket PROPERTIES EXPORT_NAME socket)
92118

93-
option(BUILD_SLICK_SOCKET_EXAMPLES "Build tests" ON)
94119
if (BUILD_SLICK_SOCKET_EXAMPLES)
95120
add_subdirectory(examples)
96121
endif()
97122

98123
# Tests
99-
option(BUILD_SLICK_SOCKET_TESTING "Build tests" ON)
100124
if(BUILD_SLICK_SOCKET_TESTING)
101125
enable_testing()
102126
add_subdirectory(tests)
@@ -105,21 +129,10 @@ endif()
105129
# Install headers
106130
install(DIRECTORY include/ DESTINATION include)
107131

108-
# Install library targets
109-
if (WIN32)
110-
install(TARGETS slick-socket
111-
EXPORT slick-socketTargets
112-
ARCHIVE DESTINATION lib
113-
LIBRARY DESTINATION lib
114-
RUNTIME DESTINATION bin
115-
)
116-
else()
117-
install(TARGETS slick-socket
118-
EXPORT slick-socketTargets
119-
ARCHIVE DESTINATION lib
120-
LIBRARY DESTINATION lib
121-
)
122-
endif()
132+
# Install library targets (header-only INTERFACE library)
133+
install(TARGETS slick-socket
134+
EXPORT slick-socketTargets
135+
)
123136

124137
# Install CMake package configuration files
125138
include(CMakePackageConfigHelpers)

README.md

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,68 @@ A header-only C++20 networking library providing cross-platform TCP and UDP mult
1010
## Features
1111

1212
- **Cross-platform**: Windows and Unix/Linux support
13-
- **Header-only**: No separate compilation required (Windows requires linking slick-socket.lib)
13+
- **Header-only**: No separate compilation required
1414
- **Modern C++**: C++20 design with CRTP for most components
1515
- **Asynchronous**: Non-blocking socket operations with timeout handling
1616
- **TCP Communication**: Client and server implementations
1717
- **UDP Multicast**: One-to-many communication support
1818
- **Logging**: Template-based logger interface with console output
1919

20+
## Dependencies
21+
22+
- **Windows**: Requires [wepoll](https://github.com/piscisaureus/wepoll) for epoll-like functionality
23+
- Automatically fetched via CMake FetchContent if not installed
24+
- Or install via vcpkg: `vcpkg install wepoll`
25+
- **Unix/Linux/macOS**: No external dependencies
26+
2027
## Installation
2128

22-
### Using FetchContent (Recommended)
29+
### Using vcpkg (Recommended for Windows users)
30+
31+
If you're using vcpkg, install wepoll first:
32+
33+
```bash
34+
vcpkg install wepoll
35+
```
36+
37+
Then use CMake with the vcpkg toolchain:
38+
39+
```bash
40+
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=[path-to-vcpkg]/scripts/buildsystems/vcpkg.cmake
41+
```
42+
43+
### Using FetchContent
2344

2445
The easiest way to use slick-socket is to fetch it directly in your CMakeLists.txt:
2546

2647
```cmake
2748
include(FetchContent)
2849
29-
# Uncomment the line below to disable static lib build on Windows
30-
# set(BUILD_SLICK_SOCKET_STATIC_LIBS OFF CACHE BOOL "" FORCE)
31-
32-
# Uncomment the line below to disable shared lib build on Windows
33-
# set(BUILD_SLICK_SOCKET_SHARED_LIBS OFF CACHE BOOL "" FORCE)
34-
35-
# Disable slick-socket example, and tests
50+
# Disable slick-socket examples and tests
3651
set(BUILD_SLICK_SOCKET_EXAMPLES OFF CACHE BOOL "" FORCE)
3752
set(BUILD_SLICK_SOCKET_TESTING OFF CACHE BOOL "" FORCE)
53+
3854
FetchContent_Declare(
3955
slick-socket
4056
GIT_REPOSITORY https://github.com/SlickQuant/slick-socket.git
41-
GIT_TAG v1.0.4 # Use the desired version
57+
GIT_TAG v1.0.6 # Use the desired version
4258
)
4359
4460
FetchContent_MakeAvailable(slick-socket)
4561
46-
# Link against slick-socket
47-
target_link_libraries(your_target PRIVATE slick-socket)
62+
# Link against slick-socket (automatically links ws2_32 and wepoll on Windows)
63+
target_link_libraries(your_target PRIVATE slick::socket)
4864
```
4965

50-
On Windows, you also need to link against `ws2_32`:
66+
**Note**: On Windows, if wepoll is not found, CMake will automatically fetch and build it from GitHub.
67+
68+
### Using find_package
69+
70+
If you have slick-socket installed, you can use it with `find_package`:
71+
5172
```cmake
52-
target_link_libraries(your_target PRIVATE slick-socket ws2_32)
73+
find_package(slick-socket REQUIRED)
74+
target_link_libraries(your_target PRIVATE slick::socket)
5375
```
5476

5577
### From Source
@@ -58,6 +80,7 @@ target_link_libraries(your_target PRIVATE slick-socket ws2_32)
5880

5981
- C++20 compatible compiler (GCC 11+, Clang 12+, MSVC 2022+)
6082
- CMake 3.25 or higher
83+
- **Windows only**: wepoll (automatically fetched if not found)
6184

6285
#### Unix/Linux/macOS
6386

@@ -80,37 +103,36 @@ target_link_libraries(your_target PRIVATE slick-socket ws2_32)
80103

81104
#### Windows (Visual Studio)
82105

83-
1. **Configure the build**:
106+
1. **(Optional) Install wepoll via vcpkg**:
107+
```bash
108+
vcpkg install wepoll
109+
```
110+
111+
2. **Configure the build**:
84112
```bash
113+
# With vcpkg
114+
cmake -S . -B build -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=[path-to-vcpkg]/scripts/buildsystems/vcpkg.cmake
115+
116+
# Without vcpkg (wepoll will be fetched automatically)
85117
cmake -S . -B build -G "Visual Studio 17 2022"
86118
```
87119

88-
2. **Build the library**:
120+
3. **Build the library**:
89121
```bash
90122
cmake --build build --config Release
91123
```
92124

93-
3. **Copy headers and library**:
125+
4. **Install (optional)**:
94126
```bash
95-
xcopy build\dist\include\slick <your-project>\include\slick /E
96-
xcopy build\dist\lib\slick-socket.lib <your-project>\lib\
127+
cmake --install build --prefix /path/to/install
97128
```
98129

99-
4. **Link in your CMakeLists.txt**:
130+
Then in your project:
100131
```cmake
101-
# Add the slick-socket include and lib directories
102-
target_include_directories(your_target PRIVATE path/to/slick/include)
103-
target_link_directories(your_target PRIVATE path/to/slick/lib)
104-
105-
# Link the libraries
106-
target_link_libraries(your_target PRIVATE slick-socket ws2_32)
132+
find_package(slick-socket REQUIRED)
133+
target_link_libraries(your_target PRIVATE slick::socket)
107134
```
108135

109-
**Or manually** in Visual Studio:
110-
- Add include path: `path/to/slick/include`
111-
- Add library path: `path/to/slick/lib`
112-
- Link with: `slick-socket.lib` and `ws2_32.lib`
113-
114136
## Usage
115137

116138
### Basic Example

cmake/slick-socketConfig.cmake.in

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,27 @@ include(CMakeFindDependencyMacro)
77

88
# Platform-specific dependencies
99
if(WIN32)
10-
# Windows requires Winsock2 library
11-
find_dependency(Threads)
10+
# Windows requires wepoll for epoll-like functionality
11+
# Check if wepoll::wepoll target already exists (from parent project)
12+
if(NOT TARGET wepoll::wepoll)
13+
# Find wepoll manually (vcpkg installations don't provide CMake config)
14+
find_path(WEPOLL_INCLUDE_DIR wepoll.h REQUIRED)
15+
find_library(WEPOLL_LIBRARY NAMES wepoll REQUIRED)
16+
17+
if(WEPOLL_INCLUDE_DIR AND WEPOLL_LIBRARY)
18+
# Create an imported target for wepoll
19+
add_library(wepoll::wepoll STATIC IMPORTED)
20+
set_target_properties(wepoll::wepoll PROPERTIES
21+
IMPORTED_LOCATION "${WEPOLL_LIBRARY}"
22+
INTERFACE_INCLUDE_DIRECTORIES "${WEPOLL_INCLUDE_DIR}"
23+
)
24+
endif()
25+
endif()
1226
endif()
1327

1428
# Include the targets file
1529
include("${CMAKE_CURRENT_LIST_DIR}/slick-socketTargets.cmake")
1630

17-
# Provide backward compatibility aliases
18-
if(NOT TARGET slick_socket)
19-
add_library(slick_socket ALIAS slick::socket)
20-
endif()
21-
22-
if(NOT TARGET slick::slick_socket)
23-
add_library(slick::slick_socket ALIAS slick::socket)
24-
endif()
25-
2631
# Set package variables
2732
set(slick-socket_VERSION @PROJECT_VERSION@)
2833
set(slick-socket_VERSION_MAJOR @PROJECT_VERSION_MAJOR@)

0 commit comments

Comments
 (0)