From f95ce167b3d4946659194db0283945d5ae9a00c6 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Wed, 18 May 2022 17:57:54 +0200 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 235f0f30..eddf551e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,9 +77,7 @@ 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/libcrc32c.cmake) -include(cmake/libopenh264.cmake) include(cmake/libpffft.cmake) include(cmake/librnnoise.cmake) include(cmake/libsrtp.cmake) @@ -2577,9 +2575,11 @@ 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()