Skip to content

Commit 1475b49

Browse files
author
deadlightreal
committed
changed cmake version
1 parent d0a0fcf commit 1475b49

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

build/cmake/deadlightreal-swiftnetConfigVersion.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
88
# The variable CVF_VERSION must be set before calling configure_file().
99

10-
set(PACKAGE_VERSION "0.1.0")
10+
set(PACKAGE_VERSION "0.2.0")
1111

1212
if (PACKAGE_FIND_VERSION_RANGE)
1313
# Package version must be in the requested version range

src/CMakeLists.txt

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,41 @@ endif()
4949

5050
add_library(swiftnet STATIC ${SOURCE_FILES})
5151
target_compile_options(swiftnet PRIVATE -O0)
52-
target_link_options(swiftnet PRIVATE -lpcap -O0)
52+
target_link_options(swiftnet PRIVATE -O0)
53+
54+
find_path(PCAP_INCLUDE_DIR
55+
NAMES pcap.h
56+
PATHS
57+
$ENV{VCPKG_ROOT}/installed
58+
/usr/include
59+
/usr/local/include
60+
/opt/homebrew/include
61+
/usr/include
62+
)
63+
64+
# Find libpcap library
65+
find_library(PCAP_LIBRARY
66+
NAMES pcap libpcap
67+
PATHS
68+
$ENV{VCPKG_ROOT}/installed
69+
/usr/lib
70+
/usr/local/lib
71+
/opt/homebrew/lib
72+
/usr/lib
73+
)
74+
75+
include(FindPackageHandleStandardArgs)
76+
find_package_handle_standard_args(Pcap DEFAULT_MSG PCAP_LIBRARY PCAP_INCLUDE_DIR)
77+
78+
if(PCAP_FOUND)
79+
message(STATUS "Found libpcap: ${PCAP_LIBRARY} (includes: ${PCAP_INCLUDE_DIR})")
80+
include_directories(${PCAP_INCLUDE_DIR})
81+
else()
82+
message(FATAL_ERROR "libpcap not found! Please install libpcap or set PCAP_INCLUDE_DIR/PCAP_LIBRARY")
83+
endif()
84+
85+
target_include_directories(swiftnet PUBLIC ${PCAP_INCLUDE_DIR})
86+
target_link_libraries(swiftnet PUBLIC ${PCAP_LIBRARY})
5387

5488
set_target_properties(swiftnet PROPERTIES
5589
OUTPUT_NAME "swiftnet"
@@ -90,7 +124,7 @@ configure_package_config_file(
90124

91125
write_basic_package_version_file(
92126
${CMAKE_CURRENT_BINARY_DIR}/cmake/deadlightreal-swiftnetConfigVersion.cmake
93-
VERSION 0.1.0
127+
VERSION 0.2.0
94128
COMPATIBILITY AnyNewerVersion
95129
)
96130

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ file(GLOB SRC_FILES "${CMAKE_SOURCE_DIR}/src/*.c")
2727

2828
add_executable(run_tests ${SRC_FILES})
2929

30-
target_link_libraries(run_tests swiftnet pcap)
31-
target_link_options(run_tests PRIVATE -g -O0)
30+
target_link_libraries(run_tests PRIVATE swiftnet)
31+
target_link_options(run_tests PRIVATE -g -O0 -lpcap)
3232

3333
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

0 commit comments

Comments
 (0)