@@ -56,7 +56,7 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
5656
5757 if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv.*" )
5858 EXECUTE_PROCESS (WORKING_DIRECTORY ${WEBRTCROOT} /src
59- COMMAND build /linux/sysroot_scripts/install -sysroot.py --arch=arm
59+ COMMAND build /linux/sysroot_scripts/install -sysroot.py --arch=arm
6060 RESULT_VARIABLE SYSROOT_RESULT
6161 OUTPUT_VARIABLE SYSROOT_OUTPUT
6262 ERROR_VARIABLE SYSROOT_ERROR
@@ -68,7 +68,7 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
6868 message ("install-sysroot.py succeeded ${SYSROOT_OUTPUT} " )
6969 endif ()
7070 elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" )
71- EXECUTE_PROCESS (WORKING_DIRECTORY ${WEBRTCROOT} /src
71+ EXECUTE_PROCESS (WORKING_DIRECTORY ${WEBRTCROOT} /src
7272 COMMAND build /linux/sysroot_scripts/install -sysroot.py --arch=arm64
7373 RESULT_VARIABLE SYSROOT_RESULT
7474 OUTPUT_VARIABLE SYSROOT_OUTPUT
@@ -83,7 +83,12 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
8383 endif ()
8484
8585 set (WEBRTCARGS rtc_include_tests=false \nrtc_enable_protobuf=false \nrtc_build_examples=false \nrtc_build_tools=false \ntreat_warnings_as_errors=false \nenable_js_protobuf=false \nuse_glib=false \n)
86- set (WEBRTCARGS use_custom_libcxx=false \nlibyuv_use_sme=false \n${WEBRTCARGS} )
86+ set (WEBRTCARGS libyuv_use_sme=false \n${WEBRTCARGS} )
87+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
88+ set (WEBRTCARGS use_custom_libcxx=true \n${WEBRTCARGS} )
89+ else ()
90+ set (WEBRTCARGS use_custom_libcxx=false \n${WEBRTCARGS} )
91+ endif ()
8792 # debug/release
8893 if (CMAKE_BUILD_TYPE STREQUAL "Release" )
8994 set (WEBRTCARGS is_debug=false \n${WEBRTCARGS} )
@@ -97,6 +102,8 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
97102 else ()
98103 set (WEBRTCARGS rtc_use_h264=true \nrtc_use_h265=true \n${WEBRTCARGS} )
99104 endif ()
105+
106+ # configure ffmpeg for armv6
100107 if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv6.*" )
101108 set (CONFIGURE_ARGS --disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --disable-error-resilience --enable-decoder=vorbis,libopus,flac --enable-decoder=pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3 --enable-decoder=pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw --enable-demuxer=ogg,matroska,wav,flac,mp3,mov --enable-parser=opus,vorbis,flac,mpegaudio,vp9 --extra-cflags=-I${WEBRTCROOT}/src/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags="-O2" --arch=arm --enable-armv6 --disable-armv6t2 --enable-vfp --disable-thumb --extra-cflags=-march=armv6 --enable-cross-compile --target-os=linux --extra-cflags=--target=arm-linux-gnueabihf --extra-ldflags=--target=arm-linux-gnueabihf --sysroot=${WEBRTCROOT}/src/build/linux/debian_bullseye_armhf-sysroot --extra-cflags=-mtune=cortex-a8 --extra-cflags=-mfloat-abi=hard --extra-cflags=-O2 --disable-neon --extra-cflags=-mfpu=vfpv3-d16 --enable-pic --cc=clang --cxx=clang++ --ld=clang --extra-ldflags=-fuse-ld=lld --enable-decoder=aac,h264 --enable-demuxer=aac --enable-parser=aac,h264)
102109 MESSAGE ("CONFIGURE_ARGS = ${CONFIGURE_ARGS} " )
@@ -113,7 +120,7 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
113120 file (COPY ${WEBRTCROOT} /src/third_party/ffmpeg/libavformat/muxer_list.c DESTINATION ${WEBRTCROOT} /src/third_party/ffmpeg/chromium/config/Chrome/linux/arm/libavformat/)
114121 file (COPY ${WEBRTCROOT} /src/third_party/ffmpeg/libavformat/protocol_list.c DESTINATION ${WEBRTCROOT} /src/third_party/ffmpeg/chromium/config/Chrome/linux/arm/libavformat/)
115122
116- endif ()
123+ endif ()
117124
118125 #patch
119126 if (APPLE )
@@ -127,7 +134,7 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
127134 file (WRITE ${WEBRTCROOT} /src/media/base/media_channel.h "${filecontent} " )
128135 file (READ ${WEBRTCROOT} /src/call/rtp_config.cc filecontent)
129136 string (REGEX REPLACE "stream_config.rtx.emplace\\ (\\ )" "stream_config.rtx.emplace(RtpStreamConfig::Rtx())" filecontent "${filecontent} " )
130- file (WRITE ${WEBRTCROOT} /src/call/rtp_config.cc "${filecontent} " )
137+ file (WRITE ${WEBRTCROOT} /src/call/rtp_config.cc "${filecontent} " )
131138
132139 # sound support
133140 if (APPLE )
@@ -173,21 +180,21 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
173180 if (WIN32 )
174181 SET (SHELLCOMMAND cmd /c )
175182 endif ()
176- EXECUTE_PROCESS (WORKING_DIRECTORY ${WEBRTCROOT} /src/out/${CMAKE_BUILD_TYPE} COMMAND ${SHELLCOMMAND} gn gen .)
183+ EXECUTE_PROCESS (WORKING_DIRECTORY ${WEBRTCROOT} /src/out/${CMAKE_BUILD_TYPE} COMMAND ${SHELLCOMMAND} gn gen .)
177184
178185 SET (NINJA_TARGET webrtc rtc_json builtin_video_decoder_factory builtin_video_encoder_factory p2p_server_utils task_queue default_task_queue_factory field_trials)
179186 EXECUTE_PROCESS (WORKING_DIRECTORY ${WEBRTCROOT} /src/out/${CMAKE_BUILD_TYPE} COMMAND ${SHELLCOMMAND} ninja ${NINJA_TARGET} RESULT_VARIABLE NINJA_RESULT)
180187 if (NOT NINJA_RESULT EQUAL 0)
181188 message (FATAL_ERROR "webrtc build failed with exit code ${NINJA_RESULT} " )
182- endif ()
189+ endif ()
183190endif ()
184191
185192# build version identifier
186193if (GIT_FOUND)
187194 EXECUTE_PROCESS (COMMAND ${GIT_EXECUTABLE} submodule update --init)
188195 EXECUTE_PROCESS (COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty OUTPUT_VARIABLE PROJECTVERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
189196 set (VERSION "${PROJECTVERSION} /${CMAKE_SYSTEM_NAME} -${CMAKE_SYSTEM_PROCESSOR} " )
190-
197+
191198 EXECUTE_PROCESS (COMMAND ${GIT_EXECUTABLE} -C civetweb describe --tags --always --dirty OUTPUT_VARIABLE CIVETVERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
192199 set (VERSION "${VERSION} civetweb@${CIVETVERSION} " )
193200
@@ -205,14 +212,20 @@ MESSAGE("WEBRTCSTREAMERRESSOURCE = ${WEBRTCSTREAMERRESSOURCE}")
205212# project target
206213FILE (GLOB_RECURSE WEBRTJSONCPPCOBJS ${WEBRTCOBJS} /third_party/jsoncpp/jsoncpp/*${CMAKE_C_OUTPUT_EXTENSION} ${WEBRTCOBJS} /rtc_base/rtc_json/*${CMAKE_C_OUTPUT_EXTENSION} )
207214FILE (GLOB_RECURSE WEBRTP2POBJ ${WEBRTCOBJS} /p2p/p2p_server_utils/*${CMAKE_C_OUTPUT_EXTENSION} )
208- SET (WEBRTCEXTRAOBJS ${WEBRTJSONCPPCOBJS} ${WEBRTP2POBJ} ${WEBRTCCOMOBJ} )
215+ SET (WEBRTCEXTRAOBJS ${WEBRTJSONCPPCOBJS} ${WEBRTP2POBJ} ${WEBRTCCOMOBJ} )
209216FILE (GLOB SOURCE src/*.cpp)
210217add_executable (${CMAKE_PROJECT_NAME} ${SOURCE} ${WEBRTCEXTRAOBJS} )
211- target_include_directories (${CMAKE_PROJECT_NAME} PRIVATE inc)
218+ target_include_directories (${CMAKE_PROJECT_NAME} PRIVATE inc)
212219
213- # webrtc
214- set (WEBRTCINCLUDE ${WEBRTCROOT} /src ${WEBRTCROOT} /src/third_party/abseil-cpp ${WEBRTCROOT} /src/third_party/jsoncpp/source /include ${WEBRTCROOT} /src/third_party/jsoncpp/generated ${WEBRTCROOT} /src/third_party/libyuv/include )
215- target_include_directories (${CMAKE_PROJECT_NAME} PRIVATE ${WEBRTCINCLUDE} )
220+ # webrtc
221+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
222+ message (STATUS "Using Clang: enabling libc++" )
223+
224+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${WEBRTCROOT} /src/buildtools/third_party/libc++ -nostdinc++ -isystem${WEBRTCROOT} /src/third_party/libc++/src/include -isystem${WEBRTCROOT} /src/third_party/libc++abi/src/include -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" )
225+ target_link_libraries (${CMAKE_PROJECT_NAME} "${WEBRTCOBJS} /buildtools/third_party/libc++/${CMAKE_STATIC_LIBRARY_PREFIX} c++${CMAKE_STATIC_LIBRARY_SUFFIX} " "${WEBRTCOBJS} /buildtools/third_party/libc++abi/${CMAKE_STATIC_LIBRARY_PREFIX} c++abi${CMAKE_STATIC_LIBRARY_SUFFIX} " )
226+ endif ()
227+
228+ target_include_directories (${CMAKE_PROJECT_NAME} PRIVATE ${WEBRTCROOT} /src ${WEBRTCROOT} /src/third_party/abseil-cpp ${WEBRTCROOT} /src/third_party/jsoncpp/source /include ${WEBRTCROOT} /src/third_party/jsoncpp/generated ${WEBRTCROOT} /src/third_party/libyuv/include )
216229
217230set (WEBRTC_LIBS_INFO
218231 "${WEBRTCOBJS} /api/${CMAKE_STATIC_LIBRARY_PREFIX} field_trials${CMAKE_STATIC_LIBRARY_SUFFIX} "
@@ -236,25 +249,25 @@ target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE CXXOPTS_NO_RTTI)
236249set (CMAKE_THREAD_PREFER_PTHREAD TRUE )
237250set (THREADS_PREFER_PTHREAD_FLAG TRUE )
238251find_package (Threads)
239- target_link_libraries (${CMAKE_PROJECT_NAME} Threads::Threads)
252+ target_link_libraries (${CMAKE_PROJECT_NAME} Threads::Threads)
240253
241254# civetweb
242- add_library (civetweb STATIC civetweb/src/civetweb.c civetweb/src/CivetServer.cpp)
243- add_definitions ( -DOPENSSL_API_3_0 -DUSE_WEBSOCKET)
244- target_link_libraries (${CMAKE_PROJECT_NAME} civetweb)
245- target_include_directories (civetweb PUBLIC civetweb/include )
255+ add_library (civetweb STATIC civetweb/src/civetweb.c civetweb/src/CivetServer.cpp)
256+ target_compile_definitions (civetweb PUBLIC -DOPENSSL_API_3_0 -DUSE_WEBSOCKET)
257+ target_link_libraries (${CMAKE_PROJECT_NAME} civetweb)
258+ target_include_directories (civetweb PUBLIC civetweb/include )
246259
247260# rtmp ?
248261find_package (PkgConfig QUIET )
249262pkg_check_modules(RTMP QUIET librtmp)
250263MESSAGE ("RTMP_FOUND = ${RTMP_FOUND} RTMP_INCLUDE_DIRS=${RTMP_INCLUDE_DIRS} RTMP_LIBRARY_DIRS=${RTMP_LIBRARY_DIRS} RTMP_LIBRARIES=${RTMP_LIBRARIES} " )
251264if (RTMP_FOUND)
252265 add_definitions (-DHAVE_RTMP)
253- target_include_directories (${CMAKE_PROJECT_NAME} PUBLIC ${RTMP_INCLUDE_DIRS} )
266+ target_include_directories (${CMAKE_PROJECT_NAME} PUBLIC ${RTMP_INCLUDE_DIRS} )
254267 target_link_directories (${CMAKE_PROJECT_NAME} PUBLIC ${RTMP_LIBRARY_DIRS} )
255268 find_library (RTMP_LIB rtmp)
256269 MESSAGE ("RTMP_LIB=${RTMP_LIB} " )
257- target_link_libraries (${CMAKE_PROJECT_NAME} ${RTMP_LIB} )
270+ target_link_libraries (${CMAKE_PROJECT_NAME} ${RTMP_LIB} )
258271endif ()
259272
260273# compiler specific
@@ -286,8 +299,8 @@ elseif (APPLE)
286299 find_library (AUDIO_TOOLBOX AudioToolBox)
287300 find_library (IO_SURFACE IOSurface)
288301 find_library (APP_KIT AppKit)
289-
290-
302+
303+
291304 target_link_libraries (${CMAKE_PROJECT_NAME} ${CORE_FOUNDATION} ${APPLICATION_SERVICES} ${CORE_SERVICES}
292305 ${CORE_AUDIO} ${AUDIO_TOOLBOX} ${IO_SURFACE} ${APP_KIT} )
293306else ()
@@ -297,9 +310,9 @@ else()
297310 # libv4l2cpp
298311 add_definitions (-DHAVE_V4L2)
299312 aux_source_directory (libv4l2cpp/src LIBSRC_FILES)
300- include_directories ("libv4l2cpp/inc" )
301313 add_library (libv4l2cpp STATIC ${LIBSRC_FILES} )
302- target_link_libraries (${CMAKE_PROJECT_NAME} libv4l2cpp)
314+ target_include_directories (libv4l2cpp PUBLIC libv4l2cpp/inc)
315+ target_link_libraries (${CMAKE_PROJECT_NAME} libv4l2cpp)
303316
304317 # webrtc
305318 add_definitions (-DWEBRTC_POSIX -fno-rtti -fpermissive)
@@ -312,7 +325,7 @@ else()
312325 target_link_libraries (${CMAKE_PROJECT_NAME} ${X11_LIBRARIES} ${X11_Xdamage_LIB} ${X11_Xfixes_LIB} ${X11_Xcomposite_LIB} ${X11_Xrandr_LIB} ${X11_Xtst_LIB} )
313326 endif ()
314327 # civetweb
315- target_link_libraries (${CMAKE_PROJECT_NAME} dl)
328+ target_link_libraries (${CMAKE_PROJECT_NAME} dl)
316329 #alsa
317330 if (ALSA_FOUND)
318331 add_definitions (-DHAVE_SOUND)
@@ -328,21 +341,21 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
328341 add_definitions (-target aarch64-linux-gnu)
329342 else ()
330343 add_definitions (-target aarch64-apple -macos)
331- endif ()
344+ endif ()
332345 endif ()
333346endif ()
334347
335- # prometheus
348+ # prometheus
336349include (GenerateExportHeader)
337350include (GNUInstallDirs)
338351set (PROJECT_NAME prometheus-cpp)
339352add_subdirectory (prometheus-cpp/core EXCLUDE_FROM_ALL )
340- target_link_libraries (${CMAKE_PROJECT_NAME} core)
353+ target_link_libraries (${CMAKE_PROJECT_NAME} core)
341354target_include_directories (${CMAKE_PROJECT_NAME} PRIVATE prometheus-cpp/core/include )
342355
343- # live555helper
344- include_directories (${WEBRTCROOT} /src/third_party/boringssl/src/include )
356+ # live555helper
345357add_subdirectory (live555helper EXCLUDE_FROM_ALL )
358+ target_include_directories (liblive555helper PRIVATE ${WEBRTCROOT} /src/third_party/boringssl/src/include )
346359target_link_libraries (${CMAKE_PROJECT_NAME} liblive555helper ${WEBRTCOBJS} /third_party/boringssl/${CMAKE_STATIC_LIBRARY_PREFIX} boringssl${CMAKE_STATIC_LIBRARY_SUFFIX} )
347360add_definitions (-DHAVE_LIVE555)
348361
@@ -351,14 +364,14 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv6.*")
351364 target_link_libraries (${CMAKE_PROJECT_NAME} -Wl,-Bstatic -latomic -Wl,-Bdynamic)
352365endif ()
353366# static link of stdc++ if available
354- if (NOT APPLE )
367+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
355368 include (CheckCXXCompilerFlag)
356369 CHECK_CXX_COMPILER_FLAG("-static-libgcc" CXX_SUPPORTS_STATIC_LIBGCC)
357- if (CXX_SUPPORTS_STATIC_LIBGCC)
370+ if (CXX_SUPPORTS_STATIC_LIBGCC)
358371 target_link_libraries (${CMAKE_PROJECT_NAME} -static -libgcc)
359- endif ()
372+ endif ()
360373 CHECK_CXX_COMPILER_FLAG("-static-libstdc++" CXX_SUPPORTS_STATIC_LIBSTDCPP)
361- if (CXX_SUPPORTS_STATIC_LIBSTDCPP)
374+ if (CXX_SUPPORTS_STATIC_LIBSTDCPP)
362375 target_link_libraries (${CMAKE_PROJECT_NAME} -static -libstdc++)
363376 endif ()
364377endif ()
@@ -369,7 +382,7 @@ install (DIRECTORY html DESTINATION share/${CMAKE_PROJECT_NAME})
369382install (FILES config.json DESTINATION share/${CMAKE_PROJECT_NAME} )
370383SET (CPACK_GENERATOR "TGZ" )
371384SET (CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME} -${CMAKE_SYSTEM_PROCESSOR} -${CMAKE_BUILD_TYPE} )
372- SET (CPACK_PACKAGE_CONTACT "michel.promonet@free.fr" )
385+ SET (CPACK_PACKAGE_CONTACT "michel.promonet@free.fr" )
373386if (PROJECTVERSION)
374387 SET (CPACK_PACKAGE_VERSION "${PROJECTVERSION} " )
375388endif ()
0 commit comments