| 1 |
#*************************************************************************** |
| 2 |
# _ _ ____ _ |
| 3 |
# Project ___| | | | _ \| | |
| 4 |
# / __| | | | |_) | | |
| 5 |
# | (__| |_| | _ <| |___ |
| 6 |
# \___|\___/|_| \_\_____| |
| 7 |
# |
| 8 |
# Copyright (C) Daniel Stenberg, <[email protected]>, et al. |
| 9 |
# |
| 10 |
# This software is licensed as described in the file COPYING, which |
| 11 |
# you should have received as part of this distribution. The terms |
| 12 |
# are also available at https://curl.se/docs/copyright.html. |
| 13 |
# |
| 14 |
# You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 15 |
# copies of the Software, and permit persons to whom the Software is |
| 16 |
# furnished to do so, under the terms of the COPYING file. |
| 17 |
# |
| 18 |
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 |
# KIND, either express or implied. |
| 20 |
# |
| 21 |
# SPDX-License-Identifier: curl |
| 22 |
# |
| 23 |
########################################################################### |
| 24 |
# Find the librtmp library |
| 25 |
# |
| 26 |
# Input variables: |
| 27 |
# |
| 28 |
# - `LIBRTMP_INCLUDE_DIR`: The librtmp include directory. |
| 29 |
# - `LIBRTMP_LIBRARY`: Path to `librtmp` library. |
| 30 |
# |
| 31 |
# Result variables: |
| 32 |
# |
| 33 |
# - `LIBRTMP_FOUND`: System has librtmp. |
| 34 |
# - `LIBRTMP_INCLUDE_DIRS`: The librtmp include directories. |
| 35 |
# - `LIBRTMP_LIBRARIES`: The librtmp library names. |
| 36 |
# - `LIBRTMP_LIBRARY_DIRS`: The librtmp library directories. |
| 37 |
# - `LIBRTMP_PC_REQUIRES`: The librtmp pkg-config packages. |
| 38 |
# - `LIBRTMP_CFLAGS`: Required compiler flags. |
| 39 |
# - `LIBRTMP_VERSION`: Version of librtmp. |
| 40 |
|
| 41 |
set(LIBRTMP_PC_REQUIRES "librtmp") |
| 42 |
|
| 43 |
if(CURL_USE_PKGCONFIG AND |
| 44 |
NOT DEFINED LIBRTMP_INCLUDE_DIR AND |
| 45 |
NOT DEFINED LIBRTMP_LIBRARY) |
| 46 |
find_package(PkgConfig QUIET) |
| 47 |
pkg_check_modules(LIBRTMP ${LIBRTMP_PC_REQUIRES}) |
| 48 |
endif() |
| 49 |
|
| 50 |
if(LIBRTMP_FOUND AND LIBRTMP_INCLUDE_DIRS) |
| 51 |
set(Librtmp_FOUND TRUE) |
| 52 |
string(REPLACE ";" " " LIBRTMP_CFLAGS "${LIBRTMP_CFLAGS}") |
| 53 |
message(STATUS "Found Librtmp (via pkg-config): ${LIBRTMP_INCLUDE_DIRS} (found version \"${LIBRTMP_VERSION}\")") |
| 54 |
else() |
| 55 |
find_path(LIBRTMP_INCLUDE_DIR NAMES "librtmp/rtmp.h") |
| 56 |
find_library(LIBRTMP_LIBRARY NAMES "rtmp") |
| 57 |
|
| 58 |
unset(LIBRTMP_VERSION CACHE) |
| 59 |
if(LIBRTMP_INCLUDE_DIR AND EXISTS "${LIBRTMP_INCLUDE_DIR}/librtmp/rtmp.h") |
| 60 |
set(_version_regex "#[\t ]*define[\t ]+RTMP_LIB_VERSION[\t ]+0x([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F]).*") |
| 61 |
file(STRINGS "${LIBRTMP_INCLUDE_DIR}/librtmp/rtmp.h" _version_str REGEX "${_version_regex}") |
| 62 |
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str1 "${_version_str}") |
| 63 |
string(REGEX REPLACE "${_version_regex}" "\\2" _version_str2 "${_version_str}") |
| 64 |
if(CMAKE_VERSION VERSION_LESS 3.13) |
| 65 |
# No support for hex version numbers, just strip leading zeroes |
| 66 |
string(REGEX REPLACE "^0" "" _version_str1 "${_version_str1}") |
| 67 |
string(REGEX REPLACE "^0" "" _version_str2 "${_version_str2}") |
| 68 |
else() |
| 69 |
math(EXPR _version_str1 "0x${_version_str1}" OUTPUT_FORMAT DECIMAL) |
| 70 |
math(EXPR _version_str2 "0x${_version_str2}" OUTPUT_FORMAT DECIMAL) |
| 71 |
endif() |
| 72 |
set(LIBRTMP_VERSION "${_version_str1}.${_version_str2}") |
| 73 |
unset(_version_regex) |
| 74 |
unset(_version_str1) |
| 75 |
unset(_version_str2) |
| 76 |
endif() |
| 77 |
|
| 78 |
include(FindPackageHandleStandardArgs) |
| 79 |
find_package_handle_standard_args(Librtmp |
| 80 |
REQUIRED_VARS |
| 81 |
LIBRTMP_INCLUDE_DIR |
| 82 |
LIBRTMP_LIBRARY |
| 83 |
VERSION_VAR |
| 84 |
LIBRTMP_VERSION |
| 85 |
) |
| 86 |
|
| 87 |
if(LIBRTMP_FOUND) |
| 88 |
set(LIBRTMP_INCLUDE_DIRS ${LIBRTMP_INCLUDE_DIR}) |
| 89 |
set(LIBRTMP_LIBRARIES ${LIBRTMP_LIBRARY}) |
| 90 |
endif() |
| 91 |
|
| 92 |
mark_as_advanced(LIBRTMP_INCLUDE_DIR LIBRTMP_LIBRARY) |
| 93 |
|
| 94 |
# Necessary when linking a static librtmp |
| 95 |
find_package(OpenSSL) |
| 96 |
if(OPENSSL_FOUND) |
| 97 |
list(APPEND LIBRTMP_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) |
| 98 |
endif() |
| 99 |
endif() |
| 100 |
|
| 101 |
if(LIBRTMP_FOUND AND WIN32) |
| 102 |
list(APPEND LIBRTMP_LIBRARIES "winmm") |
| 103 |
endif() |