FindINDI.cmake 2.47 KB
Newer Older
1 2 3 4 5 6
# - Try to find INDI
# Once done this will define
#
#  INDI_FOUND - system has INDI
#  INDI_INCLUDE_DIR - the INDI include directory
#  INDI_LIBRARIES - Link these to use INDI
7 8 9 10
#  INDI_MAIN_LIBRARIES - Link to these to build INDI drivers with main()
#  INDI_DRIVER_LIBRARIES - Link to these to build INDI drivers with indibase support
#  INDI_CLIENT_LIBRARIES - Link to these to build INDI clients
#  INDI_DATA_DIR - INDI shared data dir.
11

12
# Copyright (c) 2011, Jasem Mutlaq <mutlaqja@ikarustech.com>
13
# Copyright (c) 2012, Pino Toscano <pino@kde.org>
14 15 16 17 18
# Based on FindLibfacile by Carsten Niehaus, <cniehaus@gmx.de>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

19
if (INDI_INCLUDE_DIR AND INDI_DATA_DIR AND INDI_LIBRARIES AND INDI_DRIVER_LIBRARIES AND INDI_MAIN_LIBRARIES)
20 21 22 23 24 25

  # in cache already
  set(INDI_FOUND TRUE)
  message(STATUS "Found INDI: ${INDI_LIBRARIES}")


26
else (INDI_INCLUDE_DIR AND INDI_DATA_DIR AND INDI_LIBRARIES AND INDI_DRIVER_LIBRARIES AND INDI_MAIN_LIBRARIES)
27

28
  find_package(PkgConfig)
29

30 31 32 33 34 35 36 37 38
  if (PKG_CONFIG_FOUND)
    if (INDI_FIND_VERSION)
      set(version_string ">=${INDI_FIND_VERSION}")
    endif()
    pkg_check_modules(PC_INDI libindi${version_string})
  else()
    # assume it was found
    set(PC_INDI_FOUND TRUE)
  endif()
39

40 41 42 43 44
  if (PC_INDI_FOUND)
    find_path(INDI_INCLUDE_DIR indidevapi.h
      PATH_SUFFIXES libindi
      HINTS ${PC_INDI_INCLUDE_DIRS}
    )
45

46 47 48
    find_library(INDI_LIBRARIES NAMES indi
      HINTS ${PC_INDI_LIBRARY_DIRS}
    )
49

50 51 52
    find_library(INDI_DRIVER_LIBRARIES NAMES indidriver
      HINTS ${PC_INDI_LIBRARY_DIRS}
    )
53

54 55 56
    find_library(INDI_MAIN_LIBRARIES NAMES indimain
      HINTS ${PC_INDI_LIBRARY_DIRS}
    )
57

58 59 60 61 62
    find_library(INDI_CLIENT_LIBRARIES NAMES indiclient
      HINTS ${PC_INDI_LIBRARY_DIRS}
    )

    find_path(INDI_DATA_DIR drivers.xml
Jasem Mutlaq's avatar
Jasem Mutlaq committed
63
      PATH_SUFFIXES share/indi
64 65 66 67 68 69 70 71 72 73 74
    )

    set(INDI_VERSION "${PC_INDI_VERSION}")

  endif()

  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(INDI
                                    REQUIRED_VARS INDI_INCLUDE_DIR INDI_LIBRARIES INDI_DRIVER_LIBRARIES INDI_MAIN_LIBRARIES INDI_CLIENT_LIBRARIES
                                    VERSION_VAR INDI_VERSION
  )
75

76
  mark_as_advanced(INDI_INCLUDE_DIR INDI_DATA_DIR INDI_LIBRARIES INDI_DRIVER_LIBRARIES INDI_MAIN_LIBRARIES INDI_CLIENT_LIBRARIES)
77

78
endif (INDI_INCLUDE_DIR AND INDI_DATA_DIR AND INDI_LIBRARIES AND INDI_DRIVER_LIBRARIES AND INDI_MAIN_LIBRARIES)