Skip to content

Commit

Permalink
Print build-time warnings for LGPL gotchas (#3958)
Browse files Browse the repository at this point in the history
Print helpful reminder to check licenses when using libheif or
ffmpeg statically linked.

Fixes #3916

Signed-off-by: grdanny <[email protected]>
  • Loading branch information
grdanny authored Sep 20, 2023
1 parent d663495 commit b3ac0a2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/ffmpeg.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
22 changes: 22 additions & 0 deletions src/heif.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit b3ac0a2

Please sign in to comment.