Compare commits

...

34 commits

Author SHA1 Message Date
c4917e8f86 sync.sh and sync.bat replaced with sync.py.
Update README.md.
2024-09-23 19:29:58 +03:00
4475233318 Fix synchronization for old versions of WebRTC. 2024-08-19 22:35:00 +03:00
92fb3fdc01 Disable use of sysroot to avoid conflicts on non-Debian based systems. 2024-08-19 22:30:50 +03:00
915e13f4ce Make installation directory be relocatable (replace hard-coded paths in CMake configs with dynamic ones). 2024-08-19 22:30:50 +03:00
c3a581c11c Enable RTTI. 2023-08-05 13:45:08 +03:00
cf009964cf Discard local changes and untracked files on sync. 2023-08-23 20:46:44 +03:00
9d7075b4f0 Debian package splits into common, debug and release. 2023-08-23 20:46:25 +03:00
292a9b8751 Disable building of tests, examples and tools. 2022-10-03 19:20:27 +03:00
0e08c8388a Add an ability to replace some source files before building. 2022-10-03 15:43:17 +03:00
d667dab439 Change configurations case. 2022-09-27 23:15:08 +03:00
1e24732035 Add an option to disable the use of internal Clang compiler 2022-09-14 20:58:03 +03:00
ab22b5519e Sync branch-heads. 2021-07-21 00:51:37 +03:00
2db22c8048 Passthrough GN_EXTRA_ARGS and NINJA_ARGS.
Fix GEN_ARGS_DEBUG for MSVC.
2021-07-21 00:31:50 +03:00
477b5b2220 Add 'use_lld=false' on Windows 2021-05-26 17:38:13 +03:00
c8cdba02bc Fix PATH
Add single-configuration generators support on Windows
2021-05-21 22:30:50 +03:00
5a40775960 Add libyuv and jsoncpp include directories to INTERFACE_INCLUDE_DIRECTORIES. 2021-05-11 17:07:22 +03:00
d5583c9a6c Add option to build DEB package. 2021-04-07 22:28:41 +03:00
f158466213 Separated sources fetching and building. 2021-04-07 21:37:04 +03:00
8185da4a10
Install common_audio directory. 2021-03-05 00:54:34 +03:00
bb6c49081b Update README 2021-02-11 23:07:34 +03:00
700e94ff03 Fix prefix in CMakeTargets.cmake 2021-02-11 23:05:34 +03:00
40db8152b4 Fix: set is_clang and enable_iterator_debugging only on MSVC 2020-11-27 18:49:02 +03:00
7fefa7dc53 Enable iterator debugging in Windows debug configuration
Disable Clang completely on Windows
2020-11-26 17:49:12 +03:00
3315befa38 Update depot-tools after cloning 2020-11-25 19:04:32 +03:00
dccaa6f5f4 Do not use libc++
Use C++11 ABI on Linux
2020-11-18 19:53:15 +03:00
5ac8845681 Build with dynamic runtime on desktop Windows
Add suffix to debug library name
2020-11-11 18:06:46 +03:00
Michael Kris
b248e1cd73 gn now comes with depot tools no need to download separately 2020-10-28 13:59:51 -07:00
ssskip
336476a1f8 xcode 11.5 2020-06-14 22:50:20 +08:00
ssskip
38d6a4e9ea m83 2020-06-14 22:48:34 +08:00
Mike Lester
2ac0e402e1 Copy absl include directory directly into webrtc/ (instead of third_party/) 2020-04-08 15:55:05 +10:00
Mike Lester
05445b2fd5
Update README.md 2020-04-08 14:50:38 +10:00
Mike Lester
46f502d2d1 Copy abseil headers 2020-04-08 11:03:30 +10:00
Mike Lester
d44f0e4c3a CMake config file now points to the correct root include directory 2020-04-08 10:34:04 +10:00
湖北捷智云技术有限公司
a24a5e5947 Update WebRTC version to m72. 2019-02-19 01:31:53 +08:00
39 changed files with 594 additions and 1377 deletions

View file

@ -1,22 +0,0 @@
version: 2
jobs:
build:
docker:
- image: base/archlinux
steps:
- checkout
- run:
name: Install build dependencies
command: pacman -Syu && pacman -S --noconfirm cmake ninja libx11 python2 git
- run:
name: Enable python2
command: mkdir -p /tmp/python_for_libwebrtc_build && ln -s /usr/bin/python2 /tmp/python_for_libwebrtc_build/python
- run:
name: Run cmake
command: PATH=/tmp/python_for_libwebrtc_build:$PATH cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DWEBRTC_BRANCH_HEAD=refs/branch-heads/66 .
- run:
name: Build
command: PATH=/tmp/python_for_libwebrtc_build:$PATH ninja package
- run:
name: Move artifacts
command: mv libwebrtc-*.tar.gz $CIRCLE_ARTIFACTS/

10
.gitignore vendored
View file

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

View file

@ -1,83 +0,0 @@
matrix:
include:
- os: linux
sudo: required
env: TARGET_CPU=x64
addons:
apt: &x64-apt
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- 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
- os: linux
sudo: required
env: TARGET_CPU=x64 CMAKE_BUILD_TYPE=Debug
addons:
apt: *x64-apt
- os: osx
osx_image: xcode7.3
env: TARGET_CPU=x64
addons:
apt: *x64-apt
- os: osx
osx_image: xcode7.3
env: TARGET_CPU=x64 CMAKE_BUILD_TYPE=Debug
addons:
apt: *x64-apt
language: cpp
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}
export CXX="g++-4.8" CC="gcc-4.8"
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 -DBUILD_SAMPLE=1 -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=. -DTARGET_CPU=$TARGET_CPU ..
script:
- make -j 4 package
before_deploy:
- export TRAVIS_ARTIFACTS=$(ls libwebrtc-*.tar.gz)
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_glob: true
file: "${TRAVIS_ARTIFACTS}"
skip_cleanup: true
on:
tags: true
repo: aisouard/libwebrtc

View file

