Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper way to use libwebrtc as a submodule #61

Open
aniongithub opened this issue Jan 16, 2018 · 1 comment
Open

Proper way to use libwebrtc as a submodule #61

aniongithub opened this issue Jan 16, 2018 · 1 comment

Comments

@aniongithub
Copy link

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.

@qknight
Copy link

qknight commented Apr 21, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants