Skip to content

Commit

Permalink
CMake: Protect against empty version vars
Browse files Browse the repository at this point in the history
avcodec_VERSION and friends can be the empty string, on Windows
  • Loading branch information
ferdnyc committed Jun 6, 2021
1 parent 1cee139 commit 6a373ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Expand Up @@ -290,7 +290,7 @@ mark_as_advanced(QT_VERSION_STR)
# Find FFmpeg libraries (used for video encoding / decoding)
find_package(FFmpeg REQUIRED COMPONENTS avcodec avformat avutil swscale)

set(all_comps avcodec avformat avutil swscale avresample)
set(all_comps avcodec avformat avutil swscale)
if(TARGET FFmpeg::swresample)
list(APPEND all_comps swresample)
else()
Expand All @@ -302,7 +302,7 @@ foreach(ff_comp IN LISTS all_comps)
if(TARGET FFmpeg::${ff_comp})
target_link_libraries(openshot PUBLIC FFmpeg::${ff_comp})
# Keep track of some FFmpeg lib versions, to embed in our version header
if(${ff_comp} IN_LIST version_comps)
if(${ff_comp} IN_LIST version_comps AND ${ff_comp}_VERSION)
string(TOUPPER ${ff_comp} v_name)
set(${v_name}_VERSION_STR ${${ff_comp}_VERSION} CACHE STRING "${ff_comp} version used" FORCE)
mark_as_advanced(${v_name}_VERSION_STR)
Expand All @@ -311,7 +311,7 @@ foreach(ff_comp IN LISTS all_comps)
endforeach()

# Version check for hardware-acceleration code
if(TARGET FFmpeg::avcodec AND USE_HW_ACCEL)
if(USE_HW_ACCEL AND avcodec_VERSION)
if(${avcodec_VERSION} VERSION_GREATER 57.107.100)
set(HAVE_HW_ACCEL TRUE)
endif()
Expand Down

0 comments on commit 6a373ef

Please sign in to comment.