@ -4,10 +4,7 @@
# M I N I U P N P _ F O U N D , i f f a l s e , d o n o t t r y t o l i n k t o m i n i u p n p
# M I N I U P N P _ L I B R A R Y , t h e m i n i u p n p v a r i a n t
# M I N I U P N P _ I N C L U D E _ D I R , w h e r e t o f i n d m i n i u p n p c . h a n d f a m i l y )
# M I N I U P N P C _ V E R S I O N _ P R E 1 _ 6 - - > s e t i f w e d e t e c t t h e v e r s i o n o f m i n i u p n p c i s
# p r e 1 . 6
# M I N I U P N P C _ V E R S I O N _ P R E 1 _ 5 - - > s e t i f w e d e t e c t t h e v e r s i o n o f m i n i u p n p c i s
# p r e 1 . 5
# M I N I U P N P C _ V E R S I O N _ 1 _ 7 _ O R _ H I G H E R , s e t i f w e d e t e c t t h e v e r s i o n o f m i n i u p n p c i s 1 . 7 o r h i g h e r
#
# N o t e t h a t t h e e x p e c t e d i n c l u d e c o n v e n t i o n i s
# # i n c l u d e " m i n i u p n p c . h "
@ -16,170 +13,47 @@
# T h i s i s b e c a u s e , t h e m i n i u p n p c l o c a t i o n i s n o t s t a n d a r d i z e d a n d m a y e x i s t
# i n l o c a t i o n s o t h e r t h a n m i n i u p n p c /
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# C o p y r i g h t 2 0 1 1 M a r k V e j v o d a
#
# D i s t r i b u t e d u n d e r t h e O S I - a p p r o v e d B S D License ( the "License" ) ;
# s e e a c c o m p a n y i n g f i l e C o p y r i g h t . t x t f o r d e t a i l s .
#
# T h i s s o f t w a r e i s d i s t r i b u t e d W I T H O U T A N Y W A R R A N T Y ; w i t h o u t e v e n t h e
# i m p l i e d w a r r a n t y o f M E R C H A N T A B I L I T Y o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E .
# S e e t h e L i c e n s e f o r m o r e i n f o r m a t i o n .
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# ( T o d i s t r i b u t e d t h i s f i l e o u t s i d e o f C M a k e , s u b s t i t u t e t h e f u l l
# L i c e n s e t e x t f o r t h e a b o v e r e f e r e n c e . )
if ( MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY )
# A l r e a d y i n c a c h e , b e s i l e n t
set ( MINIUPNP_FIND_QUIETLY TRUE )
endif ( )
find_path ( MINIUPNP_INCLUDE_DIR miniupnpc.h
P A T H _ S U F F I X E S m i n i u p n p c )
find_library ( MINIUPNP_LIBRARY miniupnpc )
if ( MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY )
set ( MINIUPNP_FOUND TRUE )
endif ( )
if ( MINIUPNP_FOUND )
include ( CheckCXXSourceRuns )
if ( NOT MINIUPNP_FIND_QUIETLY )
message ( STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}" )
message ( STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}" )
endif ( )
message ( STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}" )
set ( CMAKE_REQUIRED_INCLUDES ${ MINIUPNP_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ MINIUPNP_LIBRARY } )
check_cxx_source_runs ( "
# i n c l u d e < m i n i w g e t . h >
# i n c l u d e < m i n i u p n p c . h >
# i n c l u d e < u p n p c o m m a n d s . h >
# i n c l u d e < s t d i o . h >
i n t main ( )
{
s t a t i c s t r u c t U P N P U r l s u r l s ;
s t a t i c s t r u c t I G D d a t a s d a t a ;
GetUPNPUrls ( &urls, &data, \"myurl\",0);
r e t u r n 0 ;
} "
M I N I U P N P C _ V E R S I O N _ 1 _ 7 _ O R _ H I G H E R )
IF ( NOT MINIUPNPC_VERSION_1_7_OR_HIGHER )
set ( CMAKE_REQUIRED_INCLUDES ${ MINIUPNP_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ MINIUPNP_LIBRARY } )
check_cxx_source_runs ( "
# i n c l u d e < m i n i w g e t . h >
# i n c l u d e < m i n i u p n p c . h >
# i n c l u d e < u p n p c o m m a n d s . h >
# i n c l u d e < s t d i o . h >
i n t main ( )
{
s t r u c t U P N P D e v * d e v l i s t = N U L L ;
i n t u p n p _ d e l a y = 5 0 0 0 ;
c o n s t c h a r * u p n p _ m u l t i c a s t i f = N U L L ;
c o n s t c h a r * u p n p _ m i n i s s d p d s o c k = N U L L ;
i n t u p n p _ s a m e p o r t = 0 ;
i n t u p n p _ i p v 6 = 0 ;
i n t u p n p _ e r r o r = 0 ;
d e v l i s t = upnpDiscover ( upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error ) ;
r e t u r n 0 ;
} "
M I N I U P N P C _ V E R S I O N _ P R E 1 _ 7 )
ENDIF ( )
IF ( NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER )
set ( CMAKE_REQUIRED_INCLUDES ${ MINIUPNP_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ MINIUPNP_LIBRARY } )
check_cxx_source_runs ( "
# i n c l u d e < m i n i w g e t . h >
# i n c l u d e < m i n i u p n p c . h >
# i n c l u d e < u p n p c o m m a n d s . h >
# i n c l u d e < s t d i o . h >
i n t main ( )
{
s t r u c t U P N P D e v * d e v l i s t = N U L L ;
i n t u p n p _ d e l a y = 5 0 0 0 ;
c o n s t c h a r * u p n p _ m u l t i c a s t i f = N U L L ;
c o n s t c h a r * u p n p _ m i n i s s d p d s o c k = N U L L ;
i n t u p n p _ s a m e p o r t = 0 ;
i n t u p n p _ i p v 6 = 0 ;
i n t u p n p _ e r r o r = 0 ;
d e v l i s t = upnpDiscover ( upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport ) ;
r e t u r n 0 ;
} "
M I N I U P N P C _ V E R S I O N _ P R E 1 _ 6 )
ENDIF ( )
IF ( NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER )
set ( CMAKE_REQUIRED_INCLUDES ${ MINIUPNP_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ MINIUPNP_LIBRARY } )
check_cxx_source_runs ( "
# i n c l u d e < m i n i w g e t . h >
# i n c l u d e < m i n i u p n p c . h >
# i n c l u d e < u p n p c o m m a n d s . h >
# i n c l u d e < s t d i o . h >
s t a t i c s t r u c t U P N P U r l s u r l s ;
s t a t i c s t r u c t I G D d a t a s d a t a ;
i n t main ( )
{
c h a r e x t e r n a l I P [ 1 6 ] = \ " \ " ;
UPNP_GetExternalIPAddress ( urls.controlURL, data.first.servicetype, externalIP ) ;
r e t u r n 0 ;
} "
M I N I U P N P C _ V E R S I O N _ 1 _ 5 _ O R _ H I G H E R )
ENDIF ( )
IF ( NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER )
set ( CMAKE_REQUIRED_INCLUDES ${ MINIUPNP_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ MINIUPNP_LIBRARY } )
check_cxx_source_runs ( "
# i n c l u d e < m i n i w g e t . h >
# i n c l u d e < m i n i u p n p c . h >
# i n c l u d e < u p n p c o m m a n d s . h >
# i n c l u d e < s t d i o . h >
s t a t i c s t r u c t U P N P U r l s u r l s ;
s t a t i c s t r u c t I G D d a t a s d a t a ;
i n t main ( )
{
c h a r e x t e r n a l I P [ 1 6 ] = \ " \ " ;
UPNP_GetExternalIPAddress ( urls.controlURL, data.servicetype, externalIP ) ;
r e t u r n 0 ;
} "
M I N I U P N P C _ V E R S I O N _ P R E 1 _ 5 )
ENDIF ( )
IF ( MINIUPNPC_VERSION_PRE1_5 )
message ( STATUS "Found miniupnpc version is pre v1.5" )
ENDIF ( )
IF ( MINIUPNPC_VERSION_PRE1_6 )
message ( STATUS "Found miniupnpc version is pre v1.6" )
H I N T S $ E N V { M I N I U P N P _ I N C L U D E _ D I R }
P A T H _ S U F F I X E S m i n i u p n p c
)
find_library ( MINIUPNP_LIBRARY miniupnpc
H I N T S $ E N V { M I N I U P N P _ L I B R A R Y }
)
find_library ( MINIUPNP_STATIC_LIBRARY libminiupnpc.a
H I N T S $ E N V { M I N I U P N P _ S T A T I C _ L I B R A R Y }
)
set ( MINIUPNP_INCLUDE_DIRS ${ MINIUPNP_INCLUDE_DIR } )
set ( MINIUPNP_LIBRARIES ${ MINIUPNP_LIBRARY } )
set ( MINIUPNP_STATIC_LIBRARIES ${ MINIUPNP_STATIC_LIBRARY } )
include ( FindPackageHandleStandardArgs )
find_package_handle_standard_args (
M i n i U P n P c D E F A U L T _ M S G
M I N I U P N P _ I N C L U D E _ D I R
M I N I U P N P _ L I B R A R Y
)
IF ( MINIUPNPC_FOUND )
file ( STRINGS "${MINIUPNP_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+" )
if ( MINIUPNPC_API_VERSION_STR MATCHES "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)" )
set ( MINIUPNPC_API_VERSION "${CMAKE_MATCH_1}" )
endif ( )
if ( ${ MINIUPNPC_API_VERSION } GREATER_EQUAL "10" )
message ( STATUS "Found miniupnpc API version " ${ MINIUPNPC_API_VERSION } )
set ( MINIUPNP_FOUND true )
set ( MINIUPNPC_VERSION_1_7_OR_HIGHER true )
endif ( )
ENDIF ( )
IF ( MINIUPNPC_VERSION_PRE1_7 )
message ( STATUS "Found miniupnpc version is pre v1.7" )
ENDIF ( )
IF ( NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 )
IF ( MINIUPNPC_VERSION_1_5_OR_HIGHER )
message ( STATUS "Found miniupnpc version is v1.5 or higher" )
ELSE ( )
message ( STATUS "Found miniupnpc version is v1.7 or higher" )
ENDIF ( )
ENDIF ( )
else ( )
message ( STATUS "Could not find miniupnp" )
endif ( )
MARK_AS_ADVANCED ( MINIUPNP_INCLUDE_DIR MINIUPNP _LIBRARY)
mark_as_advanced ( MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY MINIUPNP_STATIC_LIBRARY )
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - F i n d M i n i u p n p c E n d - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -