Fix FindFFMPEG.cmake for older CMake (#344)

This commit is contained in:
Florian Märkl 2020-10-21 11:59:36 +02:00 committed by GitHub
commit d5b220d7c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,21 +46,29 @@ function (_ffmpeg_find component headername)
if(PKG_CONFIG_FOUND) if(PKG_CONFIG_FOUND)
pkg_check_modules(FFMPEG_${component} lib${component} IMPORTED_TARGET) pkg_check_modules(FFMPEG_${component} lib${component} IMPORTED_TARGET)
if(FFMPEG_${component}_FOUND) if(FFMPEG_${component}_FOUND)
if(APPLE) if((TARGET PkgConfig::FFMPEG_${component}) AND (NOT CMAKE_VERSION VERSION_LESS "3.11.0"))
join(FFMPEG_LDFLAGS_STRING " " ${FFMPEG_${component}_LDFLAGS}) if(APPLE)
string(REGEX REPLACE "-Wl,-framework,([^ ]+)" "-framework \\1" FFMPEG_LDFLAGS_STRING_CLEAN ${FFMPEG_LDFLAGS_STRING}) join(FFMPEG_LDFLAGS_STRING " " ${FFMPEG_${component}_LDFLAGS})
string(REGEX MATCHALL "-framework [^ ]+" FFMPEG_FRAMEWORKS ${FFMPEG_LDFLAGS_STRING_CLEAN}) string(REGEX REPLACE "-Wl,-framework,([^ ]+)" "-framework \\1" FFMPEG_LDFLAGS_STRING_CLEAN ${FFMPEG_LDFLAGS_STRING})
list(APPEND FFMPEG_${component}_LIBRARIES ${FFMPEG_FRAMEWORKS}) string(REGEX MATCHALL "-framework [^ ]+" FFMPEG_FRAMEWORKS ${FFMPEG_LDFLAGS_STRING_CLEAN})
set_target_properties(PkgConfig::FFMPEG_${component} PROPERTIES list(APPEND FFMPEG_${component}_LIBRARIES ${FFMPEG_FRAMEWORKS})
INTERFACE_LINK_DIRECTORIES "${FFMPEG_${component}_LIBRARY_DIRS}" set_target_properties(PkgConfig::FFMPEG_${component} PROPERTIES
INTERFACE_LINK_LIBRARIES "${FFMPEG_${component}_LIBRARIES}" INTERFACE_LINK_DIRECTORIES "${FFMPEG_${component}_LIBRARY_DIRS}"
INTERFACE_LINK_OPTIONS "") INTERFACE_LINK_LIBRARIES "${FFMPEG_${component}_LIBRARIES}"
message("set libs to \"${FFMPEG_${component}_LIBRARIES}\"") INTERFACE_LINK_OPTIONS "")
message("set lib dirs to \"${FFMPEG_${component}_LIBRARY_DIRS}\"") message("set libs to \"${FFMPEG_${component}_LIBRARIES}\"")
message("set lib otps not to \"${FFMPEG_${component}_LDFLAGS}\"") message("set lib dirs to \"${FFMPEG_${component}_LIBRARY_DIRS}\"")
message("set lib otps not to \"${FFMPEG_${component}_LDFLAGS}\"")
endif()
set_target_properties(PkgConfig::FFMPEG_${component} PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(FFMPEG::${component} ALIAS PkgConfig::FFMPEG_${component})
else()
add_library("FFMPEG::${component}" INTERFACE IMPORTED)
set_target_properties("FFMPEG::${component}" PROPERTIES
INTERFACE_LINK_DIRECTORIES "${FFMPEG_${component}_LIBRARY_DIRS}"
INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFMPEG_${component}_LIBRARIES}")
endif() endif()
set_target_properties(PkgConfig::FFMPEG_${component} PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(FFMPEG::${component} ALIAS PkgConfig::FFMPEG_${component})
return() return()
endif() endif()
endif() endif()