e24442b3da6def4da293f09c6f615bdb85adb9a2
[libam7xxx.git] / examples / CMakeLists.txt
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
5
6 include_directories(${CMAKE_SOURCE_DIR}/src/)
7
8 # Build a test app that sends a single picture
9 option(BUILD_PICOPROJ "Build a test app that sends a single picture" TRUE)
10 if(BUILD_PICOPROJ)
11   add_executable(picoproj picoproj.c)
12   target_link_libraries(picoproj am7xxx)
13   install(TARGETS picoproj
14     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
15 endif()
16
17 # Build a more complete example
18 option(BUILD_AM7XXX-PLAY "Build a more complete example: am7xxx-play" TRUE)
19 if(BUILD_AM7XXX-PLAY)
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)
27     message(FATAL_ERROR
28       "Function avformat_open_input missing. Please use a newer FFmpeg release.")
29   endif()
30
31   include_directories(${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS})
32   include_directories(${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
33   include_directories(${FFMPEG_LIBSWSCALE_INCLUDE_DIRS})
34
35   set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_SOURCE)
36   check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
37   if (HAVE_SIGACTION)
38     add_definitions("-DHAVE_SIGACTION")
39   endif()
40   set(CMAKE_REQUIRED_DEFINITIONS)
41
42   # xcb is used to retrieve the full screen dimensions when using x11grab
43   # as input format
44   find_package(XCB)
45   if (XCB_FOUND)
46     add_definitions("${LIBXCB_DEFINITIONS} -DHAVE_XCB")
47     include_directories(${LIBXCB_INCLUDE_DIRS})
48   endif()
49
50   add_executable(am7xxx-play am7xxx-play.c)
51
52   target_link_libraries(am7xxx-play am7xxx
53     ${FFMPEG_LIBRARIES}
54     ${FFMPEG_LIBSWSCALE_LIBRARIES}
55     ${LIBXCB_LIBRARIES})
56   install(TARGETS am7xxx-play
57     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
58 endif()
59
60 # Build a simple usb_mode_switch clone for am7xxx devices
61 option(BUILD_AM7XXX_MODE_SWITCH "Build a simple usb_mode_switch clone for am7xxx devices" TRUE)
62 if(BUILD_AM7XXX_MODE_SWITCH)
63
64   find_package(libusb-1.0 REQUIRED)
65   include_directories(${LIBUSB_1_INCLUDE_DIRS})
66
67   add_executable(am7xxx_mode_switch am7xxx_mode_switch.c)
68   target_link_libraries(am7xxx_mode_switch ${LIBUSB_1_LIBRARIES})
69   install(TARGETS am7xxx_mode_switch
70     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
71 endif()
72