-
Notifications
You must be signed in to change notification settings - Fork 2
/
FindLive555.cmake
228 lines (201 loc) · 6.92 KB
/
FindLive555.cmake
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# ---------------------------------------------------------------------------
#
# Find Log4cplus library and headers
#
# ---------------------------------------------------------------------------
#
#
# This module reads hints about search locations from the following variables:
#
# LIVE555_ROOT
#
# ---------------------------------------------------------------------------
#
#
# Use this module by invoking find_package with the form:
#
# find_package(live555
# [REQUIRED] # Fail with error if Log4cplus is not found
# )
#
# ---------------------------------------------------------------------------
#
# Ideas for this module were picked up from various places, including github repositories.
#
# Copyright (c) 2017 Ernesto Varoli <[email protected]>
# Distributed under the MIT License (see LICENSE file)
# ---------------------------------------------------------------------------
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
if(LIVE555_USE_STATIC_LIBS)
set(_live555_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
endif()
endif()
find_path(LIVE555_GROUPSOCK_INCLUDE_DIR
NAMES
Groupsock.hh
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
groupsock
)
find_path(LIVE555_LIVEMEDIA_INCLUDE_DIR
NAMES
liveMedia.hh
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
liveMedia
)
find_path(LIVE555_USAGEENVIRONMENT_INCLUDE_DIR
NAMES
UsageEnvironment.hh
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
UsageEnvironment
)
find_path(LIVE555_BASICUSAGEENVIRONMENT_INCLUDE_DIR
NAMES
BasicUsageEnvironment.hh
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
BasicUsageEnvironment
)
if(WIN32 AND NOT CYGWIN)
# TODO
else()
find_library(LIVE555_BASICUSAGEENVIRONMENT_LIBRARY
NAMES
BasicUsageEnvironment
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
lib
)
find_library(LIVE555_USAGEENVIRONMENT_LIBRARY
NAMES
UsageEnvironment
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
lib
)
find_library(LIVE555_GROUPSOCK_LIBRARY
NAMES
groupsock
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
lib
)
find_library(LIVE555_LIVEMEDIA_LIBRARY
NAMES
liveMedia
HINTS
"${LIVE555_ROOT}"
PATH_SUFFIXES
lib
)
mark_as_advanced(LIVE555_BASICUSAGEENVIRONMENT_LIBRARY LIVE555_USAGEENVIRONMENT_LIBRARY LIVE555_GROUPSOCK_LIBRARY LIVE555_LIVEMEDIA_LIBRARY)
# compat defines
set(LIVE555_BASICUSAGEENVIRONMENT_LIBRARIES ${LIVE555_BASICUSAGEENVIRONMENT_LIBRARY} ${CMAKE_DL_LIBS})
set(LIVE555_USAGEENVIRONMENT_LIBRARIES ${LIVE555_USAGEENVIRONMENT_LIBRARY} ${CMAKE_DL_LIBS})
set(LIVE555_LIVEMEDIA_LIBRARIES ${LIVE555_LIVEMEDIA_LIBRARY} ${CMAKE_DL_LIBS})
set(LIVE555_GROUPSOCK_LIBRARIES ${LIVE555_GROUPSOCK_LIBRARY} ${CMAKE_DL_LIBS})
set(LIVE555_LIBRARIES ${LIVE555_LIVEMEDIA_LIBRARY} ${LIVE555_GROUPSOCK_LIBRARY} ${LIVE555_USAGEENVIRONMENT_LIBRARY} ${LIVE555_BASICUSAGEENVIRONMENT_LIBRARY} ${CMAKE_DL_LIBS})
endif()
function(getLiveVersion library_name library_version_ret)
string(TOUPPER ${library_name} uc_library_name)
set(library_version_define "${uc_library_name}_LIBRARY_VERSION_INT")
set(library_include_dir "${LIVE555_${uc_library_name}_INCLUDE_DIR}")
if(EXISTS "${library_include_dir}/${library_name}_version.hh")
file(STRINGS "${library_include_dir}/${library_name}_version.hh" library_version_str
REGEX "^#[\t ]*define[\t ]+${library_version_define}[\t ]+([0-9])+.*")
string(COMPARE EQUAL "${library_version_str}" "" _is_empty)
if(_is_empty)
message(
FATAL_ERROR
"Incorrect ${library_version_define} define in header"
": ${library_include_dir}/${library_name}_version.hh"
)
endif()
string(REGEX REPLACE "^.*${library_version_define}[\t ]+([0-9]+).*$"
"\\1" library_version "${library_version_str}" )
set(${library_version_ret} ${library_version} PARENT_SCOPE)
endif()
endfunction()
getLiveVersion("liveMedia" LIVEMEDIA_VERSION)
getLiveVersion("BasicUsageEnvironment" BASICUSAGEENVIRONMENT_VERSION)
getLiveVersion("UsageEnvironment" USAGEENVIRONMENT_VERSION)
getLiveVersion("groupsock" GROUPSOCK_VERSION)
include(FindPackageHandleStandardArgs)
if( NOT (LIVEMEDIA_VERSION EQUAL GROUPSOCK_VERSION AND BASICUSAGEENVIRONMENT_VERSION EQUAL USAGEENVIRONMENT_VERSION AND USAGEENVIRONMENT_VERSION EQUAL LIVEMEDIA_VERSION))
message(
FATAL_ERROR
"Incorrect libraries versions:
\tliveMedia: ${LIVEMEDIA_VERSION}
\tBasicUsageEnvironment: ${BASICUSAGEENVIRONMENT_VERSION}
\tUsageEnvironment: ${USAGEENVIRONMENT_VERSION}
\tgroupsock ${GROUPSOCK_VERSION}"
)
else()
set(LIVE555_VERSION ${LIVEMEDIA_VERSION})
endif()
if (LIVE555_VERSION)
find_package_handle_standard_args(Live555
REQUIRED_VARS
LIVE555_LIBRARIES
LIVE555_LIVEMEDIA_INCLUDE_DIR
LIVE555_GROUPSOCK_INCLUDE_DIR
LIVE555_USAGEENVIRONMENT_INCLUDE_DIR
LIVE555_BASICUSAGEENVIRONMENT_INCLUDE_DIR
VERSION_VAR
LIVE555_VERSION
FAIL_MESSAGE
"Could NOT find Live555 Streaming Media, try to set the path to Live555 root folder in the system variable LIVE555_ROOT_DIR"
)
else ()
find_package_handle_standard_args(Live555 "Could NOT find Live555 Streaming Media, try to set the path to Live555 root folder in the system variable LIVE_ROOT_DIR"
LIVE555_LIBRARIES
LIVE555_LIVEMEDIA_INCLUDE_DIR
LIVE555_GROUPSOCK_INCLUDE_DIR
LIVE555_USAGEENVIRONMENT_INCLUDE_DIR
LIVE555_BASICUSAGEENVIRONMENT_INCLUDE_DIR
)
endif ()
mark_as_advanced(LIVE555_LIVEMEDIA_INCLUDE_DIR
LIVE555_GROUPSOCK_INCLUDE_DIR
LIVE555_USAGEENVIRONMENT_INCLUDE_DIR
LIVE555_BASICUSAGEENVIRONMENT_INCLUDE_DIR
LIVE555_LIBRARIES)
function(addLiveLibrary library_name)
string(TOUPPER ${library_name} uc_library_name)
if(NOT TARGET Live555::${library_name} AND
EXISTS "${LIVE555_${uc_library_name}_LIBRARY}")
add_library(Live555::${library_name} UNKNOWN IMPORTED)
set_target_properties(Live555::${library_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LIVE555_${uc_library_name}_INCLUDE_DIR}")
set_target_properties(Live555::${library_name} PROPERTIES
INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
if(EXISTS "${LIVE555_${uc_library_name}_LIBRARY}")
set_target_properties(Live555::${library_name} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C++"
IMPORTED_LOCATION "${LIVE555_${uc_library_name}_LIBRARY}")
endif()
endif()
endfunction()
if(LIVE555_FOUND)
addLiveLibrary("LiveMedia")
addLiveLibrary("Groupsock")
addLiveLibrary("UsageEnvironment")
addLiveLibrary("BasicUsageEnvironment")
endif()
# Restore the original find library ordering
if(LIVE555_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_live555_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()