Init camera-gstreamer
[apps/camera-gstreamer.git] / app / CMakeLists.txt
1 ###########################################################################
2 # Copyright 2018 Konsulko Group
3 # Copyright 2020 Collabora, Ltd.
4 #
5 # Author: Scott Murray <scott.murray@konsulko.com>
6 # Author: Marius Vlad <marius.vlad@collabora.com>
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #     http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 ###########################################################################
20
21 set(CMAKE_INCLUDE_CURRENT_DIR ON)
22 set(CMAKE_CXX_STANDARD 14)
23 set(CMAKE_CXX_STANDARD_REQUIRED ON)
24
25 find_package(PkgConfig REQUIRED)
26 find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
27
28 PROJECT_TARGET_ADD(camera-gstreamer)
29
30 add_custom_command(
31         OUTPUT  agl-shell-desktop-client-protocol.h
32         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
33         < ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
34         > ${CMAKE_SOURCE_DIR}/app/agl-shell-desktop-client-protocol.h
35         DEPENDS ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
36 )
37
38
39 add_custom_command(
40         OUTPUT  ${CMAKE_BINARY_DIR}/app/agl-shell-desktop-client-protocol.h
41         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
42         < ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
43         > ${CMAKE_SOURCE_DIR}/app/agl-shell-desktop-client-protocol.h
44         DEPENDS ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
45 )
46
47 add_custom_command(
48         OUTPUT  agl-shell-desktop-protocol.c
49         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code
50         < ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
51         > ${CMAKE_BINARY_DIR}/app/agl-shell-desktop-protocol.c
52         DEPENDS ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
53 )
54
55
56 pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
57 pkg_check_modules(GSTREAMER_PLUGINS_BASE REQUIRED gstreamer-plugins-base-1.0)
58 pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0)
59 pkg_check_modules(GSTREAMER_PLUGINS_BAD REQUIRED gstreamer-plugins-bad-1.0)
60
61 pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
62 pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.18)
63 pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
64
65 add_custom_command(
66         OUTPUT  xdg-shell-client-protocol.h
67         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
68         < ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
69         > ${CMAKE_SOURCE_DIR}/app/xdg-shell-client-protocol.h
70         DEPENDS ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
71 )
72
73
74 add_custom_command(
75         OUTPUT  ${CMAKE_BINARY_DIR}/app/xdg-shell-client-protocol.h
76         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
77         < ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
78         > ${CMAKE_SOURCE_DIR}/app/xdg-shell-client-protocol.h
79         DEPENDS ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
80 )
81
82 add_custom_command(
83         OUTPUT  xdg-shell-protocol.c
84         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code
85         < ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
86         > ${CMAKE_BINARY_DIR}/app/xdg-shell-protocol.c
87         DEPENDS ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
88 )
89
90 add_executable(${TARGET_NAME}
91         main.cpp
92         utils.h
93         utils.cpp
94         agl-shell-desktop-protocol.c
95         agl-shell-desktop-client-protocol.h
96         xdg-shell-protocol.c
97         xdg-shell-client-protocol.h
98         ${RESOURCES}
99 )
100
101 include_directories(
102         "${GSTREAMER_INCLUDE_DIRS}"
103         "${GSTREAMER_PLUGINS_BASE_INCLUDE_DIRS}"
104         "${GSTREAMER_PLUGINS_BAD_INCLUDE_DIRS}"
105         "${GSTREAMER_VIDEO_INCLUDE_DIRS}"
106 )
107
108 set_target_properties(${TARGET_NAME} PROPERTIES
109         LABELS "EXECUTABLE"
110         PREFIX ""
111         COMPILE_FLAGS "${EXTRAS_CFLAGS} -DFOR_AFB_BINDING"
112         LINK_FLAGS "${BINDINGS_LINK_FLAG}"
113         LINK_LIBRARIES "${EXTRAS_LIBRARIES}"
114         OUTPUT_NAME "${TARGET_NAME}"
115 )
116
117 target_link_libraries(${TARGET_NAME}
118         ${GSTREAMER_LIBRARIES}
119         "${GSTREAMER_PLUGINS_BASE_LIBRARIES}"
120         "${GSTREAMER_PLUGINS_BAD_LIBRARIES}"
121         "${GSTREAMER_VIDEO_LIBRARIES}"
122         ${WAYLAND_CLIENT_LIBRARIES}
123         -lgstwayland-1.0
124 )