Compare commits

..

5 commits

Author SHA1 Message Date
Martin Müllenhaupt
6cb6c5161b add fakeaudio device 2017-02-16 13:49:51 +01:00
Martin Müllenhaupt
92847e8f47 appveyor disable tests 2017-02-16 10:56:52 +01:00
Martin Müllenhaupt
6b8be19839 appveyor build 32 bit including test stuff 2017-02-16 09:59:57 +01:00
Martin Müllenhaupt
ce4951a956 change libobject collection 2017-02-16 09:59:57 +01:00
Martin Mllenhaupt
3a390b5f25 adjust build package to match node-webrtc 2017-02-16 09:59:53 +01:00
37 changed files with 1014 additions and 782 deletions

10
.gitignore vendored
View file

@ -1,4 +1,6 @@
.idea
cmake-build-*
webrtc
depot_tools
.DS_Store
/out/
/.idea/
*.gclient
*.gclient_entries
/cmake-build-debug/

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "depot_tools"]
path = depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git

60
.travis.yml Normal file
View file

@ -0,0 +1,60 @@
matrix:
include:
- os: linux
sudo: required
- os: osx
osx_image: xcode7.3
language: cpp
addons:
apt:
packages:
- build-essential
- libglib2.0-dev
- libgtk2.0-dev
- libxtst-dev
- libxss-dev
- libpci-dev
- libdbus-1-dev
- libgconf2-dev
- libgnome-keyring-dev
- libnss3-dev
- libasound2-dev
- libpulse-dev
- libudev-dev
before_install:
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz"
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
else
if ! brew ls --version cmake &>/dev/null; then brew update && brew install cmake; fi
fi
- cd ${TRAVIS_BUILD_DIR}
- cmake --version
install:
- git submodule init
- git submodule update
- mkdir out
- cd out
- cmake -DNINJA_ARGS="-j 4" ..
script:
- make package
deploy:
provider: releases
api_key:
secure: UazaqOOoifs5xE/xw+tjVnFAkl6MMJeZSW7B0DXX0wnHorKM5K72q9Ms3JYvJIp6DDV3vIeX/Yv/WQCnfRkDDhcbLohGZoOj2X3q53RSfJiOq/iIyPiPTRmkk3jQRBOvXl5zLePNaXU2vBuSgcM8az+wGjxaDLUB+EebSGRHPbXrGSnDDHaNnmb4Zm7SZ2DpL5ubRDlLTHst7Jh7OigrIblYKNCzwEc7UQsFNzLnu7dyZT4hF2Y+2KYl/3vUUkUGxu0AxVG7zilnjJE7O5gX76r+SQXs151uWwZeH41NNPxRSod51LKQS/V/I4afjjTaYC5+9lSUdNkOpEGrxU+61hSJvNGxL6rTqfiBTAOiJdMR3u4OmF+B72O0nUUpsNtlkSPBK9402Z65LH/UI2BIJ/oMfkjNSzTNTHvB+n+18nFryzUmgEJ4CEy7Yx5HGO1vXCP4OsHGAu5YCkDGV2uVttiYHlm2qWgTY59cQt61h1saQWMwj6Uivhz8XrS86K0r/YAS30t+7+/xG6dneXgctM9oYjIbVCFnImsE30FpWlCJvGnJzo37wctbTQscHs5iuqjt1an7AhQgOTMQwmtyyg32D6N9e4n+RJA9pEj3Qtpi51LVD1cdCahbZ1l4bURlNueqfB3d4oZvr9o/QNjm+qH/FRUWjAmWtbBr16ZXfiA=
file: libwebrtc-$TRAVIS_TAG-linux-x64.tar.gz
skip_cleanup: true
overwrite: true
on:
tags: true
repo: aisouard/libwebrtc

View file

@ -1,53 +0,0 @@
# Changelog
## Version 1.1
*TBD*
[View Issues][v1.1-issues]
**Features:**
- Added `BUILD_TESTS` CMake configuration variable
## Version 1.0
*March 27, 2017*
[View Issues][v1.0-issues]
**Features:**
- Using CMake version 3.3
- Installs LibWebRTC as a CMake package
- Support for `gn`-based releases
- Synchronize depot_tools with WebRTC's commit date
- `TARGET_OS` and `TARGET_CPU` CMake config variables
- `WEBRTC_REVISION` and `WEBRTC_BRANCH_HEAD` CMake config variables
- x86 support under Windows
- Better host OS and CPU architecture detection
- pkg-config file generation
- Deprecated shared library support
- Debug mode support
- .zip package for Windows, .tar.gz for Unix
- Basic .deb and .rpm package generation
**Fixes:**
- Removed package.json and Jake support, focusing on CMake only
- Refactored source code, removed Targets folder
- Run commands with `cmake -E env`, no more Prefix File Trick
- No more `merge_libs.py` call, use CMake to create the library
- Removed the peer connection sample, wrote a little executable for tests
- Removed FindLibWebRTC.cmake, defined CMake package files
- Removed depot_tools git submodule
- Retrieve the Linux sysroot before calling the generator
- Removed support for releases older than January 1st, 2017 for now
- Removed libwebrtc-chromium-deps repository
- Wrote libwebrtc_execute macro
- Created uninstall target
- Removed BUILD_TESTS flag for now
- Fixed static linking
[v1.1-issues]:https://github.com/aisouard/libwebrtc/milestone/1
[v1.0-issues]:https://github.com/aisouard/libwebrtc/milestone/1

View file

@ -1,46 +1,17 @@
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
cmake_minimum_required(VERSION 3.3)
project(libwebrtc)
set(USE_CLANG ON CACHE BOOL "Build using internal Clang compiler (set to OFF to build using system GCC/MSVC)")
set(GN_EXTRA_ARGS "" CACHE STRING "Extra 'gn gen' arguments to pass when configuring WebRTC")
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass when compiling WebRTC")
option(BUILD_DEB_PACKAGE "Build .deb package" OFF)
#
# Allow the use of IN_LIST operand
cmake_policy(SET CMP0057 NEW)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/CMakeModules)
include(FindLibraries)
include(Version)
include(Options)
include(TargetOsAndCpu)
include(Utils)
prependPath("${CMAKE_SOURCE_DIR}/depot_tools")
if (WIN32)
set(ENV{DEPOT_TOOLS_WIN_TOOLCHAIN} 0)
endif()
set(WEBRTC_SOURCE_DIR "${CMAKE_SOURCE_DIR}/webrtc/src")
set(WEBRTC_BUILD_DIR "${CMAKE_BINARY_DIR}/webrtc")
include(Version)
get_webrtc_version_from_git(WEBRTC_VERSION)
message(STATUS "WebRTC version: ${WEBRTC_VERSION}")
if (MSVC)
# Always build with dynamic runtime on MSVC
patch_file(${WEBRTC_SOURCE_DIR}/build/config/win/BUILD.gn ":static_crt" ":dynamic_crt")
endif ()
# Copy all files from 'patches' directory to 'webrtc/src'
# For example, 'patches/api/foo.h' will be copied to 'webrtc/src/api/foo.h'
include(PatchSources)
patch_sources("${CMAKE_CURRENT_SOURCE_DIR}/patches" "${CMAKE_CURRENT_SOURCE_DIR}/webrtc/src")
include(AddWebRTCTarget)
add_webrtc_target(${WEBRTC_SOURCE_DIR} ${WEBRTC_BUILD_DIR})
add_subdirectory(libwebrtc)
add_subdirectory(Targets)
export(PACKAGE LibWebRTC)

View file

@ -0,0 +1,16 @@
find_program(DEPOTTOOLS_GCLIENT_EXECUTABLE
NAMES gclient gclient.bat
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/depot_tools)
find_path(DEPOTTOOLS_PATH
NAMES gclient gclient.py gclient.bat
gn gn.py gn.bat
ninja ninja.exe ninja-linux32 ninja-linux64 ninja-mac
download_from_google_storage download_from_google_storage.bat
download_from_google_storage.py
HINTS ${CMAKE_CURRENT_SOURCE_DIR}/depot_tools)
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(DepotTools
REQUIRED_VARS DEPOTTOOLS_GCLIENT_EXECUTABLE
FAIL_MESSAGE "Could not find the gclient executable.")

View file

