@ -1,53 +1,104 @@
@@ -1,53 +1,104 @@
# F i n d s l i b i i o f o r P l u t o S D R s u p p o r t .
#
# T h e l i b i i o 0 . x A P I i s u s e d b y d e f a u l t . S e t E N A B L E _ L I B I I O _ V 1 = O N t o b u i l d
# a g a i n s t l i b i i o 1 . x i n s t e a d . T h e h e a d e r a n d t h e l i b r a r y a l w a y s c o m e f r o m t h e
# s a m e i n s t a l l : I I O _ D I R i f s e t , e l s e t h e o n e p k g - c o n f i g r e p o r t s , e l s e t h e
# s y s t e m p a t h s . A n i n s t a l l w i t h t h e o t h e r A P I i s s k i p p e d .
#
# S e t s L I B I I O _ F O U N D , L I B I I O _ I N C L U D E _ D I R , L I B I I O _ L I B R A R I E S a n d L I B I I O _ V 1 .
if ( ENABLE_LIBIIO_V1 )
set ( _LIBIIO_WANT_V1 TRUE )
else ( )
set ( _LIBIIO_WANT_V1 FALSE )
endif ( )
# D e t e c t a g a i n w h e n E N A B L E _ L I B I I O _ V 1 c h a n g e s i n a n e x i s t i n g b u i l d d i r e c t o r y
if ( LIBIIO_FOUND AND NOT LIBIIO_EXTERNAL AND NOT ( LIBIIO_V1 STREQUAL _LIBIIO_WANT_V1 ) )
unset ( LIBIIO_FOUND CACHE )
unset ( LIBIIO_INCLUDE_DIR CACHE )
unset ( LIBIIO_LIBRARIES CACHE )
endif ( )
# C h e c k s o n e i n s t a l l f o r t h e r e q u e s t e d A P I : h e a d e r a n d l i b r a r y m u s t b o t h b e f o u n d t h e r e .
# S e t s _ L I B I I O _ I N S T A L L _ F O U N D i n t h e c a l l e r ' s s c o p e .
function ( libiio_check_install label include_dirs lib_dirs )
unset ( _LIBIIO_INC_V1 CACHE )
unset ( _LIBIIO_INC_V0 CACHE )
unset ( _LIBIIO_LIB CACHE )
find_path ( _LIBIIO_INC_V1 NAMES iio/iio.h PATHS ${ include_dirs } NO_DEFAULT_PATH )
find_path ( _LIBIIO_INC_V0 NAMES iio.h PATHS ${ include_dirs } NO_DEFAULT_PATH )
find_library ( _LIBIIO_LIB NAMES iio PATHS ${ lib_dirs }
P A T H _ S U F F I X E S $ { C M A K E _ L I B R A R Y _ A R C H I T E C T U R E } N O _ D E F A U L T _ P A T H )
if ( _LIBIIO_WANT_V1 )
set ( include_dir ${ _LIBIIO_INC_V1 } )
set ( other_include_dir ${ _LIBIIO_INC_V0 } )
set ( other_api "0.x" )
set ( option_state "ON" )
else ( )
set ( include_dir ${ _LIBIIO_INC_V0 } )
set ( other_include_dir ${ _LIBIIO_INC_V1 } )
set ( other_api "1.x" )
set ( option_state "OFF" )
endif ( )
set ( found FALSE )
if ( include_dir AND _LIBIIO_LIB )
set ( LIBIIO_INCLUDE_DIR ${ include_dir } CACHE PATH "libiio include directory" FORCE )
set ( LIBIIO_LIBRARIES ${ _LIBIIO_LIB } CACHE FILEPATH "libiio library" FORCE )
set ( found TRUE )
elseif ( other_include_dir AND _LIBIIO_LIB )
message ( STATUS "Ignoring libiio ${other_api} in ${label}: ENABLE_LIBIIO_V1 is ${option_state}" )
endif ( )
unset ( _LIBIIO_INC_V1 CACHE )
unset ( _LIBIIO_INC_V0 CACHE )
unset ( _LIBIIO_LIB CACHE )
set ( _LIBIIO_INSTALL_FOUND ${ found } PARENT_SCOPE )
endfunction ( )
if ( NOT LIBIIO_FOUND )
pkg_check_modules ( LIBIIO_PKG libiio>=0.7 )
set ( LIBIIO_V1 FALSE CACHE INTERNAL "libiio 1.x API" )
if ( LIBIIO_PKG_FOUND OR ( DEFINED IIO_DIR ) )
# l i b i i o 1 . x i n s t a l l s i t s h e a d e r a s < p r e f i x > / i n c l u d e / i i o / i i o . h
find_path ( LIBIIO_V1_INCLUDE_DIR
N A M E S i i o / i i o . h
H I N T S $ { I I O _ D I R } / i n c l u d e
$ { L I B I I O _ P K G _ I N C L U D E _ D I R S }
P A T H S / u s r / i n c l u d e
/ u s r / l o c a l / i n c l u d e
)
if ( LIBIIO_V1_INCLUDE_DIR )
set ( LIBIIO_INCLUDE_DIR ${ LIBIIO_V1_INCLUDE_DIR } CACHE PATH "libiio include directory" )
set ( LIBIIO_V1 TRUE CACHE INTERNAL "libiio 1.x API" )
else ( )
# l i b i i o 0 . x i n s t a l l s i t s h e a d e r a s < p r e f i x > / i n c l u d e / i i o . h
find_path ( LIBIIO_INCLUDE_DIR
N A M E S i i o . h
H I N T S $ { I I O _ D I R } / i n c l u d e
$ { L I B I I O _ P K G _ I N C L U D E _ D I R S }
P A T H S / u s r / i n c l u d e
/ u s r / l o c a l / i n c l u d e
)
set ( LIBIIO_V1 FALSE CACHE INTERNAL "libiio 1.x API" )
set ( _LIBIIO_INSTALL_FOUND FALSE )
if ( DEFINED IIO_DIR )
libiio_check_install ( "IIO_DIR (${IIO_DIR})"
" $ { I I O _ D I R } / i n c l u d e "
" $ { I I O _ D I R } / l i b ; $ { I I O _ D I R } / l i b 6 4 " )
endif ( )
find_library ( LIBIIO_LIBRARIES
N A M E S i i o
H I N T S $ { I I O _ D I R } / l i b
$ { L I B I I O _ P K G _ L I B R A R Y _ D I R S }
P A T H S / u s r / l i b
/ u s r / l o c a l / l i b
)
if ( NOT _LIBIIO_INSTALL_FOUND AND LIBIIO_PKG_FOUND )
libiio_check_install ( "pkg-config (libiio ${LIBIIO_PKG_VERSION})"
" $ { L I B I I O _ P K G _ I N C L U D E D I R } ; $ { L I B I I O _ P K G _ I N C L U D E _ D I R S } "
" $ { L I B I I O _ P K G _ L I B D I R } ; $ { L I B I I O _ P K G _ L I B R A R Y _ D I R S } " )
endif ( )
if ( LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES )
if ( NOT _LIBIIO_INSTALL_FOUND )
libiio_check_install ( "system paths"
" / u s r / i n c l u d e ; / u s r / l o c a l / i n c l u d e "
" / u s r / l i b ; / u s r / l o c a l / l i b " )
endif ( )
if ( _LIBIIO_INSTALL_FOUND )
set ( LIBIIO_FOUND TRUE CACHE INTERNAL "libiio found" )
set ( LIBIIO_V1 ${ _LIBIIO_WANT_V1 } CACHE INTERNAL "libiio 1.x API" )
if ( LIBIIO_V1 )
message ( STATUS "Found libiio (1.x API): ${LIBIIO_INCLUDE_DIR}, ${LIBIIO_LIBRARIES}" )
else ( )
message ( STATUS "Found libiio (0.x API): ${LIBIIO_INCLUDE_DIR}, ${LIBIIO_LIBRARIES}" )
endif ( )
else ( LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES )
else ( )
set ( LIBIIO_FOUND FALSE CACHE INTERNAL "libiio found" )
message ( STATUS "libiio not found." )
endif ( LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES )
endif ( )
mark_as_advanced ( LIBIIO_INCLUDE_DIR LIBIIO_V1_INCLUDE_DIR LIBIIO_LIBRARIES )
mark_as_advanced ( LIBIIO_INCLUDE_DIR LIBIIO_LIBRARIES )
endif ( LIBIIO_PKG_FOUND OR ( DEFINED IIO_DIR ) )