From bf55efe36edf1980a8574626b13c3e4ae78f7e26 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Sun, 16 Jan 2022 14:24:10 +0300 Subject: [PATCH] Defer third-party source handling to when it is needed Using GitHub's autogenerated source tarballs to build tg_owt requires OS package maintainers to fetch third-party software by other means as they are git submodules and thus not included. In the case of `TG_OWT_PACKAGED_BUILD=1`, third-party bundles are only needed if the system's respective package could not be found. On OpenBSD, tg_owt is built with `TG_OWT_PACKAGED_BUILD=1` and abseil, libopenh264, libusrsctp and libvpx are used as packaged libraries. Thus only libvpx must be fetched and built as bundle. However, cmake currently expects all third-party sources to be present, otherwise the `cmake/*.cmake` files fail in referencing nonexistent C/C++ source files. In packaged builds, neither the sources, nor the defined `tg_owt::*` targets are required iff packages were found, i.e. `*_FOUND=1`. Defer third-party source handling to when it is actually needed to fix the build and/or avoid needless fetching of source files. Tested on OpenBSD where I previously just removed all irrelevant `include(cmake/lib*.cmake)` lines to unbreak the packaged build. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56fd4924..18ad64ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,12 +77,9 @@ include(cmake/init_target.cmake) include(cmake/generate_target.cmake) include(cmake/target_yasm_sources.cmake) include(cmake/external.cmake) -include(cmake/libabsl.cmake) -include(cmake/libopenh264.cmake) include(cmake/libpffft.cmake) include(cmake/librnnoise.cmake) include(cmake/libsrtp.cmake) -include(cmake/libusrsctp.cmake) include(cmake/libyuv.cmake) if (APPLE) include(cmake/libsdkmacos.cmake) @@ -2406,12 +2403,15 @@ if (TG_OWT_USE_PROTOBUF) endif() if (NOT absl_FOUND) + include(cmake/libabsl.cmake) list(APPEND export_targets libabsl) endif() if (NOT LIBOPENH264_FOUND) + include(cmake/libopenh264.cmake) list(APPEND export_targets libopenh264) endif() if (NOT LIBUSRSCTP_FOUND) + include(cmake/libusrsctp.cmake) list(APPEND export_targets libusrsctp) endif()