Debian Codegraph @

Xpjproject/third_party/CMakeLists.txt

raw
1 set(DEPS)
2
3 # G7221
4 set(DEP_G7221_HELP "G7221 codec implementation provider")
5 set(DEP_G7221_SUBDIR "g7221")
6 set(DEP_G7221_PACKAGE "G7221")
7 list(APPEND DEPS G7221)
8
9 # GSM
10 set(DEP_GSM_HELP "GSM codec implementation provider")
11 set(DEP_GSM_SUBDIR "gsm")
12 set(DEP_GSM_PACKAGE "GSM")
13 list(APPEND DEPS GSM)
14
15 # iLBC
16 set(DEP_iLBC_HELP "iLBC codec implementation provider")
17 set(DEP_iLBC_SUBDIR "ilbc")
18 list(APPEND DEPS iLBC)
19
20 # Resample
21 set(DEP_Resample_HELP "libresample implementation provider")
22 set(DEP_Resample_SUBDIR "resample")
23 set(DEP_Resample_PACKAGE "Resample")
24 list(APPEND DEPS Resample)
25
26 # Speex
27 set(DEP_Speex_HELP "Speex codec & resampling implementation provider")
28 set(DEP_Speex_SUBDIR "speex")
29 set(DEP_Speex_PACKAGE "Speex")
30 list(APPEND DEPS Speex)
31
32 # SRTP
33 set(DEP_SRTP_HELP "Secure RTP (sRTP) implementation provider")
34 set(DEP_SRTP_SUBDIR "srtp")
35 set(DEP_SRTP_PACKAGE "SRTP")
36 list(APPEND DEPS SRTP)
37
38 if(NOT (APPLE OR MINGW OR CYGWIN))
39 # WebRTC
40 set(DEP_WebRTC_HELP "WebRTC implementation provider")
41 set(DEP_WebRTC_SUBDIR "webrtc")
42 list(APPEND DEPS WebRTC)
43
44 # WebRTC_AEC3
45 set(DEP_WebRTC_AEC3_HELP "WebRTC AEC3 implementation provider")
46 set(DEP_WebRTC_AEC3_SUBDIR "webrtc_aec3")
47 list(APPEND DEPS WebRTC_AEC3)
48 endif()
49
50 # YUV
51 set(DEP_YUV_HELP "libyuv codec implementation provider")
52 set(DEP_YUV_SUBDIR "yuv")
53 set(DEP_YUV_PACKAGE "YUV")
54 list(APPEND DEPS YUV)
55
56 # imports dependencies
57 set(install_subdirs)
58 foreach(dep IN LISTS DEPS)
59 # construct providers list
60 set(dep_providers)
61 if(DEP_${dep}_SUBDIR)
62 list(APPEND dep_providers "bundled")
63 endif()
64 if(DEP_${dep}_PACKAGE)
65 list(APPEND dep_providers "system")
66 endif()
67 if(NOT dep_providers)
68 message(FATAL_ERROR "No providers were set for ${dep}")
69 endif()
70
71 # add option
72 string(TOUPPER "PJ_DEP_${dep}" dep_option_name)
73 list(GET dep_providers 0 dep_option_default)
74
75 pj_option(${dep_option_name} "${DEP_${dep}_HELP}"
76 DEFAULT ${dep_option_default}
77 ALLOWED_VALUES ${dep_providers}
78 )
79
80 # import dependency
81 if(${dep_option_name} STREQUAL "bundled")
82 add_subdirectory(${DEP_${dep}_SUBDIR} EXCLUDE_FROM_ALL)
83 set(dep_target ${DEP_${dep}_SUBDIR})
84 list(APPEND install_subdirs ${DEP_${dep}_SUBDIR})
85 elseif(${dep_option_name} STREQUAL "system")
86 find_package(${DEP_${dep}_PACKAGE} REQUIRED)
87 if(${DEP_${dep}_PACKAGE}_FOUND)
88 if(${DEP_${dep}_PACKAGE_TARGET})
89 set(dep_target ${DEP_${dep}_PACKAGE_TARGET})
90 else()
91 set(dep_target ${DEP_${dep}_PACKAGE}::${DEP_${dep}_PACKAGE})
92 endif()
93 endif()
94 endif()
95
96 # set provider property on target
97 if(dep_target)
98 set_target_properties(${dep_target} PROPERTIES
99 PJ_DEP_PROVIDER ${${dep_option_name}}
100 )
101 add_library(Pj::Dep::${dep} ALIAS ${dep_target})
102 endif()
103
104 # add alias
105 endforeach()
106
107 # install selected sub-diriectories
108 if(install_subdirs)
109 # append `$ORIGIN/pjproject/third_party` to RPATH
110 if(BUILD_SHARED_LIBS)
111 if(APPLE)
112 list(APPEND CMAKE_INSTALL_RPATH "@loader_path/pjproject/third_party")
113 elseif(UNIX)
114 list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/pjproject/third_party")
115 endif()
116 set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} PARENT_SCOPE)
117 endif()
118
119 foreach(subdir IN LISTS install_subdirs)
120 # add installation config
121 install(TARGETS ${subdir}
122 EXPORT PjTargets
123 LIBRARY
124 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pjproject/third_party"
125 COMPONENT PjRuntime
126 OPTIONAL
127 ARCHIVE
128 DESTINATION "${CMAKE_INSTALL_BINDIR}/pjproject/third_party"
129 COMPONENT PjDevelopment
130 OPTIONAL
131 FILE_SET HEADERS
132 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/pjproject/third_party/${subdir}"
133 COMPONENT PjDevelopment
134 OPTIONAL
135 )
136 endforeach()
137 endif()