@ -1,133 +1,46 @@
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE)
project(libwebrtc) 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 # Allow the use of IN_LIST operand
cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0057 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
${CMAKE_SOURCE_DIR}/CMakeModules)
find_package(Git REQUIRED)
include(FindLibraries) include(FindLibraries)
include(Version)
include(Options)
include(TargetOsAndCpu) include(TargetOsAndCpu)
if (HAS_OWN_DEPOT_TOOLS) include(Utils)
find_package(DepotTools REQUIRED) prependPath("${CMAKE_SOURCE_DIR}/depot_tools")
endif (HAS_OWN_DEPOT_TOOLS) if (WIN32)
set(ENV{DEPOT_TOOLS_WIN_TOOLCHAIN} 0)
endif()
if (NOT WIN32) set(WEBRTC_SOURCE_DIR "${CMAKE_SOURCE_DIR}/webrtc/src")
find_package(PythonInterp 2.7 REQUIRED) set(WEBRTC_BUILD_DIR "${CMAKE_BINARY_DIR}/webrtc")
endif (NOT WIN32)
include(ExternalProject) include(Version)
get_webrtc_version_from_git(WEBRTC_VERSION)
message(STATUS "WebRTC version: ${WEBRTC_VERSION}")
if (NOT HAS_OWN_DEPOT_TOOLS) if (MSVC)
if (WIN32) # Always build with dynamic runtime on MSVC
set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools/gclient.bat) patch_file(${WEBRTC_SOURCE_DIR}/build/config/win/BUILD.gn ":static_crt" ":dynamic_crt")
else (WIN32) endif ()
set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools/gclient)
endif (WIN32)
ExternalProject_Add( # Copy all files from 'patches' directory to 'webrtc/src'
depot-tools # 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")
GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools include(AddWebRTCTarget)
add_webrtc_target(${WEBRTC_SOURCE_DIR} ${WEBRTC_BUILD_DIR})
PREFIX ${CMAKE_BINARY_DIR}/depot_tools add_subdirectory(libwebrtc)
CONFIGURE_COMMAND ""
UPDATE_COMMAND ""
PATCH_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
set(_NEXT_DEPENDS depot-tools)
set(DEPOT_TOOLS_PATH ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools)
endif (NOT HAS_OWN_DEPOT_TOOLS)
set(_WEBRTC_CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH:PATH=${CMAKE_MODULE_PATH}
-DDEPOT_TOOLS_PATH:PATH=${DEPOT_TOOLS_PATH}
-DGCLIENT_EXECUTABLE:PATH=${GCLIENT_EXECUTABLE}
-DHAS_OWN_DEPOT_TOOLS:PATH=${HAS_OWN_DEPOT_TOOLS}
-DTARGET_CPU=${TARGET_CPU}
-DTARGET_OS=${TARGET_OS}
-DWEBRTC_PARENT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc)
if (WEBRTC_BRANCH_HEAD)
set(_WEBRTC_CMAKE_ARGS ${_WEBRTC_CMAKE_ARGS} -DWEBRTC_BRANCH_HEAD=${WEBRTC_BRANCH_HEAD})
endif (WEBRTC_BRANCH_HEAD)
if (WEBRTC_REVISION)
set(_WEBRTC_CMAKE_ARGS ${_WEBRTC_CMAKE_ARGS} -DWEBRTC_REVISION=${WEBRTC_REVISION})
endif (WEBRTC_REVISION)
ExternalProject_Add(
webrtc-src
DEPENDS ${_NEXT_DEPENDS}
GIT_REPOSITORY https://chromium.googlesource.com/external/webrtc
PREFIX ${CMAKE_BINARY_DIR}/webrtc
BINARY_DIR ${CMAKE_BINARY_DIR}/webrtc/build
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/webrtc/src
SOURCE_DIR ${CMAKE_BINARY_DIR}/webrtc/src
STAMP_DIR ${CMAKE_BINARY_DIR}/webrtc/stamp
TMP_DIR ${CMAKE_BINARY_DIR}/webrtc/tmp
PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/webrtc/CMakeLists.txt.in ${CMAKE_BINARY_DIR}/webrtc/src/CMakeLists.txt
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_ARGS
${_WEBRTC_CMAKE_ARGS}
)
if (MSVC OR XCODE)
set(_CONFIG $<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:Release>$<$<CONFIG:MinSizeRel>:Release>)
elseif (CMAKE_BUILD_TYPE MATCHES Debug)
set(_CONFIG Debug)
else (MSVC OR XCODE)
set(_CONFIG Release)
endif (MSVC OR XCODE)
ExternalProject_Add(
libwebrtc
DEPENDS webrtc-src
INSTALL_DIR ${CMAKE_BINARY_DIR}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/libwebrtc
BINARY_DIR ${CMAKE_BINARY_DIR}/libwebrtc
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}
-DCMAKE_MODULE_PATH:PATH=${CMAKE_MODULE_PATH}
-DINSTALL_CMAKE_DIR:PATH=${CMAKE_BINARY_DIR}/lib/cmake/LibWebRTC
-DTARGET_OS:STRING=${TARGET_OS}
-DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/out/${_CONFIG}
-DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src
)
if (BUILD_SAMPLE)
ExternalProject_Add(
sample
DEPENDS libwebrtc
SOURCE_DIR ${CMAKE_SOURCE_DIR}/sample
INSTALL_COMMAND ""
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endif (BUILD_SAMPLE)
include(Install)
include(Package)
export(PACKAGE LibWebRTC)

View file

@ -1,47 +0,0 @@
if (HAS_OWN_DEPOT_TOOLS)
return()
endif (HAS_OWN_DEPOT_TOOLS)
include(LibWebRTCExecute)
if (WEBRTC_REVISION)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci ${WEBRTC_REVISION}
OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
STAMPFILE webrtc-revision-commit-date
STATUS "Retrieving date for commit ${WEBRTC_REVISION}"
ERROR "Unable to find webrtc commit date at ${WEBRTC_REVISION}"
)
elseif (WEBRTC_BRANCH_HEAD)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci
OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
STAMPFILE webrtc-branch-head-commit-date
STATUS "Retrieving date for ${WEBRTC_BRANCH_HEAD}"
ERROR "Unable to retrieve the commit date for ${WEBRTC_BRANCH_HEAD}"
)
else (WEBRTC_REVISION)
message(FATAL_ERROR "-- Both WEBRTC_REVISION and WEBRTC_BRANCH_HEAD variables are undefined")
endif (WEBRTC_REVISION)
string(STRIP ${_WEBRTC_COMMIT_DATE} _WEBRTC_COMMIT_DATE)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} rev-list -n 1 --before=\"${_WEBRTC_COMMIT_DATE}\" master
OUTPUT_VARIABLE _DEPOT_TOOLS_COMMIT
WORKING_DIRECTORY ${DEPOT_TOOLS_PATH}
STAMPFILE webrtc-depot-tools-date
STATUS "Retrieving depot_tools commit before ${_WEBRTC_COMMIT_DATE}"
ERROR "Unable to find depot_tools commit before ${_WEBRTC_COMMIT_DATE}"
)
string(STRIP ${_DEPOT_TOOLS_COMMIT} _DEPOT_TOOLS_COMMIT)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} checkout ${_DEPOT_TOOLS_COMMIT}
OUTPUT_VARIABLE _DEPOT_TOOLS_CHECKED_OUT
WORKING_DIRECTORY ${DEPOT_TOOLS_PATH}
STAMPFILE webrtc-depot-tools-checkout
STATUS "Checking out depot_tools to commit ${_DEPOT_TOOLS_COMMIT}"
ERROR "Unable to checkout depot_tools to commit ${_DEPOT_TOOLS_COMMIT}"
)

