1 include(CheckSymbolExists)
 
   2 add_definitions("-D_POSIX_C_SOURCE=2") # for getopt()
 
   3 add_definitions("-D_POSIX_SOURCE") # for sigaction
 
   4 add_definitions("-D_BSD_SOURCE") # for strdup
 
   6 include_directories(${CMAKE_SOURCE_DIR}/src/)
 
   8 # Build a test app that sends a single picture
 
   9 option(BUILD_PICOPROJ "Build a test app that sends a single picture" TRUE)
 
  11   add_executable(picoproj picoproj.c)
 
  12   target_link_libraries(picoproj am7xxx)
 
  13   install(TARGETS picoproj
 
  14     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
 
  17 # Build a more complete example
 
  18 option(BUILD_AM7XXX-PLAY "Build a more complete example: am7xxx-play" TRUE)
 
  20   find_package(FFmpeg REQUIRED)
 
  21   set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES}) 
 
  22   set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}) 
 
  23   check_symbol_exists(avformat_open_input
 
  24     "${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}/libavformat/avformat.h"
 
  25     HAVE_AVFORMAT_OPEN_INPUT)
 
  26   if(NOT HAVE_AVFORMAT_OPEN_INPUT)
 
  28       "Function avformat_open_input missing. Please use a newer FFmpeg release.")
 
  31   include_directories(${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS})
 
  32   include_directories(${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
 
  33   include_directories(${FFMPEG_LIBSWSCALE_INCLUDE_DIRS})
 
  35   set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_SOURCE)
 
  36   check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
 
  38     add_definitions("-DHAVE_SIGACTION")
 
  41   check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)
 
  43     add_definitions("-DHAVE_STRTOK_R")
 
  45   set(CMAKE_REQUIRED_DEFINITIONS)
 
  47   # xcb is used to retrieve the full screen dimensions when using x11grab
 
  51     add_definitions("${LIBXCB_DEFINITIONS} -DHAVE_XCB")
 
  52     include_directories(${LIBXCB_INCLUDE_DIRS})
 
  53     set(OPTIONAL_LIBRARIES ${LIBXCB_LIBRARIES})
 
  56   add_executable(am7xxx-play am7xxx-play.c)
 
  58   target_link_libraries(am7xxx-play am7xxx
 
  60     ${FFMPEG_LIBSWSCALE_LIBRARIES}
 
  61     ${OPTIONAL_LIBRARIES})
 
  62   install(TARGETS am7xxx-play
 
  63     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
 
  66 # Build a simple usb-modeswitch clone for am7xxx devices
 
  67 option(BUILD_am7xxx-modeswitch "Build a simple usbmode-switch clone for am7xxx devices" TRUE)
 
  68 if(BUILD_am7xxx-modeswitch)
 
  70   find_package(libusb-1.0 REQUIRED)
 
  71   include_directories(${LIBUSB_1_INCLUDE_DIRS})
 
  73   add_executable(am7xxx-modeswitch am7xxx-modeswitch.c)
 
  74   target_link_libraries(am7xxx-modeswitch ${LIBUSB_1_LIBRARIES})
 
  75   install(TARGETS am7xxx-modeswitch
 
  76     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")