-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
210 lines (177 loc) · 8.32 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
cmake_minimum_required(VERSION 3.15.0)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(common)
project(GStreamer C CXX)
include(Deps.cmake)
# Define which plugins to disable in GStreamer
set(DISABLED_PLUGINS
cairo:freetype
devtools
examples
ges
gst-examples
gst-plugins-bad:gl
gst-plugins-bad:glib-asserts
gst-plugins-bad:glib-checks
gst-plugins-bad:gobject-cast-checks
gst-plugins-bad:mediafoundation
gst-plugins-bad:openh264
gst-plugins-bad:openjpeg
gst-plugins-bad:tests
gst-plugins-bad:wasapi2
gst-plugins-base:glib-asserts
gst-plugins-base:glib-checks
gst-plugins-base:gobject-cast-checks
gst-plugins-base:pango
gst-plugins-good:cairo
gst-plugins-good:dv
gst-plugins-good:glib-asserts
gst-plugins-good:glib-checks
gst-plugins-good:gobject-cast-checks
gst-plugins-good:soup
gst-plugins-good:tests
gstreamer:extra-checks
gstreamer:glib-asserts
gstreamer:glib-checks
introspection
python
qt5
tests
tls
ugly
)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
list(APPEND DISABLED_PLUGINS gst-plugins-bad:tinyalsa)
endif ()
set(C_ARGS -DFFI_STATIC_BUILD -DG_INTL_STATIC_COMPILATION -DLIBXML_STATIC -DOPJ_STATIC -DORC_STATIC_COMPILATION -DPCRE_STATIC -DPSL_STATIC ${UL_GSTREAMER_C_FLAGS})
set(LINK_ARGS ${UL_GSTREAMER_LINK_FLAGS})
set(MESON_FLAGS
--default-library=static
--force-fallback-for=glib,libffi
-Dglib:default_library=shared
-Dglib:tests=false
-Dgst-full-version-script=""
-Dlibsoup:tests=false
${UL_GSTREAMER_MESON_FLAGS}
)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
list(APPEND MESON_FLAGS --buildtype=debug)
elseif (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
list(APPEND MESON_FLAGS --buildtype=debugoptimized)
else ()
list(APPEND MESON_FLAGS -Ddebug=false
-Doptimization=s
-Dgstreamer:gst_debug=false
)
endif ()
if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
list(APPEND MESON_FLAGS --wrap-mode=nodownload)
list(APPEND DISABLED_PLUGINS gst-plugins-base:gl)
endif ()
set(GSTREAMER_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Location of 'GStreamer'")
set(GSTREAMER_BUILD_DIR "${CMAKE_BINARY_DIR}/gstreamer")
set(GSTREAMER_INSTALL_DIR "${GSTREAMER_BUILD_DIR}/out")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(GSTREAMER_LIBNAME "libgstreamer-full-1.0.so")
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(GSTREAMER_LIBNAME "libgstreamer-full-1.0.dylib")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(GSTREAMER_LIBNAME "gstreamer-full-1.0.dll")
else ()
message(FATAL_ERROR "Unhandled target OS: '${CMAKE_SYSTEM_NAME}'")
endif ()
function(JOIN VALUES GLUE OUTPUT)
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
file(RELATIVE_PATH RELATIVE_FFMPEG_DIR ${CMAKE_CURRENT_LIST_DIR}/subprojects/FFmpeg ${FFMPEG_DIR})
set(MESON_ARGS meson --prefix="${GSTREAMER_INSTALL_DIR}" -DFFmpeg:installpath="${RELATIVE_FFMPEG_DIR}" ${MESON_FLAGS})
JOIN("${C_ARGS}" " " C_ARGS_STR)
list(APPEND MESON_ARGS -Dc_args="${C_ARGS_STR}" -Dcpp_args="${C_ARGS_STR}")
if (LINK_ARGS)
JOIN("${LINK_ARGS}" " " LINK_ARGS_STR)
list(APPEND MESON_ARGS -Dc_link_args="${LINK_ARGS_STR}" -Dcpp_link_args="${LINK_ARGS_STR}")
endif ()
foreach(plugin ${DISABLED_PLUGINS})
list(APPEND MESON_ARGS -D${plugin}=disabled)
endforeach()
# Platform-specific args should be defined in platform toolchain
if (UL_GSTREAMER_ARGS)
list(APPEND MESON_ARGS ${UL_GSTREAMER_ARGS})
endif ()
list(APPEND MESON_ARGS ${GSTREAMER_BUILD_DIR})
add_custom_command(OUTPUT "${GSTREAMER_BUILD_DIR}/build.ninja"
COMMAND ${MESON_ARGS}
WORKING_DIRECTORY "${GSTREAMER_DIR}"
COMMENT "Configuring GStreamer."
)
add_custom_command(OUTPUT "${GSTREAMER_BUILD_DIR}/${GSTREAMER_LIBNAME}"
COMMAND ninja
DEPENDS "${GSTREAMER_BUILD_DIR}/build.ninja"
WORKING_DIRECTORY "${GSTREAMER_BUILD_DIR}"
COMMENT "Building GStreamer.")
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
# We need to copy intl.lib over on Windows to avoid an install error
file(TO_NATIVE_PATH "${GSTREAMER_DIR}/data/intl.lib" INTL_LIB_PATH)
file(TO_NATIVE_PATH "${GSTREAMER_BUILD_DIR}/subprojects/proxy-libintl/" INTL_LIB_DEST)
add_custom_command(OUTPUT "${GSTREAMER_BUILD_DIR}/copy_files.stamp"
COMMAND XCOPY /Q /Y "${INTL_LIB_PATH}" "${INTL_LIB_DEST}"
COMMAND ${CMAKE_COMMAND} -E touch copy_files.stamp
DEPENDS "${GSTREAMER_BUILD_DIR}/${GSTREAMER_LIBNAME}"
WORKING_DIRECTORY "${GSTREAMER_BUILD_DIR}"
COMMENT "Copying files."
VERBATIM)
else()
# Dummy build step
add_custom_command(OUTPUT "${GSTREAMER_BUILD_DIR}/copy_files.stamp"
COMMAND ${CMAKE_COMMAND} -E touch copy_files.stamp
DEPENDS "${GSTREAMER_BUILD_DIR}/${GSTREAMER_LIBNAME}"
WORKING_DIRECTORY "${GSTREAMER_BUILD_DIR}"
COMMENT "Copying files.")
endif()
add_custom_command(OUTPUT "${GSTREAMER_INSTALL_DIR}/include/gstreamer-1.0/gst/gst.h"
COMMAND ninja install
DEPENDS "${GSTREAMER_BUILD_DIR}/copy_files.stamp"
WORKING_DIRECTORY "${GSTREAMER_BUILD_DIR}"
COMMENT "Installing GStreamer.")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
# We need to update the rpath for our dynamic libraries
set(INSTALL_LIBPATH "${GSTREAMER_INSTALL_DIR}/lib/x86_64-linux-gnu")
add_custom_command(OUTPUT "${INSTALL_LIBPATH}/update_rpath.stamp"
COMMAND ${GSTREAMER_DIR}/update_rpath_linux.sh
COMMAND ${CMAKE_COMMAND} -E touch update_rpath.stamp
DEPENDS "${GSTREAMER_INSTALL_DIR}/include/gstreamer-1.0/gst/gst.h"
WORKING_DIRECTORY "${INSTALL_LIBPATH}"
COMMENT "Updating RPath.")
add_custom_target(GStreamer ALL DEPENDS "${INSTALL_LIBPATH}/update_rpath.stamp")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/include" DESTINATION ".")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/bin" DESTINATION ".")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/lib/x86_64-linux-gnu/" DESTINATION "./lib" FILES_MATCHING
PATTERN "*.so"
PATTERN "*.0"
PATTERN "*.3")
INSTALL(FILES "${GSTREAMER_INSTALL_DIR}/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h" DESTINATION "include/")
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
# We need to update the rpath for our dynamic libraries
set(INSTALL_LIBPATH "${GSTREAMER_INSTALL_DIR}/lib")
add_custom_command(OUTPUT "${INSTALL_LIBPATH}/update_rpath.stamp"
COMMAND ${GSTREAMER_DIR}/update_rpath_macos.sh
COMMAND ${CMAKE_COMMAND} -E touch update_rpath.stamp
DEPENDS "${GSTREAMER_INSTALL_DIR}/include/gstreamer-1.0/gst/gst.h"
WORKING_DIRECTORY "${INSTALL_LIBPATH}"
COMMENT "Updating RPath.")
add_custom_target(GStreamer ALL DEPENDS "${INSTALL_LIBPATH}/update_rpath.stamp")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/include" DESTINATION ".")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/bin" DESTINATION ".")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/lib" DESTINATION "." FILES_MATCHING PATTERN "*.dylib")
INSTALL(FILES "${GSTREAMER_INSTALL_DIR}/lib/glib-2.0/include/glibconfig.h" DESTINATION "include/")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_custom_target(GStreamer ALL DEPENDS "${GSTREAMER_INSTALL_DIR}/include/gstreamer-1.0/gst/gst.h")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/include" DESTINATION ".")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/bin" DESTINATION ".")
INSTALL(DIRECTORY "${GSTREAMER_INSTALL_DIR}/lib" DESTINATION "." FILES_MATCHING PATTERN "*.lib" PATTERN "*.dll")
INSTALL(FILES "${GSTREAMER_INSTALL_DIR}/lib/glib-2.0/include/glibconfig.h" DESTINATION "include/")
endif ()
add_dependencies(GStreamer FFmpegBin)
include(CreateSDK.cmake)