├── AUTHORS ├── .gitignore ├── webrtc ├── fix-gn.sh └── CMakeLists.txt ├── CMakeModules ├── Templates │ ├── LibWebRTC.pc.in │ ├── LibWebRTCConfigVersion.cmake.in │ ├── Uninstall.cmake.in │ ├── UseLibWebRTC.cmake │ └── LibWebRTCConfig.cmake.in ├── FindDepotTools.cmake ├── GClient.cmake ├── LibWebRTCCommand.cmake ├── Version.cmake ├── FindLibraries.cmake ├── Environment.cmake ├── Gn.cmake ├── Options.cmake ├── LibWebRTCExecute.cmake ├── DepotTools.cmake ├── Package.cmake ├── TargetOsAndCpu.cmake └── Install.cmake ├── depot_tools └── CMakeLists.txt ├── sample ├── CMakeLists.txt └── main.cpp ├── appveyor.yml ├── CHANGELOG.md ├── libwebrtc └── CMakeLists.txt ├── .travis.yml ├── CMakeLists.txt ├── README.md └── LICENSE /AUTHORS: -------------------------------------------------------------------------------- 1 | Axel Isouard 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /out/ 3 | /.idea/ 4 | *.gclient 5 | *.gclient_entries 6 | /cmake-build-debug/ 7 | -------------------------------------------------------------------------------- /webrtc/fix-gn.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | sed -i.bak 's/defines = \[\]/defines = [ "_GLIBCXX_USE_CXX11_ABI=0" ]/' BUILD.gn 3 | sed -i.bak '11 a\ defines += [ "_GLIBCXX_USE_CXX11_ABI=0" ]' third_party/protobuf/BUILD.gn 4 | sed -i.bak '659 a\ defines += [ "_GLIBCXX_USE_CXX11_ABI=0" ]' rtc_base/BUILD.gn 5 | sed -i.bak '32 a\ defines += [ "_GLIBCXX_USE_CXX11_ABI=0" ]' third_party/jsoncpp/BUILD.gn -------------------------------------------------------------------------------- /CMakeModules/Templates/LibWebRTC.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: LibWebRTC 7 | Description: Google's native WebRTC implementation shipped into a single library 8 | Version: @LIBWEBRTC_VERSION@ 9 | Libs: @LIBWEBRTC_PC_LIBS@ @LIBWEBRTC_PC_LIBS_PRIVATE@ 10 | Cflags: -I${includedir} @LIBWEBRTC_PC_DEFINITIONS@ @LIBWEBRTC_PC_CXXFLAGS@ 11 | -------------------------------------------------------------------------------- /depot_tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (DEPOT_TOOLS_PATH) 2 | return() 3 | endif (DEPOT_TOOLS_PATH) 4 | 5 | include(ExternalProject) 6 | 7 | if (WIN32) 8 | set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/gclient.bat) 9 | else (WIN32) 10 | set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/gclient) 11 | endif (WIN32) 12 | 13 | ExternalProject_Add( 14 | depot-tools 15 | 16 | GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools 17 | 18 | PREFIX ${CMAKE_BINARY_DIR}/depot_tools 19 | 20 | CONFIGURE_COMMAND "" 21 | UPDATE_COMMAND "" 22 | PATCH_COMMAND "" 23 | BUILD_COMMAND "" 24 | INSTALL_COMMAND "" 25 | ) 26 | 27 | set(_NEXT_DEPENDS depot-tools) 28 | -------------------------------------------------------------------------------- /sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3) 2 | project(sample) 3 | 4 | find_package(LibWebRTC REQUIRED) 5 | include(${LIBWEBRTC_USE_FILE}) 6 | 7 | set(SOURCE_FILES main.cpp) 8 | add_executable(sample ${SOURCE_FILES}) 9 | target_link_libraries(sample ${LIBWEBRTC_LIBRARIES}) 10 | 11 | set(_STAMP_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/check-sample-done) 12 | add_custom_command( 13 | OUTPUT ${_STAMP_FILE} 14 | COMMENT "Run generated sample" 15 | COMMAND sample 16 | COMMAND ${CMAKE_COMMAND} -E touch ${_STAMP_FILE} 17 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 18 | ) 19 | 20 | add_custom_target(check-sample ALL DEPENDS ${_STAMP_FILE}) 21 | add_dependencies(check-sample sample) 22 | -------------------------------------------------------------------------------- /CMakeModules/Templates/LibWebRTCConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | # The full LibWebRTC version number. 2 | set(PACKAGE_VERSION "@LIBWEBRTC_API_VERSION@") 3 | 4 | # This version is compatible only with matching major.minor versions. 5 | if ("@LIBWEBRTC_MAJOR_VERSION@.@LIBWEBRTC_MINOR_VERSION@" VERSION_EQUAL 6 | "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}") 7 | # This version is compatible with equal or lesser patch versions. 8 | if (NOT "@LIBWEBRTC_PATCH_VERSION@" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}") 9 | set(PACKAGE_VERSION_COMPATIBLE 1) 10 | if ("@LIBWEBRTC_PATCH_VERSION@" VERSION_EQUAL "${PACKAGE_FIND_VERSION_PATCH}") 11 | set(PACKAGE_VERSION_EXACT 1) 12 | endif () 13 | endif () 14 | endif () 15 | -------------------------------------------------------------------------------- /CMakeModules/FindDepotTools.cmake: -------------------------------------------------------------------------------- 1 | find_program(GCLIENT_EXECUTABLE 2 | NAMES gclient gclient.bat 3 | DOC "Path to gclient executable" 4 | HINTS ${DEPOT_TOOLS_PATH} ENV DEPOT_TOOLS_PATH) 5 | 6 | find_path(DEPOT_TOOLS_PATH 7 | NAMES gclient gclient.py gclient.bat 8 | ninja ninja.exe ninja-linux32 ninja-linux64 ninja-mac 9 | download_from_google_storage download_from_google_storage.bat 10 | download_from_google_storage.py 11 | DOC "Path to depot_tools directory" 12 | HINTS ${DEPOT_TOOLS_PATH} ENV DEPOT_TOOLS_PATH) 13 | 14 | include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) 15 | find_package_handle_standard_args(DepotTools 16 | REQUIRED_VARS GCLIENT_EXECUTABLE DEPOT_TOOLS_PATH 17 | FAIL_MESSAGE "Could not find depot_tools.") 18 | -------------------------------------------------------------------------------- /CMakeModules/GClient.cmake: -------------------------------------------------------------------------------- 1 | file(WRITE ${WEBRTC_PARENT_DIR}/.gclient "solutions = [ 2 | { 3 | \"url\": \"https://chromium.googlesource.com/external/webrtc.git\", 4 | \"managed\": False, 5 | \"name\": \"src\", 6 | \"deps_file\": \"DEPS\", 7 | \"custom_deps\": {}, 8 | }, 9 | ] 10 | ") 11 | 12 | if (TARGET_OS STREQUAL "android") 13 | file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"android\", \"unix\"]") 14 | elseif (TARGET_OS STREQUAL "ios") 15 | file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"ios\", \"mac\"]") 16 | elseif (TARGET_OS STREQUAL "linux") 17 | file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"unix\"]") 18 | elseif (TARGET_OS STREQUAL "mac") 19 | file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"mac\"]") 20 | elseif (TARGET_OS STREQUAL "win") 21 | file(APPEND ${WEBRTC_PARENT_DIR}/.gclient "target_os = [\"win\"]") 22 | endif (TARGET_OS STREQUAL "android") 23 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | os: Visual Studio 2015 2 | 3 | matrix: 4 | fast_finish: true 5 | 6 | platform: 7 | - x86 8 | - x64 9 | 10 | configuration: 11 | - Debug 12 | - Release 13 | 14 | clone_folder: c:\projects\libwebrtc 15 | 16 | before_build: 17 | - cd c:\projects\libwebrtc 18 | - if "%platform%"=="x86" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 19 | - if "%platform%"=="x64" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015 Win64 20 | - cmake -G "%CMAKE_GENERATOR_NAME%" -DBUILD_SAMPLE=1 -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=c:\projects\libwebrtc . 21 | 22 | build: 23 | project: PACKAGE.vcxproj 24 | 25 | artifacts: 26 | - path: libwebrtc-*.zip 27 | name: Releases 28 | 29 | deploy: 30 | provider: GitHub 31 | auth_token: 32 | secure: QQrYk1F7DLgQ9eht+J6hvDiDRu8a+AKKwsOetybrL8B32UYxlNJKSZIpD0yHPVsx 33 | artifact: /libwebrtc-.*\.zip/ 34 | draft: false 35 | prerelease: false 36 | on: 37 | appveyor_repo_tag: true 38 | 39 | test: off 40 | -------------------------------------------------------------------------------- /CMakeModules/LibWebRTCCommand.cmake: -------------------------------------------------------------------------------- 1 | if(LIBWEBRTC_COMMAND_INCLUDED) 2 | return() 3 | endif(LIBWEBRTC_COMMAND_INCLUDED) 4 | set(LIBWEBRTC_COMMAND_INCLUDED true) 5 | 6 | include(CMakeParseArguments) 7 | include(Environment) 8 | 9 | function(libwebrtc_command) 10 | set(ONE_VALUE_ARGS NAME COMMENT WORKING_DIRECTORY) 11 | set(MULTI_VALUE_ARGS COMMAND DEPENDS) 12 | cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} ) 13 | 14 | set(CMF_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) 15 | set(STAMP_FILE "${CMF_DIR}/${COMMAND_NAME}-complete") 16 | 17 | add_custom_command( 18 | OUTPUT ${STAMP_FILE} 19 | COMMENT ${COMMAND_COMMENT} 20 | COMMAND ${PREFIX_EXECUTE} ${COMMAND_COMMAND} 21 | COMMAND ${CMAKE_COMMAND} -E touch ${STAMP_FILE} 22 | WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY} 23 | ) 24 | 25 | add_custom_target(${COMMAND_NAME} ALL DEPENDS ${STAMP_FILE}) 26 | 27 | if (COMMAND_DEPENDS) 28 | add_dependencies(${COMMAND_NAME} ${COMMAND_DEPENDS}) 29 | endif (COMMAND_DEPENDS) 30 | endfunction() 31 | -------------------------------------------------------------------------------- /CMakeModules/Templates/Uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 11 | OUTPUT_VARIABLE rm_out 12 | RETURN_VALUE rm_retval) 13 | if(NOT "${rm_retval}" STREQUAL 0) 14 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 15 | endif(NOT "${rm_retval}" STREQUAL 0) 16 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 17 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 18 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | endforeach(file) 20 | -------------------------------------------------------------------------------- /CMakeModules/Version.cmake: -------------------------------------------------------------------------------- 1 | include(LibWebRTCExecute) 2 | 3 | libwebrtc_execute( 4 | COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=-dirty --always 5 | OUTPUT_VARIABLE _LIBWEBRTC_TAG 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 7 | STAMPFILE webrtc-current-tag 8 | STATUS "Retrieving current git tag" 9 | ERROR "Unable to retrieve the current git tag" 10 | ) 11 | string(STRIP ${_LIBWEBRTC_TAG} _LIBWEBRTC_TAG) 12 | 13 | string(REGEX REPLACE "^v?([0-9]+)\\..*" "\\1" LIBWEBRTC_MAJOR_VERSION "${_LIBWEBRTC_TAG}") 14 | string(REGEX REPLACE "^v?[0-9]+\\.([0-9]+).*" "\\1" LIBWEBRTC_MINOR_VERSION "${_LIBWEBRTC_TAG}") 15 | string(REGEX REPLACE "^v?[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" LIBWEBRTC_PATCH_VERSION "${_LIBWEBRTC_TAG}") 16 | string(REGEX REPLACE "^v?[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" LIBWEBRTC_BUILD_VERSION "${_LIBWEBRTC_TAG}") 17 | 18 | set(LIBWEBRTC_API_VERSION 19 | "${LIBWEBRTC_MAJOR_VERSION}.${LIBWEBRTC_MINOR_VERSION}.${LIBWEBRTC_PATCH_VERSION}") 20 | set(LIBWEBRTC_VERSION 21 | ${LIBWEBRTC_API_VERSION}${LIBWEBRTC_BUILD_VERSION}) 22 | 23 | set(LIBWEBRTC_WEBRTC_HEAD refs/branch-heads/70) 24 | -------------------------------------------------------------------------------- /CMakeModules/FindLibraries.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find required packages 3 | list(APPEND LIBWEBRTC_LIBRARIES webrtc) 4 | 5 | if (UNIX AND NOT APPLE) 6 | find_package(X11 REQUIRED) 7 | list(APPEND LIBWEBRTC_LIBRARIES ${X11_LIBRARIES} ${CMAKE_DL_LIBS} rt) 8 | 9 | set(THREADS_PREFER_PTHREAD_FLAG ON) 10 | find_package(Threads REQUIRED) 11 | if (CMAKE_HAVE_THREADS_LIBRARY) 12 | list(APPEND LIBWEBRTC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) 13 | endif (CMAKE_HAVE_THREADS_LIBRARY) 14 | endif (UNIX AND NOT APPLE) 15 | 16 | if (APPLE) 17 | find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox) 18 | find_library(COREAUDIO_LIBRARY CoreAudio) 19 | find_library(COREFOUNDATION_LIBRARY CoreFoundation) 20 | find_library(COREGRAPHICS_LIBRARY CoreGraphics) 21 | find_library(FOUNDATION_LIBRARY Foundation) 22 | 23 | list(APPEND LIBWEBRTC_LIBRARIES ${AUDIOTOOLBOX_LIBRARY} ${COREAUDIO_LIBRARY} 24 | ${COREFOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY}) 25 | endif (APPLE) 26 | 27 | if (WIN32) 28 | list(APPEND LIBWEBRTC_LIBRARIES msdmo.lib wmcodecdspuuid.lib dmoguids.lib 29 | crypt32.lib iphlpapi.lib ole32.lib secur32.lib winmm.lib ws2_32.lib) 30 | endif (WIN32) 31 | -------------------------------------------------------------------------------- /CMakeModules/Environment.cmake: -------------------------------------------------------------------------------- 1 | if (ENVIRONMENT_INCLUDED) 2 | return() 3 | endif (ENVIRONMENT_INCLUDED) 4 | set(ENVIRONMENT_INCLUDED true) 5 | 6 | if (WIN32) 7 | get_filename_component(DEPOT_TOOLS_PYTHON_PATH 8 | "${_WEBRTC_PATH}/python276_bin" 9 | REALPATH) 10 | list(APPEND _WEBRTC_PATH "${DEPOT_TOOLS_PYTHON_PATH}") 11 | endif (WIN32) 12 | 13 | list(APPEND _WEBRTC_PATH ${DEPOT_TOOLS_PATH} $ENV{PATH}) 14 | 15 | get_filename_component(_CHROMIUM_PYTHONPATH 16 | "${CMAKE_SOURCE_DIR}/build" 17 | REALPATH) 18 | 19 | if (WIN32) 20 | string(REGEX REPLACE "/" "\\\\" _WEBRTC_PATH "${_WEBRTC_PATH}") 21 | string(REGEX REPLACE "/" "\\\\" _CHROMIUM_PYTHONPATH "${_CHROMIUM_PYTHONPATH}") 22 | string(REGEX REPLACE ";" "\\\\\\\;" _WEBRTC_PATH "${_WEBRTC_PATH}") 23 | else (WIN32) 24 | string(REGEX REPLACE ";" ":" _WEBRTC_PATH "${_WEBRTC_PATH}") 25 | endif (WIN32) 26 | 27 | set(_ENV 28 | PATH="${_WEBRTC_PATH}" 29 | PYTHONPATH="${_CHROMIUM_PYTHONPATH}" 30 | DEPOT_TOOLS_WIN_TOOLCHAIN=0 31 | DEPOT_TOOLS_UPDATE=0 32 | CHROME_HEADLESS=1) 33 | 34 | set(PREFIX_EXECUTE ${CMAKE_COMMAND} -E env "${_ENV}") 35 | -------------------------------------------------------------------------------- /CMakeModules/Gn.cmake: -------------------------------------------------------------------------------- 1 | set(_GEN_ARGS use_gold=false target_cpu=\\"${TARGET_CPU}\\" target_os=\\"${TARGET_OS}\\" is_component_build=false proprietary_codecs=true use_openh264=true ffmpeg_branding=\\"Chrome\\" rtc_include_tests=false treat_warnings_as_errors=false is_debug=false enable_iterator_debugging=false use_custom_libcxx=false use_custom_libcxx_for_host=false) 2 | 3 | if (MSVC OR XCODE) 4 | set(_GEN_ARGS ${_GEN_ARGS} is_debug=$<$:true>$<$:false>$<$:false>$<$:false>) 5 | set(_NINJA_BUILD_DIR out/$<$:Debug>$<$:Release>$<$:Release>$<$:Release>) 6 | elseif (CMAKE_BUILD_TYPE MATCHES Debug) 7 | set(_GEN_ARGS ${_GEN_ARGS} is_debug=true) 8 | set(_NINJA_BUILD_DIR out/Debug) 9 | else (MSVC OR XCODE) 10 | set(_GEN_ARGS ${_GEN_ARGS} is_debug=false) 11 | set(_NINJA_BUILD_DIR out/Release) 12 | endif (MSVC OR XCODE) 13 | 14 | if (BUILD_TESTS) 15 | set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=true) 16 | else (BUILD_TESTS) 17 | set(_GEN_ARGS ${_GEN_ARGS} rtc_include_tests=false) 18 | endif (BUILD_TESTS) 19 | 20 | if (GN_EXTRA_ARGS) 21 | set(_GEN_ARGS ${_GEN_ARGS} ${GN_EXTRA_ARGS}) 22 | endif (GN_EXTRA_ARGS) 23 | 24 | if (WIN32) 25 | set(_GN_EXECUTABLE gn.bat) 26 | else (WIN32) 27 | set(_GN_EXECUTABLE gn) 28 | endif (WIN32) 29 | 30 | set(_GEN_COMMAND ${_GN_EXECUTABLE} gen ${_NINJA_BUILD_DIR} --args=\"${_GEN_ARGS}\") 31 | -------------------------------------------------------------------------------- /CMakeModules/Templates/UseLibWebRTC.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This module is provided as LIBWEBRTC_USE_FILE by LibWebRTCConfig.cmake. 3 | # It can be INCLUDEd in a project to load the needed compiler and linker 4 | # settings to use LibWebRTC. 5 | # 6 | 7 | if (LIBWEBRTC_USE_FILE_INCLUDED) 8 | return() 9 | endif () 10 | set(LIBWEBRTC_USE_FILE_INCLUDED 1) 11 | 12 | # Enable threading 13 | set(THREADS_PREFER_PTHREAD_FLAG ON) 14 | find_package(Threads REQUIRED) 15 | 16 | # Update CMAKE_MODULE_PATH so includes work. 17 | list(APPEND CMAKE_MODULE_PATH ${LIBWEBRTC_CMAKE_DIR}) 18 | 19 | # Add compiler flags needed to use LibWebRTC. 20 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBWEBRTC_REQUIRED_C_FLAGS}") 21 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG}") 22 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE}") 23 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBWEBRTC_REQUIRED_CXX_FLAGS}") 24 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG}") 25 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE}") 26 | set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS}") 27 | 28 | # Add preprocessor definitions needed to use LibWebRTC. 29 | set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${LIBWEBRTC_DEFINITIONS}) 30 | 31 | # Add include directories needed to use LibWebRTC. 32 | include_directories(${LIBWEBRTC_INCLUDE_DIRS}) 33 | 34 | # Add link directories needed to use LibWebRTC. 35 | link_directories(${LIBWEBRTC_LIBRARY_DIRS}) 36 | -------------------------------------------------------------------------------- /CMakeModules/Options.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Options, flags 3 | option(BUILD_TESTS "Build test binaries" OFF) 4 | option(BUILD_SAMPLE "Build sample" OFF) 5 | set(DEPOT_TOOLS_PATH "" CACHE STRING "Path to your own depot_tools directory") 6 | set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC") 7 | set(GN_EXTRA_ARGS "" CACHE STRING "Extra gn gen arguments to pass before generating build files") 8 | set(WEBRTC_REVISION "" CACHE STRING "WebRTC commit hash to checkout") 9 | set(WEBRTC_BRANCH_HEAD "${LIBWEBRTC_WEBRTC_HEAD}" CACHE STRING "WebRTC branch head to checkout") 10 | 11 | if (DEPOT_TOOLS_PATH) 12 | set(HAS_OWN_DEPOT_TOOLS 1) 13 | endif (DEPOT_TOOLS_PATH) 14 | 15 | # 16 | # Offer the user the choice of overriding the installation directories 17 | set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") 18 | set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") 19 | set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") 20 | set(INSTALL_CMAKE_DIR lib/cmake/LibWebRTC CACHE PATH "Installation directory for CMake files") 21 | 22 | if (UNIX) 23 | set(INSTALL_PKGCONFIG_DIR lib/pkgconfig CACHE PATH "Installation directory for pkg-config script") 24 | if (NOT APPLE) 25 | option(BUILD_DEB_PACKAGE "Build Debian .deb package" OFF) 26 | option(BUILD_RPM_PACKAGE "Build Red Hat .rpm package" OFF) 27 | endif (NOT APPLE) 28 | endif (UNIX) 29 | 30 | # 31 | # Make relative paths absolute (needed later on) 32 | foreach(p LIB BIN INCLUDE CMAKE) 33 | set(var INSTALL_${p}_DIR) 34 | if(NOT IS_ABSOLUTE "${${var}}") 35 | set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") 36 | endif() 37 | endforeach() 38 | -------------------------------------------------------------------------------- /CMakeModules/LibWebRTCExecute.cmake: -------------------------------------------------------------------------------- 1 | if (LIBWEBRTC_EXECUTE_INCLUDED) 2 | return() 3 | endif (LIBWEBRTC_EXECUTE_INCLUDED) 4 | set(LIBWEBRTC_EXECUTE_INCLUDED true) 5 | 6 | include(CMakeParseArguments) 7 | include(Environment) 8 | 9 | function (libwebrtc_execute) 10 | set(ONE_VALUE_ARGS OUTPUT_VARIABLE WORKING_DIRECTORY STAMPFILE STATUS ERROR) 11 | set(MULTI_VALUE_ARGS COMMAND) 12 | cmake_parse_arguments(COMMAND "" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN}) 13 | 14 | set(CMF_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) 15 | 16 | if (COMMAND_STAMPFILE) 17 | set(STAMP_FILE "${CMF_DIR}/${COMMAND_STAMPFILE}") 18 | 19 | if (EXISTS ${STAMP_FILE}) 20 | if (COMMAND_OUTPUT_VARIABLE) 21 | file(READ ${STAMP_FILE} _OUTPUT) 22 | 23 | if (_OUTPUT) 24 | set(${COMMAND_OUTPUT_VARIABLE} ${_OUTPUT} PARENT_SCOPE) 25 | endif (_OUTPUT) 26 | endif (COMMAND_OUTPUT_VARIABLE) 27 | 28 | return() 29 | endif (EXISTS ${STAMP_FILE}) 30 | endif (COMMAND_STAMPFILE) 31 | 32 | if (COMMAND_STATUS) 33 | message(STATUS ${COMMAND_STATUS}) 34 | endif (COMMAND_STATUS) 35 | 36 | execute_process(COMMAND ${COMMAND_COMMAND} 37 | WORKING_DIRECTORY ${COMMAND_WORKING_DIRECTORY} 38 | OUTPUT_VARIABLE _OUTPUT 39 | RESULT_VARIABLE _RESULT) 40 | 41 | if (NOT _RESULT EQUAL 0) 42 | message(FATAL_ERROR "-- " ${COMMAND_ERROR}) 43 | endif (NOT _RESULT EQUAL 0) 44 | 45 | if (COMMAND_STAMPFILE) 46 | file(WRITE ${STAMP_FILE} ${_OUTPUT}) 47 | endif (COMMAND_STAMPFILE) 48 | 49 | if (COMMAND_OUTPUT_VARIABLE) 50 | set(${COMMAND_OUTPUT_VARIABLE} ${_OUTPUT} PARENT_SCOPE) 51 | endif (COMMAND_OUTPUT_VARIABLE) 52 | endfunction () 53 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Version 1.1 4 | 5 | *TBD* 6 | 7 | [View Issues][v1.1-issues] 8 | 9 | **Features:** 10 | 11 | - Added `BUILD_TESTS` CMake configuration variable 12 | 13 | ## Version 1.0 14 | 15 | *March 27, 2017* 16 | 17 | [View Issues][v1.0-issues] 18 | 19 | **Features:** 20 | 21 | - Using CMake version 3.3 22 | - Installs LibWebRTC as a CMake package 23 | - Support for `gn`-based releases 24 | - Synchronize depot_tools with WebRTC's commit date 25 | - `TARGET_OS` and `TARGET_CPU` CMake config variables 26 | - `WEBRTC_REVISION` and `WEBRTC_BRANCH_HEAD` CMake config variables 27 | - x86 support under Windows 28 | - Better host OS and CPU architecture detection 29 | - pkg-config file generation 30 | - Deprecated shared library support 31 | - Debug mode support 32 | - .zip package for Windows, .tar.gz for Unix 33 | - Basic .deb and .rpm package generation 34 | 35 | **Fixes:** 36 | 37 | - Removed package.json and Jake support, focusing on CMake only 38 | - Refactored source code, removed Targets folder 39 | - Run commands with `cmake -E env`, no more Prefix File Trick 40 | - No more `merge_libs.py` call, use CMake to create the library 41 | - Removed the peer connection sample, wrote a little executable for tests 42 | - Removed FindLibWebRTC.cmake, defined CMake package files 43 | - Removed depot_tools git submodule 44 | - Retrieve the Linux sysroot before calling the generator 45 | - Removed support for releases older than January 1st, 2017 for now 46 | - Removed libwebrtc-chromium-deps repository 47 | - Wrote libwebrtc_execute macro 48 | - Created uninstall target 49 | - Removed BUILD_TESTS flag for now 50 | - Fixed static linking 51 | 52 | [v1.1-issues]:https://github.com/aisouard/libwebrtc/milestone/1 53 | [v1.0-issues]:https://github.com/aisouard/libwebrtc/milestone/1 54 | -------------------------------------------------------------------------------- /CMakeModules/DepotTools.cmake: -------------------------------------------------------------------------------- 1 | if (HAS_OWN_DEPOT_TOOLS) 2 | return() 3 | endif (HAS_OWN_DEPOT_TOOLS) 4 | 5 | include(LibWebRTCExecute) 6 | 7 | if (WEBRTC_REVISION) 8 | libwebrtc_execute( 9 | COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci ${WEBRTC_REVISION} 10 | OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE 11 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 12 | STAMPFILE webrtc-revision-commit-date 13 | STATUS "Retrieving date for commit ${WEBRTC_REVISION}" 14 | ERROR "Unable to find webrtc commit date at ${WEBRTC_REVISION}" 15 | ) 16 | elseif (WEBRTC_BRANCH_HEAD) 17 | libwebrtc_execute( 18 | COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci 19 | OUTPUT_VARIABLE _WEBRTC_COMMIT_DATE 20 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 21 | STAMPFILE webrtc-branch-head-commit-date 22 | STATUS "Retrieving date for ${WEBRTC_BRANCH_HEAD}" 23 | ERROR "Unable to retrieve the commit date for ${WEBRTC_BRANCH_HEAD}" 24 | ) 25 | else (WEBRTC_REVISION) 26 | message(FATAL_ERROR "-- Both WEBRTC_REVISION and WEBRTC_BRANCH_HEAD variables are undefined") 27 | endif (WEBRTC_REVISION) 28 | 29 | string(STRIP ${_WEBRTC_COMMIT_DATE} _WEBRTC_COMMIT_DATE) 30 | libwebrtc_execute( 31 | COMMAND ${GIT_EXECUTABLE} rev-list -n 1 --before=\"${_WEBRTC_COMMIT_DATE}\" master 32 | OUTPUT_VARIABLE _DEPOT_TOOLS_COMMIT 33 | WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} 34 | STAMPFILE webrtc-depot-tools-date 35 | STATUS "Retrieving depot_tools commit before ${_WEBRTC_COMMIT_DATE}" 36 | ERROR "Unable to find depot_tools commit before ${_WEBRTC_COMMIT_DATE}" 37 | ) 38 | 39 | string(STRIP ${_DEPOT_TOOLS_COMMIT} _DEPOT_TOOLS_COMMIT) 40 | libwebrtc_execute( 41 | COMMAND ${GIT_EXECUTABLE} checkout ${_DEPOT_TOOLS_COMMIT} 42 | OUTPUT_VARIABLE _DEPOT_TOOLS_CHECKED_OUT 43 | WORKING_DIRECTORY ${DEPOT_TOOLS_PATH} 44 | STAMPFILE webrtc-depot-tools-checkout 45 | STATUS "Checking out depot_tools to commit ${_DEPOT_TOOLS_COMMIT}" 46 | ERROR "Unable to checkout depot_tools to commit ${_DEPOT_TOOLS_COMMIT}" 47 | ) 48 | -------------------------------------------------------------------------------- /sample/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Axel Isouard 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #ifdef WIN32 22 | #include 23 | #include 24 | #include 25 | #endif 26 | 27 | int main(int argc, char **argv) { 28 | #ifdef WIN32 29 | rtc::EnsureWinsockInit(); 30 | rtc::Win32SocketServer w32_ss; 31 | rtc::Win32Thread w32_thread(&w32_ss); 32 | rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread); 33 | #endif 34 | 35 | rtc::InitializeSSL(); 36 | rtc::InitRandom(rtc::Time()); 37 | rtc::ThreadManager::Instance()->WrapCurrentThread(); 38 | 39 | rtc::Thread *signalingThread = new rtc::Thread(); 40 | rtc::Thread *workerThread = new rtc::Thread(); 41 | 42 | signalingThread->SetName("signaling_thread", NULL); 43 | workerThread->SetName("worker_thread", NULL); 44 | 45 | if (!signalingThread->Start() || !workerThread->Start()) { 46 | return 1; 47 | } 48 | 49 | rtc::scoped_refptr pcFactory = 50 | webrtc::CreatePeerConnectionFactory(signalingThread, 51 | workerThread, 52 | NULL, NULL, NULL); 53 | 54 | pcFactory = NULL; 55 | 56 | if (rtc::ThreadManager::Instance()->CurrentThread() == signalingThread) { 57 | rtc::ThreadManager::Instance()->SetCurrentThread(NULL); 58 | } 59 | 60 | signalingThread->Stop(); 61 | workerThread->Stop(); 62 | 63 | delete signalingThread; 64 | delete workerThread; 65 | 66 | rtc::CleanupSSL(); 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /libwebrtc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(libwebrtc) 3 | 4 | set(_OBJ_EXT ${CMAKE_CXX_OUTPUT_EXTENSION}) 5 | 6 | file(GLOB_RECURSE _OBJ_FILES 7 | ${WEBRTC_OUTPUT_DIR}/obj/*${_OBJ_EXT} 8 | ${WEBRTC_OUTPUT_DIR}/clang_x64/obj/*${_OBJ_EXT}) 9 | 10 | if (NOT _OBJ_EXT STREQUAL ".o") 11 | file(GLOB_RECURSE _OBJ_FILES_ASM 12 | ${WEBRTC_OUTPUT_DIR}/obj/*.o) 13 | list(APPEND _OBJ_FILES ${_OBJ_FILES_ASM}) 14 | endif (NOT _OBJ_EXT STREQUAL ".o") 15 | 16 | file(GLOB_RECURSE _OBJ_EXCLUDED 17 | ${WEBRTC_OUTPUT_DIR}/obj/third_party/yasm/gen*/*${_OBJ_EXT} 18 | ${WEBRTC_OUTPUT_DIR}/obj/third_party/yasm/re2c/*${_OBJ_EXT} 19 | ${WEBRTC_OUTPUT_DIR}/obj/third_party/yasm/yasm/*${_OBJ_EXT} 20 | ${WEBRTC_OUTPUT_DIR}/obj/third_party/protobuf/protoc/*${_OBJ_EXT} 21 | ${WEBRTC_OUTPUT_DIR}/obj/third_party/protobuf/protobuf_lite/*${_OBJ_EXT} 22 | ${WEBRTC_OUTPUT_DIR}/obj/webrtc/examples/*${_OBJ_EXT} 23 | ${WEBRTC_OUTPUT_DIR}/obj/webrtc/tools/*${_OBJ_EXT} 24 | ${WEBRTC_OUTPUT_DIR}/obj/webrtc/modules/video_capture/video_capture/video_capture_external${_OBJ_EXT} 25 | ${WEBRTC_OUTPUT_DIR}/obj/webrtc/modules/video_capture/video_capture/device_info_external${_OBJ_EXT}) 26 | 27 | list(LENGTH _OBJ_EXCLUDED _OBJ_EXCLUDED_LEN) 28 | if (${_OBJ_EXCLUDED_LEN} GREATER "0") 29 | list(REMOVE_ITEM _OBJ_FILES ${_OBJ_EXCLUDED}) 30 | endif () 31 | 32 | add_library(webrtc STATIC ${_OBJ_FILES}) 33 | 34 | set_source_files_properties(${_OBJ_FILES} PROPERTIES 35 | EXTERNAL_OBJECT true 36 | GENERATED true) 37 | 38 | set_target_properties(webrtc PROPERTIES 39 | LINKER_LANGUAGE C 40 | LIBRARY_OUTPUT_DIRECTORY ${WEBRTC_OUTPUT_DIR}) 41 | 42 | # 43 | # Install headers 44 | install(DIRECTORY "${WEBRTC_SOURCE_DIR}/" 45 | DESTINATION "include/webrtc" 46 | FILES_MATCHING PATTERN "*.h") 47 | 48 | # 49 | # Install library 50 | install(TARGETS webrtc 51 | EXPORT LibWebRTCTargets 52 | ARCHIVE DESTINATION lib 53 | RUNTIME DESTINATION bin 54 | LIBRARY DESTINATION lib 55 | INCLUDES DESTINATION include) 56 | 57 | install(EXPORT LibWebRTCTargets 58 | FILE LibWebRTCTargets.cmake 59 | DESTINATION ${INSTALL_CMAKE_DIR}) 60 | 61 | install(FILES ${CMAKE_MODULE_PATH}/Templates/UseLibWebRTC.cmake 62 | DESTINATION ${INSTALL_CMAKE_DIR}) 63 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - os: linux 4 | sudo: required 5 | env: TARGET_CPU=x64 6 | addons: 7 | apt: &x64-apt 8 | sources: 9 | - ubuntu-toolchain-r-test 10 | packages: 11 | - gcc-4.8 12 | - g++-4.8 13 | - libglib2.0-dev 14 | - libgtk2.0-dev 15 | - libxtst-dev 16 | - libxss-dev 17 | - libpci-dev 18 | - libdbus-1-dev 19 | - libgconf2-dev 20 | - libgnome-keyring-dev 21 | - libnss3-dev 22 | - libasound2-dev 23 | - libpulse-dev 24 | - libudev-dev 25 | 26 | - os: linux 27 | sudo: required 28 | env: TARGET_CPU=x64 CMAKE_BUILD_TYPE=Debug 29 | addons: 30 | apt: *x64-apt 31 | 32 | - os: osx 33 | osx_image: xcode7.3 34 | env: TARGET_CPU=x64 35 | addons: 36 | apt: *x64-apt 37 | 38 | - os: osx 39 | osx_image: xcode7.3 40 | env: TARGET_CPU=x64 CMAKE_BUILD_TYPE=Debug 41 | addons: 42 | apt: *x64-apt 43 | 44 | language: cpp 45 | 46 | before_install: 47 | - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" 48 | - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} 49 | - | 50 | if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then 51 | CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz" 52 | mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake 53 | export PATH=${DEPS_DIR}/cmake/bin:${PATH} 54 | export CXX="g++-4.8" CC="gcc-4.8" 55 | else 56 | if ! brew ls --version cmake &>/dev/null; then brew update && brew install cmake; fi 57 | fi 58 | - cd ${TRAVIS_BUILD_DIR} 59 | - cmake --version 60 | 61 | install: 62 | - git submodule init 63 | - git submodule update 64 | - mkdir out 65 | - cd out 66 | - cmake -DBUILD_SAMPLE=1 -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=. -DTARGET_CPU=$TARGET_CPU .. 67 | 68 | script: 69 | - make -j 4 package 70 | 71 | before_deploy: 72 | - export TRAVIS_ARTIFACTS=$(ls libwebrtc-*.tar.gz) 73 | 74 | deploy: 75 | provider: releases 76 | api_key: 77 | 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= 78 | file_glob: true 79 | file: "${TRAVIS_ARTIFACTS}" 80 | skip_cleanup: true 81 | on: 82 | tags: true 83 | repo: aisouard/libwebrtc 84 | -------------------------------------------------------------------------------- /CMakeModules/Templates/LibWebRTCConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for 'LibWebRTC' package 2 | # It defines the following variables 3 | # 4 | # LIBWEBRTC_INCLUDE_DIRS - include directories 5 | # LIBWEBRTC_LIBRARY_DIRS - library directories 6 | # LIBWEBRTC_LIBRARIES - libraries to link against 7 | # LIBWEBRTC_CMAKE_DIR - path to the CMake modules 8 | # LIBWEBRTC_USE_FILE - path to the CMake use file 9 | # 10 | # - Version variables: 11 | # LIBWEBRTC_MAJOR_VERSION - major version 12 | # LIBWEBRTC_MINOR_VERSION - minor version 13 | # LIBWEBRTC_PATCH_VERSION - patch version 14 | # LIBWEBRTC_BUILD_VERSION - version suffix, release candidate etc 15 | # LIBWEBRTC_WEBRTC_REVISION - WebRTC's Git revision used for that release 16 | # LIBWEBRTC_WEBRTC_BRANCH_HEAD - WebRTC's Git branch head refspec used for that release 17 | # LIBWEBRTC_API_VERSION - full version without build prefix 18 | # LIBWEBRTC_VERSION - full version with build prefix 19 | # 20 | # - Library type and targets variables: 21 | # LIBWEBRTC_TARGET_OS - android, chromeos, ios, linux, nacl, mac or win 22 | # LIBWEBRTC_TARGET_CPU - x86, x64, arm, arm64 or mipsel 23 | 24 | # LibWebRTC version number 25 | set(LIBWEBRTC_MAJOR_VERSION "@LIBWEBRTC_MAJOR_VERSION@") 26 | set(LIBWEBRTC_MINOR_VERSION "@LIBWEBRTC_MINOR_VERSION@") 27 | set(LIBWEBRTC_PATCH_VERSION "@LIBWEBRTC_PATCH_VERSION@") 28 | set(LIBWEBRTC_BUILD_VERSION "@LIBWEBRTC_BUILD_VERSION@") 29 | set(LIBWEBRTC_API_VERSION "@LIBWEBRTC_API_VERSION@") 30 | set(LIBWEBRTC_VERSION "@LIBWEBRTC_VERSION@") 31 | set(LIBWEBRTC_WEBRTC_REVISION "@WEBRTC_REVISION@") 32 | set(LIBWEBRTC_WEBRTC_BRANCH_HEAD "@WEBRTC_BRANCH_HEAD@") 33 | 34 | # LibWebRTC library type, target OS and target CPU 35 | set(LIBWEBRTC_TARGET_OS "@TARGET_OS@") 36 | set(LIBWEBRTC_TARGET_CPU "@TARGET_CPU@") 37 | 38 | # Include directory 39 | set(LIBWEBRTC_INCLUDE_DIRS "@INSTALL_INCLUDE_DIR@/webrtc") 40 | 41 | # Libraries directory 42 | set(LIBWEBRTC_LIBRARY_DIRS "@INSTALL_LIB_DIR@") 43 | 44 | # Set the expected libraries variable 45 | set(LIBWEBRTC_LIBRARIES @LIBWEBRTC_LIBRARIES@) 46 | 47 | # The C and C++ flags added by LibWebRTC to the cmake-configured flags. 48 | set(LIBWEBRTC_REQUIRED_C_FLAGS "@LIBWEBRTC_REQUIRED_C_FLAGS@") 49 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS "@LIBWEBRTC_REQUIRED_CXX_FLAGS@") 50 | set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG@") 51 | set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE@") 52 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "@LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG@") 53 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "@LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE@") 54 | set(LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS "@LIBWEBRTC_REQUIRED_STATIC_LINKER_FLAGS@") 55 | set(LIBWEBRTC_DEFINITIONS "@LIBWEBRTC_DEFINITIONS@") 56 | 57 | # The location of the UseLibWebRTC.cmake file. 58 | set(LIBWEBRTC_CMAKE_DIR "@INSTALL_CMAKE_DIR@") 59 | set(LIBWEBRTC_USE_FILE "${LIBWEBRTC_CMAKE_DIR}/UseLibWebRTC.cmake") 60 | 61 | # Import LibWebRTC targets. 62 | include("${LIBWEBRTC_CMAKE_DIR}/LibWebRTCTargets.cmake") 63 | -------------------------------------------------------------------------------- /CMakeModules/Package.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Create package 3 | set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${TARGET_OS}-${TARGET_CPU}") 4 | 5 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "WebRTC in a single static library") 6 | set(CPACK_PACKAGE_DESCRIPTION "Google's native WebRTC implementation shipped into a single library") 7 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") 8 | 9 | set(CPACK_PACKAGE_NAME "LibWebRTC") 10 | set(CPACK_PACKAGE_VERSION "${LIBWEBRTC_VERSION}") 11 | set(CPACK_PACKAGE_VERSION_MAJOR "${LIBWEBRTC_MAJOR_VERSION}") 12 | set(CPACK_PACKAGE_VERSION_MINOR "${LIBWEBRTC_MINOR_VERSION}") 13 | set(CPACK_PACKAGE_VERSION_PATCH "${LIBWEBRTC_PATCH_VERSION}") 14 | 15 | set(CPACK_PACKAGE_VENDOR "Axel Isouard") 16 | set(CPACK_PACKAGE_CONTACT "axel@isouard.fr") 17 | 18 | if (WIN32) 19 | set(CPACK_GENERATOR "ZIP") 20 | else (WIN32) 21 | set(CPACK_GENERATOR "TGZ") 22 | endif (WIN32) 23 | 24 | if (UNIX AND NOT APPLE) 25 | if (TARGET_CPU STREQUAL "x86") 26 | set(_RPM_ARCH "i686") 27 | set(_DEB_ARCH "i386") 28 | elseif (TARGET_CPU STREQUAL "x64") 29 | set(_RPM_ARCH "x86_64") 30 | set(_DEB_ARCH "amd64") 31 | elseif (TARGET_CPU STREQUAL "arm") 32 | set(_RPM_ARCH "armhf") 33 | set(_DEB_ARCH "armhf") 34 | elseif (TARGET_CPU STREQUAL "arm64") 35 | set(_RPM_ARCH "aarch64") 36 | set(_DEB_ARCH "arm64") 37 | else () 38 | set(_RPM_ARCH ${CMAKE_SYSTEM_PROCESSOR}) 39 | set(_DEB_ARCH ${CMAKE_SYSTEM_PROCESSOR}) 40 | endif () 41 | 42 | set(CPACK_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}") 43 | if (CPACK_GENERATOR STREQUAL "RPM") 44 | set(_PACKAGE_ARCH ${_RPM_ARCH}) 45 | elseif (CPACK_GENERATOR STREQUAL "DEB") 46 | set(_PACKAGE_ARCH ${_DEB_ARCH}) 47 | else () 48 | set(_PACKAGE_ARCH ${TARGET_CPU}) 49 | set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${TARGET_OS}") 50 | endif () 51 | 52 | if (BUILD_DEB_PACKAGE) 53 | set(CPACK_DEB_COMPONENT_INSTALL FALSE) 54 | set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") 55 | set(CPACK_DEBIAN_PACKAGE_SECTION "libs") 56 | set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://axel.isouard.fr/libwebrtc") 57 | set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE) 58 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_PACKAGE_ARCH}") 59 | set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB") 60 | endif (BUILD_DEB_PACKAGE) 61 | 62 | if (BUILD_RPM_PACKAGE) 63 | set(CPACK_RPM_COMPONENT_INSTALL FALSE) 64 | set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) 65 | set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION}) 66 | set(CPACK_RPM_PACKAGE_URL "https://axel.isouard.fr/libwebrtc") 67 | set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0") 68 | set(CPACK_RPM_PACKAGE_ARCHITECTURE "${_PACKAGE_ARCH}") 69 | set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM") 70 | endif (BUILD_RPM_PACKAGE) 71 | 72 | set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${_PACKAGE_ARCH}") 73 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "libwebrtc-${LIBWEBRTC_VERSION}-${_PACKAGE_ARCH}") 74 | endif (UNIX AND NOT APPLE) 75 | 76 | if (CMAKE_BUILD_TYPE MATCHES Debug) 77 | set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}-debug) 78 | endif (CMAKE_BUILD_TYPE MATCHES Debug) 79 | 80 | set(CPACK_INSTALL_CMAKE_PROJECTS 81 | "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR}/libwebrtc;libwebrtc;ALL;/") 82 | 83 | set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) 84 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "libwebrtc") 85 | 86 | include(CPack) 87 | -------------------------------------------------------------------------------- /CMakeModules/TargetOsAndCpu.cmake: -------------------------------------------------------------------------------- 1 | include(CheckSymbolExists) 2 | 3 | # 4 | # Target OS 5 | set(TARGET_OS "" CACHE STRING "Target OS, used as --target_os argument") 6 | set(TARGET_OS_LIST android chromeos ios linux nacl mac win) 7 | 8 | if (TARGET_OS STREQUAL "") 9 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 10 | set(TARGET_OS "linux") 11 | elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") 12 | set(TARGET_OS "mac") 13 | elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") 14 | set(TARGET_OS "win") 15 | endif () 16 | endif (TARGET_OS STREQUAL "") 17 | 18 | if (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST) 19 | message(FATAL_ERROR "Unknown value '${TARGET_OS}' for variable TARGET_OS, options are: ${TARGET_OS_LIST}") 20 | endif (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST) 21 | 22 | # 23 | # Target CPU 24 | function(detect_current_arch) 25 | if (WIN32) 26 | check_symbol_exists("_M_X64" "" ARCH_X64) 27 | if (NOT ARCH_X64) 28 | check_symbol_exists("_M_AMD64" "" ARCH_X64) 29 | endif (NOT ARCH_X64) 30 | check_symbol_exists("_M_IX86" "" ARCH_X86) 31 | check_symbol_exists("_M_ARM" "" ARCH_ARM) 32 | check_symbol_exists("_M_ARM64" "" ARCH_ARM64) 33 | else (WIN32) 34 | check_symbol_exists("__i386__" "" ARCH_X86) 35 | check_symbol_exists("__x86_64__" "" ARCH_X64) 36 | check_symbol_exists("__arm__" "" ARCH_ARM) 37 | check_symbol_exists("__aarch64__" "" ARCH_ARM64) 38 | check_symbol_exists("__mips__" "" ARCH_MIPS) 39 | endif (WIN32) 40 | endfunction(detect_current_arch) 41 | 42 | set(TARGET_CPU "" CACHE STRING "Target CPU, used as --target_cpu argument") 43 | set(TARGET_CPU_LIST x86 x64 arm arm64 mipsel) 44 | 45 | if (TARGET_CPU STREQUAL "") 46 | detect_current_arch() 47 | 48 | if (ARCH_X64) 49 | set(TARGET_CPU "x64") 50 | elseif (ARCH_X86) 51 | set(TARGET_CPU "x86") 52 | elseif (ARCH_ARM64) 53 | set(TARGET_CPU "arm64") 54 | elseif (ARCH_ARM) 55 | set(TARGET_CPU "arm") 56 | elseif (ARCH_MIPS) 57 | set(TARGET_CPU "mipsel") 58 | else () 59 | set(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) 60 | endif (ARCH_X64) 61 | endif (TARGET_CPU STREQUAL "") 62 | 63 | if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST) 64 | message(FATAL_ERROR "Unknown value '${TARGET_CPU}' for variable TARGET_CPU, options are: ${TARGET_CPU_LIST}") 65 | endif (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST) 66 | 67 | if (APPLE) 68 | list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_MAC) 69 | endif (APPLE) 70 | 71 | if (UNIX) 72 | if (TARGET_CPU STREQUAL "x86") 73 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -m32") 74 | endif (TARGET_CPU STREQUAL "x86") 75 | 76 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -std=gnu++0x") 77 | 78 | if (CMAKE_USE_PTHREADS_INIT) 79 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -pthread") 80 | endif () 81 | 82 | if (CMAKE_BUILD_TYPE MATCHES Debug) 83 | list(APPEND LIBWEBRTC_DEFINITIONS _GLIBCXX_DEBUG=1 _DEBUG=1) 84 | endif (CMAKE_BUILD_TYPE MATCHES Debug) 85 | list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_POSIX _GLIBCXX_USE_CXX11_ABI=0) 86 | elseif (WIN32) 87 | set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "/MTd") 88 | set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "/MT") 89 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "/MTd") 90 | set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "/MT") 91 | list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_WIN NOMINMAX _CRT_SECURE_NO_WARNINGS) 92 | endif (UNIX) 93 | 94 | message(STATUS "Building for ${TARGET_OS} (${TARGET_CPU})") 95 | -------------------------------------------------------------------------------- /CMakeModules/Install.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Install library 3 | file(GLOB_RECURSE _LIBRARY_FILES 4 | ${CMAKE_BINARY_DIR}/lib/*${CMAKE_STATIC_LIBRARY_SUFFIX}) 5 | 6 | install(FILES ${_LIBRARY_FILES} 7 | DESTINATION ${INSTALL_LIB_DIR} 8 | COMPONENT lib) 9 | 10 | # 11 | # Install headers 12 | install(DIRECTORY "${CMAKE_BINARY_DIR}/include/" 13 | DESTINATION ${INSTALL_INCLUDE_DIR} 14 | COMPONENT include 15 | FILES_MATCHING PATTERN "*.h") 16 | 17 | # 18 | # Install abseil-cpp headers 19 | install(DIRECTORY "${CMAKE_BINARY_DIR}/include/webrtc/third_party/abseil-cpp/" 20 | DESTINATION ${INSTALL_INCLUDE_DIR}/webrtc 21 | COMPONENT include 22 | FILES_MATCHING PATTERN "*.h") 23 | 24 | # 25 | # Install CMake Config file 26 | configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTCConfig.cmake.in 27 | ${CMAKE_BINARY_DIR}/LibWebRTCConfig.cmake @ONLY) 28 | install(FILES ${CMAKE_BINARY_DIR}/LibWebRTCConfig.cmake 29 | DESTINATION ${INSTALL_CMAKE_DIR} 30 | COMPONENT cmake) 31 | 32 | # 33 | # Install CMake ConfigVersion file 34 | configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTCConfigVersion.cmake.in 35 | ${CMAKE_BINARY_DIR}/LibWebRTCConfigVersion.cmake @ONLY) 36 | install(FILES ${CMAKE_BINARY_DIR}/LibWebRTCConfigVersion.cmake 37 | DESTINATION ${INSTALL_CMAKE_DIR} 38 | COMPONENT cmake) 39 | 40 | # 41 | # Install pkg-config file 42 | if (UNIX) 43 | set(prefix "${CMAKE_INSTALL_PREFIX}") 44 | set(exec_prefix "\${prefix}") 45 | set(libdir "${INSTALL_LIB_DIR}") 46 | set(includedir "${INSTALL_INCLUDE_DIR}") 47 | 48 | set(LIBWEBRTC_PC_LIBS "-L${INSTALL_LIB_DIR}" "-lwebrtc") 49 | foreach(LIB_NAME ${LIBWEBRTC_LIBRARIES}) 50 | if (LIB_NAME MATCHES "[\\/]") 51 | get_filename_component(LIB_DIR "${LIB_NAME}" PATH) 52 | get_filename_component(LIB_NAME "${LIB_NAME}" NAME_WE) 53 | string(REGEX REPLACE "^lib(.*)" "-l\\1" LIB_NAME "${LIB_NAME}") 54 | 55 | if (NOT ${LIB_DIR} IN_LIST LIB_DIRS) 56 | list(APPEND LIB_DIRS ${LIB_DIR}) 57 | list(APPEND LIBWEBRTC_PC_LIBS_PRIVATE "-L${LIB_DIR}") 58 | endif (NOT ${LIB_DIR} IN_LIST LIB_DIRS) 59 | 60 | elseif (NOT LIB_NAME MATCHES "^-l") 61 | set(LIB_NAME "-l${LIB_NAME}") 62 | endif () 63 | list(APPEND LIBWEBRTC_PC_LIBS_PRIVATE "${LIB_NAME}") 64 | endforeach(LIB_NAME ${LIBWEBRTC_LIBRARIES}) 65 | 66 | foreach(DEFINITION ${LIBWEBRTC_DEFINITIONS}) 67 | list(APPEND LIBWEBRTC_PC_DEFINITIONS "-D${DEFINITION}") 68 | endforeach(DEFINITION ${LIBWEBRTC_DEFINITIONS}) 69 | 70 | list(REMOVE_ITEM LIBWEBRTC_PC_LIBS_PRIVATE "-lwebrtc") 71 | string(REPLACE ";" " " LIBWEBRTC_PC_DEFINITIONS "${LIBWEBRTC_PC_DEFINITIONS}") 72 | string(REPLACE ";" " " LIBWEBRTC_PC_LIBS "${LIBWEBRTC_PC_LIBS}") 73 | string(REPLACE ";" " " LIBWEBRTC_PC_LIBS_PRIVATE "${LIBWEBRTC_PC_LIBS_PRIVATE}") 74 | string(REPLACE ";" " " LIBWEBRTC_PC_CXXFLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS}") 75 | 76 | configure_file(${CMAKE_MODULE_PATH}/Templates/LibWebRTC.pc.in 77 | ${CMAKE_BINARY_DIR}/LibWebRTC.pc @ONLY) 78 | install(FILES ${CMAKE_BINARY_DIR}/LibWebRTC.pc 79 | DESTINATION ${INSTALL_PKGCONFIG_DIR} 80 | COMPONENT cmake) 81 | endif (UNIX) 82 | 83 | # 84 | # Install CMake Use file 85 | install(FILES ${CMAKE_MODULE_PATH}/Templates/UseLibWebRTC.cmake 86 | DESTINATION ${INSTALL_CMAKE_DIR} 87 | COMPONENT cmake) 88 | 89 | # 90 | # Install CMake Targets file 91 | install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/cmake/LibWebRTC/" 92 | DESTINATION ${INSTALL_CMAKE_DIR} 93 | COMPONENT cmake 94 | FILES_MATCHING PATTERN "*.cmake") 95 | 96 | # 97 | # Add uninstall target 98 | configure_file( 99 | "${CMAKE_MODULE_PATH}/Templates/Uninstall.cmake.in" 100 | "${CMAKE_BINARY_DIR}/Uninstall.cmake" 101 | IMMEDIATE @ONLY) 102 | 103 | add_custom_target(uninstall 104 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/Uninstall.cmake) 105 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3) 2 | project(libwebrtc) 3 | 4 | # 5 | # Allow the use of IN_LIST operand 6 | cmake_policy(SET CMP0057 NEW) 7 | 8 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} 9 | ${CMAKE_SOURCE_DIR}/CMakeModules) 10 | 11 | find_package(Git REQUIRED) 12 | 13 | include(FindLibraries) 14 | include(Version) 15 | include(Options) 16 | include(TargetOsAndCpu) 17 | 18 | if (HAS_OWN_DEPOT_TOOLS) 19 | find_package(DepotTools REQUIRED) 20 | endif (HAS_OWN_DEPOT_TOOLS) 21 | 22 | if (NOT WIN32) 23 | find_package(PythonInterp 2.7 REQUIRED) 24 | endif (NOT WIN32) 25 | 26 | include(ExternalProject) 27 | 28 | if (NOT HAS_OWN_DEPOT_TOOLS) 29 | if (WIN32) 30 | set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools/gclient.bat) 31 | else (WIN32) 32 | set(GCLIENT_EXECUTABLE ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools/gclient) 33 | endif (WIN32) 34 | 35 | ExternalProject_Add( 36 | depot-tools 37 | 38 | GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools 39 | 40 | PREFIX ${CMAKE_BINARY_DIR}/depot_tools 41 | 42 | CONFIGURE_COMMAND "" 43 | UPDATE_COMMAND "" 44 | PATCH_COMMAND "" 45 | BUILD_COMMAND "" 46 | INSTALL_COMMAND "" 47 | ) 48 | 49 | set(_NEXT_DEPENDS depot-tools) 50 | set(DEPOT_TOOLS_PATH ${CMAKE_BINARY_DIR}/depot_tools/src/depot-tools) 51 | endif (NOT HAS_OWN_DEPOT_TOOLS) 52 | 53 | set(_WEBRTC_CMAKE_ARGS 54 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 55 | -DCMAKE_MODULE_PATH:PATH=${CMAKE_MODULE_PATH} 56 | -DDEPOT_TOOLS_PATH:PATH=${DEPOT_TOOLS_PATH} 57 | -DGCLIENT_EXECUTABLE:PATH=${GCLIENT_EXECUTABLE} 58 | -DHAS_OWN_DEPOT_TOOLS:PATH=${HAS_OWN_DEPOT_TOOLS} 59 | -DTARGET_CPU=${TARGET_CPU} 60 | -DTARGET_OS=${TARGET_OS} 61 | -DWEBRTC_PARENT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc) 62 | 63 | if (BUILD_TESTS) 64 | set(_WEBRTC_CMAKE_ARGS ${_WEBRTC_CMAKE_ARGS} -DBUILD_TESTS=${BUILD_TESTS}) 65 | endif (BUILD_TESTS) 66 | 67 | if (WEBRTC_BRANCH_HEAD) 68 | set(_WEBRTC_CMAKE_ARGS ${_WEBRTC_CMAKE_ARGS} -DWEBRTC_BRANCH_HEAD=${WEBRTC_BRANCH_HEAD}) 69 | endif (WEBRTC_BRANCH_HEAD) 70 | 71 | if (WEBRTC_REVISION) 72 | set(_WEBRTC_CMAKE_ARGS ${_WEBRTC_CMAKE_ARGS} -DWEBRTC_REVISION=${WEBRTC_REVISION}) 73 | endif (WEBRTC_REVISION) 74 | 75 | ExternalProject_Add( 76 | webrtc-src 77 | 78 | DEPENDS ${_NEXT_DEPENDS} 79 | GIT_REPOSITORY https://chromium.googlesource.com/external/webrtc 80 | 81 | PREFIX ${CMAKE_BINARY_DIR}/webrtc 82 | BINARY_DIR ${CMAKE_BINARY_DIR}/webrtc/build 83 | DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/webrtc/src 84 | SOURCE_DIR ${CMAKE_BINARY_DIR}/webrtc/src 85 | STAMP_DIR ${CMAKE_BINARY_DIR}/webrtc/stamp 86 | TMP_DIR ${CMAKE_BINARY_DIR}/webrtc/tmp 87 | 88 | PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/webrtc/CMakeLists.txt ${CMAKE_SOURCE_DIR}/webrtc/fix-gn.sh ${CMAKE_BINARY_DIR}/webrtc/src 89 | UPDATE_COMMAND "" 90 | INSTALL_COMMAND "" 91 | 92 | CMAKE_ARGS 93 | ${_WEBRTC_CMAKE_ARGS} 94 | ) 95 | 96 | if (MSVC OR XCODE) 97 | set(_CONFIG $<$:Debug>$<$:Release>$<$:Release>$<$:Release>) 98 | elseif (CMAKE_BUILD_TYPE MATCHES Debug) 99 | set(_CONFIG Debug) 100 | else (MSVC OR XCODE) 101 | set(_CONFIG Release) 102 | endif (MSVC OR XCODE) 103 | 104 | ExternalProject_Add( 105 | libwebrtc 106 | DEPENDS webrtc-src 107 | 108 | INSTALL_DIR ${CMAKE_BINARY_DIR} 109 | SOURCE_DIR ${CMAKE_SOURCE_DIR}/libwebrtc 110 | BINARY_DIR ${CMAKE_BINARY_DIR}/libwebrtc 111 | 112 | CMAKE_ARGS 113 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 114 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR} 115 | -DCMAKE_MODULE_PATH:PATH=${CMAKE_MODULE_PATH} 116 | -DINSTALL_CMAKE_DIR:PATH=${CMAKE_BINARY_DIR}/lib/cmake/LibWebRTC 117 | -DTARGET_OS:STRING=${TARGET_OS} 118 | -DWEBRTC_OUTPUT_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src/out/${_CONFIG} 119 | -DWEBRTC_SOURCE_DIR:PATH=${CMAKE_BINARY_DIR}/webrtc/src 120 | ) 121 | 122 | if (BUILD_SAMPLE) 123 | ExternalProject_Add( 124 | sample 125 | DEPENDS libwebrtc 126 | SOURCE_DIR ${CMAKE_SOURCE_DIR}/sample 127 | INSTALL_COMMAND "" 128 | 129 | CMAKE_ARGS 130 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 131 | ) 132 | endif (BUILD_SAMPLE) 133 | 134 | include(Install) 135 | include(Package) 136 | 137 | export(PACKAGE LibWebRTC) 138 | -------------------------------------------------------------------------------- /webrtc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3) 2 | project(webrtc) 3 | 4 | find_package(Git REQUIRED) 5 | if (WIN32) 6 | set(PYTHON_EXECUTABLE ${DEPOT_TOOLS_PATH}/python.bat) 7 | else (WIN32) 8 | find_package(PythonInterp 2.7 REQUIRED) 9 | endif (WIN32) 10 | 11 | include(LibWebRTCExecute) 12 | 13 | if (WEBRTC_REVISION) 14 | libwebrtc_execute( 15 | COMMAND ${GIT_EXECUTABLE} checkout ${WEBRTC_REVISION} 16 | OUTPUT_VARIABLE _WEBRTC_CHECKOUT 17 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 18 | STAMPFILE webrtc-checkout-commit 19 | STATUS "Checking out webrtc to commit ${WEBRTC_REVISION}" 20 | ERROR "Unable to checkout webrtc to commit ${WEBRTC_REVISION}" 21 | ) 22 | elseif (WEBRTC_BRANCH_HEAD) 23 | libwebrtc_execute( 24 | COMMAND ${GIT_EXECUTABLE} config remote.origin.fetch +refs/branch-heads/*:refs/remotes/branch-heads/* ^\\+refs/branch-heads/\\*:.*$ 25 | OUTPUT_VARIABLE _WEBRTC_CONFIG_FETCH 26 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 27 | STAMPFILE webrtc-config-fetch 28 | STATUS "Setting up branch-heads refspecs" 29 | ERROR "Unable to add branch-heads refspec to the git config" 30 | ) 31 | 32 | libwebrtc_execute( 33 | COMMAND ${GIT_EXECUTABLE} fetch origin ${WEBRTC_BRANCH_HEAD} 34 | OUTPUT_VARIABLE _WEBRTC_FETCH 35 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 36 | STAMPFILE webrtc-fetch-branch-heads 37 | STATUS "Fetching ${WEBRTC_BRANCH_HEAD}" 38 | ERROR "Unable to fetch ${WEBRTC_BRANCH_HEAD}" 39 | ) 40 | 41 | libwebrtc_execute( 42 | COMMAND ${GIT_EXECUTABLE} checkout FETCH_HEAD 43 | OUTPUT_VARIABLE _WEBRTC_CHECKOUT 44 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 45 | STAMPFILE webrtc-checkout-branch-head 46 | STATUS "Checking out ${WEBRTC_BRANCH_HEAD}" 47 | ERROR "Unable to checkout ${WEBRTC_BRANCH_HEAD}" 48 | ) 49 | endif (WEBRTC_REVISION) 50 | 51 | include(DepotTools) 52 | include(GClient) 53 | include(Environment) 54 | include(LibWebRTCCommand) 55 | 56 | libwebrtc_command( 57 | NAME webrtc-sync 58 | COMMAND ${GCLIENT_EXECUTABLE} sync --nohooks 59 | WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" 60 | COMMENT "Synchronizing WebRTC" 61 | ) 62 | 63 | libwebrtc_command( 64 | NAME webrtc-clang 65 | COMMAND ${PYTHON_EXECUTABLE} src/tools/clang/scripts/update.py 66 | WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" 67 | COMMENT "Updating clang" 68 | DEPENDS webrtc-sync 69 | ) 70 | set(_DEPENDENCIES webrtc-clang) 71 | 72 | if (UNIX AND NOT APPLE) 73 | set(SYSROOT_ARCH ${TARGET_CPU}) 74 | 75 | if (SYSROOT_ARCH STREQUAL "x64") 76 | set(SYSROOT_ARCH "amd64") 77 | elseif (SYSROOT_ARCH STREQUAL "x86") 78 | set(SYSROOT_ARCH "i386") 79 | endif (SYSROOT_ARCH STREQUAL "x64") 80 | 81 | libwebrtc_command( 82 | NAME webrtc-toolchain 83 | COMMAND ${PYTHON_EXECUTABLE} ${WEBRTC_PARENT_DIR}/src/build/linux/sysroot_scripts/install-sysroot.py --arch=${SYSROOT_ARCH} 84 | WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" 85 | COMMENT "Retrieving sysroot" 86 | DEPENDS webrtc-sync 87 | ) 88 | set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-toolchain) 89 | 90 | set(_FIX_GN_FILE_COMMAND sh ${CMAKE_SOURCE_DIR}/fix-gn.sh) 91 | libwebrtc_command( 92 | NAME webrtc-gn-fix 93 | COMMAND ${_FIX_GN_FILE_COMMAND} 94 | WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}/src" 95 | COMMENT "Fix Gn files" 96 | DEPENDS webrtc-sync 97 | ) 98 | set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-gn-fix) 99 | 100 | set(_PLATFORM linux*) 101 | set(_FOLDER linux64) 102 | elseif (APPLE) 103 | set(_PLATFORM darwin) 104 | set(_FOLDER mac) 105 | elseif (WIN32) 106 | libwebrtc_command( 107 | NAME webrtc-toolchain 108 | COMMAND ${PYTHON_EXECUTABLE} src/build/vs_toolchain.py update 109 | WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" 110 | COMMENT "Retrieving Visual Studio toolchain" 111 | DEPENDS webrtc-sync 112 | ) 113 | set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-toolchain) 114 | 115 | set(_PLATFORM win32) 116 | set(_FOLDER win) 117 | set(_SUFFIX .exe) 118 | set(_SCRIPT_SUFFIX .bat) 119 | endif (UNIX AND NOT APPLE) 120 | 121 | set(_GN_COMMAND download_from_google_storage${_SCRIPT_SUFFIX} --no_resume --platform=${_PLATFORM} 122 | --no_auth --bucket chromium-gn 123 | -s src/buildtools/${_FOLDER}/gn${_SUFFIX}.sha1) 124 | 125 | libwebrtc_command( 126 | NAME webrtc-gn 127 | COMMAND ${_GN_COMMAND} 128 | WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" 129 | COMMENT "Fetching gn${_SUFFIX} for ${_PLATFORM}" 130 | DEPENDS webrtc-sync 131 | ) 132 | set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-gn) 133 | 134 | set(_CLANG_FORMAT_COMMAND download_from_google_storage${_SCRIPT_SUFFIX} --no_resume 135 | --platform=${_PLATFORM} --no_auth --bucket chromium-clang-format 136 | -s src/buildtools/${_FOLDER}/clang-format${_SUFFIX}.sha1) 137 | 138 | libwebrtc_command( 139 | NAME webrtc-clang-format 140 | COMMAND ${_CLANG_FORMAT_COMMAND} 141 | WORKING_DIRECTORY "${WEBRTC_PARENT_DIR}" 142 | COMMENT "Fetching clang-format${_SUFFIX} for ${_PLATFORM}" 143 | DEPENDS webrtc-gn 144 | ) 145 | set(_DEPENDENCIES ${_DEPENDENCIES} webrtc-clang-format) 146 | 147 | include(Gn) 148 | 149 | libwebrtc_command( 150 | NAME webrtc-generate 151 | COMMAND ${_GEN_COMMAND} 152 | WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" 153 | COMMENT "Generating build files" 154 | DEPENDS ${_DEPENDENCIES} 155 | ) 156 | 157 | set(_NINJA_COMMAND ninja ${NINJA_ARGS} -C ${_NINJA_BUILD_DIR} webrtc system_wrappers_default) 158 | 159 | if (BUILD_TESTS) 160 | set(_NINJA_COMMAND ${_NINJA_COMMAND} webrtc_tests) 161 | endif (BUILD_TESTS) 162 | 163 | libwebrtc_command( 164 | NAME webrtc-build 165 | COMMAND ${_NINJA_COMMAND} 166 | WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" 167 | COMMENT "Running ninja" 168 | DEPENDS webrtc-generate 169 | ) 170 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 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] 2 | 3 | This repository contains a collection of CMake scripts to help you embed 4 | Google's native WebRTC implementation inside your project as simple as this: 5 | 6 | ```cmake 7 | cmake_minimum_required(VERSION 3.3) 8 | project(sample) 9 | 10 | find_package(LibWebRTC REQUIRED) 11 | include(${LIBWEBRTC_USE_FILE}) 12 | 13 | set(SOURCE_FILES main.cpp) 14 | add_executable(sample ${SOURCE_FILES}) 15 | target_link_libraries(sample ${LIBWEBRTC_LIBRARIES}) 16 | ``` 17 | 18 | It also produces a `pkg-config` file if you prefer the classic way: 19 | 20 | ``` 21 | $ g++ `pkg-config --cflags LibWebRTC` main.cpp -o main `pkg-config --libs LibWebRTC` 22 | ``` 23 | 24 | ## Branch-Heads 25 | 26 | I changed some things, make it could build M70 webrtc with h264. 27 | 28 | ## Status 29 | 30 | The following table displays the current state of this project, including 31 | supported platforms and architectures. 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
x86x64armarm64
Linux
macOS---
Windows
63 | 64 | ## Prerequisites 65 | 66 | - CMake 3.3 or later 67 | - Python 2.7 (optional for Windows since it will use the interpreter located 68 | inside the `depot_tools` installation) 69 | 70 | ### Debian & Ubuntu 71 | 72 | - Required development packages: 73 | 74 | ``` 75 | # apt-get install build-essential libglib2.0-dev libgtk2.0-dev libxtst-dev \ 76 | libxss-dev libpci-dev libdbus-1-dev libgconf2-dev \ 77 | libgnome-keyring-dev libnss3-dev libasound2-dev libpulse-dev \ 78 | libudev-dev 79 | ``` 80 | 81 | - GCC & G++ 4.8 or later, for C++11 support 82 | 83 | ### macOS 84 | 85 | - OS X 10.11 or later 86 | - Xcode 7.3.1 or later 87 | 88 | ### Windows 89 | 90 | - Windows 7 x64 or later 91 | - Visual Studio 2015 **with updates** - Download the [Installer][vs2015-installer] 92 | 93 | Make sure that you install the following components: 94 | 95 | - Visual C++, which will select three sub-categories including MFC 96 | - Universal Windows Apps Development Tools 97 | - Tools (1.4.1) and Windows 10 SDK (**10.0.14393**) 98 | 99 | - [Windows 10 SDK][w10sdk] with **Debugging Tools for Windows** or 100 | [Windows Driver Kit 10][wdk10] installed in the same Windows 10 SDK 101 | installation directory. 102 | 103 | ## Compiling 104 | 105 | Clone the repository, create an output directory, browse inside it, 106 | then run CMake. 107 | 108 | ``` 109 | $ git clone https://github.com/BeiKeJieDeLiuLangMao/libwebrtc-m70.git 110 | $ cd libwebrtc-m70 111 | $ mkdir out 112 | $ cd out 113 | $ cmake .. 114 | ``` 115 | 116 | Windows users **must** add the Win64 suffix to their Visual Studio generator 117 | name if they want to build the library for 64-bit platforms, they'll omit it for 118 | 32-bit builds and define the `TARGET_CPU` variable accordingly. 119 | 120 | ``` 121 | > cmake -G "Visual Studio 14 2015" -DTARGET_CPU=x86 122 | > cmake -G "Visual Studio 14 2015 Win64" 123 | ``` 124 | 125 | Then they'll have to open the `libwebrtc.sln` located inside the current output 126 | directory and build the `ALL_BUILD` project. 127 | 128 | Unix users will just have to run the following `make` commands. 129 | 130 | ``` 131 | $ make 132 | # make install 133 | ``` 134 | 135 | The library will be located inside the `lib` folder of the current output 136 | directory. The `include` folder will contain the header files. CMake scripts 137 | will be placed inside the `lib/cmake/LibWebRTC` directory. 138 | 139 | ## Debug and Release configurations 140 | 141 | If you are using XCode or Visual Studio, you can simply switch between the Debug 142 | and Release configuration from your IDE. The debugging flags will be 143 | appended to the generator's parameters. 144 | 145 | Otherwise, you must define the `CMAKE_BUILD_TYPE` variable to `Debug`. 146 | 147 | ``` 148 | $ cmake -DCMAKE_BUILD_TYPE=Debug .. 149 | ``` 150 | 151 | ## Using WebRTC in your project 152 | 153 | At the time of writing this README file, there's no proper way to detect any 154 | installation of the WebRTC library and header files. In the meantime, this CMake 155 | script generates and declares a `LibWebRTC` package that will be very easy to 156 | use for your projects. 157 | 158 | All you have to do is include the package, then embed the "use file" that will 159 | automatically find the required libraries, define the proper compiling flags and 160 | include directories. 161 | 162 | ```cmake 163 | find_package(LibWebRTC REQUIRED) 164 | include(${LIBWEBRTC_USE_FILE}) 165 | 166 | target_link_libraries(my-app ${LIBWEBRTC_LIBRARIES}) 167 | ``` 168 | 169 | A pkg-config file is also provided, you can obtain the required compiler and 170 | linker flags by specifying `LibWebRTC` as the package name. 171 | 172 | ``` 173 | $ pkg-config --cflags --libs LibWebRTC 174 | ``` 175 | 176 | ## Fetching a specific revision 177 | 178 | The latest working release will be fetched by default, unless you decide to 179 | retrieve a specific commit by setting it's hash into the **WEBRTC_REVISION** 180 | CMake variable, or another branch head ref into the **WEBRTC_BRANCH_HEAD** 181 | variable. 182 | 183 | ``` 184 | $ cmake -DWEBRTC_REVISION=be22d51 .. 185 | $ cmake -DWEBRTC_BRANCH_HEAD=refs/branch-heads/57 .. 186 | ``` 187 | 188 | If both variables are set, it will focus on fetching the commit defined inside 189 | **WEBRTC_REVISION**. 190 | 191 | ## Managing depot_tools 192 | 193 | CMake will retrieve the latest revision of the `depot_tools` repository. It will 194 | get the WebRTC repository's commit date, then check-out `depot_tools` to the 195 | commit having the closest date to WebRTC's, in order to ensure a high 196 | compatibility with `gclient` and other tools. 197 | 198 | It is possible to prevent this behavior by specifying the location to your own 199 | `depot_tools` repository by defining the **DEPOT_TOOLS_PATH** variable. 200 | 201 | ``` 202 | $ cmake -DDEPOT_TOOLS_PATH=/opt/depot_tools .. 203 | ``` 204 | 205 | ## Configuration 206 | 207 | The library will be compiled and usable on the same host's platform and 208 | architecture. Here are some CMake flags which could be useful if you need to 209 | perform cross-compiling. 210 | 211 | - **BUILD_DEB_PACKAGE** 212 | 213 | Generate Debian package, defaults to OFF, available under Linux only. 214 | 215 | - **BUILD_RPM_PACKAGE** 216 | 217 | Generate Red Hat package, defaults to OFF, available under Linux only. 218 | 219 | - **BUILD_TESTS** 220 | 221 | Build WebRTC unit tests and mocked classes such as `FakeAudioCaptureModule`. 222 | 223 | - **BUILD_SAMPLE** 224 | 225 | Build an executable located inside the `sample` folder. 226 | 227 | - **DEPOT_TOOLS_PATH** 228 | 229 | Set this variable to your own `depot_tools` directory. This will prevent 230 | CMake from fetching the one matching with the desired WebRTC revision. 231 | 232 | - **GN_EXTRA_ARGS** 233 | 234 | Add extra arguments to the `gn gen --args` parameter. 235 | 236 | - **NINJA_ARGS** 237 | 238 | Arguments to pass while executing the `ninja` command. 239 | 240 | - **TARGET_OS** 241 | 242 | Target operating system, the value will be used inside the `--target_os` 243 | argument of the `gn gen` command. The value **must** be one of the following: 244 | 245 | - `android` 246 | - `chromeos` 247 | - `ios` 248 | - `linux` 249 | - `mac` 250 | - `nacl` 251 | - `win` 252 | 253 | - **TARGET_CPU** 254 | 255 | Target architecture, the value will be used inside the `--target_cpu` 256 | argument of the `gn gen` command. The value **must** be one of the following: 257 | 258 | - `x86` 259 | - `x64` 260 | - `arm` 261 | - `arm64` 262 | - `mipsel` 263 | 264 | - **WEBRTC_BRANCH_HEAD** 265 | 266 | Set the branch head ref to retrieve, it is set to the latest working one. 267 | This variable is ignored if **WEBRTC_REVISION** is set. 268 | 269 | - **WEBRTC_REVISION** 270 | 271 | Set a specific commit hash to check-out. 272 | 273 | ## Contributing 274 | 275 | Feel free to open an issue if you wish a bug to be fixed, to discuss a new 276 | feature or to ask a question. I'm open to pull requests, as long as your 277 | modifications are working on the three major OS (Windows, macOS and Linux). 278 | 279 | Don't forget to put your name and e-mail address inside the `AUTHORS` file! 280 | You can also reach me on [Twitter][twitter] for further discussion. 281 | 282 | ## Acknowledgements 283 | 284 | Many thanks to Dr. Alex Gouaillard for being an excellent mentor for this 285 | project. 286 | 287 | Everything started from his 288 | « [Automating libwebrtc build with CMake][webrtc-dr-alex-cmake] » blog article, 289 | which was a great source of inspiration for me to create the easiest way to link 290 | the WebRTC library in any native project. 291 | 292 | ## License 293 | 294 | Apache License 2.0 © [Axel Isouard][author] 295 | 296 | [license-img]:https://img.shields.io/badge/License-Apache%202.0-blue.svg 297 | [license-href]:https://opensource.org/licenses/Apache-2.0 298 | [appveyor-img]:https://ci.appveyor.com/api/projects/status/yd1s303md3tt4w9a?svg=true 299 | [appveyor-href]:https://ci.appveyor.com/project/aisouard/libwebrtc 300 | [travis-img]:https://travis-ci.org/aisouard/libwebrtc.svg?branch=master 301 | [travis-href]:https://travis-ci.org/aisouard/libwebrtc 302 | [gitter-img]:https://badges.gitter.im/aisouard/libwebrtc.svg 303 | [gitter-href]:https://gitter.im/aisouard/libwebrtc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge 304 | [osx1011sdk]: https://github.com/phracker/MacOSX-SDKs/releases/download/MacOSX10.11.sdk/MacOSX10.11.sdk.tar.xz 305 | [vs2015-installer]:https://www.microsoft.com/en-US/download/details.aspx?id=48146 306 | [w10sdk]:https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk 307 | [wdk10]:https://go.microsoft.com/fwlink/p/?LinkId=526733 308 | [twitter]:https://twitter.com/aisouard 309 | [webrtc-dr-alex-cmake]:http://webrtcbydralex.com/index.php/2015/07/22/automating-libwebrtc-build-with-cmake 310 | [author]:https://axel.isouard.fr 311 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2016 Axel Isouard 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------