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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
|
# OpenSSL
set(TG_OWT_OPENSSL_INCLUDE_PATH "" CACHE STRING "Include path for openssl.")
function(link_openssl target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(OpenSSL REQUIRED)
target_include_directories(${target_name} PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(${target_name} PRIVATE ${OPENSSL_LIBRARIES})
else()
if (TG_OWT_OPENSSL_INCLUDE_PATH STREQUAL "")
message(FATAL_ERROR "You should specify 'TG_OWT_OPENSSL_INCLUDE_PATH'.")
endif()
target_include_directories(${target_name}
PRIVATE
${TG_OWT_OPENSSL_INCLUDE_PATH}
)
endif()
endfunction()
# Opus
set(TG_OWT_OPUS_INCLUDE_PATH "" CACHE STRING "Include path for opus.")
function(link_opus target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(OPUS REQUIRED opus)
target_include_directories(${target_name} PRIVATE ${OPUS_INCLUDE_DIRS})
target_link_libraries(${target_name} PRIVATE ${OPUS_LINK_LIBRARIES})
else()
if (TG_OWT_OPUS_INCLUDE_PATH STREQUAL "")
message(FATAL_ERROR "You should specify 'TG_OWT_OPUS_INCLUDE_PATH'.")
endif()
target_include_directories(${target_name}
PRIVATE
${TG_OWT_OPUS_INCLUDE_PATH}
)
endif()
endfunction()
# FFmpeg
set(TG_OWT_FFMPEG_INCLUDE_PATH "" CACHE STRING "Include path for ffmpeg.")
option(TG_OWT_PACKAGED_BUILD_FFMPEG_STATIC "Link ffmpeg statically in packaged mode." OFF)
function(link_ffmpeg target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED libavcodec)
pkg_check_modules(AVFORMAT REQUIRED libavformat)
pkg_check_modules(AVUTIL REQUIRED libavutil)
pkg_check_modules(SWSCALE REQUIRED libswscale)
pkg_check_modules(SWRESAMPLE REQUIRED libswresample)
target_include_directories(${target_name} PRIVATE
${AVCODEC_INCLUDE_DIRS}
${AVFORMAT_INCLUDE_DIRS}
${AVUTIL_INCLUDE_DIRS}
${SWSCALE_INCLUDE_DIRS}
${SWRESAMPLE_INCLUDE_DIRS}
)
if (TG_OWT_PACKAGED_BUILD_FFMPEG_STATIC)
target_link_libraries(${target_name}
PRIVATE
${AVCODEC_STATIC_LINK_LIBRARIES}
${AVFORMAT_STATIC_LINK_LIBRARIES}
${AVUTIL_STATIC_LINK_LIBRARIES}
${SWSCALE_STATIC_LINK_LIBRARIES}
${SWRESAMPLE_STATIC_LINK_LIBRARIES}
)
else()
target_link_libraries(${target_name}
PRIVATE
${AVCODEC_LINK_LIBRARIES}
${AVFORMAT_LINK_LIBRARIES}
${AVUTIL_LINK_LIBRARIES}
${SWSCALE_LINK_LIBRARIES}
${SWRESAMPLE_LINK_LIBRARIES}
)
endif()
else()
if (TG_OWT_FFMPEG_INCLUDE_PATH STREQUAL "")
message(FATAL_ERROR "You should specify 'TG_OWT_FFMPEG_INCLUDE_PATH'.")
endif()
target_include_directories(${target_name}
PRIVATE
${TG_OWT_FFMPEG_INCLUDE_PATH}
)
endif()
endfunction()
# libjpeg
set(TG_OWT_LIBJPEG_INCLUDE_PATH "" CACHE STRING "Include path for libjpeg.")
function(link_libjpeg target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(JPEG REQUIRED)
target_include_directories(${target_name} PRIVATE ${JPEG_INCLUDE_DIRS})
target_link_libraries(${target_name} PRIVATE ${JPEG_LIBRARIES})
else()
if (TG_OWT_LIBJPEG_INCLUDE_PATH STREQUAL "")
message(FATAL_ERROR "You should specify 'TG_OWT_LIBJPEG_INCLUDE_PATH'.")
endif()
target_include_directories(${target_name}
PRIVATE
${TG_OWT_LIBJPEG_INCLUDE_PATH}
${TG_OWT_LIBJPEG_INCLUDE_PATH}/src
)
endif()
endfunction()
# libabsl
# HINT: System abseil should be built with -DCMAKE_CXX_STANDARD=17
function(link_libabsl target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(absl)
set(absl_FOUND ${absl_FOUND} PARENT_SCOPE)
if (absl_FOUND)
target_link_libraries(${target_name} INTERFACE absl::strings)
endif()
endif()
if (NOT absl_FOUND)
target_link_libraries(${target_name} PRIVATE tg_owt::libabsl)
endif()
endfunction()
# libopenh264
function(link_libopenh264 target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBOPENH264 openh264)
set(LIBOPENH264_FOUND ${LIBOPENH264_FOUND} PARENT_SCOPE)
if (LIBOPENH264_FOUND)
target_link_libraries(${target_name} PRIVATE ${LIBOPENH264_LIBRARIES})
target_include_directories(${target_name} PRIVATE ${LIBOPENH264_INCLUDE_DIRS})
endif()
endif()
if (NOT LIBOPENH264_FOUND)
target_link_libraries(${target_name} PRIVATE tg_owt::libopenh264)
target_include_directories(${target_name} PRIVATE ${libopenh264_loc}/include)
endif()
endfunction()
# libusrsctp
function(link_libusrsctp target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUSRSCTP usrsctp)
set(LIBUSRSCTP_FOUND ${LIBUSRSCTP_FOUND} PARENT_SCOPE)
if (LIBUSRSCTP_FOUND)
target_link_libraries(${target_name} PRIVATE ${LIBUSRSCTP_LIBRARIES})
target_include_directories(${target_name} PRIVATE ${LIBUSRSCTP_INCLUDE_DIRS})
endif()
endif()
if (NOT LIBUSRSCTP_FOUND)
target_link_libraries(${target_name} PRIVATE tg_owt::libusrsctp)
endif()
endfunction()
# libvpx
function(link_libvpx target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBVPX vpx>=1.10.0)
set(LIBVPX_FOUND ${LIBVPX_FOUND} PARENT_SCOPE)
if (LIBVPX_FOUND)
target_link_libraries(${target_name} PRIVATE ${LIBVPX_LIBRARIES})
target_include_directories(${target_name} PRIVATE ${LIBVPX_INCLUDE_DIRS})
endif()
endif()
if (NOT LIBVPX_FOUND)
target_link_libraries(${target_name} PRIVATE tg_owt::libvpx)
if (is_x86 OR is_x64)
target_link_libraries(${target_name}
PRIVATE
tg_owt::libvpx_mmx
tg_owt::libvpx_sse2
tg_owt::libvpx_ssse3
tg_owt::libvpx_sse4
tg_owt::libvpx_avx
tg_owt::libvpx_avx2
)
endif()
endif()
endfunction()
# libevent
function(link_libevent target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBEVENT libevent)
set(LIBEVENT_FOUND ${LIBEVENT_FOUND} PARENT_SCOPE)
if (LIBEVENT_FOUND)
target_link_libraries(${target_name} PRIVATE ${LIBEVENT_LIBRARIES})
target_include_directories(${target_name} PRIVATE ${LIBEVENT_INCLUDE_DIRS})
endif()
endif()
if (NOT LIBEVENT_FOUND)
target_link_libraries(${target_name} PRIVATE tg_owt::libevent)
endif()
endfunction()
function(link_glib target_name)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GOBJECT REQUIRED gobject-2.0)
pkg_check_modules(GIO REQUIRED gio-2.0)
pkg_check_modules(GIO_UNIX REQUIRED gio-unix-2.0)
target_include_directories(${target_name}
PRIVATE
${GIO_UNIX_INCLUDE_DIRS}
${GIO_INCLUDE_DIRS}
${GOBJECT_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
)
if (TG_OWT_PACKAGED_BUILD)
target_link_libraries(${target_name}
PRIVATE
${GIO_UNIX_LINK_LIBRARIES}
${GIO_LINK_LIBRARIES}
${GOBJECT_LINK_LIBRARIES}
${GLIB2_LINK_LIBRARIES}
)
endif()
endfunction()
# x11
function(link_x11 target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(X11 REQUIRED COMPONENTS Xcomposite Xdamage Xext Xfixes Xrender Xrandr Xtst)
target_include_directories(${target_name}
PRIVATE
${X11_X11_INCLUDE_PATH}
${X11_Xlib_INCLUDE_PATH}
${X11_Xcomposite_INCLUDE_PATH}
${X11_Xdamage_INCLUDE_PATH}
${X11_Xext_INCLUDE_PATH}
${X11_Xfixes_INCLUDE_PATH}
${X11_Xrender_INCLUDE_PATH}
${X11_Xrandr_INCLUDE_PATH}
${X11_Xtst_INCLUDE_PATH}
)
target_link_libraries(${target_name}
PRIVATE
${X11_X11_LIB}
${X11_Xcomposite_LIB}
${X11_Xdamage_LIB}
${X11_Xext_LIB}
${X11_Xfixes_LIB}
${X11_Xrender_LIB}
${X11_Xrandr_LIB}
${X11_Xtst_LIB}
)
endif()
endfunction()
# PipeWire
function(link_pipewire target_name)
find_package(PkgConfig REQUIRED)
pkg_search_module(PIPEWIRE REQUIRED libpipewire-0.3 libpipewire-0.2)
target_include_directories(${target_name} PRIVATE ${PIPEWIRE_INCLUDE_DIRS})
target_link_libraries(${target_name} PRIVATE ${PIPEWIRE_LINK_LIBRARIES})
endfunction()
# Alsa
function(link_libalsa target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(ALSA REQUIRED)
target_include_directories(${target_name} PRIVATE ${ALSA_INCLUDE_DIRS})
endif()
endfunction()
# PulseAudio
function(link_libpulse target_name)
if (TG_OWT_PACKAGED_BUILD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PULSE REQUIRED libpulse)
target_include_directories(${target_name} PRIVATE ${PULSE_INCLUDE_DIRS})
endif()
endfunction()
# dl
function(link_dl target_name)
if (TG_OWT_PACKAGED_BUILD)
target_link_libraries(${target_name} PRIVATE ${CMAKE_DL_LIBS})
endif()
endfunction()
|