cmake: Find FFMPEG_LDFLAGS in FindFFmpeg.cmake.

Add support for setting the <component>_LDFLAGS and FFMPEG_LDFLAGS cmake
variables based on pkg-config in FindFFmpeg.cmake.

The LDFLAGS can be necessary when linking FFmpeg statically, as is the
case for the mac builder script.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-12-25 07:59:56 -08:00
parent fb068e55c4
commit f7f424ea1b
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 10 additions and 6 deletions

View File

@ -83,6 +83,7 @@ macro(find_component _component _pkgconfig _library _header)
) )
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.") set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
set(${_component}_LDFLAGS ${PC_${_component}_LDFLAGS} CACHE STRING "The ${_component} LDFLAGS.")
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.") set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
set_component_found(${_component}) set_component_found(${_component})
@ -113,8 +114,9 @@ if (NOT FFMPEG_LIBRARIES)
foreach (_component ${FFmpeg_FIND_COMPONENTS}) foreach (_component ${FFmpeg_FIND_COMPONENTS})
if (${_component}_FOUND) if (${_component}_FOUND)
# message(STATUS "Required component ${_component} present.") # message(STATUS "Required component ${_component} present.")
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES}) list(APPEND FFMPEG_LIBRARIES ${${_component}_LIBRARIES})
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS}) list(APPEND FFMPEG_DEFINITIONS ${${_component}_DEFINITIONS})
list(APPEND FFMPEG_LDFLAGS ${${_component}_LDFLAGS})
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS}) list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
else () else ()
# message(STATUS "Required component ${_component} missing.") # message(STATUS "Required component ${_component} missing.")
@ -129,9 +131,11 @@ if (NOT FFMPEG_LIBRARIES)
# cache the vars. # cache the vars.
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg CFLAGS." FORCE)
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} CACHE STRING "The FFmpeg LDFLAGS." FORCE)
mark_as_advanced(FFMPEG_INCLUDE_DIRS mark_as_advanced(FFMPEG_INCLUDE_DIRS
FFMPEG_LDFLAGS
FFMPEG_LIBRARIES FFMPEG_LIBRARIES
FFMPEG_DEFINITIONS) FFMPEG_DEFINITIONS)
@ -143,9 +147,9 @@ foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE)
endforeach () endforeach ()
# Compile the list of required vars # Compile the list of required vars
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_LDFLAGS FFMPEG_INCLUDE_DIRS)
foreach (_component ${FFmpeg_FIND_COMPONENTS}) foreach (_component ${FFmpeg_FIND_COMPONENTS})
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS) list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_LDFLAGS ${_component}_INCLUDE_DIRS)
endforeach () endforeach ()
# Give a nice error message if some of the required vars are missing. # Give a nice error message if some of the required vars are missing.