debian/patches: new FFmpeg-5.0-compatibility.patch
[libam7xxx.git] / examples / CMakeLists.txt
1 include(CheckSymbolExists)
2 add_definitions("-D_POSIX_C_SOURCE=200809L") # for getopt(), sigaction(), and strdup()
3
4 include_directories(${CMAKE_SOURCE_DIR}/src/)
5
6 # Build a test app that sends a single picture
7 option(BUILD_PICOPROJ "Build a test app that sends a single picture" TRUE)
8 if(BUILD_PICOPROJ)
9   add_executable(picoproj picoproj.c)
10   target_link_libraries(picoproj am7xxx)
11   install(TARGETS picoproj
12     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
13 endif()
14
15 # Build a more complete example
16 option(BUILD_AM7XXX-PLAY "Build a more complete example: am7xxx-play" TRUE)
17 if(BUILD_AM7XXX-PLAY)
18   find_package(FFmpeg REQUIRED)
19   set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBAVFORMAT_LIBRARIES})
20   set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
21   check_symbol_exists(avformat_open_input
22     "libavformat/avformat.h"
23     HAVE_AVFORMAT_OPEN_INPUT)
24   if(NOT HAVE_AVFORMAT_OPEN_INPUT)
25     message(FATAL_ERROR
26       "Function avformat_open_input missing. Please use a newer FFmpeg release.")
27   endif()
28
29   include_directories(${FFMPEG_LIBAVDEVICE_INCLUDE_DIRS})
30   include_directories(${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
31   include_directories(${FFMPEG_LIBSWSCALE_INCLUDE_DIRS})
32
33   set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_SOURCE)
34   check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
35   if (HAVE_SIGACTION)
36     add_definitions("-DHAVE_SIGACTION")
37   endif()
38
39   check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)
40   if (HAVE_STRTOK_R)
41     add_definitions("-DHAVE_STRTOK_R")
42   endif()
43   set(CMAKE_REQUIRED_DEFINITIONS)
44
45   # xcb is used to retrieve the full screen dimensions when using x11grab
46   # as input format
47   find_package(XCB)
48   if (XCB_FOUND)
49     add_definitions("${LIBXCB_DEFINITIONS} -DHAVE_XCB")
50     include_directories(${LIBXCB_INCLUDE_DIRS})
51     set(OPTIONAL_LIBRARIES ${LIBXCB_LIBRARIES})
52   endif()
53
54   add_executable(am7xxx-play am7xxx-play.c)
55
56   target_link_libraries(am7xxx-play am7xxx
57     ${FFMPEG_LIBRARIES}
58     ${FFMPEG_LIBSWSCALE_LIBRARIES}
59     ${OPTIONAL_LIBRARIES})
60   install(TARGETS am7xxx-play
61     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
62 endif()
63
64 # Build a simple usb-modeswitch clone for am7xxx devices
65 option(BUILD_am7xxx-modeswitch "Build a simple usbmode-switch clone for am7xxx devices" TRUE)
66 if(BUILD_am7xxx-modeswitch)
67
68   find_package(libusb-1.0 REQUIRED)
69   include_directories(${LIBUSB_1_INCLUDE_DIRS})
70
71   add_executable(am7xxx-modeswitch am7xxx-modeswitch.c)
72   target_link_libraries(am7xxx-modeswitch ${LIBUSB_1_LIBRARIES})
73   install(TARGETS am7xxx-modeswitch
74     DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
75 endif()
76