Warning, /graphics/digikam/core/cmake/modules/FindGphoto2.cmake is written in an unsupported language. File is not indexed.

0001 # Cmake macro to detect gphoto2 libraries
0002 #
0003 # This module defines
0004 #  Gphoto2_FOUND          - True if libgphoto2 is detected.
0005 #  GPHOTO2_INCLUDE_DIRS   - Path to libgphoto2 header files.
0006 #  GPHOTO2_LIBRARIES      - Libraries to link against to use libgphoto2.
0007 #  GPHOTO2_VERSION_STRING - e.g. "2.4.14"
0008 #  GPHOTO2_VERSION_MAJOR  - e.g. "2"
0009 #  GPHOTO2_VERSION_MINOR  - e.g. "4"
0010 #  GPHOTO2_VERSION_PATCH  - e.g. "14"
0011 #
0012 # SPDX-FileCopyrightText: 2006-2007 by Laurent Montel <montel@kde.org>
0013 # SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier.gilles@gmail.com>
0014 #
0015 # SPDX-License-Identifier: BSD-3-Clause
0016 #
0017 
0018 set(GPHOTO2_FIND_REQUIRED ${Gphoto2_FIND_REQUIRED})
0019 
0020 find_path(GPHOTO2_INCLUDE_DIRS gphoto2/gphoto2.h)
0021 mark_as_advanced(GPHOTO2_INCLUDE_DIRS)
0022 
0023 set(GPHOTO2_NAMES      ${GPHOTO2_NAMES}      gphoto2      libgphoto2)
0024 set(GPHOTO2_PORT_NAMES ${GPHOTO2_PORT_NAMES} gphoto2_port libgphoto2_port)
0025 
0026 find_library(GPHOTO2_LIBRARY      NAMES ${GPHOTO2_NAMES})
0027 find_library(GPHOTO2_PORT_LIBRARY NAMES ${GPHOTO2_PORT_NAMES})
0028 
0029 mark_as_advanced(GPHOTO2_LIBRARY)
0030 mark_as_advanced(GPHOTO2_PORT_LIBRARY)
0031 
0032 # Detect libgphoto2 version
0033 
0034 find_package(PkgConfig)
0035 pkg_check_modules(PC_GPHOTO2 QUIET libgphoto2)
0036 
0037 if(PC_GPHOTO2_FOUND)
0038 
0039     set(GPHOTO2_VERSION_STRING "${PC_GPHOTO2_VERSION}")
0040 
0041 endif()
0042 
0043 # handle the QUIETLY and REQUIRED arguments and set Gphoto2_FOUND to TRUE if
0044 # all listed variables are TRUE
0045 
0046 include(FindPackageHandleStandardArgs)
0047 find_package_handle_standard_args(Gphoto2 DEFAULT_MSG
0048                                   GPHOTO2_LIBRARY
0049                                   GPHOTO2_INCLUDE_DIRS)
0050 
0051 if(Gphoto2_FOUND)
0052 
0053     set(GPHOTO2_INCLUDE_DIRS ${GPHOTO2_INCLUDE_DIRS}/gphoto2)
0054     set(GPHOTO2_LIBRARIES    ${GPHOTO2_LIBRARY} ${GPHOTO2_PORT_LIBRARY})
0055 
0056     # See bug #268267: digiKam need to be linked to libusb to prevent crash
0057     # at gphoto2 init if opencv is linked with libdc1394.
0058     #
0059     # libgphoto2 dynamically loads and unloads usb library
0060     # without calling any cleanup functions (since they are absent from libusb-0.1).
0061     # This leaves usb event handling threads running with invalid callback and return addresses,
0062     # which causes a crash after any usb event is generated.
0063     # libusb1 backend does correctly call exit function, but ATM it crashes anyway.
0064     # Workaround is to link against libusb so that it wouldn't get unloaded.
0065 
0066     find_library(USB1_LIBRARY NAMES usb-1.0 libusb-1.0)
0067     mark_as_advanced(USB1_LIBRARY)
0068 
0069     if(USB1_LIBRARY)
0070 
0071         set(GPHOTO2_LIBRARIES ${GPHOTO2_LIBRARIES} ${USB1_LIBRARY})
0072 
0073     endif()
0074 
0075 endif()
0076 
0077 message(STATUS "libgphoto2 found    : ${Gphoto2_FOUND}")
0078 message(STATUS "libgphoto2 version  : ${GPHOTO2_VERSION_STRING}")
0079 message(STATUS "libgphoto2 includes : ${GPHOTO2_INCLUDE_DIRS}")
0080 message(STATUS "libgphoto2 libraries: ${GPHOTO2_LIBRARIES}")