From b3ac0a2ceb89fc26ed272e8b338e4858382ac285 Mon Sep 17 00:00:00 2001 From: Danny Greenstein Date: Tue, 19 Sep 2023 20:13:14 -0700 Subject: [PATCH] Print build-time warnings for LGPL gotchas (#3958) Print helpful reminder to check licenses when using libheif or ffmpeg statically linked. Fixes #3916 Signed-off-by: grdanny --- src/ffmpeg.imageio/CMakeLists.txt | 22 ++++++++++++++++++++++ src/heif.imageio/CMakeLists.txt | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/ffmpeg.imageio/CMakeLists.txt b/src/ffmpeg.imageio/CMakeLists.txt index 59fe404c30..a34402cf2e 100644 --- a/src/ffmpeg.imageio/CMakeLists.txt +++ b/src/ffmpeg.imageio/CMakeLists.txt @@ -3,6 +3,28 @@ # https://github.com/OpenImageIO/oiio if (FFmpeg_FOUND) + if (LINKSTATIC) + set (_static_suffixes .lib .a) + set (_static_libraries_found 0) + + foreach (_ffmpeg_library IN LISTS FFMPEG_LIBRARIES) + get_filename_component (_ext ${_ffmpeg_library} LAST_EXT) + list (FIND _static_suffixes ${_ext} _index) + if (${_index} GREATER -1) + MATH (EXPR _static_libraries_found "${_static_libraries_found}+1") + endif() + endforeach() + + if (${_static_libraries_found} GREATER 0) + message (STATUS "${ColorYellow}") + message (STATUS "You are linking OpenImageIO against a static version of FFmpeg, which may have") + message (STATUS "LGPL and possibly GPL licensed components (depending on exactly how your copy") + message (STATUS "of FFmpeg was built). If you intend to redistribute this build of OpenImageIO,") + message (STATUS "we recommend that you review the FFmpeg build flags and licensing terms.") + message ("${ColorReset}") + endif() + endif() + add_oiio_plugin (ffmpeginput.cpp INCLUDE_DIRS ${FFMPEG_INCLUDES} LINK_LIBRARIES ${FFMPEG_LIBRARIES} diff --git a/src/heif.imageio/CMakeLists.txt b/src/heif.imageio/CMakeLists.txt index 12ad634002..86a099539e 100644 --- a/src/heif.imageio/CMakeLists.txt +++ b/src/heif.imageio/CMakeLists.txt @@ -3,6 +3,28 @@ # https://github.com/OpenImageIO/oiio if (Libheif_FOUND) + if (LINKSTATIC) + set (_static_suffixes .lib .a) + set (_static_libraries_found 0) + + foreach (_libeheif_library IN LISTS LIBHEIF_LIBRARIES) + get_filename_component (_ext ${_libeheif_library} LAST_EXT) + list (FIND _static_suffixes ${_ext} _index) + if (${_index} GREATER -1) + MATH (EXPR _static_libraries_found "${static_libraries_found}+1") + endif() + endforeach() + + if (${_static_libraries_found} GREATER 0) + message (STATUS "${ColorYellow}") + message (STATUS "You are linking OpenImageIO against a static version of libheif, which is LGPL") + message (STATUS "licensed. If you intend to redistribute this build of OpenImageIO, we recommend") + message (STATUS "that you review the libheif license terms, or you may wish to switch to using a") + message (STATUS "dynamically-linked libheif.") + message ("${ColorReset}") + endif() + endif() + add_oiio_plugin (heifinput.cpp heifoutput.cpp INCLUDE_DIRS ${LIBHEIF_INCLUDES} LINK_LIBRARIES ${LIBHEIF_LIBRARIES}