mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 03:15:11 +00:00
123 lines
3.7 KiB
CMake
123 lines
3.7 KiB
CMake
cmake_minimum_required(VERSION 2.8)
|
|
cmake_policy(SET CMP0057 NEW)
|
|
project(libwebrtc)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
|
${CMAKE_SOURCE_DIR}/CMakeModules)
|
|
|
|
if (CMAKE_CONFIGURATION_TYPES)
|
|
set(CMAKE_CONFIGURATION_TYPES Debug Release)
|
|
endif (CMAKE_CONFIGURATION_TYPES)
|
|
|
|
#
|
|
# Required packages
|
|
find_package(Git REQUIRED)
|
|
find_package(DepotTools REQUIRED)
|
|
|
|
if (WIN32)
|
|
set(PYTHON_EXECUTABLE ${CMAKE_SOURCE_DIR}/depot_tools/python.bat)
|
|
else (WIN32)
|
|
find_package(PythonInterp REQUIRED)
|
|
endif (WIN32)
|
|
|
|
#
|
|
# Set the project's version
|
|
set(LIBWEBRTC_MAJOR_VERSION 0)
|
|
set(LIBWEBRTC_MINOR_VERSION 0)
|
|
set(LIBWEBRTC_PATCH_VERSION 1)
|
|
set(LIBWEBRTC_BUILD_VERSION -rc.4)
|
|
set(LIBWEBRTC_WEBRTC_REVISION ae2551232b5249e38298a50f2d9a64d3c862db00)
|
|
|
|
set(LIBWEBRTC_API_VERSION
|
|
"${LIBWEBRTC_MAJOR_VERSION}.${LIBWEBRTC_MINOR_VERSION}.${LIBWEBRTC_PATCH_VERSION}")
|
|
set(LIBWEBRTC_VERSION
|
|
${LIBWEBRTC_API_VERSION}${LIBWEBRTC_BUILD_VERSION})
|
|
|
|
#
|
|
# Options
|
|
#
|
|
|
|
option(BUILD_TESTS "Build test binaries" OFF)
|
|
option(BUILD_SAMPLES "Build samples binaries" OFF)
|
|
set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC")
|
|
|
|
#
|
|
# Directories
|
|
#
|
|
|
|
if (NOT LIBWEBRTC_INSTALL_BIN_DIR)
|
|
set(LIBWEBRTC_INSTALL_BIN_DIR "bin")
|
|
endif ()
|
|
if (NOT LIBWEBRTC_INSTALL_LIB_DIR)
|
|
set(LIBWEBRTC_INSTALL_LIB_DIR "lib")
|
|
endif ()
|
|
if (NOT LIBWEBRTC_INSTALL_DATA_DIR)
|
|
set(LIBWEBRTC_INSTALL_DATA_DIR "share")
|
|
endif ()
|
|
if (NOT LIBWEBRTC_INSTALL_INCLUDE_DIR)
|
|
set(LIBWEBRTC_INSTALL_INCLUDE_DIR "include")
|
|
endif ()
|
|
|
|
#
|
|
# Target OS
|
|
set(TARGET_OS "" CACHE STRING "Target OS, used as --target_os argument")
|
|
set(TARGET_OS_LIST android chromeos ios linux nacl mac win)
|
|
|
|
if (TARGET_OS STREQUAL "")
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
set(TARGET_OS "linux")
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
set(TARGET_OS "mac")
|
|
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
set(TARGET_OS "win")
|
|
endif ()
|
|
endif (TARGET_OS STREQUAL "")
|
|
|
|
if (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST)
|
|
message(FATAL_ERROR "Unknown value '${TARGET_OS}' for variable TARGET_OS, options are: ${TARGET_OS_LIST}")
|
|
endif (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST)
|
|
|
|
#
|
|
# Target CPU
|
|
set(TARGET_CPU "" CACHE STRING "Target CPU, used as --target_cpu argument")
|
|
set(TARGET_CPU_LIST x86 x64 arm arm64 mipsel)
|
|
|
|
if (TARGET_CPU STREQUAL "")
|
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
|
|
set(TARGET_CPU "x86")
|
|
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^x86.64$")
|
|
set(TARGET_CPU "x64")
|
|
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
|
set(TARGET_CPU "x64")
|
|
else ()
|
|
set(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR})
|
|
endif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
|
|
endif (TARGET_CPU STREQUAL "")
|
|
|
|
if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
|
|
message(FATAL_ERROR "Unknown value '${TARGET_CPU}' for variable TARGET_CPU, options are: ${TARGET_CPU_LIST}")
|
|
endif (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)
|
|
|
|
if (UNIX)
|
|
if (TARGET_CPU STREQUAL "x86")
|
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "-m32")
|
|
endif (TARGET_CPU STREQUAL "x86")
|
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -std=gnu++0x")
|
|
list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_POSIX _GLIBCXX_USE_CXX11_ABI=0)
|
|
elseif (WIN32)
|
|
set(LIBWEBRTC_REQUIRED_C_FLAGS_DEBUG "/MTd")
|
|
set(LIBWEBRTC_REQUIRED_C_FLAGS_RELEASE "/MT")
|
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_DEBUG "/MTd")
|
|
set(LIBWEBRTC_REQUIRED_CXX_FLAGS_RELEASE "/MT")
|
|
list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_WIN NOMINMAX _CRT_SECURE_NO_WARNINGS)
|
|
endif(UNIX)
|
|
|
|
set(LIBWEBRTC_LIBRARY_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_LIBRARY_SUFFIX})
|
|
set(LIBWEBRTC_LIBRARY_PATH ${CMAKE_BINARY_DIR}/${LIBWEBRTC_INSTALL_LIB_DIR}/${LIBWEBRTC_LIBRARY_NAME})
|
|
|
|
set(LIBWEBRTC_BUILD_ROOT ${CMAKE_SOURCE_DIR}/src/out/Default)
|
|
add_subdirectory(Targets)
|
|
|
|
if (BUILD_SAMPLES)
|
|
add_subdirectory(Samples)
|
|
endif (BUILD_SAMPLES)
|