]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: add librtmp/rtmpdump option and detection
authorViktor Szakats <commit@vsz.me>
Mon, 15 Apr 2024 10:35:07 +0000 (10:35 +0000)
committerViktor Szakats <commit@vsz.me>
Tue, 16 Apr 2024 07:36:42 +0000 (09:36 +0200)
Add CMake option `USE_LIBRTMP`. Disabled by default.

This library requires OpenSSL TLS-backend when linked statically.

Follow-up to 6eb9e65781fa1fd8a0bcfe0715187a3a35f09ae4 #13364
Closes #13373

CMakeLists.txt

index d5c778bb047d6774023cf43769856eb2e1568175..21a6a365419392f0c4bf7a53eb1be9d32c541cae 100644 (file)
@@ -380,9 +380,6 @@ check_function_exists(gethostname HAVE_GETHOSTNAME)
 
 if(WIN32)
   list(APPEND CURL_LIBS "ws2_32" "bcrypt")
-  if(USE_LIBRTMP)
-    list(APPEND CURL_LIBS "winmm")
-  endif()
 endif()
 
 # check SSL libraries
@@ -603,8 +600,8 @@ if(CURL_ZSTD)
   endif()
 endif()
 
-# Check symbol in OpenSSL-like TLS backends.
-macro(openssl_check_symbol_exists SYMBOL FILES VARIABLE)
+# Check symbol in an OpenSSL-like TLS backend, or in EXTRA_LIBS depending on it.
+macro(openssl_check_symbol_exists SYMBOL FILES VARIABLE EXTRA_LIBS)
   cmake_push_check_state()
   if(USE_OPENSSL)
     set(CMAKE_REQUIRED_INCLUDES   "${OPENSSL_INCLUDE_DIR}")
@@ -628,6 +625,9 @@ macro(openssl_check_symbol_exists SYMBOL FILES VARIABLE)
     endif()
     list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_UINTPTR_T)  # to pull in stdint.h (as of wolfSSL v5.5.4)
   endif()
+  if(NOT "${EXTRA_LIBS}" STREQUAL "")
+    list(APPEND CMAKE_REQUIRED_LIBRARIES "${EXTRA_LIBS}")
+  endif()
   check_symbol_exists("${SYMBOL}" "${FILES}" "${VARIABLE}")
   cmake_pop_check_state()
 endmacro()
@@ -636,9 +636,9 @@ endmacro()
 macro(openssl_check_quic)
   if(NOT DEFINED HAVE_SSL_CTX_SET_QUIC_METHOD)
     if(USE_OPENSSL)
-      openssl_check_symbol_exists(SSL_CTX_set_quic_method "openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD)
+      openssl_check_symbol_exists(SSL_CTX_set_quic_method "openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD "")
     elseif(USE_WOLFSSL)
-      openssl_check_symbol_exists(wolfSSL_set_quic_method "wolfssl/options.h;wolfssl/openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD)
+      openssl_check_symbol_exists(wolfSSL_set_quic_method "wolfssl/options.h;wolfssl/openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD "")
     endif()
   endif()
   if(NOT HAVE_SSL_CTX_SET_QUIC_METHOD)
@@ -648,10 +648,10 @@ endmacro()
 
 if(USE_OPENSSL OR USE_WOLFSSL)
   if(NOT DEFINED HAVE_SSL_SET0_WBIO)
-    openssl_check_symbol_exists(SSL_set0_wbio "openssl/ssl.h" HAVE_SSL_SET0_WBIO)
+    openssl_check_symbol_exists(SSL_set0_wbio "openssl/ssl.h" HAVE_SSL_SET0_WBIO "")
   endif()
   if(NOT DEFINED HAVE_OPENSSL_SRP AND NOT CURL_DISABLE_SRP)
-    openssl_check_symbol_exists(SSL_CTX_set_srp_username "openssl/ssl.h" HAVE_OPENSSL_SRP)
+    openssl_check_symbol_exists(SSL_CTX_set_srp_username "openssl/ssl.h" HAVE_OPENSSL_SRP "")
   endif()
 endif()
 
@@ -1004,6 +1004,26 @@ if(CURL_USE_GSSAPI)
   endif()
 endif()
 
+option(USE_LIBRTMP "Enable librtmp from rtmpdump" OFF)
+if(USE_LIBRTMP)
+  cmake_push_check_state()
+  set(_extra_libs "rtmp")
+  if(WIN32)
+    list(APPEND _extra_libs "winmm")
+  endif()
+  openssl_check_symbol_exists("RTMP_Init" "librtmp/rtmp.h" HAVE_LIBRTMP "${_extra_libs}")
+  cmake_pop_check_state()
+  if(HAVE_LIBRTMP)
+    list(APPEND CURL_LIBS "rtmp")
+    if(WIN32)
+      list(APPEND CURL_LIBS "winmm")
+    endif()
+  else()
+    message(WARNING "librtmp requested, but not found or missing OpenSSL. Skipping.")
+    set(USE_LIBRTMP OFF)
+  endif()
+endif()
+
 option(ENABLE_UNIX_SOCKETS "Define if you want Unix domain sockets support" ON)
 if(ENABLE_UNIX_SOCKETS)
   include(CheckStructHasMember)