@ -1,17 +1,21 @@
#
# Find required packages
find_package(Git REQUIRED)
find_package(DepotTools REQUIRED)
if (WIN32)
set(PYTHON_EXECUTABLE ${DEPOTTOOLS_PATH}/python.bat)
else (WIN32)
find_package(PythonInterp REQUIRED)
endif (WIN32)
list(APPEND LIBWEBRTC_LIBRARIES webrtc)
if (UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
list(APPEND LIBWEBRTC_LIBRARIES ${X11_LIBRARIES} ${CMAKE_DL_LIBS} rt)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if (CMAKE_HAVE_THREADS_LIBRARY)
list(APPEND LIBWEBRTC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif ()
endif ()
list(APPEND LIBWEBRTC_LIBRARIES ${X11_LIBRARIES} ${CMAKE_DL_LIBS})
endif (UNIX AND NOT APPLE)
if (APPLE)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
@ -22,9 +26,9 @@ if (APPLE)
list(APPEND LIBWEBRTC_LIBRARIES ${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY})
endif ()
endif (APPLE)
if (WIN32)
list(APPEND LIBWEBRTC_LIBRARIES msdmo.lib wmcodecdspuuid.lib dmoguids.lib
crypt32.lib iphlpapi.lib ole32.lib secur32.lib winmm.lib ws2_32.lib)
endif ()
ole32.lib secur32.lib winmm.lib ws2_32.lib)
endif (WIN32)

View file

@ -0,0 +1,25 @@
#
# Retrieve WebRTC source code
#
file(WRITE ${CMAKE_BINARY_DIR}/.gclient "solutions = [
{
\"url\": \"https://chromium.googlesource.com/external/webrtc.git\",
\"managed\": False,
\"name\": \"src\",
\"deps_file\": \"DEPS\",
\"custom_deps\": {},
},
]
")
if (TARGET_OS STREQUAL "android")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"android\", \"unix\"]")
elseif (TARGET_OS STREQUAL "ios")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"ios\", \"mac\"]")
elseif (TARGET_OS STREQUAL "linux")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"unix\"]")
elseif (TARGET_OS STREQUAL "mac")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"mac\"]")
elseif (TARGET_OS STREQUAL "win")
file(APPEND ${CMAKE_BINARY_DIR}/.gclient "target_os = [\"win\"]")
endif (TARGET_OS STREQUAL "android")

View file

