forked from rawrtc/rawrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
105 lines (87 loc) · 3.88 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Project
cmake_minimum_required(VERSION 3.2)
# TODO: Find a way to keep this in sync with the one in rawrtc.h
project(librawrtc
VERSION 0.2.2)
set(PROJECT_DESCRIPTION
"A WebRTC and ORTC library with a small footprint that runs everywhere.")
set(PROJECT_URL
"https://github.com/rawrtc/rawrtc")
# Use prefix pkgconfig
set(ENV{PKG_CONFIG_PATH} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/:$ENV{PKG_CONFIG_PATH}")
# Dependency versions
set(OPENSSL_VERSION "openssl >= 1.0.2")
set(LIB_RE_VERSION "libre >= 0.5.7")
set(LIB_REW_VERISON "librew >= 0.5.0")
# Note: This MUST be here as cmake 3.5.0 overwrites LIB_RE_VERSION for some reason...
set(DEPENDENCY_VERSIONS "${OPENSSL_VERSION}, ${LIB_RE_VERSION}, ${LIB_REW_VERISON}")
# Debug build type as default
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, using DEBUG")
set(CMAKE_BUILD_TYPE "DEBUG")
endif ()
# Enable verbose output in DEBUG mode
if (${CMAKE_BUILD_TYPE} MATCHES "DEBUG")
message(STATUS "enabling verbose outout")
set(CMAKE_VERBOSE_MAKEFILE on)
endif ()
# Flag for enabling building of SCTP redirect transport
set(SCTP_REDIRECT_TRANSPORT OFF CACHE BOOL "Build the SCTP redirect transport tool.")
# Use pkg-config
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
# Dependency list
set(rawrtc_DEP_LIBRARIES)
# Dependency: Threads
list(APPEND rawrtc_DEP_LIBRARIES
Threads::Threads)
# Apple-specific dependencies
# TODO: This should probably be in libre's pkg-config file in Libs.private
if (APPLE)
find_library(LIB_SYSTEM_CONFIGURATION_LIBRARIES NAMES SystemConfiguration)
find_library(LIB_CORE_FOUNDATION_LIBRARIES NAMES CoreFoundation)
list(APPEND rawrtc_DEP_LIBRARIES
${LIB_SYSTEM_CONFIGURATION_LIBRARIES}
${LIB_CORE_FOUNDATION_LIBRARIES})
endif ()
# Dependency: OpenSSL
pkg_check_modules(LIB_OPENSSL REQUIRED ${OPENSSL_VERSION})
include_directories(${LIB_OPENSSL_INCLUDE_DIRS})
link_directories(${LIB_OPENSSL_LIBRARY_DIRS})
list(APPEND rawrtc_DEP_LIBRARIES ${LIB_OPENSSL_LIBRARIES})
# Dependency: libre
pkg_check_modules(LIB_RE REQUIRED ${LIB_RE_VERSION})
include_directories(${LIB_RE_STATIC_INCLUDE_DIRS})
link_directories(${LIB_RE_STATIC_LIBRARY_DIRS})
list(APPEND rawrtc_DEP_LIBRARIES ${LIB_RE_STATIC_LIBRARIES})
# Dependency: librew
pkg_check_modules(LIB_REW REQUIRED ${LIB_REW_VERISON})
include_directories(${LIB_REW_STATIC_INCLUDE_DIRS})
link_directories(${LIB_REW_STATIC_LIBRARY_DIRS})
list(APPEND rawrtc_DEP_LIBRARIES ${LIB_REW_STATIC_LIBRARIES})
# Dependency: usrsctp
# TODO: Use the pkg-config file of usrsctp once it has been added
find_library(LIB_USRSCTP_LIBRARIES NAMES usrsctp.a libusrsctp.a HINTS ${CMAKE_INSTALL_PREFIX}/lib )
find_path(LIB_USRSCTP_INCLUDE_DIRS usrsctp.h HINTS ${CMAKE_INSTALL_PREFIX}/include )
get_filename_component(LIB_USRSCTP_LIBRARY_DIRS ${LIB_USRSCTP_LIBRARIES} DIRECTORY)
include_directories(${LIB_USRSCTP_INCLUDE_DIRS})
link_directories(${LIB_USRSCTP_LIBRARY_DIRS})
list(APPEND rawrtc_DEP_LIBRARIES ${LIB_USRSCTP_LIBRARIES})
# Dependency versions
set(PKG_CONFIG_REQUIRES "")
set(PKG_CONFIG_REQUIRES_PRIVATE "${DEPENDENCY_VERSIONS}")
# Linker flags (includes libs that have no pkg-config files)
set(PKG_CONFIG_LIB_DIRS "-L\${libdir}")
set(PKG_CONFIG_LIBRARIES "-lrawrtc")
set(PKG_CONFIG_LIBS "${PKG_CONFIG_LIB_DIRS} ${PKG_CONFIG_LIBRARIES}")
set(PKG_CONFIG_LIB_DIRS_PRIVATE "${PKG_CONFIG_LIB_DIRS} -L${LIB_USRSCTP_LIBRARY_DIRS}")
set(PKG_CONFIG_LIBRARIES_PRIVATE "${PKG_CONFIG_LIBRARIES} ${LIB_USRSCTP_LIBRARIES}")
set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIB_DIRS_PRIVATE} ${PKG_CONFIG_LIBRARIES_PRIVATE}")
# Cflags (includes includes that have no pkg-config files)
set(PKG_CONFIG_CFLAGS "-I\${includedir} -I${LIB_USRSCTP_INCLUDE_DIRS}")
# Add custom target to install the library
add_custom_target(install-${PROJECT_NAME}
$(MAKE) install
COMMENT "Installing ${PROJECT_NAME}")
# Walk through subdirectories
add_subdirectory(src)