summaryrefslogtreecommitdiffstats
path: root/cmake_modules/FindFTDI.cmake
blob: 35989ce585da6b0411e77ebe3e7cb29427208324 (plain)
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
# - Try to find FTDI
# This finds libFTDI that is compatible with old libusb v 0.1
# For newer libusb > 1.0, use FindFTDI1.cmake
# Once done this will define
#
#  FTDI_FOUND - system has FTDI
#  FTDI_INCLUDE_DIR - the FTDI include directory
#  FTDI_LIBRARIES - Link these to use FTDI

# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES)

  # in cache already
  set(FTDI_FOUND TRUE)
  message(STATUS "Found libftdi: ${FTDI_LIBRARIES}")

else (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES)

  find_path(FTDI_INCLUDE_DIR ftdi.h
    PATH_SUFFIXES libftdi1
    ${_obIncDir}
    ${GNUWIN32_DIR}/include
    /usr/local/include
  )

  find_library(FTDI_LIBRARIES NAMES ftdi ftdi1
    PATHS
    ${_obLinkDir}
    ${GNUWIN32_DIR}/lib
    /usr/local/lib
  )

  if(FTDI_INCLUDE_DIR AND FTDI_LIBRARIES)
    set(FTDI_FOUND TRUE)
  else (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES)
    set(FTDI_FOUND FALSE)
  endif(FTDI_INCLUDE_DIR AND FTDI_LIBRARIES)


  if (FTDI_FOUND)
    if (NOT FTDI_FIND_QUIETLY)
      message(STATUS "Found FTDI: ${FTDI_LIBRARIES}")
    endif (NOT FTDI_FIND_QUIETLY)
  else (FTDI_FOUND)
    if (FTDI_FIND_REQUIRED)
      message(FATAL_ERROR "FTDI not found. Please install libftdi-dev")
    endif (FTDI_FIND_REQUIRED)
  endif (FTDI_FOUND)

  mark_as_advanced(FTDI_INCLUDE_DIR FTDI_LIBRARIES)
  
endif (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES)