@@ -19,7 +19,7 @@ set (CMAKE_CXX_EXTENSIONS OFF)
1919
2020# set CMAKE_FIND_ROOT_PATH to search package in WebRTC sysroot
2121if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv.*" )
22- set (CMAKE_FIND_ROOT_PATH ${WEBRTCROOT} /src/build /linux/debian_bullseye_arm -sysroot)
22+ set (CMAKE_FIND_ROOT_PATH ${WEBRTCROOT} /src/build /linux/debian_bullseye_armhf -sysroot)
2323 add_compile_options (--sysroot=${CMAKE_FIND_ROOT_PATH} )
2424elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" )
2525 set (CMAKE_FIND_ROOT_PATH ${WEBRTCROOT} /src/build /linux/debian_bullseye_arm64-sysroot)
@@ -41,7 +41,8 @@ MESSAGE("PATH = $ENV{PATH}")
4141find_package (Git)
4242
4343# webrtc build
44- set (WEBRTCOBJS ${WEBRTCROOT} /src/out/${CMAKE_BUILD_TYPE} /obj)
44+ set (WEBRTCBUILD ${WEBRTCROOT} /src/out/${CMAKE_BUILD_TYPE} )
45+ set (WEBRTCOBJS ${WEBRTCBUILD} /obj)
4546
4647if (NOT EXISTS ${WEBRTCOBJS} /${CMAKE_STATIC_LIBRARY_PREFIX} webrtc${CMAKE_STATIC_LIBRARY_SUFFIX} )
4748 if (GIT_FOUND)
@@ -57,7 +58,7 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
5758
5859 if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv.*" )
5960 EXECUTE_PROCESS (WORKING_DIRECTORY ${WEBRTCROOT} /src
60- COMMAND build /linux/sysroot_scripts/install -sysroot.py --arch=arm
61+ COMMAND build /linux/sysroot_scripts/install -sysroot.py --arch=armhf
6162 RESULT_VARIABLE SYSROOT_RESULT
6263 OUTPUT_VARIABLE SYSROOT_OUTPUT
6364 ERROR_VARIABLE SYSROOT_ERROR
@@ -85,7 +86,7 @@ if (NOT EXISTS ${WEBRTCOBJS}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_
8586
8687 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)
8788 set (WEBRTCARGS libyuv_use_sme=false \n${WEBRTCARGS} )
88- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
89+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT WIN32 )
8990 set (WEBRTCARGS use_custom_libcxx=true \n${WEBRTCARGS} )
9091 else ()
9192 set (WEBRTCARGS use_custom_libcxx=false \n${WEBRTCARGS} )
@@ -210,26 +211,64 @@ MESSAGE("VERSION = ${VERSION}")
210211add_definitions (-DWEBRTCSTREAMERRESSOURCE=\"${WEBRTCSTREAMERRESSOURCE} \")
211212MESSAGE ("WEBRTCSTREAMERRESSOURCE = ${WEBRTCSTREAMERRESSOURCE} " )
212213
214+ # clang custom libc++
215+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
216+ if (NOT WIN32 )
217+ message (STATUS "Using Clang: enabling libc++" )
218+
219+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++" )
220+ add_compile_definitions (_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE)
221+ add_compile_options (-I${WEBRTCROOT} /src/buildtools/third_party/libc++)
222+ if (EXISTS ${WEBRTCBUILD} /gen/third_party/libc++/src/include )
223+ add_compile_options (-isystem${WEBRTCBUILD} /gen/third_party/libc++/src/include )
224+ else ()
225+ add_compile_options (-isystem${WEBRTCROOT} /src/third_party/libc++/src/include )
226+ endif ()
227+ add_compile_options (-isystem${WEBRTCROOT} /src/third_party/libc++abi/src/include )
228+ find_library (LIBC++ NAMES c++ HINTS "${WEBRTCOBJS} /buildtools/third_party/libc++" NO_DEFAULT_PATH)
229+ find_library (LIBC++ABI NAMES c++abi HINTS "${WEBRTCOBJS} /buildtools/third_party/libc++abi" NO_DEFAULT_PATH)
230+ add_compile_options (-Wno-nullability-completeness)
231+ endif ()
232+
233+ message (STATUS "Compiler is Clang CMAKE_LIBRARY_ARCHITECTURE:${CMAKE_LIBRARY_ARCHITECTURE} CMAKE_SYSTEM_PROCESSOR:${CMAKE_SYSTEM_PROCESSOR} " )
234+ if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv.*" )
235+ add_compile_options (-isystem${CMAKE_FIND_ROOT_PATH} /usr/include /arm-linux-gnueabihf -target arm-linux-gnueabihf)
236+ elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" )
237+ if (NOT APPLE )
238+ add_compile_options (-isystem${CMAKE_FIND_ROOT_PATH} /usr/include /aarch64-linux-gnu -arch arm64)
239+ else ()
240+ add_compile_options (-target aarch64-apple -macos)
241+ endif ()
242+ endif ()
243+ endif ()
244+
213245# project target
214246FILE (GLOB_RECURSE WEBRTJSONCPPCOBJS ${WEBRTCOBJS} /third_party/jsoncpp/jsoncpp/*${CMAKE_C_OUTPUT_EXTENSION} ${WEBRTCOBJS} /rtc_base/rtc_json/*${CMAKE_C_OUTPUT_EXTENSION} )
215247FILE (GLOB_RECURSE WEBRTP2POBJ ${WEBRTCOBJS} /p2p/p2p_server_utils/*${CMAKE_C_OUTPUT_EXTENSION} )
216248SET (WEBRTCEXTRAOBJS ${WEBRTJSONCPPCOBJS} ${WEBRTP2POBJ} ${WEBRTCCOMOBJ} )
217249FILE (GLOB SOURCE src/*.cpp)
218250add_executable (${CMAKE_PROJECT_NAME} ${SOURCE} ${WEBRTCEXTRAOBJS} )
219251target_include_directories (${CMAKE_PROJECT_NAME} PRIVATE inc)
252+ if (LIBC++)
253+ message (STATUS "Found libc++ library at ${LIBC++}" )
254+ target_link_libraries (${CMAKE_PROJECT_NAME} "${LIBC++}" )
255+ endif ()
256+ if (LIBC++ABI)
257+ message (STATUS "Found libc++abi library at ${LIBC++ABI}" )
258+ target_link_libraries (${CMAKE_PROJECT_NAME} "${LIBC++ABI}" )
259+ endif ()
220260
221- # webrtc
222- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
223- message ( STATUS "Using Clang: enabling libc++" )
261+ # cxxopts
262+ target_include_directories ( ${CMAKE_PROJECT_NAME} PRIVATE cxxopts/ include )
263+ target_compile_definitions ( ${CMAKE_PROJECT_NAME} PRIVATE CXXOPTS_NO_RTTI )
224264
225- if (WIN32 )
226- target_link_libraries (${CMAKE_PROJECT_NAME} "/DEFAULTLIB:msvcprt.lib" )
227- else ()
228- 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" )
229- 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} " )
230- endif ()
231- endif ()
265+ # thread
266+ set (CMAKE_THREAD_PREFER_PTHREAD TRUE )
267+ set (THREADS_PREFER_PTHREAD_FLAG TRUE )
268+ find_package (Threads)
269+ target_link_libraries (${CMAKE_PROJECT_NAME} Threads::Threads)
232270
271+ # webrtc
233272target_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 )
234273
235274set (WEBRTC_LIBS_INFO
@@ -244,36 +283,7 @@ set(WEBRTC_LIBS_INFO
244283foreach (LIB ${WEBRTC_LIBS_INFO} )
245284 target_link_libraries (${CMAKE_PROJECT_NAME} ${LIB} )
246285endforeach ()
247- add_definitions (-DHAVE_JPEG)
248-
249- # cxxopts
250- target_include_directories (${CMAKE_PROJECT_NAME} PRIVATE cxxopts/include )
251- target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE CXXOPTS_NO_RTTI)
252-
253- # thread
254- set (CMAKE_THREAD_PREFER_PTHREAD TRUE )
255- set (THREADS_PREFER_PTHREAD_FLAG TRUE )
256- find_package (Threads)
257- target_link_libraries (${CMAKE_PROJECT_NAME} Threads::Threads)
258-
259- # civetweb
260- add_library (civetweb STATIC civetweb/src/civetweb.c civetweb/src/CivetServer.cpp)
261- target_compile_definitions (civetweb PUBLIC -DOPENSSL_API_3_0 -DUSE_WEBSOCKET)
262- target_link_libraries (${CMAKE_PROJECT_NAME} civetweb)
263- target_include_directories (civetweb PUBLIC civetweb/include )
264-
265- # rtmp ?
266- find_package (PkgConfig QUIET )
267- pkg_check_modules(RTMP QUIET librtmp)
268- MESSAGE ("RTMP_FOUND = ${RTMP_FOUND} RTMP_INCLUDE_DIRS=${RTMP_INCLUDE_DIRS} RTMP_LIBRARY_DIRS=${RTMP_LIBRARY_DIRS} RTMP_LIBRARIES=${RTMP_LIBRARIES} " )
269- if (RTMP_FOUND)
270- add_definitions (-DHAVE_RTMP)
271- target_include_directories (${CMAKE_PROJECT_NAME} PUBLIC ${RTMP_INCLUDE_DIRS} )
272- target_link_directories (${CMAKE_PROJECT_NAME} PUBLIC ${RTMP_LIBRARY_DIRS} )
273- find_library (RTMP_LIB rtmp)
274- MESSAGE ("RTMP_LIB=${RTMP_LIB} " )
275- target_link_libraries (${CMAKE_PROJECT_NAME} ${RTMP_LIB} )
276- endif ()
286+ target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE HAVE_JPEG)
277287
278288# compiler specific
279289if (WIN32 )
@@ -283,19 +293,24 @@ if (WIN32)
283293 string (REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag} }" )
284294 endforeach ()
285295
296+ # live555
297+ add_definitions (-D_HAS_ITERATOR_DEBUGGING=0 -D_WINSOCKAPI_)
298+
286299 # webrtc
287- add_definitions (-DWEBRTC_WIN - EHsc -DNOMINMAX -D__PRETTY_FUNCTION__ =__FUNCTION__ -D_HAS_ITERATOR_DEBUGGING=0 )
288- add_definitions (-DUSE_X11 -DHAVE_SOUND -D_WINSOCKAPI_ )
300+ target_compile_definitions ( ${CMAKE_PROJECT_NAME} PRIVATE WEBRTC_WIN EHsc NOMINMAX __PRETTY_FUNCTION__ =__FUNCTION__)
301+ target_compile_definitions ( ${CMAKE_PROJECT_NAME} PRIVATE USE_X11 HAVE_SOUND )
289302 target_link_libraries (${CMAKE_PROJECT_NAME} secur32 dmoguids wmcodecdspuuid strmiids msdmo winmm dxgi d3d11 iphlpapi dwmapi shcore)
290303elseif (APPLE )
291304 # use lld to link
292305 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -B${WEBRTCROOT} /src/third_party/llvm-build/Release+Asserts/bin" )
293306
294307 # live555
295308 add_definitions (-DNEED_XLOCALE_H=1)
309+
296310 # webrtc
297- add_definitions (-DHAVE_SOUND)
298- add_definitions (-DWEBRTC_MAC -DWEBRTC_POSIX -fno-rtti)
311+ target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE WEBRTC_MAC WEBRTC_POSIX)
312+ target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE HAVE_SOUND)
313+ add_definitions (-fno-rtti)
299314
300315 find_library (CORE_FOUNDATION Foundation)
301316 find_library (APPLICATION_SERVICES ApplicationServices)
@@ -313,41 +328,49 @@ else()
313328 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -B${WEBRTCROOT} /src/third_party/llvm-build/Release+Asserts/bin" )
314329
315330 # libv4l2cpp
316- add_definitions (-DHAVE_V4L2)
317331 aux_source_directory (libv4l2cpp/src LIBSRC_FILES)
318332 add_library (libv4l2cpp STATIC ${LIBSRC_FILES} )
319333 target_include_directories (libv4l2cpp PUBLIC libv4l2cpp/inc)
334+ target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE HAVE_V4L2)
320335 target_link_libraries (${CMAKE_PROJECT_NAME} libv4l2cpp)
321336
322337 # webrtc
323- add_definitions (-DWEBRTC_POSIX -fno-rtti -fpermissive)
338+ target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE WEBRTC_POSIX)
339+ add_definitions (-fno-rtti -fpermissive)
324340 if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv6.*" )
325341 add_definitions (-marm -march=armv6 -mfpu=vfp -mfloat-abi=hard)
326342 endif ()
327343 if (EXISTS ${WEBRTCROOT} /src/out/${CMAKE_BUILD_TYPE} /obj/modules/desktop_capture/desktop_capture.ninja)
328- add_definitions (-DUSE_X11 )
344+ target_compile_definitions ( ${CMAKE_PROJECT_NAME} PRIVATE USE_X11 )
329345 find_package (X11)
330346 target_link_libraries (${CMAKE_PROJECT_NAME} ${X11_LIBRARIES} ${X11_Xdamage_LIB} ${X11_Xfixes_LIB} ${X11_Xcomposite_LIB} ${X11_Xrandr_LIB} ${X11_Xtst_LIB} )
331347 endif ()
332348 # civetweb
333349 target_link_libraries (${CMAKE_PROJECT_NAME} dl)
334350 #alsa
335351 if (ALSA_FOUND)
336- add_definitions (-DHAVE_SOUND )
352+ target_compile_definitions ( ${CMAKE_PROJECT_NAME} PRIVATE HAVE_SOUND )
337353 endif ()
338354endif ()
339355
340- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
341- message (STATUS "Compiler is Clang CMAKE_LIBRARY_ARCHITECTURE:${CMAKE_LIBRARY_ARCHITECTURE} CMAKE_SYSTEM_PROCESSOR:${CMAKE_SYSTEM_PROCESSOR} " )
342- if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv.*" )
343- add_definitions (-target arm-linux-gnueabihf)
344- elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" )
345- if (NOT APPLE )
346- add_definitions (-target aarch64-linux-gnu)
347- else ()
348- add_definitions (-target aarch64-apple -macos)
349- endif ()
350- endif ()
356+
357+ # civetweb
358+ add_library (civetweb STATIC civetweb/src/civetweb.c civetweb/src/CivetServer.cpp)
359+ target_compile_definitions (civetweb PUBLIC OPENSSL_API_3_0 USE_WEBSOCKET)
360+ target_link_libraries (${CMAKE_PROJECT_NAME} civetweb)
361+ target_include_directories (civetweb PUBLIC civetweb/include )
362+
363+ # rtmp ?
364+ find_package (PkgConfig QUIET )
365+ pkg_check_modules(RTMP QUIET librtmp)
366+ MESSAGE ("RTMP_FOUND = ${RTMP_FOUND} RTMP_INCLUDE_DIRS=${RTMP_INCLUDE_DIRS} RTMP_LIBRARY_DIRS=${RTMP_LIBRARY_DIRS} RTMP_LIBRARIES=${RTMP_LIBRARIES} " )
367+ if (RTMP_FOUND)
368+ target_compile_definitions (${CMAKE_PROJECT_NAME} PRIVATE HAVE_RTMP)
369+ target_include_directories (${CMAKE_PROJECT_NAME} PUBLIC ${RTMP_INCLUDE_DIRS} )
370+ target_link_directories (${CMAKE_PROJECT_NAME} PUBLIC ${RTMP_LIBRARY_DIRS} )
371+ find_library (RTMP_LIB rtmp)
372+ MESSAGE ("RTMP_LIB=${RTMP_LIB} " )
373+ target_link_libraries (${CMAKE_PROJECT_NAME} ${RTMP_LIB} )
351374endif ()
352375
353376# prometheus
@@ -362,12 +385,13 @@ target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE prometheus-cpp/core/inc
362385add_subdirectory (live555helper EXCLUDE_FROM_ALL )
363386target_include_directories (liblive555helper PRIVATE ${WEBRTCROOT} /src/third_party/boringssl/src/include )
364387target_link_libraries (${CMAKE_PROJECT_NAME} liblive555helper ${WEBRTCOBJS} /third_party/boringssl/${CMAKE_STATIC_LIBRARY_PREFIX} boringssl${CMAKE_STATIC_LIBRARY_SUFFIX} )
365- add_definitions (-DHAVE_LIVE555 )
388+ target_compile_definitions ( ${CMAKE_PROJECT_NAME} PRIVATE HAVE_LIVE555 )
366389
367390# static link of libatomic on armv6l
368391if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv6.*" )
369- target_link_libraries (${CMAKE_PROJECT_NAME} -Wl,-Bstatic -latomic -Wl,-Bdynamic)
392+ target_link_libraries (${CMAKE_PROJECT_NAME} -Wl,-Bstatic -latomic -Wl,-Bdynamic)
370393endif ()
394+
371395# static link of stdc++ if available
372396if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
373397 include (CheckCXXCompilerFlag)
0 commit comments