View file

@ -1,34 +0,0 @@
if (ENVIRONMENT_INCLUDED)
return()
endif (ENVIRONMENT_INCLUDED)
set(ENVIRONMENT_INCLUDED true)
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 ${DEPOT_TOOLS_PATH} $ENV{PATH})
get_filename_component(_CHROMIUM_PYTHONPATH
"${CMAKE_SOURCE_DIR}/build"
REALPATH)
if (WIN32)
string(REGEX REPLACE "/" "\\\\" _WEBRTC_PATH "${_WEBRTC_PATH}")
string(REGEX REPLACE "/" "\\\\" _CHROMIUM_PYTHONPATH "${_CHROMIUM_PYTHONPATH}")
string(REGEX REPLACE ";" "\\\\\\\;" _WEBRTC_PATH "${_WEBRTC_PATH}")
else (WIN32)
string(REGEX REPLACE ";" ":" _WEBRTC_PATH "${_WEBRTC_PATH}")
endif (WIN32)
set(_ENV
PATH="${_WEBRTC_PATH}"
PYTHONPATH="${_CHROMIUM_PYTHONPATH}"
DEPOT_TOOLS_WIN_TOOLCHAIN=0
DEPOT_TOOLS_UPDATE=0
CHROME_HEADLESS=1)
set(PREFIX_EXECUTE ${CMAKE_COMMAND} -E env "${_ENV}")

View file

@ -1,17 +0,0 @@
find_program(GCLIENT_EXECUTABLE
NAMES gclient gclient.bat
DOC "Path to gclient executable"
HINTS ${DEPOT_TOOLS_PATH} ENV DEPOT_TOOLS_PATH)
find_path(DEPOT_TOOLS_PATH
NAMES gclient gclient.py gclient.bat
ninja ninja.exe ninja-linux32 ninja-linux64 ninja-mac
download_from_google_storage download_from_google_storage.bat
download_from_google_storage.py
DOC "Path to depot_tools directory"
HINTS ${DEPOT_TOOLS_PATH} ENV DEPOT_TOOLS_PATH)
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(DepotTools
REQUIRED_VARS GCLIENT_EXECUTABLE DEPOT_TOOLS_PATH
FAIL_MESSAGE "Could not find depot_tools.")

View file

@ -1,22 +0,0 @@
file(WRITE ${WEBRTC_PARENT_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 ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"android\", \"unix\"]")
elseif (TARGET_OS STREQUAL "ios")
file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"ios\", \"mac\"]")
elseif (TARGET_OS STREQUAL "linux")
file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"unix\"]")
elseif (TARGET_OS STREQUAL "mac")
file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"mac\"]")
elseif (TARGET_OS STREQUAL "win")
file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"win\"]")
endif (TARGET_OS STREQUAL "android")

View file

@ -1,24 +0,0 @@
set(_GEN_ARGS use_gold=false target_cpu=\\"${TARGET_CPU}\\" target_os=\\"${TARGET_OS}\\" is_component_build=false)
if (MSVC OR XCODE)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=$<$<CONFIG:Debug>:true>$<$<CONFIG:Release>:false>$<$<CONFIG:RelWithDebInfo>:false>$<$<CONFIG:MinSizeRel>:false>)
set(_NINJA_BUILD_DIR out/$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:Release>$<$<CONFIG:MinSizeRel>:Release>)
elseif (CMAKE_BUILD_TYPE MATCHES Debug)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=true)
set(_NINJA_BUILD_DIR out/Debug)
else (MSVC OR XCODE)
set(_GEN_ARGS ${_GEN_ARGS} is_debug=false)
set(_NINJA_BUILD_DIR out/Release)
endif (MSVC OR XCODE)
if (GN_EXTRA_ARGS)
set(_GEN_ARGS ${_GEN_ARGS} ${GN_EXTRA_ARGS})
endif (GN_EXTRA_ARGS)
if (WIN32)
set(_GN_EXECUTABLE gn.bat)
else (WIN32)
set(_GN_EXECUTABLE gn)
endif (WIN32)
set(_GEN_COMMAND ${_GN_EXECUTABLE} gen ${_NINJA_BUILD_DIR} --args=\"${_GEN_ARGS}\")

View file

@ -1,97 +0,0 @@
#
# Install library
file(GLOB_RECURSE _LIBRARY_FILES
${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})
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})
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

@ -1,30 +0,0 @@
if(LIBWEBRTC_COMMAND_INCLUDED)
return()
endif(LIBWEBRTC_COMMAND_INCLUDED)
set(LIBWEBRTC_COMMAND_INCLUDED true)
include(CMakeParseArguments)
include(Environment)
function(libwebrtc_command)
set(ONE_VALUE_ARGS NAME COMMENT WORKING_DIRECTORY)
set(MULTI_VALUE_ARGS COMMAND DEPENDS)
cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} )
set(CMF_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
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})
if (COMMAND_DEPENDS)
add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS})
endif (COMMAND_DEPENDS)
endfunction()

View file