@ -0,0 +1,98 @@
#
# Install library
file(GLOB_RECURSE _LIBRARY_FILES
${CMAKE_BINARY_DIR}/lib/*${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/lib/*${CMAKE_STATIC_LIBRARY_SUFFIX})
install(FILES ${_LIBRARY_FILES}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT lib)
#
# Install headers
install(DIRECTORY "${CMAKE_BINARY_DIR}/include/"
DESTINATION ${INSTALL_INCLUDE_DIR}
COMPONENT include
FILES_MATCHING PATTERN "*.h")
#
# Install CMake Config file
configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTCConfig.cmake.in
${CMAKE_BINARY_DIR}/LibWebRTCConfig.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/LibWebRTCConfig.cmake
DESTINATION ${INSTALL_CMAKE_DIR}
COMPONENT cmake)
#
# Install CMake ConfigVersion file
configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTCConfigVersion.cmake.in
${CMAKE_BINARY_DIR}/LibWebRTCConfigVersion.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/LibWebRTCConfigVersion.cmake
DESTINATION ${INSTALL_CMAKE_DIR}
COMPONENT cmake)
#
# Install pkg-config file
if (UNIX)
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "${INSTALL_LIB_DIR}")
set(includedir "${INSTALL_INCLUDE_DIR}")
set(LIBWEBRTC_PC_LIBS "-L${INSTALL_LIB_DIR}" "-lwebrtc")
foreach(LIB_NAME ${LIBWEBRTC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
if (LIB_NAME MATCHES "[\\/]")
get_filename_component(LIB_DIR "${LIB_NAME}" PATH)
get_filename_component(LIB_NAME "${LIB_NAME}" NAME_WE)
string(REGEX REPLACE "^lib(.*)" "-l\\1" LIB_NAME "${LIB_NAME}")
if (NOT ${LIB_DIR} IN_LIST LIB_DIRS)
list(APPEND LIB_DIRS ${LIB_DIR})
list(APPEND LIBWEBRTC_PC_LIBS_PRIVATE "-L${LIB_DIR}")
endif (NOT ${LIB_DIR} IN_LIST LIB_DIRS)
elseif (NOT LIB_NAME MATCHES "^-l")
set(LIB_NAME "-l${LIB_NAME}")
endif ()
list(APPEND LIBWEBRTC_PC_LIBS_PRIVATE "${LIB_NAME}")
endforeach(LIB_NAME ${LIBWEBRTC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
foreach(DEFINITION ${LIBWEBRTC_DEFINITIONS})
list(APPEND LIBWEBRTC_PC_DEFINITIONS "-D${DEFINITION}")
endforeach(DEFINITION ${LIBWEBRTC_DEFINITIONS})
list(REMOVE_ITEM LIBWEBRTC_PC_LIBS_PRIVATE "-lwebrtc")
string(REPLACE ";" " " LIBWEBRTC_PC_DEFINITIONS "${LIBWEBRTC_PC_DEFINITIONS}")
string(REPLACE ";" " " LIBWEBRTC_PC_LIBS "${LIBWEBRTC_PC_LIBS}")
string(REPLACE ";" " " LIBWEBRTC_PC_LIBS_PRIVATE "${LIBWEBRTC_PC_LIBS_PRIVATE}")
string(REPLACE ";" " " LIBWEBRTC_PC_CXXFLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS}")
configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTC.pc.in
${CMAKE_BINARY_DIR}/LibWebRTC.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/LibWebRTC.pc
DESTINATION ${INSTALL_PKGCONFIG_DIR}
COMPONENT cmake)
endif (UNIX)
#
# Install CMake Use file
install(FILES ${CMAKE_MODULE_PATH}/Templates/UseLibWebRTC.cmake
DESTINATION ${INSTALL_CMAKE_DIR}
COMPONENT cmake)
#
# Install CMake Targets file
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/cmake/LibWebRTC/"
DESTINATION ${INSTALL_CMAKE_DIR}
COMPONENT cmake
FILES_MATCHING PATTERN "*.cmake")
#
# Add uninstall target
configure_file(
"${CMAKE_MODULE_PATH}/Templates/Uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/Uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/Uninstall.cmake)

View file

@ -0,0 +1,23 @@
include(CMakeParseArguments)
include(Prefix)
function(libwebrtc_command)
set(ONE_VALUE_ARGS NAME COMMENT DEPENDS WORKING_DIRECTORY)
set(MULTI_VALUE_ARGS COMMAND)
cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} )
set(CMF_DIR ${CMAKE_BINARY_DIR}/CMakeFiles)
set(STAMP_FILE "${CMF_DIR}/${COMMAND_NAME}-complete")
add_custom_command(
OUTPUT ${STAMP_FILE}
COMMENT ${COMMAND_COMMENT}
COMMAND ${PREFIX_EXECUTE} ${COMMAND_COMMAND}
COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_FILE}
WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY}
)
add_custom_target(${COMMAND_NAME} ALL DEPENDS ${STAMP_FILE})
add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS})
endfunction()

View file

@ -0,0 +1,35 @@
#
# Options, flags
option(BUILD_TESTS "Build test binaries" OFF)
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC")
option(BUILD_SHARED_LIB "Build WebRTC as a shared library." OFF)
if(BUILD_SHARED_LIB)
set(LIBRARY_TYPE SHARED)
else()
set(LIBRARY_TYPE STATIC)
endif()
#
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
set(INSTALL_CMAKE_DIR lib/cmake/LibWebRTC CACHE PATH "Installation directory for CMake files")
if (UNIX)
set(INSTALL_PKGCONFIG_DIR lib/pkgconfig CACHE PATH "Installation directory for pkg-config script")
if (NOT APPLE)
option(BUILD_DEB_PACKAGE "Build Debian .deb package" OFF)
option(BUILD_RPM_PACKAGE "Build Red Hat .rpm package" OFF)
endif (NOT APPLE)
endif (UNIX)
#
# Make relative paths absolute (needed later on)
foreach(p LIB BIN INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()

View file

@ -0,0 +1,79 @@
#
# Create package
set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${TARGET_OS}-${TARGET_CPU}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "WebRTC in a single static library")
set(CPACK_PACKAGE_DESCRIPTION "Google's native WebRTC implementation shipped into a single library")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_NAME "LibWebRTC")
set(CPACK_PACKAGE_VERSION "${LIBWEBRTC_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${LIBWEBRTC_MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${LIBWEBRTC_MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${LIBWEBRTC_PATCH_VERSION}")
set(CPACK_PACKAGE_VENDOR "Axel Isouard")
set(CPACK_PACKAGE_CONTACT "axel@isouard.fr")
if (WIN32)
set(CPACK_GENERATOR "ZIP")
else (WIN32)
set(CPACK_GENERATOR "TGZ")
endif (WIN32)
if (UNIX AND NOT APPLE)
if (TARGET_CPU STREQUAL "x86")
set(_RPM_ARCH "i686")
set(_DEB_ARCH "i386")
elseif (TARGET_CPU STREQUAL "x64")
set(_RPM_ARCH "x86_64")
set(_DEB_ARCH "amd64")
elseif (TARGET_CPU STREQUAL "arm")
set(_RPM_ARCH "armhf")
set(_DEB_ARCH "armhf")
elseif (TARGET_CPU STREQUAL "arm64")
set(_RPM_ARCH "aarch64")
set(_DEB_ARCH "arm64")
else ()
set(_RPM_ARCH ${CMAKE_SYSTEM_PROCESSOR})
set(_DEB_ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif ()
set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}")
if (CPACK_GENERATOR STREQUAL "RPM")
set(_PACKAGE_ARCH ${_RPM_ARCH})
elseif (CPACK_GENERATOR STREQUAL "DEB")
set(_PACKAGE_ARCH ${_DEB_ARCH})
else ()
set(_PACKAGE_ARCH ${TARGET_CPU})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${TARGET_OS}")
endif ()
if (BUILD_DEB_PACKAGE)
set(CPACK_DEB_COMPONENT_INSTALL FALSE)
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://axel.isouard.fr/libwebrtc")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE)
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
endif (BUILD_DEB_PACKAGE)
if (BUILD_RPM_PACKAGE)
set(CPACK_RPM_COMPONENT_INSTALL FALSE)
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
set(CPACK_RPM_PACKAGE_URL "https://axel.isouard.fr/libwebrtc")
set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0")
set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
endif (BUILD_RPM_PACKAGE)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${_PACKAGE_ARCH}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${_PACKAGE_ARCH}")
endif (UNIX AND NOT APPLE)
set(CPACK_INSTALL_CMAKE_PROJECTS
"${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR}/libwebrtc;libwebrtc;ALL;/")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "libwebrtc")
include(CPack)

49
CMakeModules/Prefix.cmake Normal file
View file

@ -0,0 +1,49 @@
#
# Generate environment variables
#
set(WEBRTC_PATH ${CMAKE_SOURCE_DIR}/depot_tools)
if (WIN32)
get_filename_component(DEPOT_TOOLS_PYTHON_PATH
"${WEBRTC_PATH}/python276_bin"
REALPATH)
list(APPEND WEBRTC_PATH ${DEPOT_TOOLS_PYTHON_PATH})
endif (WIN32)
list(APPEND WEBRTC_PATH $ENV{PATH})
if (WIN32)
string(REGEX REPLACE "/" "\\\\" WEBRTC_PATH "${WEBRTC_PATH}")
string(REGEX REPLACE ";" "\\\;" WEBRTC_PATH "${WEBRTC_PATH}")
else (WIN32)
string(REGEX REPLACE ";" ":" WEBRTC_PATH "${WEBRTC_PATH}")
endif (WIN32)
get_filename_component(CHROMIUM_PYTHONPATH
"${CMAKE_BINARY_DIR}/src/build"
REALPATH)
if (WIN32)
set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.bat)
set(PREFIX_COMMAND set)
set(PREFIX_HEADER "@ECHO OFF")
set(PREFIX_EVAL "%*")
set(PREFIX_EXECUTE cmd /c ${PREFIX_FILENAME})
set(PREFIX_NEWLINE \r\n)
else (WIN32)
set(PREFIX_FILENAME ${CMAKE_BINARY_DIR}/prefix.sh)
set(PREFIX_COMMAND export)
set(PREFIX_HEADER "")
set(PREFIX_EVAL eval\ $@)
set(PREFIX_EXECUTE /bin/sh ${PREFIX_FILENAME})
set(PREFIX_NEWLINE \n)
endif (WIN32)
file(WRITE ${PREFIX_FILENAME} "${PREFIX_HEADER}
${PREFIX_COMMAND} PATH=${WEBRTC_PATH}
${PREFIX_COMMAND} PYTHONPATH=${CHROMIUM_PYTHONPATH}
${PREFIX_COMMAND} DEPOT_TOOLS_WIN_TOOLCHAIN=0
${PREFIX_COMMAND} DEPOT_TOOLS_UPDATE=0
${PREFIX_COMMAND} CHROME_HEADLESS=1
${PREFIX_EVAL}
")

View file

@ -1,5 +1,6 @@
include(CheckSymbolExists)
#
# Target OS
set(TARGET_OS "" CACHE STRING "Target OS, used as --target_os argument")
set(TARGET_OS_LIST android chromeos ios linux nacl mac win)
@ -12,29 +13,30 @@ if (TARGET_OS STREQUAL "")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(TARGET_OS "win")
endif ()
endif ()
endif (TARGET_OS STREQUAL "")
if (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST)
message(FATAL_ERROR "Unknown value '${TARGET_OS}' for variable TARGET_OS, options are: ${TARGET_OS_LIST}")
endif ()
endif (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST)
#
# Target CPU
function(detect_current_arch)
if (WIN32)
check_symbol_exists("_M_X64" "" ARCH_X64)
if (NOT ARCH_X64)
check_symbol_exists("_M_AMD64" "" ARCH_X64)
endif ()
endif (NOT ARCH_X64)
check_symbol_exists("_M_IX86" "" ARCH_X86)
check_symbol_exists("_M_ARM" "" ARCH_ARM)
check_symbol_exists("_M_ARM64" "" ARCH_ARM64)
else ()
else (WIN32)
check_symbol_exists("__i386__" "" ARCH_X86)
check_symbol_exists("__x86_64__" "" ARCH_X64)
check_symbol_exists("__arm__" "" ARCH_ARM)
check_symbol_exists("__aarch64__" "" ARCH_ARM64)
check_symbol_exists("__mips__" "" ARCH_MIPS)
endif ()
endif (WIN32)
endfunction(detect_current_arch)
set(TARGET_CPU "" CACHE STRING "Target CPU, used as --target_cpu argument")
@ -55,38 +57,30 @@ if (TARGET_CPU STREQUAL "")
set(TARGET_CPU "mipsel")
else ()
set(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR})
endif ()
endif ()
endif (ARCH_X64)
endif (TARGET_CPU STREQUAL "")
if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
message(FATAL_ERROR "Unknown value '${TARGET_CPU}' for variable TARGET_CPU, options are: ${TARGET_CPU_LIST}")
endif ()
if (APPLE)
list(APPEND LIBWEBRTC_DEFINITIONS_DEBUG WEBRTC_MAC)
list(APPEND LIBWEBRTC_DEFINITIONS_RELEASE ${LIBWEBRTC_DEFINITIONS_DEBUG})
endif ()
endif (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
if (UNIX)
if (TARGET_CPU STREQUAL "x86")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -m32")
endif (TARGET_CPU STREQUAL "x86")
if (ARCH_X86)
list(APPEND LIBWEBRTC_REQUIRED_CXX_FLAGS "-m32")
endif (ARCH_X86)
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -std=gnu++0x")
list(APPEND LIBWEBRTC_REQUIRED_CXX_FLAGS "-std=gnu++0x")
if (CMAKE_USE_PTHREADS_INIT)
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -pthread")
if(THREADS_HAVE_PTHREAD_ARG)
list(APPEND LIBWEBRTC_REQUIRED_CXX_FLAGS "-pthread")
endif()
list(APPEND LIBWEBRTC_DEFINITIONS_DEBUG WEBRTC_POSIX _DEBUG=1)
list(APPEND LIBWEBRTC_DEFINITIONS_RELEASE WEBRTC_POSIX)
list(APPEND LIBWEBRTC_DEFINITIONS
WEBRTC_POSIX _GLIBCXX_USE_CXX11_ABI=0 _CRT_SECURE_NO_WARNINGS)
elseif (WIN32)
set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "/MDd")
set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "/MD")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "${LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG}")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "${LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE}")
list(APPEND LIBWEBRTC_DEFINITIONS_DEBUG WEBRTC_WIN NOMINMAX _CRT_SECURE_NO_WARNINGS)
list(APPEND LIBWEBRTC_DEFINITIONS_RELEASE ${LIBWEBRTC_DEFINITIONS_DEBUG})
endif ()
message(STATUS "Building for ${TARGET_OS} (${TARGET_CPU})")
set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "/MTd")
set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "/MT")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "/MTd")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "/MT")
list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_WIN NOMINMAX _CRT_SECURE_NO_WARNINGS)
endif(UNIX)

View file

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: LibWebRTC
Description: Google's native WebRTC implementation shipped into a single library
Version: @LIBWEBRTC_VERSION@
Libs: @LIBWEBRTC_PC_LIBS@
Libs.private: @LIBWEBRTC_PC_LIBS_PRIVATE@
Cflags: -I${includedir} @LIBWEBRTC_PC_DEFINITIONS@ @LIBWEBRTC_PC_CXXFLAGS@

View file

@ -0,0 +1,63 @@
# - Config file for 'LibWebRTC' package
# It defines the following variables
#
# LIBWEBRTC_INCLUDE_DIRS - include directories
# LIBWEBRTC_LIBRARY_DIRS - library directories
# LIBWEBRTC_LIBRARIES - libraries to link against
# LIBWEBRTC_CMAKE_DIR - path to the CMake modules
# LIBWEBRTC_USE_FILE - path to the CMake use file
#
# - Version variables:
# LIBWEBRTC_MAJOR_VERSION - major version
# LIBWEBRTC_MINOR_VERSION - minor version
# LIBWEBRTC_PATCH_VERSION - patch version
# LIBWEBRTC_BUILD_VERSION - version suffix, release candidate etc
# LIBWEBRTC_WEBRTC_REVISION - WebRTC's Git revision used for that release
# LIBWEBRTC_API_VERSION - full version without build prefix
# LIBWEBRTC_VERSION - full version with build prefix
#
# - Library type and targets variables:
# LIBWEBRTC_LIBRARY_TYPE - STATIC or SHARED
# LIBWEBRTC_TARGET_OS - android, chromeos, ios, linux, nacl, mac or win
# LIBWEBRTC_TARGET_CPU - x86, x64, arm, arm64 or mipsel
# LibWebRTC version number
set(LIBWEBRTC_MAJOR_VERSION "@LIBWEBRTC_MAJOR_VERSION@")
set(LIBWEBRTC_MINOR_VERSION "@LIBWEBRTC_MINOR_VERSION@")
set(LIBWEBRTC_PATCH_VERSION "@LIBWEBRTC_PATCH_VERSION@")
set(LIBWEBRTC_BUILD_VERSION "@LIBWEBRTC_BUILD_VERSION@")
set(LIBWEBRTC_WEBRTC_REVISION "@LIBWEBRTC_WEBRTC_REVISION@")
set(LIBWEBRTC_API_VERSION "@LIBWEBRTC_API_VERSION@")
set(LIBWEBRTC_VERSION "@LIBWEBRTC_VERSION@")
# LibWebRTC library type, target OS and target CPU
set(LIBWEBRTC_LIBRARY_TYPE "@LIBRARY_TYPE@")
set(LIBWEBRTC_TARGET_OS "@TARGET_OS@")
set(LIBWEBRTC_TARGET_CPU "@TARGET_CPU@")
# Include directory
set(LIBWEBRTC_INCLUDE_DIRS "@INSTALL_INCLUDE_DIR@")
# Libraries directory
set(LIBWEBRTC_LIBRARY_DIRS "@INSTALL_LIB_DIR@")
# Set the expected libraries variable
set(LIBWEBRTC_LIBRARIES @LIBWEBRTC_LIBRARIES@)
# The C and C++ flags added by LibWebRTC to the cmake-configured flags.
set(LIBWEBRTC_REQUIRED_C_FLAGS "@LIBWEBRTC_REQUIRED_C_FLAGS@")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "@LIBWEBRTC_REQUIRED_CXX_FLAGS@")
set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG@")
set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE@")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG@")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE@")
set(LIBWEBRTC_REQUIRED_SHARED_LINKER_FLAGS "@LIBWEBRTC_REQUIRED_SHARED_LINKER_FLAGS@")
set(LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS "@LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS@")
set(LIBWEBRTC_DEFINITIONS "@LIBWEBRTC_DEFINITIONS@")
# The location of the UseLibWebRTC.cmake file.
set(LIBWEBRTC_CMAKE_DIR "@INSTALL_CMAKE_DIR@")
set(LIBWEBRTC_USE_FILE "${LIBWEBRTC_CMAKE_DIR}/UseLibWebRTC.cmake")
# Import LibWebRTC targets.
include("${LIBWEBRTC_CMAKE_DIR}/LibWebRTCTargets.cmake")

View file

@ -0,0 +1,14 @@
# The full LibWebRTC version number.
set(PACKAGE_VERSION "@LIBWEBRTC_API_VERSION@")
# This version is compatible only with matching major.minor versions.
if ("@LIBWEBRTC_MAJOR_VERSION@.@LIBWEBRTC_MINOR_VERSION@" VERSION_EQUAL
"${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}")
# This version is compatible with equal or lesser patch versions.
if (NOT "@LIBWEBRTC_PATCH_VERSION@" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}")
set(PACKAGE_VERSION_COMPATIBLE 1)
if ("@LIBWEBRTC_PATCH_VERSION@" VERSION_EQUAL "${PACKAGE_FIND_VERSION_PATCH}")
set(PACKAGE_VERSION_EXACT 1)
endif ()
endif ()
endif ()

View file

@ -0,0 +1,19 @@
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

View file

@ -4,8 +4,6 @@
# settings to use LibWebRTC.
#
cmake_minimum_required(VERSION 3.9)
if (LIBWEBRTC_USE_FILE_INCLUDED)
return()
endif ()
@ -25,14 +23,14 @@ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${LIBWEBRTC_REQUIRED_C_FLAGS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBWEBRTC_REQUIRED_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LIBWEBRTC_REQUIRED_SHARED_LINKER_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS}")
# Add preprocessor definitions needed to use LibWebRTC.
if (GENERATOR_IS_MULTI_CONFIG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG ${LIBWEBRTC_DEFINITIONS_DEBUG})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE ${LIBWEBRTC_DEFINITIONS_RELEASE})
elseif (CMAKE_BUILD_TYPE MATCHES Debug)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS_DEBUG})
else ()
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS_RELEASE})
endif ()
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS})
# Add include directories needed to use LibWebRTC.
include_directories(${LIBWEBRTC_INCLUDE_DIRS})
# Add link directories needed to use LibWebRTC.
link_directories(${LIBWEBRTC_LIBRARY_DIRS})

View file

@ -0,0 +1,13 @@
#
# Set the project's version
set(LIBWEBRTC_MAJOR_VERSION 0)
set(LIBWEBRTC_MINOR_VERSION 0)
set(LIBWEBRTC_PATCH_VERSION 1)
set(LIBWEBRTC_BUILD_VERSION -rc.4)
set(LIBWEBRTC_WEBRTC_REVISION ae2551232b5249e38298a50f2d9a64d3c862db00)
set(LIBWEBRTC_API_VERSION
"${LIBWEBRTC_MAJOR_VERSION}.${LIBWEBRTC_MINOR_VERSION}.${LIBWEBRTC_PATCH_VERSION}")
set(LIBWEBRTC_VERSION
${LIBWEBRTC_API_VERSION}${LIBWEBRTC_BUILD_VERSION})

318
README.md
View file

@ -1,10 +1,10 @@
# libwebrtc [![License][license-img]][license-href]
# libwebrtc [![License][license-img]][license-href] [![Join the chat at https://gitter.im/aisouard/libwebrtc][gitter-img]][gitter-href] [![Build Status][travis-img]][travis-href] [![Build Status][appveyor-img]][appveyor-href]
This repository contains a collection of CMake scripts to help you embed
Google's native WebRTC implementation inside your project as simple as this:
```cmake
cmake_minimum_required(VERSION 3.9)
```
cmake_minimum_required(VERSION 3.3)
project(sample)
find_package(LibWebRTC REQUIRED)
@ -15,106 +15,12 @@ add_executable(sample ${SOURCE_FILES})
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
```
## Prerequisites
- CMake 3.9 or later
- Python 2.7 (optional for Windows since it will use the interpreter located
inside the `depot_tools` installation)
### Debian & Ubuntu
- Required development packages:
It also produces a `pkg-config` file if you prefer the classic way:
```
# apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \
libxss-dev libpci-dev libdbus-1-dev libgconf2-dev \
libgnome-keyring-dev libnss3-dev libasound2-dev libpulse-dev \
libudev-dev
$ g++ `pkg-config --cflags LibWebRTC` main.cpp -o main `pkg-config --libs LibWebRTC`
```
- GCC & G++ 4.8 or later, for C++11 support
### macOS
- OS X 10.11 or later
- Xcode 7.3.1 or later
### Windows
- Windows 7 x64 or later
- Visual Studio 2015/2017
Make sure that you install the following components:
- Visual C++, which will select three sub-categories including MFC
- Universal Windows Apps Development Tools
- Tools (1.4.1) and Windows 10 SDK (**10.0.14393**)
- [Windows 10 SDK][w10sdk] with **Debugging Tools for Windows** or
[Windows Driver Kit 10][wdk10] installed in the same Windows 10 SDK
installation directory.
## Getting sources
Clone the repository and run script to fetch WebRTC sources.
You can pass WebRTC version (branch) to script to fetch specific version.
```
git clone https://github.com/UltraCoderRU/libwebrtc.git
cd libwebrtc
python3 sync.py [WEBRTC_VERSION]
```
## Compiling
Create an output directory, browse inside it, then run CMake to configure project.
```
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=<Debug/Release> -DCMAKE_INSTALL_PREFIX=<install_path> ..
```
After configuration build library using standard CMake commands.
```
cmake --build .
cmake --install .
```
The library will be located inside the `lib` subdirectory of the `<install_path>`.
The `include` subdirectory will contain the header files.
CMake scripts will be placed inside the `lib/cmake/LibWebRTC` subdirectory.
## Using WebRTC in your project
To import LibWebRTC into your CMake project use `find_package`:
```cmake
find_package(LibWebRTC REQUIRED)
include(${LIBWEBRTC_USE_FILE})
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
```
You should add library installation path to `CMAKE_INSTALL_PREFIX` variable
while configuring your project:
```
cmake -DCMAKE_PREFIX_PATH=<install_path> ...
```
## Configuration
The library will be compiled and usable on the same host's platform and
architecture. Here are some CMake flags which could be useful if you need to
perform cross-compiling.
- **GN_EXTRA_ARGS**
Add extra arguments to the `gn gen --args` parameter.
- **NINJA_ARGS**
Arguments to pass while executing the `ninja` command.
## Status
The following table displays the current state of this project, including
@ -124,60 +30,198 @@ supported platforms and architectures.
<tr>
<td align="center"></td>
<td align="center">x86</td>
<td align="center">amd64</td>
<td align="center">x64</td>
<td align="center">arm</td>
<td align="center">arm64</td>
</tr>
<tr>
<th align="center">Linux</th>
<td align="center">-</td>
<td align="center"></td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center"></td>
<td></td>
<td></td>
</tr>
<tr>
<th align="center">macOS</th>
<td></td>
<td align="center"></td>
<td></td>
<td></td>
</tr>
<tr>
<th align="center">Windows</th>
<td align="center">-</td>
<td align="center"></td>
<td align="center">-</td>
<td align="center">-</td>
</tr>
<tr>
<th align="center">MacOS</th>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">-</td>
</tr>
<tr>
<th align="center">Android</th>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">-</td>
</tr>
<tr>
<th align="center">iOS</th>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center"></td>
<td></td>
<td></td>
</tr>
</table>
## Prerequisites
## Acknowledgements
- CMake 3.3 or later,
- Python 2.7 (optional for Windows since it will use the interpreter located
inside the `depot_tools` installation)
Many thanks to Dr. Alex Gouaillard for being an excellent mentor for this
project.
### Debian & Ubuntu
Everything started from his
«[Automating libwebrtc build with CMake][webrtc-dr-alex-cmake]» blog article,
which was a great source of inspiration for me to create the easiest way to link
the WebRTC library in any native project.
Install the required development packages
```
# apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \
libxss-dev libpci-dev libdbus-1-dev libgconf2-dev \
libgnome-keyring-dev libnss3-dev libasound2-dev libpulse-dev \
libudev-dev
```
### macOS
- OS X 10.11 or later,
- Xcode 7.3.1 or later
### Windows
* Windows 7 x64 or later,
* Visual Studio 2015 **with updates** - Download the [Installer][vs2015-installer]
Make sure that you install the following components:
* Visual C++, which will select three sub-categories including MFC
* Universal Windows Apps Development Tools > Tools
* Universal Windows Apps Development Tools > Windows 10 SDK (**10.0.10586**)
## Compiling
Clone the repository, initialize the submodules if `depot_tools` is not
installed on your system or not defined inside your `PATH` environment variable.
Create an output directory, browse inside it, then run CMake.
```
$ git clone https://github.com/aisouard/libwebrtc.git
$ cd libwebrtc
$ git submodule init
$ git submodule update
$ mkdir out
$ cd out
$ cmake ..
```
Windows users will have to open the `libwebrtc.sln` located inside the current
directory output directory and build the `ALL_BUILD` project.
Unix users will just have to run the following `make` commands.
```
$ make
# make install
```
The library will be located inside the `lib` folder of the current output
directory. The `include` folder will contain the header files. CMake scripts
will be placed inside the `lib/cmake/LibWebRTC` directory.
## Using WebRTC in your project
At the time of writing this README file, there's no proper way to detect any
installation of the WebRTC library and header files. In the meantime, this CMake
script generates and declares a `LibWebRTC` package that will be very easy to
use for your projects.
All you have to do is include the package, then embed the "use file" that will
automatically find the required libraries, define the proper compiling flags and
include directories.
```
find_package(LibWebRTC REQUIRED)
include(${LIBWEBRTC_USE_FILE})
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
```
A pkg-config file is also provided, you can obtain the required compiler and
linker flags by specifying `LibWebRTC` as the package name.
```
$ pkg-config --cflags --libs LibWebRTC
```
## Configuration
The library will be compiled and usable on the same host's platform and
architecture. Here are some CMake flags which could be useful if you need to
perform cross-compiling.
- **BUILD_DEB_PACKAGE**
Generate Debian package, defaults to OFF, available under Linux only.
- **BUILD_RPM_PACKAGE**
Generate Red Hat package, defaults to OFF, available under Linux only.
- **BUILD_TESTS**
Build WebRTC tests. (not supported yet)
- **BUILD_SHARED_LIB**
Defaults to OFF, will define the `component_build` gn argument to `true` if
enabled. This option will build a shared library instead of a static one.
- **NINJA_ARGS**
Arguments to pass while executing the `ninja` command. For instance, you can
define the number of cores you would like to use, in order to speed-up the
build process:
`cmake -DNINJA_ARGS="-j 4" ..`
- **TARGET_OS**
Target operating system, the value will be used inside the `--target_os`
argument of the `gn gen` command. The value **must** be one of the following:
- `android`
- `chromeos`
- `ios`
- `linux`
- `mac`
- `nacl`
- `win`
- **TARGET_CPU**
Target architecture, the value will be used inside the `--target_cpu`
argument of the `gn gen` command. The value **must** be one of the following:
- `x86`
- `x64`
- `arm`
- `arm64`
- `mipsel`
## Contributing
Feel free to open an issue if you wish a bug to be fixed, to discuss a new
feature or to ask a question. I'm open to pull requests, as long as your
modifications are working on the three major OS (Windows, macOS and Linux).
Don't forget to put your name and e-mail address inside the `AUTHORS` file!
You can also reach me on [Twitter][twitter] for further discussion.
## License
Apache License 2.0 © [Axel Isouard][author]
[license-img]:https://img.shields.io/badge/License-Apache%202.0-blue.svg
[license-href]:https://opensource.org/licenses/Apache-2.0
[w10sdk]:https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
[wdk10]:https://go.microsoft.com/fwlink/p/?LinkId=526733
[webrtc-dr-alex-cmake]:http://webrtcbydralex.com/index.php/2015/07/22/automating-libwebrtc-build-with-cmake
[appveyor-img]:https://ci.appveyor.com/api/projects/status/yd1s303md3tt4w9a?svg=true
[appveyor-href]:https://ci.appveyor.com/project/aisouard/libwebrtc
[travis-img]:https://travis-ci.org/aisouard/libwebrtc.svg?branch=master
[travis-href]:https://travis-ci.org/aisouard/libwebrtc
[gitter-img]:https://badges.gitter.im/aisouard/libwebrtc.svg
[gitter-href]:https://gitter.im/aisouard/libwebrtc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[osx1011sdk]: https://github.com/phracker/MacOSX-SDKs/releases/download/MacOSX10.11.sdk/MacOSX10.11.sdk.tar.xz
[vs2015-installer]:https://www.microsoft.com/en-US/download/details.aspx?id=48146
[twitter]:https://twitter.com/aisouard
[author]:https://axel.isouard.fr

173
Targets/CMakeLists.txt Normal file
View file

@ -0,0 +1,173 @@
include(ExternalProject)
include(LibWebRTCCommand)
include(GClientConfig)
set(_DOWNLOAD_COMMAND ${DEPOTTOOLS_GCLIENT_EXECUTABLE} sync --revision
${LIBWEBRTC_WEBRTC_REVISION} -D -n)
set(_BUILD_COMMAND ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py)
ExternalProject_Add(
webrtc-src
PREFIX ${CMAKE_BINARY_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}
SOURCE_DIR ${CMAKE_BINARY_DIR}
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}
DOWNLOAD_COMMAND ${PREFIX_EXECUTE} ${_DOWNLOAD_COMMAND}
BUILD_COMMAND ${PREFIX_EXECUTE} ${_BUILD_COMMAND}
INSTALL_COMMAND ""
)
set(_NEXT_DEPENDS webrtc-src)
if (UNIX AND NOT APPLE)
libwebrtc_command(
NAME webrtc-install-sysroot
COMMAND ${CMAKE_BINARY_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --running-as-hook
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Installing Linux sysroots"
DEPENDS ${_NEXT_DEPENDS}
)
set(_NEXT_DEPENDS webrtc-install-sysroot)
set(_PLATFORM linux*)
set(_FOLDER linux64)
elseif (APPLE)
set(_PLATFORM darwin)
set(_FOLDER mac)
elseif (WIN32)
libwebrtc_command(
NAME webrtc-vs-toolchain
COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Updating Visual Studio toolchain"
DEPENDS ${_NEXT_DEPENDS}
)
set(_NEXT_DEPENDS webrtc-vs-toolchain)
set(_PLATFORM win32)
set(_FOLDER win)
set(_SUFFIX .exe)
endif (UNIX AND NOT APPLE)
libwebrtc_command(
NAME webrtc-fetch-gn
COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-gn -s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching gn binary"
DEPENDS ${_NEXT_DEPENDS}
)
libwebrtc_command(
NAME webrtc-fetch-clang-format
COMMAND download_from_google_storage --no_resume --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format -s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching clang-format binary"
DEPENDS webrtc-fetch-gn
)
#
# Android dependencies
set(_NEXT_DEPENDS webrtc-fetch-clang-format)
if (TARGET_OS STREQUAL "android")
libwebrtc_command(
NAME webrtc-android-fetch-play-services
COMMAND ${PYTHON_EXECUTABLE} src/build/android/play_services/update.py download
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching Google Play Services"
DEPENDS webrtc-fetch-clang-format
)
libwebrtc_command(
NAME webrtc-android-update-lastchange
COMMAND ${PYTHON_EXECUTABLE} src/build/util/lastchange.py -o src/build/util/LASTCHANGE
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Updating src/build/util/LASTCHANGE"
DEPENDS webrtc-android-fetch-play-services
)
set(_NEXT_DEPENDS webrtc-android-update-lastchange)
foreach(_DEPENDENCY_NAME android-support-test-runner espresso guava hamcrest javax-inject)
string(REPLACE "-" "_" _DEPENDENCY_FOLDER ${_DEPENDENCY_NAME})
libwebrtc_command(
NAME webrtc-android-fetch-${_DEPENDENCY_NAME}
COMMAND ${PYTHON_EXECUTABLE} src/build/android/update_deps/update_third_party_deps.py download -b chromium-${_DEPENDENCY_NAME} -l third_party/${_DEPENDENCY_FOLDER}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Fetching Android dependency: ${_DEPENDENCY_NAME}"
DEPENDS ${_NEXT_DEPENDS}
)
set(_NEXT_DEPENDS webrtc-android-fetch-${_DEPENDENCY_NAME})
endforeach(_DEPENDENCY_NAME)
endif (TARGET_OS STREQUAL "android")
#
# Generate build files
set(_GEN_ARGS use_gold=false target_cpu=\\"${TARGET_CPU}\\" target_os=\\"${TARGET_OS}\\")
if (MSVC OR XCODE)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=$<$<CONFIG:Debug>:true>$<$<CONFIG:Release>:false>)
elseif (CMAKE_BUILD_TYPE MATCHES Debug)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=true)
else (MSVC OR XCODE)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=false)
endif (MSVC OR XCODE)
if (BUILD_TESTS)
set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=true)
else (BUILD_TESTS)
set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=false)
endif (BUILD_TESTS)
if (LIBRARY_TYPE STREQUAL STATIC)
set(_GEN_ARGS ${_GEN_ARGS} is_component_build=false)
else (LIBRARY_TYPE STREQUAL STATIC)
set(_GEN_ARGS ${_GEN_ARGS} is_component_build=true)
endif (LIBRARY_TYPE STREQUAL STATIC)
if (WIN32)
set(_GEN_COMMAND gn gen out/Default --args="${_GEN_ARGS}")
elseif (UNIX)
set(_GEN_COMMAND gn gen out/Default --args='"${_GEN_ARGS}"')
endif (WIN32)
libwebrtc_command(
NAME webrtc-generate
COMMAND ${_GEN_COMMAND}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src"
COMMENT "Generating build files"
DEPENDS ${_NEXT_DEPENDS}
)
#
# Run ninja
libwebrtc_command(
NAME webrtc-build
COMMAND ninja ${NINJA_ARGS} -C out/Default
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src"
COMMENT "Building WebRTC"
DEPENDS webrtc-generate
)
#
# Link the library
ExternalProject_Add(
libwebrtc
DEPENDS webrtc-build
INSTALL_DIR ${CMAKE_BINARY_DIR}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/Targets/libwebrtc
BINARY_DIR ${CMAKE_BINARY_DIR}/libwebrtc
CMAKE_ARGS
-DLIBRARY_TYPE:STRING=${LIBRARY_TYPE}
-DTARGET_OS:STRING=${TARGET_OS}
-DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/src/out/Default
-DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/src/webrtc
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DINSTALL_CMAKE_DIR:PATH=${CMAKE_BINARY_DIR}/lib/cmake/LibWebRTC
)
include(Install)
include(Package)

View file

@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.0)
project(libwebrtc)
set(_OBJ_EXT ${CMAKE_CXX_OUTPUT_EXTENSION})
file(GLOB_RECURSE _OBJ_FILES
${WEBRTC_OUTPUT_DIR}/obj/*${_OBJ_EXT})
if (NOT _OBJ_EXT STREQUAL ".o")
file(GLOB_RECURSE _OBJ_FILES_ASM
${WEBRTC_OUTPUT_DIR}/obj/*.o)
list(APPEND _OBJ_FILES ${_OBJ_FILES_ASM})
endif (NOT _OBJ_EXT STREQUAL ".o")
file(GLOB_RECURSE _OBJ_EXCLUDED
${WEBRTC_OUTPUT_DIR}/obj/third_party/yasm/gen*/*${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/third_party/yasm/re2c/*${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/third_party/yasm/yasm/*${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/third_party/protobuf/protoc/*${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/third_party/protobuf/protobuf_full/*${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/webrtc/examples/*${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/webrtc/tools/*${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/webrtc/modules/video_capture/video_capture/video_capture_external${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/webrtc/modules/video_capture/video_capture/device_info_external${_OBJ_EXT})
list(LENGTH _OBJ_EXCLUDED _OBJ_EXCLUDED_LEN)
if (${_OBJ_EXCLUDED_LEN} GREATER "0")
list(REMOVE_ITEM _OBJ_FILES ${_OBJ_EXCLUDED})
endif ()
list(FILTER _OBJ_FILES EXCLUDE REGEX test)
list(FILTER _OBJ_FILES EXCLUDE REGEX unittests)
#add fakeaudio device
file(GLOB_RECURSE LIBWEBRTC_TEST_COMMON_FILES
"${WEBRTC_OUTPUT_DIR}/obj/webrtc/test/test_common/*${_OBJ_EXT}"
"${WEBRTC_OUTPUT_DIR}/obj/testing/gtest/gtest*${_OBJ_EXT}")
list(APPEND _OBJ_FILES ${LIBWEBRTC_TEST_COMMON_FILES})
add_library(webrtc ${LIBRARY_TYPE} ${_OBJ_FILES})
set_source_files_properties(${_OBJ_FILES} PROPERTIES
EXTERNAL_OBJECT true
GENERATED true)
set_target_properties(webrtc PROPERTIES
LINKER_LANGUAGE C
LIBRARY_OUTPUT_DIRECTORY ${WEBRTC_OUTPUT_DIR}
PREFIX lib)
#
# Install headers
install(DIRECTORY ${WEBRTC_SOURCE_DIR}
DESTINATION "include"
FILES_MATCHING PATTERN "*.h")
#
# Install library
install(TARGETS webrtc
EXPORT LibWebRTCTargets
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
INCLUDES DESTINATION include)
install(EXPORT LibWebRTCTargets
FILE LibWebRTCTargets.cmake
DESTINATION ${INSTALL_CMAKE_DIR})

21
appveyor.yml Normal file
View file

@ -0,0 +1,21 @@
os: Visual Studio 2015
platform:
- x86
configuration: Release
clone_folder: c:\projects\libwebrtc
build:
project: PACKAGE.vcxproj
before_build:
- cd c:\projects\libwebrtc
- git submodule update --init --recursive
- cmake -G "Visual Studio 14 2015" -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc -DNINJA_ARGS="-j 2" -DBUILD_TESTS=ON .
artifacts:
- path: libwebrtc-0.0.1-rc.4-win-x86.zip
test: OFF

View file

@ -1,75 +0,0 @@
function(add_webrtc_target SOURCE_DIR BUILD_DIR)
set(GEN_ARGS_COMMON "target_cpu=\"${TARGET_CPU}\" target_os=\"${TARGET_OS}\" is_component_build=false use_gold=false use_sysroot=false use_custom_libcxx=false use_custom_libcxx_for_host=false use_rtti=true treat_warnings_as_errors=false rtc_include_tests=false rtc_build_tools=false rtc_build_examples=false rtc_enable_protobuf=false")
if (USE_CLANG)
set(GEN_ARGS_COMMON "${GEN_ARGS_COMMON} is_clang=true use_lld=true")
else()
set(GEN_ARGS_COMMON "${GEN_ARGS_COMMON} is_clang=false use_lld=false")
endif()
set(GEN_ARGS_DEBUG "${GEN_ARGS_COMMON} is_debug=true")
set(GEN_ARGS_RELEASE "${GEN_ARGS_COMMON} is_debug=false")
if (MSVC)
set(GEN_ARGS_DEBUG "${GEN_ARGS_DEBUG} enable_iterator_debugging=true")
endif ()
if (WIN32)
set(GN_EXECUTABLE gn.bat)
else ()
set(GN_EXECUTABLE gn)
endif ()
macro(run_gn DIRECTORY)
execute_process(COMMAND ${GN_EXECUTABLE} gen ${DIRECTORY} "--args=${GEN_ARGS}" WORKING_DIRECTORY ${SOURCE_DIR})
endmacro()
if (CMAKE_GENERATOR MATCHES "Visual Studio")
# Debug config
message(STATUS "Running gn for debug configuration...")
set(GEN_ARGS "${GEN_ARGS_DEBUG}")
if (GN_EXTRA_ARGS)
set(GEN_ARGS "${GEN_ARGS} ${GN_EXTRA_ARGS}")
endif ()
run_gn("${BUILD_DIR}/Debug")
# Release config
message(STATUS "Running gn for release configuration...")
set(GEN_ARGS "${GEN_ARGS_RELEASE}")
if (GN_EXTRA_ARGS)
set(GEN_ARGS "${GEN_ARGS} ${GN_EXTRA_ARGS}")
endif ()
run_gn("${BUILD_DIR}/Release")
else ()
message(STATUS "Running gn...")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(GEN_ARGS "${GEN_ARGS_DEBUG}")
else ()
set(GEN_ARGS "${GEN_ARGS_RELEASE}")
endif ()
if (GN_EXTRA_ARGS)
set(GEN_ARGS "${GEN_ARGS} ${GN_EXTRA_ARGS}")
endif ()
run_gn("${BUILD_DIR}")
endif ()
macro(add_custom_command_with_path TARGET_NAME)
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E env "PATH=$ENV{PATH}" ${ARGN}
WORKING_DIRECTORY ${SOURCE_DIR}
VERBATIM
)
endmacro()
add_custom_target(webrtc-build ALL)
add_custom_target(webrtc-clean)
if (CMAKE_GENERATOR MATCHES "Visual Studio")
add_custom_command_with_path(webrtc-build ninja -C "${BUILD_DIR}/$<CONFIG>" :webrtc jsoncpp libyuv ${NINJA_ARGS})
add_custom_command_with_path(webrtc-clean ${GN_EXECUTABLE} clean "${BUILD_DIR}/$<CONFIG>")
else ()
add_custom_command_with_path(webrtc-build ninja -C "${BUILD_DIR}" :webrtc jsoncpp libyuv ${NINJA_ARGS})
add_custom_command_with_path(webrtc-clean ${GN_EXECUTABLE} clean "${BUILD_DIR}")
endif ()
endfunction()

View file

@ -1,10 +0,0 @@
function(patch_sources PATCH_DIR SOURCE_DIR)
file(GLOB_RECURSE PATCHED_SOURCES RELATIVE ${PATCH_DIR} ${PATCH_DIR}/*)
list(REMOVE_ITEM PATCHED_SOURCES ".gitkeep")
foreach (file ${PATCHED_SOURCES})
message(STATUS "Patching ${file}...")
set(destination "${SOURCE_DIR}/${file}")
cmake_path(GET destination PARENT_PATH dest_dir)
file(COPY ${PATCH_DIR}/${file} DESTINATION ${dest_dir})
endforeach ()
endfunction()

View file

@ -1,13 +0,0 @@
function(patch_file TARGET_FILE SEARCH_REGEX REPLACE_REGEX)
file(READ ${TARGET_FILE} filedata)
string(REGEX REPLACE ${SEARCH_REGEX} ${REPLACE_REGEX} filedata "${filedata}")
file(WRITE ${TARGET_FILE} "${filedata}")
endfunction()
function(prependPath DIRECTORY)
if (WIN32)
set(ENV{PATH} "${DIRECTORY};$ENV{PATH}")
else()
set(ENV{PATH} "${DIRECTORY}:$ENV{PATH}")
endif()
endfunction()

View file

@ -1,14 +0,0 @@
function(get_webrtc_version_from_git OUT_VAR)
find_package(Git REQUIRED)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE WEBRTC_BRANCH
WORKING_DIRECTORY ${WEBRTC_SOURCE_DIR}
)
string(REGEX REPLACE "\n$" "" WEBRTC_BRANCH "${WEBRTC_BRANCH}")
set(${OUT_VAR} ${WEBRTC_BRANCH} PARENT_SCOPE)
endfunction()

1
depot_tools Submodule

@ -0,0 +1 @@
Subproject commit 33e88a4e19aa1eb306fe66431e8b0621773eb66c

View file

@ -1,129 +0,0 @@
if (BUILD_DEB_PACKAGE)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH INTERNAL FORCE)
endif ()
# Prepare CMake exports
configure_file(LibWebRTCConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfig.cmake @ONLY)
configure_file(LibWebRTCConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfigVersion.cmake @ONLY)
######################
# INSTALL SECTION
######################
# Install headers
install(DIRECTORY
"${WEBRTC_SOURCE_DIR}/api"
"${WEBRTC_SOURCE_DIR}/base"
"${WEBRTC_SOURCE_DIR}/call"
"${WEBRTC_SOURCE_DIR}/common_audio"
"${WEBRTC_SOURCE_DIR}/common_video"
"${WEBRTC_SOURCE_DIR}/logging"
"${WEBRTC_SOURCE_DIR}/media"
"${WEBRTC_SOURCE_DIR}/modules"
"${WEBRTC_SOURCE_DIR}/p2p"
"${WEBRTC_SOURCE_DIR}/pc"
"${WEBRTC_SOURCE_DIR}/rtc_base"
"${WEBRTC_SOURCE_DIR}/system_wrappers"
DESTINATION "include/webrtc"
COMPONENT common
FILES_MATCHING PATTERN "*.h"
)
if (EXISTS "${WEBRTC_SOURCE_DIR}/common_types.h")
install(FILES "${WEBRTC_SOURCE_DIR}/common_types.h" DESTINATION "include/webrtc" COMPONENT common)
endif ()
install(DIRECTORY "${WEBRTC_SOURCE_DIR}/third_party/jsoncpp"
DESTINATION "include/webrtc/third_party"
COMPONENT common
FILES_MATCHING PATTERN "*.h"
)
install(DIRECTORY "${WEBRTC_SOURCE_DIR}/third_party/libyuv"
DESTINATION "include/webrtc/third_party"
COMPONENT common
FILES_MATCHING PATTERN "*.h"
)
install(DIRECTORY "${WEBRTC_SOURCE_DIR}/third_party/abseil-cpp/absl"
DESTINATION "include/webrtc"
COMPONENT common
FILES_MATCHING PATTERN "*.h"
)
# Install pdb files
if (MSVC)
# TODO: fix install on first run
file(GLOB_RECURSE PDB_FILES "${WEBRTC_BUILD_DIR}/Debug/*.pdb")
install(FILES DESTINATION lib COMPONENT debug)
endif()
# Install library
if (WIN32)
set(LIBRARY_FILENAME_DEBUG "webrtcd.lib")
set(LIBRARY_FILENAME_RELEASE "webrtc.lib")
else()
set(LIBRARY_FILENAME_DEBUG "libwebrtcd.a")
set(LIBRARY_FILENAME_RELEASE "libwebrtc.a")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (WIN32)
install(FILES ${WEBRTC_BUILD_DIR}/obj/webrtc.lib DESTINATION lib RENAME "webrtcd.lib" COMPONENT debug)
else()
install(FILES ${WEBRTC_BUILD_DIR}/obj/libwebrtc.a DESTINATION lib RENAME "libwebrtcd.a" COMPONENT debug)
endif()
else ()
if (WIN32)
install(FILES ${WEBRTC_BUILD_DIR}/obj/webrtc.lib DESTINATION lib COMPONENT release)
else()
install(FILES ${WEBRTC_BUILD_DIR}/obj/libwebrtc.a DESTINATION lib COMPONENT release)
endif()
endif ()
install(FILES
UseLibWebRTC.cmake
${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfigVersion.cmake
${CMAKE_CURRENT_SOURCE_DIR}/LibWebRTCTargets.cmake
DESTINATION "lib/cmake/LibWebRTC"
COMPONENT common
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES LibWebRTCTargets-debug.cmake DESTINATION "lib/cmake/LibWebRTC" COMPONENT debug)
else ()
install(FILES LibWebRTCTargets-release.cmake DESTINATION "lib/cmake/LibWebRTC" COMPONENT release)
endif ()
if (BUILD_DEB_PACKAGE)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VENDOR "Kirill Kirilenko")
set(CPACK_PACKAGE_CONTACT "Kirill Kirilenko <kirill@ultracoder.org>")
set(CPACK_PACKAGE_VERSION_MAJOR ${WEBRTC_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR "")
set(CPACK_PACKAGE_VERSION_PATCH "")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/UltraCoderRU/libwebrtc")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
set(CPACK_DEBIAN_COMMON_PACKAGE_NAME "libwebrtc-common-dev")
set(CPACK_DEBIAN_COMMON_FILE_NAME "libwebrtc-common-dev-${WEBRTC_VERSION}.deb")
set(CPACK_DEBIAN_COMMON_DESCRIPTION "WebRTC header files and CMake modules")
set(CPACK_DEBIAN_RELEASE_PACKAGE_NAME "libwebrtc-release-dev")
set(CPACK_DEBIAN_RELEASE_FILE_NAME "libwebrtc-release-dev-${WEBRTC_VERSION}.deb")
set(CPACK_DEBIAN_RELEASE_DESCRIPTION "WebRTC static library (release version)")
set(CPACK_DEBIAN_RELEASE_PACKAGE_DEPENDS "libwebrtc-common-dev (=${WEBRTC_VERSION})")
set(CPACK_DEBIAN_RELEASE_PACKAGE_PROVIDES "libwebrtc-dev")
set(CPACK_DEBIAN_DEBUG_PACKAGE_NAME "libwebrtc-debug-dev")
set(CPACK_DEBIAN_DEBUG_FILE_NAME "libwebrtc-debug-dev-${WEBRTC_VERSION}.deb")
set(CPACK_DEBIAN_DEBUG_DESCRIPTION "WebRTC static library (debug version)")
set(CPACK_DEBIAN_DEBUG_PACKAGE_DEPENDS "libwebrtc-common-dev (=${WEBRTC_VERSION})")
set(CPACK_DEBIAN_DEBUG_PACKAGE_PROVIDES "libwebrtc-dev")
include(CPack)
endif ()

View file

@ -1,43 +0,0 @@
# - Config file for 'LibWebRTC' package
# It defines the following variables
#
# LIBWEBRTC_INCLUDE_DIRS - include directories
# LIBWEBRTC_LIBRARY_DIRS - library directories
# LIBWEBRTC_LIBRARIES - libraries to link against
# LIBWEBRTC_CMAKE_DIR - path to the CMake modules
# LIBWEBRTC_USE_FILE - path to the CMake use file
#
# - Version variables:
# WEBRTC_VERSION - WebRTC version with build prefix
#
# - Library type and targets variables:
# LIBWEBRTC_TARGET_OS - android, chromeos, ios, linux, nacl, mac or win
# LIBWEBRTC_TARGET_CPU - x86, x64, arm, arm64 or mipsel
# WebRTC version number (branch head)
set(WEBRTC_VERSION "@WEBRTC_VERSION@")
# LibWebRTC library type, target OS and target CPU
set(LIBWEBRTC_TARGET_OS "@TARGET_OS@")
set(LIBWEBRTC_TARGET_CPU "@TARGET_CPU@")
# Set the expected libraries variable
set(LIBWEBRTC_LIBRARIES @LIBWEBRTC_LIBRARIES@)
# The C and C++ flags added by LibWebRTC to the cmake-configured flags.
set(LIBWEBRTC_REQUIRED_C_FLAGS "@LIBWEBRTC_REQUIRED_C_FLAGS@")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "@LIBWEBRTC_REQUIRED_CXX_FLAGS@")
set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG@")
set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE@")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG@")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE@")
set(LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS "@LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS@")
set(LIBWEBRTC_DEFINITIONS_DEBUG "@LIBWEBRTC_DEFINITIONS_DEBUG@")
set(LIBWEBRTC_DEFINITIONS_RELEASE "@LIBWEBRTC_DEFINITIONS_RELEASE@")
# The location of the UseLibWebRTC.cmake file.
set(LIBWEBRTC_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(LIBWEBRTC_USE_FILE "${LIBWEBRTC_CMAKE_DIR}/UseLibWebRTC.cmake")
# Import LibWebRTC targets.
include("${LIBWEBRTC_CMAKE_DIR}/LibWebRTCTargets.cmake")

View file

@ -1,8 +0,0 @@
# The full LibWebRTC version number.
set(PACKAGE_VERSION "@WEBRTC_VERSION@")
# This version is compatible only with equal version
if ("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "@WEBRTC_VERSION@")
set(PACKAGE_VERSION_COMPATIBLE 1)
set(PACKAGE_VERSION_EXACT 1)
endif ()

View file

@ -1,23 +0,0 @@
#----------------------------------------------------------------
# CMake target import file for configuration "Debug".
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "webrtc" for configuration "Debug"
set_property(TARGET webrtc APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug)
if (MSVC)
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/webrtcd.lib")
else ()
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/libwebrtcd.a")
endif ()
set_target_properties(webrtc PROPERTIES IMPORTED_LOCATION_DEBUG "${_WEBRTC_LIBRARY_PATH}")
list(APPEND _IMPORT_CHECK_TARGETS webrtc)
list(APPEND _IMPORT_CHECK_FILES_FOR_webrtc "${_WEBRTC_LIBRARY_PATH}")
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)

View file

@ -1,23 +0,0 @@
#----------------------------------------------------------------
# CMake target import file for configuration "Release".
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "webrtc" for configuration "Release"
set_property(TARGET webrtc APPEND PROPERTY IMPORTED_CONFIGURATIONS Release)
if (MSVC)
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/webrtc.lib")
else ()
set(_WEBRTC_LIBRARY_PATH "${_IMPORT_PREFIX}/lib/libwebrtc.a")
endif ()
set_target_properties(webrtc PROPERTIES IMPORTED_LOCATION_RELEASE "${_WEBRTC_LIBRARY_PATH}")
list(APPEND _IMPORT_CHECK_TARGETS webrtc)
list(APPEND _IMPORT_CHECK_FILES_FOR_webrtc "${_WEBRTC_LIBRARY_PATH}")
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)

View file

@ -1,83 +0,0 @@
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget webrtc)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
endif()
if(TARGET ${_expectedTarget})
list(APPEND _targetsDefined ${_expectedTarget})
endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
# The installation prefix configured by this project.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
# Create imported target webrtc
add_library(webrtc STATIC IMPORTED)
set_target_properties(webrtc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include/webrtc;${_IMPORT_PREFIX}/include/webrtc/third_party/libyuv/include;${_IMPORT_PREFIX}/include/webrtc/third_party/jsoncpp/source/include"
)
# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/LibWebRTCTargets-*.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
endforeach()
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
if(NOT EXISTS "${file}" )
message(FATAL_ERROR "The imported target \"${target}\" references the file
\"${file}\"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
\"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
endif()
endforeach()
unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)
# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)

View file

78
sync.py
View file

@ -1,78 +0,0 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
from pathlib import Path
def execute(command: str):
subprocess.run(command, shell=True, check=True)
def get_output(command: str):
return subprocess.run(command, capture_output=True, shell=True, check=True).stdout.decode()
# To determine last stable WebRTC revision,
# see https://chromiumdash.appspot.com/branches
# and https://chromiumdash.appspot.com/schedule
WEBRTC_REVISION = 4692
if len(sys.argv) == 2:
WEBRTC_REVISION = sys.argv[1]
REPO_ROOT = Path(__file__).resolve().parent
DEPOT_TOOLS_DIR = REPO_ROOT / 'depot_tools'
WEBRTC_DIR = REPO_ROOT / 'webrtc'
SRC_DIR = WEBRTC_DIR / 'src'
os.environ['PATH'] = '{}{}{}'.format(DEPOT_TOOLS_DIR, os.pathsep, os.environ['PATH'])
if sys.platform == 'win32':
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0'
os.chdir(REPO_ROOT)
if not os.path.isdir(DEPOT_TOOLS_DIR):
print('Cloning Depot Tools...')
execute('git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git')
os.chdir(DEPOT_TOOLS_DIR)
if sys.platform == 'win32':
execute('gclient --version')
execute('where python')
execute('python update_depot_tools_toggle.py --disable')
else:
print('Updating Depot Tools to the latest revision...')
os.chdir(DEPOT_TOOLS_DIR)
execute('git checkout -q -f main')
execute('git pull -q')
if not os.path.isdir(WEBRTC_DIR):
print('Cloning WebRTC...')
os.mkdir(WEBRTC_DIR)
os.chdir(WEBRTC_DIR)
execute('fetch --nohooks webrtc')
os.chdir(SRC_DIR)
execute('gclient sync --with_branch_heads --nohooks')
else:
print('Updating WebRTC branches info...')
os.chdir(SRC_DIR)
execute('gclient sync --with_branch_heads --nohooks')
# Latest Depot Tools versions are not compatible
# with old WebRTC versions, so we peek revision
# from around the same time as the WebRTC and
# forbid gclient to auto-update Depot Tools.
os.chdir(SRC_DIR)
LAST_WEBRTC_COMMIT_DATE = get_output('git log -n 1 --pretty=format:%ci branch-heads/{}'.format(WEBRTC_REVISION)).strip()
os.chdir(DEPOT_TOOLS_DIR)
DEPOT_TOOLS_COMPATIBLE_REVISION = get_output('git rev-list -n 1 --before="{}" main'.format(LAST_WEBRTC_COMMIT_DATE)).strip()
print('Updating Depot Tools to a compatible revision {}...'.format(DEPOT_TOOLS_COMPATIBLE_REVISION))
execute('git checkout -f {}'.format(DEPOT_TOOLS_COMPATIBLE_REVISION))
print('Updating WebRTC to version {}...'.format(WEBRTC_REVISION))
os.chdir(SRC_DIR)
execute('git clean -ffd')
execute('git checkout -q -B {} branch-heads/{}'.format(WEBRTC_REVISION, WEBRTC_REVISION))
execute('gclient sync --force -D --reset')