diff options
Diffstat (limited to 'cmake_modules/FindGPHOTO2.cmake')
-rw-r--r-- | cmake_modules/FindGPHOTO2.cmake | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/cmake_modules/FindGPHOTO2.cmake b/cmake_modules/FindGPHOTO2.cmake new file mode 100644 index 0000000..e5ffe29 --- /dev/null +++ b/cmake_modules/FindGPHOTO2.cmake @@ -0,0 +1,66 @@ +# - Find the native sqlite3 includes and library +# +# This module defines +# GPHOTO2_INCLUDE_DIR, where to find libgphoto2 header files +# GPHOTO2_LIBRARIES, the libraries to link against to use libgphoto2 +# GPHOTO2_FOUND, If false, do not try to use libgphoto2. +# GPHOTO2_VERSION_STRING, e.g. 2.4.14 +# GPHOTO2_VERSION_MAJOR, e.g. 2 +# GPHOTO2_VERSION_MINOR, e.g. 4 +# GPHOTO2_VERSION_PATCH, e.g. 14 +# +# also defined, but not for general use are +# GPHOTO2_LIBRARY, where to find the sqlite3 library. + + +#============================================================================= +# Copyright 2010 henrik andersson +#============================================================================= + +SET(GPHOTO2_FIND_REQUIRED ${Gphoto2_FIND_REQUIRED}) + +find_path(GPHOTO2_INCLUDE_DIR gphoto2/gphoto2.h) +mark_as_advanced(GPHOTO2_INCLUDE_DIR) + +set(GPHOTO2_NAMES ${GPHOTO2_NAMES} gphoto2 libgphoto2) +set(GPHOTO2_PORT_NAMES ${GPHOTO2_PORT_NAMES} gphoto2_port libgphoto2_port) +find_library(GPHOTO2_LIBRARY NAMES ${GPHOTO2_NAMES} ) +find_library(GPHOTO2_PORT_LIBRARY NAMES ${GPHOTO2_PORT_NAMES} ) +mark_as_advanced(GPHOTO2_LIBRARY) +mark_as_advanced(GPHOTO2_PORT_LIBRARY) + +# Detect libgphoto2 version +FIND_PROGRAM(GPHOTO2CONFIG_EXECUTABLE NAMES gphoto2-config) +IF(GPHOTO2CONFIG_EXECUTABLE) + EXEC_PROGRAM(${GPHOTO2CONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GPHOTO2_VERSION) + string(REGEX REPLACE "^.*libgphoto2 ([0-9]+).*$" "\\1" GPHOTO2_VERSION_MAJOR "${GPHOTO2_VERSION}") + string(REGEX REPLACE "^.*libgphoto2 [0-9]+\\.([0-9]+).*$" "\\1" GPHOTO2_VERSION_MINOR "${GPHOTO2_VERSION}") + string(REGEX REPLACE "^.*libgphoto2 [0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GPHOTO2_VERSION_PATCH "${GPHOTO2_VERSION}") + + set(GPHOTO2_VERSION_STRING "${GPHOTO2_VERSION_MAJOR}.${GPHOTO2_VERSION_MINOR}.${GPHOTO2_VERSION_PATCH}") +ENDIF(GPHOTO2CONFIG_EXECUTABLE) + +# handle the QUIETLY and REQUIRED arguments and set GPHOTO2_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GPHOTO2 DEFAULT_MSG GPHOTO2_LIBRARY GPHOTO2_INCLUDE_DIR) + +IF(GPHOTO2_FOUND) + SET(Gphoto2_LIBRARIES ${GPHOTO2_LIBRARY} ${GPHOTO2_PORT_LIBRARY}) + SET(Gphoto2_INCLUDE_DIRS ${GPHOTO2_INCLUDE_DIR}) + + # libgphoto2 dynamically loads and unloads usb library + # without calling any cleanup functions (since they are absent from libusb-0.1). + # This leaves usb event handling threads running with invalid callback and return addresses, + # which causes a crash after any usb event is generated, at least in Mac OS X. + # libusb1 backend does correctly call exit function, but ATM it crashes anyway. + # Workaround is to link against libusb so that it wouldn't get unloaded. + IF(APPLE) + find_library(USB_LIBRARY NAMES usb-1.0 libusb-1.0) + mark_as_advanced(USB_LIBRARY) + IF(USB_LIBRARY) + SET(Gphoto2_LIBRARIES ${Gphoto2_LIBRARIES} ${USB_LIBRARY}) + ENDIF(USB_LIBRARY) + ENDIF(APPLE) + +ENDIF(GPHOTO2_FOUND) |