libwebrtc icon indicating copy to clipboard operation
libwebrtc copied to clipboard

Proper way to use libwebrtc as a submodule

Open aniongithub opened this issue 7 years ago • 1 comments

That's built in-source, not as a build/install globally. My .gitmodules is:

    [submodule "libwebrtc"]
	path = libwebrtc
	url = https://github.com/aisouard/libwebrtc.git
	branch = release-58

The intention is to be able to get my source tree and build it all once, with libwebrtc binaries being generated locally in my binary directory.

aniongithub avatar Jan 16 '18 21:01 aniongithub

I assume this is a question "how to use libwebrtc" as a submodule and you did not figure that out yet.

I've asked myself the same question but the solution is not so straight forward:

https://stackoverflow.com/questions/61205068/how-to-rewrite-a-find-package-based-library-into-one-which-can-be-embedded-into

SET(CUSTOM_LIBWEBRTC_INSTALLATION_DIR "" CACHE STRING "Should point to the build/installation directory of libwebrtc (the directory with lib/, include/ and webrtc/)")

if( NOT "${CUSTOM_LIBWEBRTC_INSTALLATION_DIR}" STREQUAL "" )
    message("CUSTOM_LIBWEBRTC_INSTALLATION_DIR = '${CUSTOM_LIBWEBRTC_INSTALLATION_DIR}' so we build with a user-supplied LIBWEBRTC location")

    include_directories(
      ${CUSTOM_LIBWEBRTC_INSTALLATION_DIR}/include/webrtc
      ${CUSTOM_LIBWEBRTC_INSTALLATION_DIR}/include/webrtc/third_party/libyuv/include/
      ${CUSTOM_LIBWEBRTC_INSTALLATION_DIR}/webrtc/src/third_party/abseil-cpp
    )
    add_library(libwebrtc STATIC IMPORTED)
    set_property(TARGET libwebrtc PROPERTY IMPORTED_LOCATION "${CUSTOM_LIBWEBRTC_INSTALLATION_DIR}/lib/libwebrtc.a")
    target_link_libraries(${PROJECT_NAME} libwebrtc)
else ()
    message("CUSTOM_LIBWEBRTC_INSTALLATION_DIR NOT DEFINED -> build with bundled LIBWEBRTC")
    # HACK: In libwebrtc's CMakeLists.txt one has to rename the project(libwebrtcx) and also ExternalProject_Add(libwebrtcx ...) to inject
    #       a build time dependency which will build the library/includes first before they can be used from this CMakeLists.txt
    #       This is also why the libwebrtc is included as a third party library below.
    add_dependencies(${PROJECT_NAME} libwebrtcx)
    add_subdirectory(third-party/libwebrtc)
    include_directories(
      ${CMAKE_BINARY_DIR}/sources/third-party/libwebrtc/include/webrtc
      ${CMAKE_BINARY_DIR}/sources/third-party/libwebrtc/include/webrtc/third_party/libyuv/include/
      ${CMAKE_BINARY_DIR}/sources/third-party/libwebrtc/webrtc/src/third_party/abseil-cpp
    )
    add_library(libwebrtc STATIC IMPORTED)
    # FIXME maybe never build in debug mode
    if(CMAKE_BUILD_TYPE MATCHES DEBUG)
        set_property(TARGET libwebrtc PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/sources/third-party/libwebrtc/webrtc/src/out/Debug/obj/libwebrtc.a")
    else()
        set_property(TARGET libwebrtc PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/sources/third-party/libwebrtc/webrtc/src/out/Release/obj/libwebrtc.a")
    endif()
    target_link_libraries(${PROJECT_NAME} libwebrtc)
endif()

# webrtc specific libraries
target_link_libraries(${PROJECT_NAME} X11 Xcomposite Xdamage Xfixes Xext)

qknight avatar Apr 21 '20 13:04 qknight