@ -35,7 +35,7 @@ if(NOT DEFINED FIND_THIRD_PARTY_LIBRARIES_EXISTS)
elseif ( "${REQUIRED}" STREQUAL "REQUIRED" )
set ( ${ NAME } _REQUIRED "REQUIRED" )
else ( )
message ( FATAL_ERROR "Invalid use of use_external _library; must specify either REQUIRED or OPTIONAL.")
message ( FATAL_ERROR "Invalid use of link_against _library; must specify either REQUIRED or OPTIONAL.")
endif ( )
# a d d l i b r a r y t o l i s t o f l i b r a r i e s t o l i n k a g a i n s t w h e n b u i l d i n g d y n a m i c l i b r a r i e s o r a p p l i c a t i o n s
@ -55,9 +55,36 @@ if(NOT DEFINED FIND_THIRD_PARTY_LIBRARIES_EXISTS)
# a d d l i b r a r y t o l i s t o f l i b r a r i e s t o b e p r o v i d e d a s t r a n s i t i v e d e p e n d e n c i e s w h e n b u i l d i n g s t a t i c l i b r a r i e s
list ( APPEND STATIC_LIBRARIES ${ ${NAME } _STATIC_LIB} )
message ( STATUS "Adding ${${NAME}_STATIC_LIB} to static library dependencies of ${META_PROJECT_NAME}." )
endmacro ( )
macro ( use_external_library_from_package NAME VERSION INCLUDE_VAR LIBRARY_VAR LINKAGE REQUIRED )
macro ( use_external_library NAME LINKAGE REQUIRED )
save_default_library_suffixes ( )
configure_dynamic_library_suffixes ( )
find_library ( ${ NAME } _DYNAMIC_LIB ${ NAME } )
configure_static_library_suffixes ( )
find_library ( ${ NAME } _STATIC_LIB ${ NAME } )
link_against_library ( ${ NAME } ${ LINKAGE } ${ REQUIRED } )
restore_default_library_suffixes ( )
endmacro ( )
function ( use_external_library_from_package_dynamic NAME PKGNAME INCLUDE_VAR LIBRARY_VAR COMPAT_VERSION )
# i n t e r n a l l y u s e d b y u s e _ e x t e r n a l _ l i b r a r y _ f r o m _ p a c k a g e t o f i n d d y n a m i c l i b r a r i e s
configure_dynamic_library_suffixes ( )
find_package ( ${ PKGNAME } ${ COMPAT_VERSION } )
include_directories ( ${ ${INCLUDE_VAR } } )
set ( ${ NAME } _DYNAMIC_LIB ${ ${LIBRARY_VAR } } PARENT_SCOPE )
endfunction ( )
function ( use_external_library_from_package_static NAME PKGNAME INCLUDE_VAR LIBRARY_VAR COMPAT_VERSION )
# i n t e r n a l l y u s e d b y u s e _ e x t e r n a l _ l i b r a r y _ f r o m _ p a c k a g e t o f i n d s t a t i c l i b r a r i e s
configure_static_library_suffixes ( )
find_package ( ${ PKGNAME } ${ COMPAT_VERSION } )
include_directories ( ${ ${INCLUDE_VAR } } )
set ( ${ NAME } _STATIC_LIB ${ ${LIBRARY_VAR } } PARENT_SCOPE )
endfunction ( )
macro ( use_external_library_from_package NAME PKGNAME VERSION INCLUDE_VAR LIBRARY_VAR LINKAGE REQUIRED )
save_default_library_suffixes ( )
# h a n d l e s p e c i f i e d V E R S I O N
@ -67,24 +94,28 @@ if(NOT DEFINED FIND_THIRD_PARTY_LIBRARIES_EXISTS)
set ( ${ NAME } _COMPATIBLE_VERSION ${ VERSION } )
endif ( )
# fi n d d y n a m i c l i b r a r y
# us e t h e f i n d _ l i b r a r y a p p r o a c h f i r s t b e c a u s e i t i s l e s s b u g g y w h e n t r y i n g t o d e t e c t s t a t i c l i b r a r i e s
configure_dynamic_library_suffixes ( )
find_package ( ${ NAME } ${ ${NAME } _COMPATIBLE_VERSION} )
include_directories ( ${ ${INCLUDE_VAR } } )
set ( ${ NAME } _DYNAMIC_LIB ${ ${LIBRARY_VAR } } )
unset ( ${ ${LIBRARY_VAR } } )
# f i n d s t a t i c l i b r a r y
find_library ( ${ NAME } _DYNAMIC_LIB ${ NAME } )
configure_static_library_suffixes ( )
find_package ( ${ NAME } ${ ${NAME } _COMPATIBLE_VERSION} )
set ( ${ NAME } _STATIC_LIB ${ ${LIBRARY_VAR } } )
find_library ( ${ NAME } _STATIC_LIB ${ NAME } )
# f a l l b a c k t o a c t u a l u s e o f f i n d _ p a c k a g e
# u s e s e p a r a t e f u n c t i o n s t o g e t a n e w s c o p e
if ( NOT ${ NAME } _DYNAMIC_LIB )
use_external_library_from_package_dynamic ( ${ NAME } ${ PKGNAME } ${ INCLUDE_VAR } "${LIBRARY_VAR}" "${${NAME}_COMPATIBLE_VERSION}" )
endif ( )
if ( NOT ${ NAME } _STATIC_LIB )
use_external_library_from_package_static ( ${ NAME } ${ PKGNAME } ${ INCLUDE_VAR } "${LIBRARY_VAR}" "${${NAME}_COMPATIBLE_VERSION}" )
endif ( )
link_against_library ( ${ NAME } ${ LINKAGE } ${ REQUIRED } )
restore_default_library_suffixes ( )
endmacro ( )
macro ( find_iconv LINKAGE REQUIRED )
macro ( use _iconv LINKAGE REQUIRED )
# c h e c k w h e t h e r i c o n v e x i s t s i n t h e s t a n d a r d l i b r a r y
include ( CheckFunctionExists )
check_function_exists ( iconv HAS_ICONV )
@ -92,17 +123,7 @@ if(NOT DEFINED FIND_THIRD_PARTY_LIBRARIES_EXISTS)
message ( STATUS "Using iconv from the standard library for ${META_PROJECT_NAME}." )
else ( )
# f i n d e x t e r n a l i c o n v l i b r a r y
save_default_library_suffixes ( )
configure_dynamic_library_suffixes ( )
find_library ( ICONV_DYNAMIC_LIB iconv )
configure_static_library_suffixes ( )
find_library ( ICONV_STATIC_LIB iconv )
link_against_library ( ICONV ${ LINKAGE } ${ REQUIRED } )
restore_default_library_suffixes ( )
use_external_library ( iconv ${ LINKAGE } ${ REQUIRED } )
endif ( )
endmacro ( )
endif ( )