@ -1,52 +0,0 @@
if (LIBWEBRTC_EXECUTE_INCLUDED)
return()
endif (LIBWEBRTC_EXECUTE_INCLUDED)
set(LIBWEBRTC_EXECUTE_INCLUDED true)
include(CMakeParseArguments)
include(Environment)
function (libwebrtc_execute)
set(ONE_VALUE_ARGS OUTPUT_VARIABLE WORKING_DIRECTORY STAMPFILE STATUS ERROR)
set(MULTI_VALUE_ARGS COMMAND)
cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
set(CMF_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
if (COMMAND_STAMPFILE)
set(STAMP_FILE "${CMF_DIR}/${COMMAND_STAMPFILE}")
if (EXISTS ${STAMP_FILE})
if (COMMAND_OUTPUT_VARIABLE)
file(READ ${STAMP_FILE} _OUTPUT)
if (_OUTPUT)
set(${COMMAND_OUTPUT_VARIABLE} ${_OUTPUT} PARENT_SCOPE)
endif (_OUTPUT)
endif (COMMAND_OUTPUT_VARIABLE)
return()
endif (EXISTS ${STAMP_FILE})
endif (COMMAND_STAMPFILE)
if (COMMAND_STATUS)
message(STATUS ${COMMAND_STATUS})
endif (COMMAND_STATUS)
execute_process(COMMAND ${COMMAND_COMMAND}
WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY}
OUTPUT_VARIABLE _OUTPUT
RESULT_VARIABLE _RESULT)
if (NOT _RESULT EQUAL 0)
message(FATAL_ERROR "-- " ${COMMAND_ERROR})
endif (NOT _RESULT EQUAL 0)
if (COMMAND_STAMPFILE)
file(WRITE ${STAMP_FILE} ${_OUTPUT})
endif (COMMAND_STAMPFILE)
if (COMMAND_OUTPUT_VARIABLE)
set(${COMMAND_OUTPUT_VARIABLE} ${_OUTPUT} PARENT_SCOPE)
endif (COMMAND_OUTPUT_VARIABLE)
endfunction ()

View file

@ -1,36 +0,0 @@
#
# Options, flags
option(BUILD_SAMPLE "Build sample" OFF)
set(DEPOT_TOOLS_PATH "" CACHE STRING "Path to your own depot_tools directory")
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC")
set(GN_EXTRA_ARGS "" CACHE STRING "Extra gn gen arguments to pass before generating build files")
set(WEBRTC_REVISION "" CACHE STRING "WebRTC commit hash to checkout")
set(WEBRTC_BRANCH_HEAD "${LIBWEBRTC_WEBRTC_HEAD}" CACHE STRING "WebRTC branch head to checkout")
if (DEPOT_TOOLS_PATH)
set(HAS_OWN_DEPOT_TOOLS 1)
endif (DEPOT_TOOLS_PATH)
#
# 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

@ -1,86 +0,0 @@
#
# 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_DEBIAN_PACKAGE_ARCHITECTURE "${_PACKAGE_ARCH}")
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_RPM_PACKAGE_ARCHITECTURE "${_PACKAGE_ARCH}")
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)
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}-debug)
endif (CMAKE_BUILD_TYPE MATCHES Debug)
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)

View file

@ -1,10 +0,0 @@
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@ @LIBWEBRTC_PC_LIBS_PRIVATE@
Cflags: -I${includedir} @LIBWEBRTC_PC_DEFINITIONS@ @LIBWEBRTC_PC_CXXFLAGS@

View file

@ -1,14 +0,0 @@
# 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

@ -1,19 +0,0 @@
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

@ -1,23 +0,0 @@
include(LibWebRTCExecute)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=-dirty
OUTPUT_VARIABLE _LIBWEBRTC_TAG
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
STAMPFILE webrtc-current-tag
STATUS "Retrieving current git tag"
ERROR "Unable to retrieve the current git tag"
)
string(STRIP ${_LIBWEBRTC_TAG} _LIBWEBRTC_TAG)
string(REGEX REPLACE "^v?([0-9]+)\\..*" "\\1" LIBWEBRTC_MAJOR_VERSION "${_LIBWEBRTC_TAG}")
string(REGEX REPLACE "^v?[0-9]+\\.([0-9]+).*" "\\1" LIBWEBRTC_MINOR_VERSION "${_LIBWEBRTC_TAG}")
string(REGEX REPLACE "^v?[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" LIBWEBRTC_PATCH_VERSION "${_LIBWEBRTC_TAG}")
string(REGEX REPLACE "^v?[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" LIBWEBRTC_BUILD_VERSION "${_LIBWEBRTC_TAG}")
set(LIBWEBRTC_API_VERSION
"${LIBWEBRTC_MAJOR_VERSION}.${LIBWEBRTC_MINOR_VERSION}.${LIBWEBRTC_PATCH_VERSION}")
set(LIBWEBRTC_VERSION
${LIBWEBRTC_API_VERSION}${LIBWEBRTC_BUILD_VERSION})
set(LIBWEBRTC_WEBRTC_HEAD refs/branch-heads/68)

275
README.md
View file

