2020-06-12 14:13:23 +08:00
if ( EXISTS "${CURRENT_INSTALLED_DIR}/share/libpcap" )
message ( FATAL_ERROR "FATAL ERROR: libpcap and winpcap are incompatible." )
endif ( )
2018-10-24 07:00:17 +08:00
set ( WINPCAP_VERSION 4_1_3 )
2017-08-25 13:43:08 +08:00
vcpkg_download_distfile ( ARCHIVE
2018-10-24 07:00:17 +08:00
U R L S " h t t p s : / / w w w . w i n p c a p . o r g / i n s t a l l / b i n / W p c a p S r c _ $ { W I N P C A P _ V E R S I O N } . z i p "
F I L E N A M E " W p c a p S r c _ $ { W I N P C A P _ V E R S I O N } . z i p "
2017-08-25 23:55:26 +08:00
S H A 5 1 2 8 9 a 5 1 0 9 e d 1 7 f 8 0 6 9 f 7 a 4 3 4 9 7 f 6 f e c 8 1 7 c 5 8 6 2 0 d b c 5 f a 5 0 6 e 5 2 0 6 9 b 9 1 1 3 c 5 b c 1 3 f 6 9 c 3 0 7 a f f e 6 1 1 2 8 1 c b 7 2 7 c f a 0 f 8 5 2 9 d 0 7 0 4 4 d 4 1 4 2 7 e 3 5 0 b 2 4 4 6 8 c c c 8 9 a 8 7 f 3 3
2017-08-25 13:43:08 +08:00
)
2018-03-09 03:12:22 +08:00
# MSBuild performs in-source builds, so to ensure reliability we must clear them each time
file ( REMOVE_RECURSE ${ CURRENT_BUILDTREES_DIR } /src )
2017-08-28 00:03:32 +08:00
if ( VCPKG_CRT_LINKAGE STREQUAL "static" )
set ( CRT_LINKAGE "MT" )
elseif ( VCPKG_CRT_LINKAGE STREQUAL "dynamic" )
set ( CRT_LINKAGE "MD" )
endif ( )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
2018-10-24 07:00:17 +08:00
set ( LIBRARY_LINKAGE "4" )
2017-08-28 00:03:32 +08:00
elseif ( VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" )
2018-10-24 07:00:17 +08:00
set ( LIBRARY_LINKAGE "2" )
2017-08-28 00:03:32 +08:00
endif ( )
2018-10-24 07:00:17 +08:00
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/packetNtx.patch.in" "${CURRENT_BUILDTREES_DIR}/src/packetNtx.patch" @ONLY )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/wpcap.patch.in" "${CURRENT_BUILDTREES_DIR}/src/wpcap.patch" @ONLY )
2023-04-14 00:13:15 +08:00
vcpkg_extract_source_archive (
S O U R C E _ P A T H
2018-10-24 07:00:17 +08:00
A R C H I V E $ { A R C H I V E }
2023-04-14 00:13:15 +08:00
S O U R C E _ B A S E $ { W I N P C A P _ V E R S I O N }
2018-10-24 07:00:17 +08:00
P A T C H E S
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / s r c / p a c k e t N t x . p a t c h "
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / s r c / w p c a p . p a t c h "
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / c r e a t e _ l i b . p a t c h "
2019-02-28 15:50:52 +08:00
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / f i x - c r e a t e - l i b - b a t c h . p a t c h "
2017-08-25 23:55:26 +08:00
)
2021-11-16 08:46:48 +08:00
file ( COPY "${CURRENT_PORT_DIR}/create_bin.bat" DESTINATION "${SOURCE_PATH}" )
2017-08-25 23:55:26 +08:00
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" )
set ( PLATFORM Win32 )
elseif ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" )
set ( PLATFORM x64 )
endif ( )
vcpkg_execute_required_process (
C O M M A N D " d e v e n v . e x e "
" P a c k e t . s l n "
/ U p g r a d e
2021-11-16 08:46:48 +08:00
W O R K I N G _ D I R E C T O R Y " $ { S O U R C E _ P A T H } / p a c k e t N t x / D l l / P r o j e c t "
2017-08-25 23:55:26 +08:00
L O G N A M E u p g r a d e - P a c k e t - $ { T A R G E T _ T R I P L E T }
)
2019-02-28 15:50:52 +08:00
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" AND VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
2023-06-02 02:05:06 +08:00
configure_file ( "${CURRENT_PORT_DIR}/Packet.vcxproj.in" "${SOURCE_PATH}/packetNtx/Dll/Project/Packet.vcxproj" COPYONLY )
2019-02-28 15:50:52 +08:00
endif ( )
2017-08-25 23:55:26 +08:00
vcpkg_build_msbuild (
P R O J E C T _ P A T H " $ { S O U R C E _ P A T H } / p a c k e t N t x / D l l / P r o j e c t / P a c k e t . s l n "
2019-02-28 15:50:52 +08:00
R E L E A S E _ C O N F I G U R A T I O N " R e l e a s e "
D E B U G _ C O N F I G U R A T I O N " D e b u g "
2017-08-25 23:55:26 +08:00
P L A T F O R M $ { P L A T F O R M }
)
vcpkg_find_acquire_program ( BISON )
vcpkg_find_acquire_program ( FLEX )
vcpkg_execute_required_process (
C O M M A N D $ { S O U R C E _ P A T H } / w p c a p / P R J / b u i l d _ s c a n n e r _ p a r s e r . b a t
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H }
L O G N A M E b u i l d _ s c a n n e r _ p a r s e r - $ { T A R G E T _ T R I P L E T }
)
vcpkg_execute_required_process (
C O M M A N D " d e v e n v . e x e "
" w p c a p . s l n "
/ U p g r a d e
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H } / w p c a p / P R J
L O G N A M E u p g r a d e - w p c a p - $ { T A R G E T _ T R I P L E T }
)
2019-02-28 15:50:52 +08:00
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" AND VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
2023-06-02 02:05:06 +08:00
configure_file ( "${CURRENT_PORT_DIR}/wpcap.vcxproj.in" "${SOURCE_PATH}/wpcap/PRJ/wpcap.vcxproj" COPYONLY )
2019-02-28 15:50:52 +08:00
endif ( )
2017-08-25 23:55:26 +08:00
vcpkg_build_msbuild (
P R O J E C T _ P A T H " $ { S O U R C E _ P A T H } / w p c a p / P R J / w p c a p . s l n "
R E L E A S E _ C O N F I G U R A T I O N " R e l e a s e - N o A i r P c a p "
D E B U G _ C O N F I G U R A T I O N " D e b u g - N o A i r P c a p "
P L A T F O R M $ { P L A T F O R M }
)
vcpkg_execute_required_process (
C O M M A N D $ { S O U R C E _ P A T H } / c r e a t e _ i n c l u d e . b a t
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H }
L O G N A M E c r e a t e _ i n c l u d e - $ { T A R G E T _ T R I P L E T }
)
2020-07-31 13:45:15 +08:00
file ( INSTALL
2017-08-25 23:55:26 +08:00
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / b i t t y p e s . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / i p 6 _ m i s c . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / P a c k e t 3 2 . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p - b p f . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p - n a m e d b . h "
2017-09-22 22:57:54 +08:00
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p - s t d i n c . h "
2017-08-25 23:55:26 +08:00
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / r e m o t e - e x t . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / W i n 3 2 - E x t e n s i o n s . h "
2021-11-16 08:46:48 +08:00
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / i n c l u d e " )
2017-08-25 13:43:08 +08:00
2020-07-31 13:45:15 +08:00
file ( INSTALL
2017-08-25 23:55:26 +08:00
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p / b l u e t o o t h . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p / b p f . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p / n a m e d b . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p / p c a p . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p / s l l . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p / u s b . h "
" $ { S O U R C E _ P A T H } / W p d P a c k / I n c l u d e / p c a p / v l a n . h "
2021-11-16 08:46:48 +08:00
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / i n c l u d e / p c a p " )
2017-08-25 13:43:08 +08:00
2017-08-25 23:55:26 +08:00
vcpkg_execute_required_process (
C O M M A N D $ { S O U R C E _ P A T H } / c r e a t e _ l i b . b a t
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H }
L O G N A M E c r e a t e _ l i b - $ { T A R G E T _ T R I P L E T }
)
set ( PCAP_LIBRARY_PATH "${SOURCE_PATH}/WpdPack/Lib" )
2017-08-25 13:43:08 +08:00
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" )
set ( PCAP_LIBRARY_PATH "${PCAP_LIBRARY_PATH}/x64" )
endif ( )
2020-07-31 13:45:15 +08:00
file ( INSTALL
2017-08-25 13:43:08 +08:00
" $ { P C A P _ L I B R A R Y _ P A T H } / P a c k e t . l i b "
" $ { P C A P _ L I B R A R Y _ P A T H } / w p c a p . l i b "
2021-11-16 08:46:48 +08:00
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / l i b " )
2017-08-25 13:43:08 +08:00
2020-07-31 13:45:15 +08:00
file ( INSTALL
2019-02-28 15:50:52 +08:00
" $ { P C A P _ L I B R A R Y _ P A T H } / d e b u g / P a c k e t . l i b "
" $ { P C A P _ L I B R A R Y _ P A T H } / d e b u g / w p c a p . l i b "
2021-11-16 08:46:48 +08:00
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / d e b u g / l i b " )
2017-08-25 13:43:08 +08:00
2017-08-28 00:03:32 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" )
vcpkg_execute_required_process (
2021-11-16 08:46:48 +08:00
C O M M A N D " $ { S O U R C E _ P A T H } / c r e a t e _ b i n . b a t "
W O R K I N G _ D I R E C T O R Y " $ { S O U R C E _ P A T H } "
2017-08-28 00:03:32 +08:00
L O G N A M E c r e a t e _ b i n - $ { T A R G E T _ T R I P L E T }
)
set ( PCAP_BINARY_PATH "${SOURCE_PATH}/WpdPack/Bin" )
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" )
set ( PCAP_BINARY_PATH "${PCAP_BINARY_PATH}/x64" )
endif ( )
2020-07-31 13:45:15 +08:00
file ( INSTALL
2017-08-28 00:03:32 +08:00
" $ { P C A P _ B I N A R Y _ P A T H } / P a c k e t . d l l "
" $ { P C A P _ B I N A R Y _ P A T H } / w p c a p . d l l "
2021-11-16 08:46:48 +08:00
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / b i n " )
2017-08-28 00:03:32 +08:00
2020-07-31 13:45:15 +08:00
file ( INSTALL
2017-08-28 00:03:32 +08:00
" $ { P C A P _ B I N A R Y _ P A T H } / P a c k e t . d l l "
" $ { P C A P _ B I N A R Y _ P A T H } / w p c a p . d l l "
2021-11-16 08:46:48 +08:00
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / d e b u g / b i n " )
2017-08-25 23:55:26 +08:00
endif ( )
2021-11-16 08:46:48 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/include/pcap-stdinc.h" "#define inline __inline" "#ifndef __cplusplus\n#define inline __inline\n#endif" )
2020-07-31 13:45:15 +08:00
2023-06-02 02:05:06 +08:00
file ( WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "The latest license is available in https://www.winpcap.org/misc/copyright.htm and in the header files." )