1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
# cmake macro to detect gphoto2 libraries
# GPHOTO2_FOUND - system has the GPHOTO2 library
# GPHOTO2_INCLUDE_DIR - the GPHOTO2 include directory
# GPHOTO2_LIBRARIES - The libraries needed to use GPHOTO2
# Copyright (c) 2006, 2007 Laurent Montel, <montel@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(GPHOTO2_LIBRARIES AND GPHOTO2_INCLUDE_DIR)
# in cache already
set(GPHOTO2_FOUND TRUE)
else()
find_program(GHOTO2CONFIG_EXECUTABLE NAMES gphoto2-config)
find_program(GHOTO2PORTCONFIG_EXECUTABLE NAMES gphoto2-port-config)
set(GPHOTO2_LIBRARIES)
set(GPHOTO2_INCLUDE_DIRS)
# if gphoto2-port-config and gphoto2-config have been found
if(GHOTO2PORTCONFIG_EXECUTABLE AND GHOTO2CONFIG_EXECUTABLE)
exec_program(${GHOTO2PORTCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GPHOTO2PORT_LIBRARY)
exec_program(${GHOTO2CONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GPHOTO2_LIBRARY)
exec_program(${GHOTO2PORTCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _GPHOTO2PORT_RESULT_INCLUDE_DIR)
exec_program(${GHOTO2CONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _GPHOTO2_RESULT_INCLUDE_DIR)
set(GPHOTO2_LIBRARIES ${GPHOTO2PORT_LIBRARY} ${GPHOTO2_LIBRARY})
# the cflags can contain more than one include path
separate_arguments(_GPHOTO2_RESULT_INCLUDE_DIR)
foreach(_includedir ${_GPHOTO2_RESULT_INCLUDE_DIR})
string(REGEX REPLACE "-I(.+)" "\\1" _includedir "${_includedir}")
set(GPHOTO2_INCLUDE_DIR ${GPHOTO2_INCLUDE_DIR} ${_includedir})
endforeach()
separate_arguments(_GPHOTO2PORT_RESULT_INCLUDE_DIR)
foreach(_includedir ${_GPHOTO2PORT_RESULT_INCLUDE_DIR})
string(REGEX REPLACE "-I(.+)" "\\1" _includedir "${_includedir}")
set(GPHOTO2PORT_INCLUDE_DIR ${GPHOTO2PORT_INCLUDE_DIR} ${_includedir})
endforeach()
set(GPHOTO2_INCLUDE_DIRS ${GPHOTO2PORT_INCLUDE_DIR} ${GPHOTO2_INCLUDE_DIR} )
else()
find_package(PkgConfig QUIET)
PKG_CHECK_MODULES(PC_GPHOTO2 QUIET libgphoto2_port)
PKG_CHECK_MODULES(PC_GPHOTO2PORT QUIET libgphoto2)
foreach(_library ${PC_GPHOTO2PORT_LIBRARIES})
set(GPHOTO2_LIBRARIES ${GPHOTO2_LIBRARIES} "-l${_library}")
endforeach()
foreach(_library ${PC_GPHOTO2_LIBRARIES})
set(GPHOTO2_LIBRARIES ${GPHOTO2_LIBRARIES} "-l${_library}")
endforeach()
set(GPHOTO2_INCLUDE_DIRS
${PC_GPHOTO2PORT_INCLUDE_DIRS} ${PC_GPHOTO2_INCLUDE_DIRS})
endif()
if(GPHOTO2_LIBRARIES AND GPHOTO2_INCLUDE_DIRS)
set(GPHOTO2_FOUND TRUE)
message(STATUS "Found gphoto2: ${GPHOTO2_LIBRARIES}")
else()
pkg_check_modules(GPHOTO2 QUIET libgphoto2)
if(GPHOTO2_LIBRARIES AND GPHOTO2_INCLUDE_DIRS)
message(STATUS "Found gphoto2: ${GPHOTO2_LIBRARIES}")
endif()
endif()
endif()
mark_as_advanced(GPHOTO2_LIBRARIES GPHOTO2_INCLUDE_DIRS)
|