summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-12-22 10:45:30 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-01-08 21:29:14 +0000
commitf32ae321f6f6a6676acd5dce997c4f40cebabd76 (patch)
tree0c60247c98e86ca8664bd5f3afe6ba87a71facde /cmake
parentf6724fd47e7adb48068af443c95d5185567228ab (diff)
Fix finding ffmpeg if cached libs have been deleted
The fix is useful after implementation of copying ffmpeg libs to lib folder. In this case the following development flow is possible: - build QtMM in with QT_DEPLOY_FFMPEG (ffmpeg is copied to libs) - clean only QtMM build + cmake cache, run cmake and build it again. (now ffmpeg libs may be found in qtbase/libs dir). - clean qtbase/libs dir without cleaning cmake cache and build agian. (cached ffmpeg libs paths have become invalid). The patch fixes the corner case above. Pick-to: 6.6 6.5 Change-Id: Ifee6b249f1d2fb459c5fe88f676f7c96e0c04588 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> (cherry picked from commit d4d3af139e90d99280651ff5527fd9da1df5c69d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindFFmpeg.cmake20
1 files changed, 15 insertions, 5 deletions
diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake
index 44a70ec8f..661de90ca 100644
--- a/cmake/FindFFmpeg.cmake
+++ b/cmake/FindFFmpeg.cmake
@@ -79,7 +79,7 @@ endif()
# Marks the given component as found if both *_LIBRARY_NAME AND *_INCLUDE_DIRS is present.
#
macro(set_component_found _component)
- if (${_component}_LIBRARY_NAME AND ${_component}_INCLUDE_DIRS AND
+ if (${_component}_LIBRARY_NAME AND ${_component}_INCLUDE_DIR AND
(${_component}_SHARED_LIBRARIES OR NOT shared_libs_required))
# message(STATUS " - ${_component} found.")
set(${_component}_FOUND TRUE)
@@ -119,7 +119,12 @@ macro(find_component _component _pkgconfig _library _header)
list(APPEND CMAKE_FIND_ROOT_PATH "${FFMPEG_ROOT}")
endif()
- find_path(${_component}_INCLUDE_DIRS ${_header}
+ if (${_component}_INCLUDE_DIR AND NOT EXISTS ${${_component}_INCLUDE_DIR})
+ message(STATUS "Cached include dir ${${_component}_INCLUDE_DIR} doesn't exist")
+ unset(${_component}_INCLUDE_DIR CACHE)
+ endif()
+
+ find_path(${_component}_INCLUDE_DIR ${_header}
HINTS
${PC_${_component}_INCLUDEDIR}
${PC_${_component}_INCLUDE_DIRS}
@@ -134,6 +139,11 @@ macro(find_component _component _pkgconfig _library _header)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
+ if (${_component}_LIBRARY AND NOT EXISTS ${${_component}_LIBRARY})
+ message(STATUS "Cached library ${${_component}_LIBRARY} doesn't exist")
+ unset(${_component}_LIBRARY CACHE)
+ endif()
+
find_library(${_component}_LIBRARY
NAMES ${PC_${_component}_LIBRARIES} ${_library}
HINTS
@@ -185,7 +195,7 @@ foreach (_component ${FFmpeg_FIND_COMPONENTS})
if (${_component}_FOUND)
list(APPEND FFMPEG_LIBRARIES ${${_component}_LIBRARY_NAME})
list(APPEND FFMPEG_DEFINITIONS ${${_component}_DEFINITIONS})
- list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
+ list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIR})
list(APPEND FFMPEG_LIBRARY_DIRS ${${_component}_LIBRARY_DIR})
if (${_component}_SHARED_LIBRARIES)
@@ -270,7 +280,7 @@ endfunction()
add_library(FFmpeg::${_lowerComponent} INTERFACE IMPORTED)
set_target_properties(FFmpeg::${_lowerComponent} PROPERTIES
INTERFACE_COMPILE_OPTIONS "${${_component}_DEFINITIONS}"
- INTERFACE_INCLUDE_DIRECTORIES ${${_component}_INCLUDE_DIRS}
+ INTERFACE_INCLUDE_DIRECTORIES ${${_component}_INCLUDE_DIR}
INTERFACE_LINK_LIBRARIES "${${_component}_LIBRARY_NAME}"
INTERFACE_LINK_DIRECTORIES "${${_component}_LIBRARY_DIR}"
)
@@ -331,7 +341,7 @@ endif()
# Compile the list of required vars
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
foreach (_component ${FFmpeg_FIND_COMPONENTS})
- list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARY ${_component}_INCLUDE_DIRS)
+ list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARY ${_component}_INCLUDE_DIR)
endforeach ()
# Give a nice error message if some of the required vars are missing.