@ -1,10 +1,10 @@
# 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] # libwebrtc [![License][license-img]][license-href]
This repository contains a collection of CMake scripts to help you embed This repository contains a collection of CMake scripts to help you embed
Google's native WebRTC implementation inside your project as simple as this: Google's native WebRTC implementation inside your project as simple as this:
```cmake ```cmake
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.9)
project(sample) project(sample)
find_package(LibWebRTC REQUIRED) find_package(LibWebRTC REQUIRED)
@ -15,51 +15,9 @@ add_executable(sample ${SOURCE_FILES})
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES}) target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
``` ```
It also produces a `pkg-config` file if you prefer the classic way:
```
$ g++ `pkg-config --cflags LibWebRTC` main.cpp -o main `pkg-config --libs LibWebRTC`
```
## Status
The following table displays the current state of this project, including
supported platforms and architectures.
<table>
<tr>
<td align="center"></td>
<td align="center">x86</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></td>
<td></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">Windows</th>
<td align="center"></td>
<td align="center"></td>
<td></td>
<td></td>
</tr>
</table>
## Prerequisites ## Prerequisites
- CMake 3.3 or later - CMake 3.9 or later
- Python 2.7 (optional for Windows since it will use the interpreter located - Python 2.7 (optional for Windows since it will use the interpreter located
inside the `depot_tools` installation) inside the `depot_tools` installation)
@ -84,7 +42,7 @@ supported platforms and architectures.
### Windows ### Windows
- Windows 7 x64 or later - Windows 7 x64 or later
- Visual Studio 2015 **with updates** - Download the [Installer][vs2015-installer] - Visual Studio 2015/2017
Make sure that you install the following components: Make sure that you install the following components:
@ -96,65 +54,40 @@ supported platforms and architectures.
[Windows Driver Kit 10][wdk10] installed in the same Windows 10 SDK [Windows Driver Kit 10][wdk10] installed in the same Windows 10 SDK
installation directory. 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 ## Compiling
Clone the repository, create an output directory, browse inside it, Create an output directory, browse inside it, then run CMake to configure project.
then run CMake.
``` ```
$ git clone https://github.com/aisouard/libwebrtc.git mkdir build
$ cd libwebrtc cd build
$ mkdir out cmake -G Ninja -DCMAKE_BUILD_TYPE=<Debug/Release> -DCMAKE_INSTALL_PREFIX=<install_path> ..
$ cd out
$ cmake ..
``` ```
Windows users **must** add the Win64 suffix to their Visual Studio generator After configuration build library using standard CMake commands.
name if they want to build the library for 64-bit platforms, they'll omit it for
32-bit builds and define the `TARGET_CPU` variable accordingly.
``` ```
> cmake -G "Visual Studio 14 2015" -DTARGET_CPU=x86 cmake --build .
> cmake -G "Visual Studio 14 2015 Win64" cmake --install .
``` ```
Then they'll have to open the `libwebrtc.sln` located inside the current output The library will be located inside the `lib` subdirectory of the `<install_path>`.
directory and build the `ALL_BUILD` project. The `include` subdirectory will contain the header files.
CMake scripts will be placed inside the `lib/cmake/LibWebRTC` subdirectory.
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.
## Debug and Release configurations
If you are using XCode or Visual Studio, you can simply switch between the Debug
and Release configuration from your IDE. The debugging flags will be
appended to the generator's parameters.
Otherwise, you must define the `CMAKE_BUILD_TYPE` variable to `Debug`.
```
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
```
## Using WebRTC in your project ## Using WebRTC in your project
At the time of writing this README file, there's no proper way to detect any To import LibWebRTC into your CMake project use `find_package`:
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.
```cmake ```cmake
find_package(LibWebRTC REQUIRED) find_package(LibWebRTC REQUIRED)
include(${LIBWEBRTC_USE_FILE}) include(${LIBWEBRTC_USE_FILE})
@ -162,40 +95,10 @@ include(${LIBWEBRTC_USE_FILE})
target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES}) target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES})
``` ```
A pkg-config file is also provided, you can obtain the required compiler and You should add library installation path to `CMAKE_INSTALL_PREFIX` variable
linker flags by specifying `LibWebRTC` as the package name. while configuring your project:
``` ```
$ pkg-config --cflags --libs LibWebRTC cmake -DCMAKE_PREFIX_PATH=<install_path> ...
```
## Fetching a specific revision
The latest working release will be fetched by default, unless you decide to
retrieve a specific commit by setting it's hash into the **WEBRTC_REVISION**
CMake variable, or another branch head ref into the **WEBRTC_BRANCH_HEAD**
variable.
```
$ cmake -DWEBRTC_REVISION=be22d51 ..
$ cmake -DWEBRTC_BRANCH_HEAD=refs/branch-heads/68 ..
```
If both variables are set, it will focus on fetching the commit defined inside
**WEBRTC_REVISION**.
## Managing depot_tools
CMake will retrieve the latest revision of the `depot_tools` repository. It will
get the WebRTC repository's commit date, then check-out `depot_tools` to the
commit having the closest date to WebRTC's, in order to ensure a high
compatibility with `gclient` and other tools.
It is possible to prevent this behavior by specifying the location to your own
`depot_tools` repository by defining the **DEPOT_TOOLS_PATH** variable.
```
$ cmake -DDEPOT_TOOLS_PATH=/opt/depot_tools ..
``` ```
## Configuration ## Configuration
@ -204,27 +107,6 @@ 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 architecture. Here are some CMake flags which could be useful if you need to
perform cross-compiling. 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 unit tests and mocked classes such as `FakeAudioCaptureModule`.
- **BUILD_SAMPLE**
Build an executable located inside the `sample` folder.
- **DEPOT_TOOLS_PATH**
Set this variable to your own `depot_tools` directory. This will prevent
CMake from fetching the one matching with the desired WebRTC revision.
- **GN_EXTRA_ARGS** - **GN_EXTRA_ARGS**
Add extra arguments to the `gn gen --args` parameter. Add extra arguments to the `gn gen --args` parameter.
@ -233,47 +115,56 @@ perform cross-compiling.
Arguments to pass while executing the `ninja` command. Arguments to pass while executing the `ninja` command.
- **TARGET_OS** ## Status
Target operating system, the value will be used inside the `--target_os` The following table displays the current state of this project, including
argument of the `gn gen` command. The value **must** be one of the following: supported platforms and architectures.
- `android`
- `chromeos`
- `ios`
- `linux`
- `mac`
- `nacl`
- `win`
- **TARGET_CPU** <table>
<tr>
<td align="center"></td>
<td align="center">x86</td>
<td align="center">amd64</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>
</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>
</tr>
</table>
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`
- **WEBRTC_BRANCH_HEAD**
Set the branch head ref to retrieve, it is set to the latest working one.
This variable is ignored if **WEBRTC_REVISION** is set.
- **WEBRTC_REVISION**
Set a specific commit hash to check-out.
## 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.
## Acknowledgements ## Acknowledgements
@ -281,26 +172,12 @@ Many thanks to Dr. Alex Gouaillard for being an excellent mentor for this
project. project.
Everything started from his Everything started from his
« [Automating libwebrtc build with CMake][webrtc-dr-alex-cmake] » blog article, «[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 which was a great source of inspiration for me to create the easiest way to link
the WebRTC library in any native project. the WebRTC library in any native project.
## License
Apache License 2.0 © [Axel Isouard][author]
[license-img]:https://img.shields.io/badge/License-Apache%202.0-blue.svg [license-img]:https://img.shields.io/badge/License-Apache%202.0-blue.svg
[license-href]:https://opensource.org/licenses/Apache-2.0 [license-href]:https://opensource.org/licenses/Apache-2.0
[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
[w10sdk]:https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk [w10sdk]:https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
[wdk10]:https://go.microsoft.com/fwlink/p/?LinkId=526733 [wdk10]:https://go.microsoft.com/fwlink/p/?LinkId=526733
[twitter]:https://twitter.com/aisouard
[webrtc-dr-alex-cmake]:http://webrtcbydralex.com/index.php/2015/07/22/automating-libwebrtc-build-with-cmake [webrtc-dr-alex-cmake]:http://webrtcbydralex.com/index.php/2015/07/22/automating-libwebrtc-build-with-cmake
[author]:https://axel.isouard.fr

View file

@ -1,39 +0,0 @@
image: Visual Studio 2017
matrix:
fast_finish: true
platform:
- x86
configuration:
- Release
- Debug
clone_folder: c:\projects\libwebrtc
before_build:
- cmd: set GYP_MSVS_VERSION=2017
- cd c:\projects\libwebrtc
- if "%platform%"=="x86" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017
- if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017 Win64
- cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%configuration% -DWEBRTC_BRANCH_HEAD=refs/branch-heads/68 -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc .
build:
project: PACKAGE.vcxproj
artifacts:
- path: libwebrtc-*.zip
name: Releases
deploy:
provider: GitHub
auth_token:
secure: QQrYk1F7DLgQ9eht+J6hvDiDRu8a+AKKwsOetybrL8B32UYxlNJKSZIpD0yHPVsx
artifact: /libwebrtc-.*\.zip/
draft: false
prerelease: false
on:
appveyor_repo_tag: true
test: off

View file

@ -0,0 +1,75 @@
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

@ -10,8 +10,8 @@ if (UNIX AND NOT APPLE)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if (CMAKE_HAVE_THREADS_LIBRARY) if (CMAKE_HAVE_THREADS_LIBRARY)
list(APPEND LIBWEBRTC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) list(APPEND LIBWEBRTC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif (CMAKE_HAVE_THREADS_LIBRARY) endif ()
endif (UNIX AND NOT APPLE) endif ()
if (APPLE) if (APPLE)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox) find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
@ -22,9 +22,9 @@ if (APPLE)
list(APPEND LIBWEBRTC_LIBRARIES ${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY} list(APPEND LIBWEBRTC_LIBRARIES ${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY}) ${COREFOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY})
endif (APPLE) endif ()
if (WIN32) if (WIN32)
list(APPEND LIBWEBRTC_LIBRARIES msdmo.lib wmcodecdspuuid.lib dmoguids.lib list(APPEND LIBWEBRTC_LIBRARIES msdmo.lib wmcodecdspuuid.lib dmoguids.lib
crypt32.lib iphlpapi.lib ole32.lib secur32.lib winmm.lib ws2_32.lib) crypt32.lib iphlpapi.lib ole32.lib secur32.lib winmm.lib ws2_32.lib)
endif (WIN32) endif ()

10
cmake/PatchSources.cmake Normal file
View file

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

13
cmake/Utils.cmake Normal file
View file

@ -0,0 +1,13 @@
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()

14
cmake/Version.cmake Normal file
View file

@ -0,0 +1,14 @@
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()

View file

@ -1,27 +0,0 @@
if (DEPOT_TOOLS_PATH)
return()
endif (DEPOT_TOOLS_PATH)
include(ExternalProject)
if (WIN32)
set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/gclient.bat)
else (WIN32)
set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/gclient)
endif (WIN32)
ExternalProject_Add(
depot-tools
GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools
PREFIX ${CMAKE_BINARY_DIR}/depot_tools
CONFIGURE_COMMAND ""
UPDATE_COMMAND ""
PATCH_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
set(_NEXT_DEPENDS depot-tools)

View file

@ -1,84 +1,129 @@
cmake_minimum_required(VERSION 3.0) if (BUILD_DEB_PACKAGE)
project(libwebrtc) set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH INTERNAL FORCE)
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/modules/audio_coding/delay_test/utility${_OBJ_EXT}
${WEBRTC_OUTPUT_DIR}/obj/webrtc/modules/modules_tests/utility${_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 () endif ()
add_library(webrtc STATIC ${_OBJ_FILES}) # Prepare CMake exports
configure_file(LibWebRTCConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfig.cmake @ONLY)
set_source_files_properties(${_OBJ_FILES} PROPERTIES configure_file(LibWebRTCConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibWebRTCConfigVersion.cmake @ONLY)
EXTERNAL_OBJECT true
GENERATED true)
set_target_properties(webrtc PROPERTIES
LINKER_LANGUAGE C
LIBRARY_OUTPUT_DIRECTORY ${WEBRTC_OUTPUT_DIR}
PREFIX lib)
######################
# INSTALL SECTION
######################
# Install headers # Install headers
install(FILES "${WEBRTC_SOURCE_DIR}/common_types.h" DESTINATION "include/webrtc")
install(FILES "${WEBRTC_SOURCE_DIR}/typedefs.h" DESTINATION "include/webrtc")
install(DIRECTORY install(DIRECTORY
"${WEBRTC_SOURCE_DIR}/api" "${WEBRTC_SOURCE_DIR}/api"
"${WEBRTC_SOURCE_DIR}/base" "${WEBRTC_SOURCE_DIR}/base"
"${WEBRTC_SOURCE_DIR}/call" "${WEBRTC_SOURCE_DIR}/call"
"${WEBRTC_SOURCE_DIR}/common_video" "${WEBRTC_SOURCE_DIR}/common_audio"
"${WEBRTC_SOURCE_DIR}/logging" "${WEBRTC_SOURCE_DIR}/common_video"
"${WEBRTC_SOURCE_DIR}/media" "${WEBRTC_SOURCE_DIR}/logging"
"${WEBRTC_SOURCE_DIR}/modules" "${WEBRTC_SOURCE_DIR}/media"
"${WEBRTC_SOURCE_DIR}/p2p" "${WEBRTC_SOURCE_DIR}/modules"
"${WEBRTC_SOURCE_DIR}/pc" "${WEBRTC_SOURCE_DIR}/p2p"
"${WEBRTC_SOURCE_DIR}/rtc_base" "${WEBRTC_SOURCE_DIR}/pc"
"${WEBRTC_SOURCE_DIR}/system_wrappers" "${WEBRTC_SOURCE_DIR}/rtc_base"
DESTINATION "include/webrtc" "${WEBRTC_SOURCE_DIR}/system_wrappers"
FILES_MATCHING PATTERN "*.h") 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" install(DIRECTORY "${WEBRTC_SOURCE_DIR}/third_party/jsoncpp"
DESTINATION "include/webrtc/third_party" DESTINATION "include/webrtc/third_party"
FILES_MATCHING PATTERN "*.h") 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 # Install pdb files
if (CMAKE_BUILD_TYPE MATCHES Debug) if (MSVC)
file(GLOB_RECURSE PDB_FILES [${WEBRTC_OUTPUT_DIR} "*.pdb") # TODO: fix install on first run
install(FILES ${PDB_FILES} DESTINATION lib) file(GLOB_RECURSE PDB_FILES "${WEBRTC_BUILD_DIR}/Debug/*.pdb")
endif() install(FILES DESTINATION lib COMPONENT debug)
endif()
# Install library # Install library
install(TARGETS webrtc if (WIN32)
EXPORT LibWebRTCTargets set(LIBRARY_FILENAME_DEBUG "webrtcd.lib")
ARCHIVE DESTINATION lib set(LIBRARY_FILENAME_RELEASE "webrtc.lib")
RUNTIME DESTINATION bin else()
LIBRARY DESTINATION lib set(LIBRARY_FILENAME_DEBUG "libwebrtcd.a")
INCLUDES DESTINATION include) set(LIBRARY_FILENAME_RELEASE "libwebrtc.a")
endif()
install(EXPORT LibWebRTCTargets if (CMAKE_BUILD_TYPE STREQUAL "Debug")
FILE LibWebRTCTargets.cmake if (WIN32)
DESTINATION ${INSTALL_CMAKE_DIR}) 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 ${CMAKE_MODULE_PATH}/Templates/UseLibWebRTC.cmake
DESTINATION ${INSTALL_CMAKE_DIR}) 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

@ -8,39 +8,19 @@
# LIBWEBRTC_USE_FILE - path to the CMake use file # LIBWEBRTC_USE_FILE - path to the CMake use file
# #
# - Version variables: # - Version variables:
# LIBWEBRTC_MAJOR_VERSION - major version # WEBRTC_VERSION - WebRTC version with build prefix
# 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_WEBRTC_BRANCH_HEAD - WebRTC's Git branch head refspec used for that release
# LIBWEBRTC_API_VERSION - full version without build prefix
# LIBWEBRTC_VERSION - full version with build prefix
# #
# - Library type and targets variables: # - Library type and targets variables:
# LIBWEBRTC_TARGET_OS - android, chromeos, ios, linux, nacl, mac or win # LIBWEBRTC_TARGET_OS - android, chromeos, ios, linux, nacl, mac or win
# LIBWEBRTC_TARGET_CPU - x86, x64, arm, arm64 or mipsel # LIBWEBRTC_TARGET_CPU - x86, x64, arm, arm64 or mipsel
# LibWebRTC version number # WebRTC version number (branch head)
set(LIBWEBRTC_MAJOR_VERSION "@LIBWEBRTC_MAJOR_VERSION@") set(WEBRTC_VERSION "@WEBRTC_VERSION@")
set(LIBWEBRTC_MINOR_VERSION "@LIBWEBRTC_MINOR_VERSION@")
set(LIBWEBRTC_PATCH_VERSION "@LIBWEBRTC_PATCH_VERSION@")
set(LIBWEBRTC_BUILD_VERSION "@LIBWEBRTC_BUILD_VERSION@")
set(LIBWEBRTC_API_VERSION "@LIBWEBRTC_API_VERSION@")
set(LIBWEBRTC_VERSION "@LIBWEBRTC_VERSION@")
set(LIBWEBRTC_WEBRTC_REVISION "@WEBRTC_REVISION@")
set(LIBWEBRTC_WEBRTC_BRANCH_HEAD "@WEBRTC_BRANCH_HEAD@")
# LibWebRTC library type, target OS and target CPU # LibWebRTC library type, target OS and target CPU
set(LIBWEBRTC_TARGET_OS "@TARGET_OS@") set(LIBWEBRTC_TARGET_OS "@TARGET_OS@")
set(LIBWEBRTC_TARGET_CPU "@TARGET_CPU@") 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 the expected libraries variable
set(LIBWEBRTC_LIBRARIES @LIBWEBRTC_LIBRARIES@) set(LIBWEBRTC_LIBRARIES @LIBWEBRTC_LIBRARIES@)
@ -52,10 +32,11 @@ 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_DEBUG "@LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG@")
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE@") set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE@")
set(LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS "@LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS@") set(LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS "@LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS@")
set(LIBWEBRTC_DEFINITIONS "@LIBWEBRTC_DEFINITIONS@") set(LIBWEBRTC_DEFINITIONS_DEBUG "@LIBWEBRTC_DEFINITIONS_DEBUG@")
set(LIBWEBRTC_DEFINITIONS_RELEASE "@LIBWEBRTC_DEFINITIONS_RELEASE@")
# The location of the UseLibWebRTC.cmake file. # The location of the UseLibWebRTC.cmake file.
set(LIBWEBRTC_CMAKE_DIR "@INSTALL_CMAKE_DIR@") set(LIBWEBRTC_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(LIBWEBRTC_USE_FILE "${LIBWEBRTC_CMAKE_DIR}/UseLibWebRTC.cmake") set(LIBWEBRTC_USE_FILE "${LIBWEBRTC_CMAKE_DIR}/UseLibWebRTC.cmake")
# Import LibWebRTC targets. # Import LibWebRTC targets.

View file

@ -0,0 +1,8 @@
# 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

@ -0,0 +1,23 @@
#----------------------------------------------------------------
# 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

@ -0,0 +1,23 @@
#----------------------------------------------------------------
# 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

@ -0,0 +1,83 @@
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

@ -4,6 +4,8 @@
# settings to use LibWebRTC. # settings to use LibWebRTC.
# #
cmake_minimum_required(VERSION 3.9)
if (LIBWEBRTC_USE_FILE_INCLUDED) if (LIBWEBRTC_USE_FILE_INCLUDED)
return() return()
endif () endif ()
@ -26,10 +28,11 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBWEBRTC_REQUIRED_CXX
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS}") set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS}")
# Add preprocessor definitions needed to use LibWebRTC. # Add preprocessor definitions needed to use LibWebRTC.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS}) if (GENERATOR_IS_MULTI_CONFIG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG ${LIBWEBRTC_DEFINITIONS_DEBUG})
# Add include directories needed to use LibWebRTC. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE ${LIBWEBRTC_DEFINITIONS_RELEASE})
include_directories(${LIBWEBRTC_INCLUDE_DIRS}) elseif (CMAKE_BUILD_TYPE MATCHES Debug)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS_DEBUG})
# Add link directories needed to use LibWebRTC. else ()
link_directories(${LIBWEBRTC_LIBRARY_DIRS}) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS_RELEASE})
endif ()

0
patches/.gitkeep Normal file
View file

View file

@ -1,21 +0,0 @@
cmake_minimum_required(VERSION 3.3)
project(sample)
find_package(LibWebRTC REQUIRED)
include(${LIBWEBRTC_USE_FILE})
set(SOURCE_FILES main.cpp)
add_executable(sample ${SOURCE_FILES})
target_link_libraries(sample ${LIBWEBRTC_LIBRARIES})
set(_STAMP_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/check-sample-done)
add_custom_command(
OUTPUT ${_STAMP_FILE}
COMMENT "Run generated sample"
COMMAND sample
COMMAND ${CMAKE_COMMAND} -E touch ${_STAMP_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(check-sample ALL DEPENDS ${_STAMP_FILE})
add_dependencies(check-sample sample)

View file

@ -1,67 +0,0 @@
/*
* Copyright (c) 2017 Axel Isouard <axel@isouard.fr>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <webrtc/api/peerconnectioninterface.h>
#include <webrtc/base/ssladapter.h>
#include <webrtc/base/thread.h>
#ifdef WIN32
#include <webrtc/base/win32socketinit.h>
#include <webrtc/base/win32socketserver.h>
#include <Windows.h>
#endif
int main(int argc, char **argv) {
#ifdef WIN32
rtc::EnsureWinsockInit();
rtc::Win32Thread w32_thread;
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
#endif
rtc::InitializeSSL();
rtc::InitRandom(rtc::Time());
rtc::ThreadManager::Instance()->WrapCurrentThread();
rtc::Thread *signalingThread = new rtc::Thread();
rtc::Thread *workerThread = new rtc::Thread();
signalingThread->SetName("signaling_thread", NULL);
workerThread->SetName("worker_thread", NULL);
if (!signalingThread->Start() || !workerThread->Start()) {
return 1;
}
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pcFactory =
webrtc::CreatePeerConnectionFactory(signalingThread,
workerThread,
NULL, NULL, NULL);
pcFactory = NULL;
if (rtc::ThreadManager::Instance()->CurrentThread() == signalingThread) {
rtc::ThreadManager::Instance()->SetCurrentThread(NULL);
}
signalingThread->Stop();
workerThread->Stop();
delete signalingThread;
delete workerThread;
rtc::CleanupSSL();
return 0;
}

78
sync.py Executable file
View file

@ -0,0 +1,78 @@
#!/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')

View file

@ -1,155 +0,0 @@
cmake_minimum_required(VERSION 3.3)
project(webrtc)
find_package(Git REQUIRED)
if (WIN32)
set(PYTHON_EXECUTABLE ${DEPOT_TOOLS_PATH}/python.bat)
else (WIN32)
find_package(PythonInterp 2.7 REQUIRED)
endif (WIN32)
include(LibWebRTCExecute)
if (WEBRTC_REVISION)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} checkout ${WEBRTC_REVISION}
OUTPUT_VARIABLE _WEBRTC_CHECKOUT
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
STAMPFILE webrtc-checkout-commit
STATUS "Checking out webrtc to commit ${WEBRTC_REVISION}"
ERROR "Unable to checkout webrtc to commit ${WEBRTC_REVISION}"
)
elseif (WEBRTC_BRANCH_HEAD)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$
OUTPUT_VARIABLE _WEBRTC_CONFIG_FETCH
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
STAMPFILE webrtc-config-fetch
STATUS "Setting up branch-heads refspecs"
ERROR "Unable to add branch-heads refspec to the git config"
)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD}
OUTPUT_VARIABLE _WEBRTC_FETCH
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
STAMPFILE webrtc-fetch-branch-heads
STATUS "Fetching ${WEBRTC_BRANCH_HEAD}"
ERROR "Unable to fetch ${WEBRTC_BRANCH_HEAD}"
)
libwebrtc_execute(
COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD
OUTPUT_VARIABLE _WEBRTC_CHECKOUT
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
STAMPFILE webrtc-checkout-branch-head
STATUS "Checking out ${WEBRTC_BRANCH_HEAD}"
ERROR "Unable to checkout ${WEBRTC_BRANCH_HEAD}"
)
endif (WEBRTC_REVISION)
include(DepotTools)
include(GClient)
include(Environment)
include(LibWebRTCCommand)
libwebrtc_command(
NAME webrtc-sync
COMMAND ${GCLIENT_EXECUTABLE} sync --force
WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}"
COMMENT "Synchronizing WebRTC"
)
libwebrtc_command(
NAME webrtc-clang
COMMAND ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py
WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}"
COMMENT "Updating clang"
DEPENDS webrtc-sync
)
set(_DEPENDENCIES webrtc-clang)
if (UNIX AND NOT APPLE)
set(SYSROOT_ARCH ${TARGET_CPU})
if (SYSROOT_ARCH STREQUAL "x64")
set(SYSROOT_ARCH "amd64")
elseif (SYSROOT_ARCH STREQUAL "x86")
set(SYSROOT_ARCH "i386")
endif (SYSROOT_ARCH STREQUAL "x64")
libwebrtc_command(
NAME webrtc-toolchain
COMMAND ${PYTHON_EXECUTABLE} ${WEBRTC_PARENT_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --arch=${SYSROOT_ARCH}
WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}"
COMMENT "Retrieving sysroot"
DEPENDS webrtc-sync
)
set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-toolchain)
set(_PLATFORM linux*)
set(_FOLDER linux64)
elseif (APPLE)
set(_PLATFORM darwin)
set(_FOLDER mac)
elseif (WIN32)
libwebrtc_command(
NAME webrtc-toolchain
COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update
WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}"
COMMENT "Retrieving Visual Studio toolchain"
DEPENDS webrtc-sync
)
set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-toolchain)
set(_PLATFORM win32)
set(_FOLDER win)
set(_SUFFIX .exe)
set(_SCRIPT_SUFFIX .bat)
endif (UNIX AND NOT APPLE)
set(_GN_COMMAND download_from_google_storage${_SCRIPT_SUFFIX} --no_resume --platform=${_PLATFORM}
--no_auth --bucket chromium-gn
-s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1)
libwebrtc_command(
NAME webrtc-gn
COMMAND ${_GN_COMMAND}
WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}"
COMMENT "Fetching gn${_SUFFIX} for ${_PLATFORM}"
DEPENDS webrtc-sync
)
set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-gn)
set(_CLANG_FORMAT_COMMAND download_from_google_storage${_SCRIPT_SUFFIX} --no_resume
--platform=${_PLATFORM} --no_auth --bucket chromium-clang-format
-s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1)
libwebrtc_command(
NAME webrtc-clang-format
COMMAND ${_CLANG_FORMAT_COMMAND}
WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}"
COMMENT "Fetching clang-format${_SUFFIX} for ${_PLATFORM}"
DEPENDS webrtc-gn
)
set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-clang-format)
include(Gn)
libwebrtc_command(
NAME webrtc-generate
COMMAND ${_GEN_COMMAND}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Generating build files"
DEPENDS ${_DEPENDENCIES}
)
set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C ${_NINJA_BUILD_DIR} pc:peerconnection system_wrappers:field_trial_default system_wrappers:metrics_default jsoncpp)
libwebrtc_command(
NAME webrtc-build
COMMAND ${_NINJA_COMMAND}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Running ninja"
DEPENDS webrtc-generate
)