summarylogtreecommitdiffstats
path: root/use-findffmpeg.patch
blob: 31685f65cd92d0cb2d2978a9cb16bcb37b6b0cd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
diff -Naur ./k9copy.orig/cmake/FindFFmpeg.cmake ./k9copy/cmake/FindFFmpeg.cmake
--- ./k9copy.orig/cmake/FindFFmpeg.cmake	1969-12-31 19:00:00.000000000 -0500
+++ ./k9copy/cmake/FindFFmpeg.cmake	2022-05-22 20:05:55.788701784 -0400
@@ -0,0 +1,116 @@
+# Taken from openmw 0.47.0
+
+# vim: ts=2 sw=2
+# - Try to find the required ffmpeg components
+#
+# This module accepts the following env variable
+#  FFMPEG_HOME - Can be set to custom install path
+#
+# Once done this will define
+#  FFmpeg_FOUND         - System has the all required components.
+#  FFmpeg_INCLUDE_DIRS  - Include directory necessary for using the required components headers.
+#  FFmpeg_LIBRARIES     - Link these to use the required ffmpeg components.
+#  FFmpeg_DEFINITIONS   - Compiler switches required for using the required ffmpeg components.
+#
+# For each of the components it will additionaly set.
+#   - AVCODEC
+#   - AVDEVICE
+#   - AVFORMAT
+#   - AVUTIL
+#   - POSTPROCESS
+#   - SWSCALE
+#   - SWRESAMPLE
+# the following variables will be defined
+#  FFmpeg_<component>_FOUND        - System has <component>
+#  FFmpeg_<component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
+#  FFmpeg_<component>_LIBRARIES    - Link these to use <component>
+#  FFmpeg_<component>_DEFINITIONS  - Compiler switches required for using <component>
+#  FFmpeg_<component>_VERSION      - The components version
+#
+# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
+# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
+# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
+# Copyright (c) 2016, Roman Proskuryakov, <humbug@deeptown.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+include(LibFindMacros)
+include(FindPackageHandleStandardArgs)
+
+# Macro: _internal_find_component
+# Checks for the given component by invoking pkgconfig etc.
+macro(_internal_find_component _component _pkgconfig _library _header)
+    set(_package_component FFmpeg_${_component})
+    libfind_pkg_detect(${_package_component} ${_pkgconfig}
+        FIND_PATH ${_header}
+            HINTS $ENV{FFMPEG_HOME}
+            PATH_SUFFIXES include ffmpeg
+        FIND_LIBRARY ${_library}
+            HINTS $ENV{FFMPEG_HOME}
+            PATH_SUFFIXES lib
+    )
+    set(${_package_component}_DEFINITIONS  ${${_package_component}_PKGCONF_CFLAGS_OTHER})
+    set(${_package_component}_VERSION      ${${_package_component}_PKGCONF_VERSION})
+    libfind_process(${_package_component})
+endmacro()
+
+
+# setter for 'hashmap'
+macro(hashmap_set _table _key) # ARGN
+    set(${_table}_${_key} ${ARGN})
+endmacro()
+
+# check for key in 'hashmap'
+macro(hashmap_exists _table _key _out_var)
+    if (DEFINED ${_table}_${_key})
+        set(${_out_var} TRUE)
+    else()
+        set(${_out_var} FALSE)
+    endif()
+endmacro()
+
+# getter for 'hashmap'
+macro(hashmap_get _table _key _out_var)
+    set(${_out_var} ${${_table}_${_key}})
+endmacro()
+
+
+# fill 'hashmap' named find_args
+hashmap_set(find_args AVCODEC  libavcodec  avcodec  libavcodec/avcodec.h)
+hashmap_set(find_args AVFORMAT libavformat avformat libavformat/avformat.h)
+#hashmap_set(find_args AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
+hashmap_set(find_args AVUTIL   libavutil   avutil   libavutil/avutil.h)
+hashmap_set(find_args SWSCALE  libswscale  swscale  libswscale/swscale.h)
+#hashmap_set(find_args POSTPROC libpostproc postproc libpostproc/postprocess.h)
+#hashmap_set(find_args SWRESAMPLE  libswresample  swresample  libswresample/swresample.h)
+#hashmap_set(find_args AVRESAMPLE  libavresample  avresample  libavresample/avresample.h)
+
+# Check if the required components were found and add their stuff to the FFmpeg_* vars.
+foreach (_component ${FFmpeg_FIND_COMPONENTS})
+    hashmap_exists(find_args ${_component} _known_component)
+    if (NOT _known_component)
+        message(FATAL_ERROR "Unknown component '${_component}'")
+    endif()
+    hashmap_get(find_args ${_component} _component_find_args)
+    _internal_find_component(${_component} ${_component_find_args})
+    set(_package_component FFmpeg_${_component})
+    if (${_package_component}_FOUND)
+        list(APPEND FFmpeg_LIBRARIES ${${_package_component}_LIBRARIES})
+        list(APPEND FFmpeg_INCLUDE_DIRS ${${_package_component}_INCLUDE_DIRS})
+        list(APPEND FFmpeg_DEFINITIONS ${${_package_component}_DEFINITIONS})
+    endif ()
+endforeach ()
+
+# Build the include path with duplicates removed.
+if (FFmpeg_INCLUDE_DIRS)
+    list(REMOVE_DUPLICATES FFmpeg_INCLUDE_DIRS)
+endif()
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFmpeg
+    FOUND_VAR FFmpeg_FOUND
+    HANDLE_COMPONENTS
+    REQUIRED_VARS
+        FFmpeg_LIBRARIES
+        FFmpeg_INCLUDE_DIRS
+)
diff -Naur ./k9copy.orig/cmake/LibFindMacros.cmake ./k9copy/cmake/LibFindMacros.cmake
--- ./k9copy.orig/cmake/LibFindMacros.cmake	1969-12-31 19:00:00.000000000 -0500
+++ ./k9copy/cmake/LibFindMacros.cmake	2022-05-22 20:05:55.790701784 -0400
@@ -0,0 +1,363 @@
+# Version 2.2
+# Public Domain, originally written by Lasse Kärkkäinen <tronic>
+# Maintained at https://github.com/Tronic/cmake-modules
+# Please send your improvements as pull requests on Github.
+
+include(CMakeParseArguments)
+
+# Find another package and make it a dependency of the current package.
+# This also automatically forwards the "REQUIRED" argument.
+# Usage: libfind_package(<prefix> <another package> [extra args to find_package])
+macro (libfind_package PREFIX PKG)
+  set(${PREFIX}_args ${PKG} ${ARGN})
+  if (${PREFIX}_FIND_REQUIRED)
+    set(${PREFIX}_args ${${PREFIX}_args} REQUIRED)
+  endif()
+  find_package(${${PREFIX}_args})
+  set(${PREFIX}_DEPENDENCIES ${${PREFIX}_DEPENDENCIES};${PKG})
+  unset(${PREFIX}_args)
+endmacro()
+
+# A simple wrapper to make pkg-config searches a bit easier.
+# Works the same as CMake's internal pkg_search_module but is always quiet.
+macro (libfind_pkg_search_module)
+  find_package(PkgConfig QUIET)
+  if (PKG_CONFIG_FOUND)
+    pkg_search_module(${ARGN} QUIET)
+  endif()
+endmacro()
+
+# Avoid useless copy&pasta by doing what most simple libraries do anyway:
+# pkg-config, find headers, find library.
+# Usage: libfind_pkg_detect(<prefix> <pkg-config args> FIND_PATH <name> [other args] FIND_LIBRARY <name> [other args])
+# E.g. libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2)
+function (libfind_pkg_detect PREFIX)
+  # Parse arguments
+  set(argname pkgargs)
+  foreach (i ${ARGN})
+    if ("${i}" STREQUAL "FIND_PATH")
+      set(argname pathargs)
+    elseif ("${i}" STREQUAL "FIND_LIBRARY")
+      set(argname libraryargs)
+    else()
+      set(${argname} ${${argname}} ${i})
+    endif()
+  endforeach()
+  if (NOT pkgargs)
+    message(FATAL_ERROR "libfind_pkg_detect requires at least a pkg_config package name to be passed.")
+  endif()
+  # Find library
+  libfind_pkg_search_module(${PREFIX}_PKGCONF ${pkgargs})
+  if (pathargs)
+    find_path(${PREFIX}_INCLUDE_DIR NAMES ${pathargs} HINTS ${${PREFIX}_PKGCONF_INCLUDE_DIRS})
+  endif()
+  if (libraryargs)
+    find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
+  endif()
+endfunction()
+
+# libfind_header_path(<PREFIX> [PATHS <path> [<path> ...]] NAMES <name> [name ...] VAR <out_var> [QUIET])
+# Get fullpath of the first found header looking inside <PREFIX>_INCLUDE_DIR or in the given PATHS
+# Usage: libfind_header_path(Foobar NAMES foobar/version.h VAR filepath)
+function (libfind_header_path PREFIX)
+  set(options QUIET)
+  set(one_value_keywords VAR PATH)
+  set(multi_value_keywords NAMES PATHS)
+  CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN})
+  if (NOT OPT_VAR OR NOT OPT_NAMES)
+    message(FATAL_ERROR "Arguments VAR, NAMES are required!")
+  endif()
+  if (OPT_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Calling function with unused arguments '${OPT_UNPARSED_ARGUMENTS}'!")
+  endif()
+  if (OPT_QUIET OR ${PREFIX}_FIND_QUIETLY)
+    set(quiet TRUE)
+  endif()
+  set(paths ${OPT_PATHS} ${PREFIX}_INCLUDE_DIR)
+
+  foreach(name ${OPT_NAMES})
+    foreach(path ${paths})
+      set(filepath "${${path}}/${name}")
+      # check for existance
+      if (EXISTS ${filepath})
+        set(${OPT_VAR} ${filepath} PARENT_SCOPE) # export path
+        return()
+      endif()
+    endforeach()
+  endforeach()
+
+  # report error if not found
+  set(${OPT_VAR} NOTFOUND PARENT_SCOPE)
+  if (NOT quiet)
+    message(AUTHOR_WARNING "Unable to find '${OPT_NAMES}'")
+  endif()
+endfunction()
+
+# libfind_version_n_header(<PREFIX>
+#  NAMES <name> [<name> ...]
+#  DEFINES <define> [<define> ...] | CONSTANTS <const> [<const> ...]
+#  [PATHS <path> [<path> ...]]
+#  [QUIET]
+# )
+# Collect all defines|constants from a header inside <PREFIX>_INCLUDE_DIR or in the given PATHS
+#  output stored to <PREFIX>_VERSION.
+# This function does nothing if the version variable is already defined.
+# Usage: libfind_version_n_header(Foobar NAMES foobar/version.h DEFINES FOOBAR_VERSION_MAJOR FOOBAR_VERSION_MINOR)
+function (libfind_version_n_header PREFIX)
+  # Skip processing if we already have a version
+  if (${PREFIX}_VERSION)
+    return()
+  endif()
+
+  set(options QUIET)
+  set(one_value_keywords )
+  set(multi_value_keywords NAMES PATHS DEFINES CONSTANTS)
+  CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN})
+  if (NOT OPT_NAMES OR (NOT OPT_DEFINES AND NOT OPT_CONSTANTS))
+    message(FATAL_ERROR "Arguments NAMES, DEFINES|CONSTANTS are required!")
+  endif()
+  if (OPT_DEFINES AND OPT_CONSTANTS)
+    message(FATAL_ERROR "Either DEFINES or CONSTANTS must be set!")
+  endif()
+  if (OPT_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Calling function with unused arguments '${OPT_UNPARSED_ARGUMENTS}'!")
+  endif()
+  if (OPT_QUIET OR ${PREFIX}_FIND_QUIETLY)
+    set(quiet TRUE)
+    set(force_quiet "QUIET") # to propagate argument QUIET
+  endif()
+
+  # Read the header
+  libfind_header_path(${PREFIX} NAMES ${OPT_NAMES} PATHS ${OPT_PATHS} VAR filename ${force_quiet})
+  if (NOT filename)
+    return()
+  endif()
+  file(READ "${filename}" header)
+  # Parse for version number
+  unset(version_parts)
+  foreach(define_name ${OPT_DEFINES})
+    string(REGEX MATCH "# *define +${define_name} +((\"([^\n]*)\")|([^ \n]*))" match "${header}")
+    # No regex match?
+    if (NOT match OR match STREQUAL header)
+      if (NOT quiet)
+        message(AUTHOR_WARNING "Unable to find \#define ${define_name} \"<version>\" from ${filename}")
+      endif()
+      return()
+    else()
+      list(APPEND version_parts "${CMAKE_MATCH_3}${CMAKE_MATCH_4}")
+    endif()
+  endforeach()
+  foreach(constant_name ${OPT_CONSTANTS})
+    string(REGEX MATCH "${constant_name} *= *((\"([^\;]*)\")|([^ \;]*))" match "${header}")
+    # No regex match?
+    if (NOT match OR match STREQUAL header)
+      if (NOT quiet)
+        message(AUTHOR_WARNING "Unable to find ${constant_name} = \"<version>\" from ${filename}")
+      endif()
+      return()
+    else()
+      list(APPEND version_parts "${CMAKE_MATCH_3}${CMAKE_MATCH_4}")
+    endif()
+  endforeach()
+
+  # Export the version string
+  string(REPLACE ";" "." version "${version_parts}")
+  set(${PREFIX}_VERSION "${version}" PARENT_SCOPE)
+endfunction()
+
+# libfind_version_header(<PREFIX> <HEADER> <DEFINE_NAME> [PATHS <path> [<path> ...]] [QUIET])
+# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION.
+# This function does nothing if the version variable is already defined.
+# Usage: libfind_version_header(Foobar foobar/version.h FOOBAR_VERSION_STR)
+function (libfind_version_header PREFIX VERSION_H DEFINE_NAME)
+  # Skip processing if we already have a version
+  if (${PREFIX}_VERSION)
+    return()
+  endif()
+
+  set(options QUIET)
+  set(one_value_keywords )
+  set(multi_value_keywords PATHS)
+  CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN})
+  if (OPT_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Calling function with unused arguments '${OPT_UNPARSED_ARGUMENTS}'!")
+  endif()
+  if (OPT_QUIET OR ${PREFIX}_FIND_QUIETLY)
+    set(force_quiet "QUIET") # to propagate argument QUIET
+  endif()
+
+  libfind_version_n_header(${PREFIX} NAMES ${VERSION_H} PATHS ${OPT_PATHS} DEFINES ${DEFINE_NAME} ${force_quiet})
+  set(${PREFIX}_VERSION "${${PREFIX}_VERSION}" PARENT_SCOPE)
+endfunction()
+
+# Do the final processing once the paths have been detected.
+# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
+# all the variables, each of which contain one include directory.
+# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
+# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
+# Also handles errors in case library detection was required, etc.
+function (libfind_process PREFIX)
+  # Skip processing if already processed during this configuration run
+  if (${PREFIX}_FOUND)
+    return()
+  endif()
+
+  set(found TRUE)  # Start with the assumption that the package was found
+
+  # Did we find any files? Did we miss includes? These are for formatting better error messages.
+  set(some_files FALSE)
+  set(missing_headers FALSE)
+
+  # Shorthands for some variables that we need often
+  set(quiet ${${PREFIX}_FIND_QUIETLY})
+  set(required ${${PREFIX}_FIND_REQUIRED})
+  set(exactver ${${PREFIX}_FIND_VERSION_EXACT})
+  set(findver "${${PREFIX}_FIND_VERSION}")
+  set(version "${${PREFIX}_VERSION}")
+
+  # Lists of config option names (all, includes, libs)
+  unset(configopts)
+  set(includeopts ${${PREFIX}_PROCESS_INCLUDES})
+  set(libraryopts ${${PREFIX}_PROCESS_LIBS})
+
+  # Process deps to add to
+  foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
+    if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS)
+      # The package seems to export option lists that we can use, woohoo!
+      list(APPEND includeopts ${${i}_INCLUDE_OPTS})
+      list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
+    else()
+      # If plural forms don't exist or they equal singular forms
+      if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR
+          ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES))
+        # Singular forms can be used
+        if (DEFINED ${i}_INCLUDE_DIR)
+          list(APPEND includeopts ${i}_INCLUDE_DIR)
+        endif()
+        if (DEFINED ${i}_LIBRARY)
+          list(APPEND libraryopts ${i}_LIBRARY)
+        endif()
+      else()
+        # Oh no, we don't know the option names
+        message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!")
+      endif()
+    endif()
+  endforeach()
+
+  if (includeopts)
+    list(REMOVE_DUPLICATES includeopts)
+  endif()
+
+  if (libraryopts)
+    list(REMOVE_DUPLICATES libraryopts)
+  endif()
+
+  string(REGEX REPLACE ".*[ ;]([^ ;]*(_INCLUDE_DIRS|_LIBRARIES))" "\\1" tmp "${includeopts} ${libraryopts}")
+  if (NOT tmp STREQUAL "${includeopts} ${libraryopts}")
+    message(AUTHOR_WARNING "Plural form ${tmp} found in config options of ${PREFIX}. This works as before but is now deprecated. Please only use singular forms INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros > 2.0 automatic dependency system (most often you can simply remove the PROCESS variables entirely).")
+  endif()
+
+  # Include/library names separated by spaces (notice: not CMake lists)
+  unset(includes)
+  unset(libs)
+
+  # Process all includes and set found false if any are missing
+  foreach (i ${includeopts})
+    list(APPEND configopts ${i})
+    if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND")
+      list(APPEND includes "${${i}}")
+    else()
+      set(found FALSE)
+      set(missing_headers TRUE)
+    endif()
+  endforeach()
+
+  # Process all libraries and set found false if any are missing
+  foreach (i ${libraryopts})
+    list(APPEND configopts ${i})
+    if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND")
+      list(APPEND libs "${${i}}")
+    else()
+      set (found FALSE)
+    endif()
+  endforeach()
+
+  # Version checks
+  if (found AND findver)
+    if (NOT version)
+      message(WARNING "The find module for ${PREFIX} does not provide version information, so we'll just assume that it is OK. Please fix the module or remove package version requirements to get rid of this warning.")
+    elseif (version VERSION_LESS findver OR (exactver AND NOT version VERSION_EQUAL findver))
+      set(found FALSE)
+      set(version_unsuitable TRUE)
+    endif()
+  endif()
+
+  # If all-OK, hide all config options, export variables, print status and exit
+  if (found)
+    foreach (i ${configopts})
+      mark_as_advanced(${i})
+    endforeach()
+    set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
+    set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
+    set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
+    set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
+    set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
+    if (NOT quiet)
+      message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
+      if (LIBFIND_DEBUG)
+        message(STATUS "  ${PREFIX}_DEPENDENCIES=${${PREFIX}_DEPENDENCIES}")
+        message(STATUS "  ${PREFIX}_INCLUDE_OPTS=${includeopts}")
+        message(STATUS "  ${PREFIX}_INCLUDE_DIRS=${includes}")
+        message(STATUS "  ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
+        message(STATUS "  ${PREFIX}_LIBRARIES=${libs}")
+      endif()
+    endif()
+    return()
+  endif()
+
+  # Format messages for debug info and the type of error
+  set(vars "Relevant CMake configuration variables:\n")
+  foreach (i ${configopts})
+    mark_as_advanced(CLEAR ${i})
+    set(val ${${i}})
+    if ("${val}" STREQUAL "${i}-NOTFOUND")
+      set (val "<not found>")
+    elseif (val AND NOT EXISTS "${val}")
+      set (val "${val}  (does not exist)")
+    else()
+      set(some_files TRUE)
+    endif()
+    set(vars "${vars}  ${i}=${val}\n")
+  endforeach()
+  set(vars "${vars}You may use CMake GUI, cmake -D or ccmake to modify the values. Delete CMakeCache.txt to discard all values and force full re-detection if necessary.\n")
+  if (version_unsuitable)
+    set(msg "${PREFIX} ${${PREFIX}_VERSION} was found but")
+    if (exactver)
+      set(msg "${msg} only version ${findver} is acceptable.")
+    else()
+      set(msg "${msg} version ${findver} is the minimum requirement.")
+    endif()
+  else()
+    if (missing_headers)
+      set(msg "We could not find development headers for ${PREFIX}. Do you have the necessary dev package installed?")
+    elseif (some_files)
+      set(msg "We only found some files of ${PREFIX}, not all of them. Perhaps your installation is incomplete or maybe we just didn't look in the right place?")
+      if(findver)
+        set(msg "${msg} This could also be caused by incompatible version (if it helps, at least ${PREFIX} ${findver} should work).")
+      endif()
+    else()
+      set(msg "We were unable to find package ${PREFIX}.")
+    endif()
+  endif()
+
+  # Fatal error out if REQUIRED
+  if (required)
+    set(msg "REQUIRED PACKAGE NOT FOUND\n${msg} This package is REQUIRED and you need to install it or adjust CMake configuration in order to continue building ${CMAKE_PROJECT_NAME}.")
+    message(FATAL_ERROR "${msg}\n${vars}")
+  endif()
+  # Otherwise just print a nasty warning
+  if (NOT quiet)
+    message(WARNING "WARNING: MISSING PACKAGE\n${msg} This package is NOT REQUIRED and you may ignore this warning but by doing so you may miss some functionality of ${CMAKE_PROJECT_NAME}. \n${vars}")
+  endif()
+endfunction()
+
diff -Naur ./k9copy.orig/CMakeLists.txt ./k9copy/CMakeLists.txt
--- ./k9copy.orig/CMakeLists.txt	2022-05-22 20:05:48.242702145 -0400
+++ ./k9copy/CMakeLists.txt	2022-05-22 20:06:40.760699629 -0400
@@ -59,11 +59,13 @@
 INCLUDE(CheckIncludeFiles)
 INCLUDE(FindLibMpeg2)
 INCLUDE(FindXine)
-INCLUDE(FindAvcodec)
-INCLUDE(FindAvformat)
+#INCLUDE(FindAvcodec)
+#INCLUDE(FindAvformat)
 #INCLUDE(FindAvutil)
-INCLUDE(FindFFmpegScale)
+#INCLUDE(FindFFmpegScale)
 INCLUDE(FindLibDvdread)
+find_package(FFmpeg REQUIRED COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
+
 
 # usage: CHECK_INCLUDE_FILES (<header> <RESULT_VARIABLE> )
 CHECK_INCLUDE_FILES(inttypes.h      HAVE_INTTYPES_H)                    # inttypes.h
@@ -76,7 +78,7 @@
 CHECK_INCLUDE_FILES(unistd.h        HAVE_UNISTD_H)                      # unistd.h
 CHECK_INCLUDE_FILES(malloc.h        HAVE_MALLOC_H)                      # malloc.h
 
-FINDFFMPEGSCALE("swscale")
+#FINDFFMPEGSCALE("swscale")
 
 
 CONFIGURE_FILE(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
@@ -106,8 +108,8 @@
 FINDLIBDVDREAD("dvdread/ifo_types.h" "dvdread")
 
 
-FINDAVFORMAT("avformat")
-FINDAVCODEC("avcodec")
+#FINDAVFORMAT("avformat")
+#FINDAVCODEC("avcodec")
 #FINDAVUTIL("avutil")
 
 add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
@@ -144,11 +146,11 @@
  ${CMAKE_CURRENT_SOURCE_DIR}/src/batch
 ${KDE4_INCLUDES} ${QT_INCLUDES}
 ${LIBDVDREAD_INCLUDE_DIR}/dvdread
- ${AVCODEC_INCLUDE_DIR}
- ${AVFORMAT_INCLUDE_DIR}
- ${AVUTIL_INCLUDE_DIR}
- ${FFMPEGSCALE_INCLUDE_DIR}
- ${FFMPEG_INCLUDE_DIR}
+# ${AVCODEC_INCLUDE_DIR}
+# ${AVFORMAT_INCLUDE_DIR}
+# ${AVUTIL_INCLUDE_DIR}
+# ${FFMPEGSCALE_INCLUDE_DIR}
+ ${FFmpeg_INCLUDE_DIRS}
 )