| 1 |
# - Find the native sqlite3 includes and library |
| 2 |
# |
| 3 |
# This module defines |
| 4 |
# GPHOTO2_INCLUDE_DIR, where to find libgphoto2 header files |
| 5 |
# GPHOTO2_LIBRARIES, the libraries to link against to use libgphoto2 |
| 6 |
# GPHOTO2_FOUND, If false, do not try to use libgphoto2. |
| 7 |
# GPHOTO2_VERSION_STRING, e.g. 2.4.14 |
| 8 |
# GPHOTO2_VERSION_MAJOR, e.g. 2 |
| 9 |
# GPHOTO2_VERSION_MINOR, e.g. 4 |
| 10 |
# GPHOTO2_VERSION_PATCH, e.g. 14 |
| 11 |
# |
| 12 |
# also defined, but not for general use are |
| 13 |
# GPHOTO2_LIBRARY, where to find the sqlite3 library. |
| 14 |
|
| 15 |
|
| 16 |
#============================================================================= |
| 17 |
# Copyright 2010 henrik andersson |
| 18 |
#============================================================================= |
| 19 |
|
| 20 |
SET(GPHOTO2_FIND_REQUIRED ${Gphoto2_FIND_REQUIRED}) |
| 21 |
|
| 22 |
find_path(GPHOTO2_INCLUDE_DIR gphoto2/gphoto2.h) |
| 23 |
mark_as_advanced(GPHOTO2_INCLUDE_DIR) |
| 24 |
|
| 25 |
set(GPHOTO2_NAMES ${GPHOTO2_NAMES} gphoto2 libgphoto2) |
| 26 |
set(GPHOTO2_PORT_NAMES ${GPHOTO2_PORT_NAMES} gphoto2_port libgphoto2_port) |
| 27 |
find_library(GPHOTO2_LIBRARY NAMES ${GPHOTO2_NAMES} ) |
| 28 |
find_library(GPHOTO2_PORT_LIBRARY NAMES ${GPHOTO2_PORT_NAMES} ) |
| 29 |
mark_as_advanced(GPHOTO2_LIBRARY) |
| 30 |
mark_as_advanced(GPHOTO2_PORT_LIBRARY) |
| 31 |
|
| 32 |
# Detect libgphoto2 version |
| 33 |
FIND_PROGRAM(GPHOTO2CONFIG_EXECUTABLE NAMES gphoto2-config) |
| 34 |
IF(GPHOTO2CONFIG_EXECUTABLE) |
| 35 |
EXEC_PROGRAM(${GPHOTO2CONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GPHOTO2_VERSION) |
| 36 |
string(REGEX REPLACE "^.*libgphoto2 ([0-9]+).*$" "\\1" GPHOTO2_VERSION_MAJOR "${GPHOTO2_VERSION}") |
| 37 |
string(REGEX REPLACE "^.*libgphoto2 [0-9]+\\.([0-9]+).*$" "\\1" GPHOTO2_VERSION_MINOR "${GPHOTO2_VERSION}") |
| 38 |
string(REGEX REPLACE "^.*libgphoto2 [0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GPHOTO2_VERSION_PATCH "${GPHOTO2_VERSION}") |
| 39 |
|
| 40 |
set(GPHOTO2_VERSION_STRING "${GPHOTO2_VERSION_MAJOR}.${GPHOTO2_VERSION_MINOR}.${GPHOTO2_VERSION_PATCH}") |
| 41 |
ENDIF(GPHOTO2CONFIG_EXECUTABLE) |
| 42 |
|
| 43 |
# handle the QUIETLY and REQUIRED arguments and set GPHOTO2_FOUND to TRUE if |
| 44 |
# all listed variables are TRUE |
| 45 |
include(FindPackageHandleStandardArgs) |
| 46 |
find_package_handle_standard_args(GPHOTO2 DEFAULT_MSG GPHOTO2_LIBRARY GPHOTO2_INCLUDE_DIR) |
| 47 |
|
| 48 |
IF(GPHOTO2_FOUND) |
| 49 |
SET(Gphoto2_LIBRARIES ${GPHOTO2_LIBRARY} ${GPHOTO2_PORT_LIBRARY}) |
| 50 |
SET(Gphoto2_INCLUDE_DIRS ${GPHOTO2_INCLUDE_DIR}) |
| 51 |
|
| 52 |
# libgphoto2 dynamically loads and unloads usb library |
| 53 |
# without calling any cleanup functions (since they are absent from libusb-0.1). |
| 54 |
# This leaves usb event handling threads running with invalid callback and return addresses, |
| 55 |
# which causes a crash after any usb event is generated, at least in Mac OS X. |
| 56 |
# libusb1 backend does correctly call exit function, but ATM it crashes anyway. |
| 57 |
# Workaround is to link against libusb so that it wouldn't get unloaded. |
| 58 |
IF(APPLE) |
| 59 |
find_library(USB_LIBRARY NAMES usb-1.0 libusb-1.0) |
| 60 |
mark_as_advanced(USB_LIBRARY) |
| 61 |
IF(USB_LIBRARY) |
| 62 |
SET(Gphoto2_LIBRARIES ${Gphoto2_LIBRARIES} ${USB_LIBRARY}) |
| 63 |
ENDIF(USB_LIBRARY) |
| 64 |
ENDIF(APPLE) |
| 65 |
|
| 66 |
ENDIF(GPHOTO2_FOUND) |