likscan: Prefer pkg-config for libsane detection

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/1/head
Slávek Banko 8 years ago
parent 15c0bc505a
commit f4d9c54240

@ -9,17 +9,20 @@
# #
################################################# #################################################
if( NOT HAVE_SANE ) if( NOT SANE_FOUND )
message( STATUS "checking for 'sane'..." ) pkg_search_module( SANE sane-backends )
endif( ) endif( )
# find sane-config if( NOT SANE_FOUND )
find_program( SANE_EXECUTABLE NAMES sane-config ) message( STATUS "checking for 'sane'..." )
if( NOT SANE_EXECUTABLE )
# find sane-config
find_program( SANE_EXECUTABLE NAMES sane-config )
if( NOT SANE_EXECUTABLE )
tde_message_fatal( "sane-config is NOT found.\n sane library is installed?" ) tde_message_fatal( "sane-config is NOT found.\n sane library is installed?" )
endif( ) endif( )
macro( __run_sane_config __type __var ) macro( __run_sane_config __type __var )
execute_process( execute_process(
COMMAND ${SANE_EXECUTABLE} --${__type} COMMAND ${SANE_EXECUTABLE} --${__type}
OUTPUT_VARIABLE ${__var} OUTPUT_VARIABLE ${__var}
@ -28,17 +31,19 @@ macro( __run_sane_config __type __var )
if( _result ) if( _result )
tde_message_fatal( "Unable to run ${SANE_EXECUTABLE}!\n sane library is correctly installed?\n Path to sane-config is corect?" ) tde_message_fatal( "Unable to run ${SANE_EXECUTABLE}!\n sane library is correctly installed?\n Path to sane-config is corect?" )
endif( ) endif( )
endmacro( ) endmacro( )
__run_sane_config( version SANE_VERSION ) __run_sane_config( version SANE_VERSION )
__run_sane_config( cflags SANE_INCLUDE_DIRS ) __run_sane_config( cflags SANE_INCLUDE_DIRS )
__run_sane_config( libs SANE_LIBRARIES ) __run_sane_config( libs SANE_LIBRARIES )
# cleanup # cleanup
if( SANE_INCLUDE_DIRS ) if( SANE_INCLUDE_DIRS )
string( REGEX REPLACE "(^| )-I" ";" SANE_INCLUDE_DIRS "${SANE_INCLUDE_DIRS}" ) string( REGEX REPLACE "(^| )-I" ";" SANE_INCLUDE_DIRS "${SANE_INCLUDE_DIRS}" )
endif( ) else( )
if( SANE_LIBRARIES ) set( SANE_INCLUDE_DIRS "/usr/include" )
endif( )
if( SANE_LIBRARIES )
## remove all spaces and replace whitespace with ';' ## remove all spaces and replace whitespace with ';'
string( REGEX REPLACE "[ ]+" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" ) string( REGEX REPLACE "[ ]+" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" )
## remove all non-library information ## remove all non-library information
@ -47,8 +52,11 @@ if( SANE_LIBRARIES )
string( REGEX REPLACE "[;]+" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" ) string( REGEX REPLACE "[;]+" ";" SANE_LIBRARIES "${SANE_LIBRARIES}" )
## remove '-l' ## remove '-l'
string( REGEX REPLACE "-l" "" SANE_LIBRARIES "${SANE_LIBRARIES}" ) string( REGEX REPLACE "-l" "" SANE_LIBRARIES "${SANE_LIBRARIES}" )
endif( ) endif( )
if( NOT HAVE_SANE )
message( STATUS " found 'sane', version ${SANE_VERSION}" ) message( STATUS " found 'sane', version ${SANE_VERSION}" )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( SANE DEFAULT_MSG
SANE_LIBRARIES
SANE_INCLUDE_DIRS )
endif( ) endif( )

Loading…
Cancel
Save