+5
.github/workflows/vita.yml
+5
.github/workflows/vita.yml
···
87
87
run: |
88
88
cp -rv /vita/dependencies/* ${VITASDK}/arm-vita-eabi
89
89
90
+
- name: Fix vita.toolchain.cmake
91
+
run: |
92
+
# cache PKG_CONFIG_PATH
93
+
sed -i -E 's/set\( PKG_CONFIG_EXECUTABLE "\$\{VITASDK}\/bin\/arm-vita-eabi-pkg-config" )/set( PKG_CONFIG_EXECUTABLE "${VITASDK}\/bin\/arm-vita-eabi-pkg-config" CACHE PATH "Path of pkg-config executable" )/' ${VITASDK}/share/vita.toolchain.cmake
94
+
90
95
- name: Configure (CMake)
91
96
run: |
92
97
cmake -S . -B build -G Ninja \
+77
-90
cmake/FindFFmpeg.cmake
+77
-90
cmake/FindFFmpeg.cmake
···
1
-
# vim: ts=2 sw=2
2
1
# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC)
3
2
#
4
3
# Once done this will define
5
4
# FFMPEG_FOUND - System has the all required components.
6
-
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
7
5
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
8
-
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
9
6
#
10
7
# For each of the components it will additionally set.
11
8
# - AVCODEC
···
15
12
# - AVUTIL
16
13
# - POSTPROC
17
14
# - SWSCALE
15
+
# the following target will be defined
16
+
# FFmpeg::SDL::<component> - link to this target to
18
17
# the following variables will be defined
19
-
# <component>_FOUND - System has <component>
20
-
# <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
21
-
# <component>_LIBRARIES - Link these to use <component>
22
-
# <component>_DEFINITIONS - Compiler switches required for using <component>
23
-
# <component>_VERSION - The components version
18
+
# FFmpeg_<component>_FOUND - System has <component>
19
+
# FFmpeg_<component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
20
+
# FFmpeg_<component>_LIBRARIES - Link these to use <component>
21
+
# FFmpeg_<component>_DEFINITIONS - Compiler switches required for using <component>
22
+
# FFmpeg_<component>_VERSION - The components version
24
23
#
25
24
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
26
25
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
27
26
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
27
+
# Copyright (c) 2023, Sam lantinga, <slouken@libsdl.org>
28
28
#
29
29
# Redistribution and use is allowed according to the terms of the BSD license.
30
30
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
31
31
32
32
include(FindPackageHandleStandardArgs)
33
+
include("${CMAKE_CURRENT_LIST_DIR}/PkgConfigHelper.cmake")
33
34
34
35
# The default components were taken from a survey over other FindFFMPEG.cmake files
35
-
if (NOT FFmpeg_FIND_COMPONENTS)
36
+
if(NOT FFmpeg_FIND_COMPONENTS)
36
37
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
37
-
endif ()
38
+
foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS)
39
+
set(FFmpeg_FIND_REQUIRED_${_component} TRUE)
40
+
endforeach()
41
+
endif()
38
42
39
-
#
40
-
### Macro: set_component_found
41
-
#
42
-
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
43
-
#
44
-
macro(set_component_found _component )
45
-
if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
46
-
# message(STATUS " - ${_component} found.")
47
-
set(${_component}_FOUND TRUE)
48
-
else ()
49
-
# message(STATUS " - ${_component} not found.")
50
-
endif ()
51
-
endmacro()
43
+
find_package(PkgConfig QUIET)
52
44
53
45
#
54
46
### Macro: find_component
···
58
50
#
59
51
macro(find_component _component _pkgconfig _library _header)
60
52
61
-
if (NOT WIN32)
62
-
# use pkg-config to get the directories and then use these values
63
-
# in the FIND_PATH() and FIND_LIBRARY() calls
64
-
find_package(PkgConfig)
65
-
if (PKG_CONFIG_FOUND)
66
-
pkg_check_modules(PC_${_component} ${_pkgconfig})
67
-
endif ()
68
-
endif (NOT WIN32)
53
+
# use pkg-config to get the directories and then use these values
54
+
# in the FIND_PATH() and FIND_LIBRARY() calls
55
+
if(PKG_CONFIG_FOUND)
56
+
pkg_check_modules(PC_${_component} QUIET ${_pkgconfig})
57
+
endif()
69
58
70
-
find_path(${_component}_INCLUDE_DIRS ${_header}
59
+
find_path(FFmpeg_${_component}_INCLUDE_DIRS
60
+
NAMES ${_header}
71
61
HINTS
72
-
${PC_${_component}_INCLUDEDIR}
73
62
${PC_${_component}_INCLUDE_DIRS}
74
63
PATH_SUFFIXES
75
64
ffmpeg
76
65
)
77
66
78
-
find_library(${_component}_LIBRARIES NAMES ${_library}
79
-
HINTS
80
-
${PC_${_component}_LIBDIR}
67
+
find_library(FFmpeg_${_component}_LIBRARY
68
+
NAMES ${_library}
69
+
HINTS
81
70
${PC_${_component}_LIBRARY_DIRS}
82
71
)
83
72
84
-
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
85
-
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
73
+
if(FFmpeg_${_component}_INCLUDE_DIRS AND FFmpeg_${_component}_LIBRARY)
74
+
set(FFmpeg_${_component}_FOUND TRUE)
75
+
endif()
86
76
87
-
set_component_found(${_component})
77
+
if(PC_${_component}_FOUND)
78
+
get_flags_from_pkg_config("${FFmpeg_${_component}_LIBRARY}" "PC_${_component}" "${_component}")
79
+
endif()
88
80
89
-
mark_as_advanced(
90
-
${_component}_INCLUDE_DIRS
91
-
${_component}_LIBRARIES
92
-
${_component}_DEFINITIONS
93
-
${_component}_VERSION)
81
+
set(FFmpeg_${_component}_VERSION "${PC_${_component}_VERSION}")
94
82
95
-
endmacro()
83
+
set(FFmpeg_${_component}_COMPILE_OPTIONS "${${_component}_options}" CACHE STRING "Extra compile options of FFmpeg ${_component}")
96
84
85
+
set(FFmpeg_${_component}_LIBRARIES "${${_component}_link_libraries}" CACHE STRING "Extra link libraries of FFmpeg ${_component}")
97
86
98
-
# Check for cached results. If there are skip the costly part.
99
-
if (NOT FFMPEG_LIBRARIES)
87
+
set(FFmpeg_${_component}_LINK_OPTIONS "${${_component}_link_options}" CACHE STRING "Extra link flags of FFmpeg ${_component}")
100
88
101
-
# Check for all possible component.
102
-
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
103
-
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
104
-
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
105
-
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
106
-
find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
107
-
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
108
-
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
109
-
find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h)
89
+
set(FFmpeg_${_component}_LINK_DIRECTORIES "${${_component}_link_directories}" CACHE PATH "Extra link directories of FFmpeg ${_component}")
110
90
111
-
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
112
-
foreach (_component ${FFmpeg_FIND_COMPONENTS})
113
-
if (${_component}_FOUND)
114
-
# message(STATUS "Required component ${_component} present.")
115
-
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES})
116
-
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS})
117
-
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
118
-
else ()
119
-
# message(STATUS "Required component ${_component} missing.")
120
-
endif ()
121
-
endforeach ()
91
+
mark_as_advanced(
92
+
FFmpeg_${_component}_INCLUDE_DIRS
93
+
FFmpeg_${_component}_LIBRARY
94
+
FFmpeg_${_component}_COMPILE_OPTIONS
95
+
FFmpeg_${_component}_LIBRARIES
96
+
FFmpeg_${_component}_LINK_OPTIONS
97
+
FFmpeg_${_component}_LINK_DIRECTORIES
98
+
)
99
+
endmacro()
122
100
123
-
# Build the include path with duplicates removed.
124
-
if (FFMPEG_INCLUDE_DIRS)
125
-
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
126
-
endif ()
127
-
128
-
# cache the vars.
129
-
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
130
-
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)
131
-
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE)
132
-
133
-
mark_as_advanced(FFMPEG_INCLUDE_DIRS
134
-
FFMPEG_LIBRARIES
135
-
FFMPEG_DEFINITIONS)
136
-
137
-
endif ()
138
-
139
-
# Now set the noncached _FOUND vars for the components.
140
-
foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE)
141
-
set_component_found(${_component})
142
-
endforeach ()
101
+
# Check for all possible component.
102
+
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
103
+
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
104
+
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
105
+
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
106
+
find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
107
+
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
108
+
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
109
+
find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h)
143
110
144
111
# Compile the list of required vars
145
-
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
146
-
foreach (_component ${FFmpeg_FIND_COMPONENTS})
147
-
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
112
+
set(_FFmpeg_REQUIRED_VARS)
113
+
foreach(_component ${FFmpeg_FIND_COMPONENTS})
114
+
list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_${_component}_INCLUDE_DIRS FFmpeg_${_component}_LIBRARY)
148
115
endforeach ()
149
116
150
117
# Give a nice error message if some of the required vars are missing.
151
118
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
119
+
120
+
set(FFMPEG_LIBRARIES)
121
+
if(FFmpeg_FOUND)
122
+
foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS)
123
+
if(FFmpeg_${_component}_FOUND)
124
+
list(APPEND FFMPEG_LIBRARIES FFmpeg::SDL::${_component})
125
+
if(NOT TARGET FFmpeg::SDL::${_component})
126
+
add_library(FFmpeg::SDL::${_component} UNKNOWN IMPORTED)
127
+
set_target_properties(FFmpeg::SDL::${_component} PROPERTIES
128
+
IMPORTED_LOCATION "${FFmpeg_${_component}_LIBRARY}"
129
+
INTERFACE_INCLUDE_DIRECTORIES "${FFmpeg_${_component}_INCLUDE_DIRS}"
130
+
INTERFACE_COMPILE_OPTIONS "${FFmpeg_${_component}_COMPILE_OPTIONS}"
131
+
INTERFACE_LINK_LIBRARIES "${FFmpeg_${_component}_LIBRARIES}"
132
+
INTERFACE_LINK_OPTIONS "${FFmpeg_${_component}_LINK_OPTIONS}"
133
+
INTERFACE_LINK_DIRECTORIES "${FFmpeg_${_component}_LINK_DIRECTORIES}"
134
+
)
135
+
endif()
136
+
endif()
137
+
endforeach()
138
+
endif()
-5
cmake/PkgConfigHelper.cmake
-5
cmake/PkgConfigHelper.cmake
···
2
2
3
3
function(get_flags_from_pkg_config _library _pc_prefix _out_prefix)
4
4
if("${_library}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$")
5
-
set(_include_dirs ${_pc_prefix}_STATIC_INCLUDE_DIRS)
6
5
set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER)
7
6
set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES)
8
7
set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER)
9
8
set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS)
10
9
else()
11
-
set(_include_dirs ${_pc_prefix}_INCLUDE_DIRS)
12
10
set(_cflags ${_pc_prefix}_CFLAGS_OTHER)
13
11
set(_link_libraries ${_pc_prefix}_LIBRARIES)
14
12
set(_link_options ${_pc_prefix}_LDFLAGS_OTHER)
···
21
19
# Work around CMake's flag deduplication when pc files use `-framework A` instead of `-Wl,-framework,A`
22
20
string(REPLACE "-framework;" "-Wl,-framework," "_filtered_link_options" "${${_link_options}}")
23
21
24
-
set(${_out_prefix}_include_dirs
25
-
"${${_include_dirs}}"
26
-
PARENT_SCOPE)
27
22
set(${_out_prefix}_compile_options
28
23
"${${_cflags}}"
29
24
PARENT_SCOPE)
+1
-2
test/CMakeLists.txt
+1
-2
test/CMakeLists.txt
···
184
184
185
185
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
186
186
include("${SDL3_SOURCE_DIR}/cmake/FindFFmpeg.cmake")
187
-
if(FFMPEG_FOUND)
187
+
if(FFmpeg_FOUND)
188
188
add_sdl_test_executable(testspriteffmpeg NO_C90 SOURCES testspriteffmpeg.c ${icon_bmp_header})
189
-
target_include_directories(testspriteffmpeg PRIVATE ${FFMPEG_INCLUDE_DIRS})
190
189
target_link_libraries(testspriteffmpeg PRIVATE ${FFMPEG_LIBRARIES})
191
190
else()
192
191
message(STATUS "Cannot find ffmpeg, skipping testspriteffmpeg")