Update for app framework removal
[apps/camera-gstreamer.git] / app / CMakeLists.txt
1 ###########################################################################
2 # Copyright 2018,2022 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 project(camera-gstreamer)
22
23 if(CMAKE_VERSION VERSION_LESS "3.7.0")
24     set(CMAKE_INCLUDE_CURRENT_DIR ON)
25 endif()
26
27 set(CMAKE_CXX_STANDARD 14)
28 set(CMAKE_CXX_STANDARD_REQUIRED ON)
29
30 find_package(PkgConfig REQUIRED)
31 find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
32
33 add_custom_command(
34         OUTPUT  agl-shell-desktop-client-protocol.h
35         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
36         < ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
37         > ${CMAKE_SOURCE_DIR}/app/agl-shell-desktop-client-protocol.h
38         DEPENDS ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
39 )
40
41 add_custom_command(
42         OUTPUT  ${CMAKE_BINARY_DIR}/app/agl-shell-desktop-client-protocol.h
43         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
44         < ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
45         > ${CMAKE_SOURCE_DIR}/app/agl-shell-desktop-client-protocol.h
46         DEPENDS ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
47 )
48
49 add_custom_command(
50         OUTPUT  agl-shell-desktop-protocol.c
51         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code
52         < ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
53         > ${CMAKE_BINARY_DIR}/app/agl-shell-desktop-protocol.c
54         DEPENDS ${CMAKE_SOURCE_DIR}/app/protocol/agl-shell-desktop.xml
55 )
56
57 pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
58 pkg_check_modules(GSTREAMER_PLUGINS_BASE REQUIRED gstreamer-plugins-base-1.0)
59 pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0)
60 pkg_check_modules(GSTREAMER_PLUGINS_BAD REQUIRED gstreamer-plugins-bad-1.0)
61
62 pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
63 pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.18)
64 pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
65
66 add_custom_command(
67         OUTPUT  xdg-shell-client-protocol.h
68         COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
69         < ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
70         > ${CMAKE_SOURCE_DIR}/app/xdg-shell-client-protocol.h
71         DEPENDS ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
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(${PROJECT_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 target_link_libraries(${PROJECT_NAME}
109         ${GSTREAMER_LIBRARIES}
110         "${GSTREAMER_PLUGINS_BASE_LIBRARIES}"
111         "${GSTREAMER_PLUGINS_BAD_LIBRARIES}"
112         "${GSTREAMER_VIDEO_LIBRARIES}"
113         ${WAYLAND_CLIENT_LIBRARIES}
114         -lgstwayland-1.0
115 )
116
117 install(TARGETS ${PROJECT_NAME} DESTINATION bin)
118 include(GNUInstallDirs)
119 install(FILES ${PROJECT_NAME}.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)