-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
executable file
·112 lines (94 loc) · 4.1 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.16)
project(ffmpeg_examples VERSION 0.0.3 DESCRIPTION "ffmpeg tutorial & examples" LANGUAGES C CXX)
# #######################################################################################################################
# compiler config
# #######################################################################################################################
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build type: Release." FORCE)
endif()
if(MSVC)
message(STATUS "Windows SDK version is ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
add_compile_options(/W3 /utf-8 /DUNICODE /D_UNICODE /DNOMINMAX /Zc:preprocessor /Zc:__cplusplus)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/$<0:>)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/$<0:>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<0:>)
# #######################################################################################################################
# options
# #######################################################################################################################
option(DISABLE_WGC "Disable the Windows Graphics Capture Example" OFF)
# #######################################################################################################################
# dependencies
# #######################################################################################################################
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# 3rdparty: glog fmt
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build static libraries.")
set(WITH_GFLAGS OFF CACHE BOOL "Use gflags")
add_subdirectory(3rdparty/glog EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/fmt EXCLUDE_FROM_ALL)
# Qt5
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt5 COMPONENTS Widgets Gui Multimedia REQUIRED)
if (DISABLE_WGC)
find_package(FFmpeg 4.3 REQUIRED)
else()
find_package(FFmpeg 6 REQUIRED)
endif()
if(UNIX AND NOT APPLE)
find_package(Qt5 COMPONENTS X11Extras REQUIRED)
endif()
# #######################################################################################################################
# Create the executable files
# #######################################################################################################################
add_definitions(-D__STDC_CONSTANT_MACROS)
list(
APPEND
LIBS
Qt5::Widgets Qt5::Gui Qt5::Multimedia
glog::glog fmt::fmt
ffmpeg::ffmpeg
$<$<PLATFORM_ID:Linux>:Qt5::X11Extras>
$<$<PLATFORM_ID:Windows>:dwmapi>
$<$<PLATFORM_ID:Windows>:strmiids>
$<$<PLATFORM_ID:Windows>:ntdll>
$<$<PLATFORM_ID:Windows>:Shcore>
$<$<PLATFORM_ID:Windows>:DXGI>
$<$<PLATFORM_ID:Windows>:D3D11>
)
function(create_exe name source_file)
add_executable(${name} ${source_file})
target_link_libraries(${name} PRIVATE ${LIBS})
target_include_directories(${name} PRIVATE utils)
endfunction(create_exe)
create_exe(remux 01_remuxing/remuxing.cpp)
create_exe(transcode 02_transcoding/transcoding.cpp)
create_exe(record 03_recording/recording.cpp)
create_exe(record_mic 03_recording/recording_mic.cpp)
create_exe(filter 04_simple_filter/filter.cpp)
create_exe(hw_decode 13_hwaccel/hw_decoding.cpp)
create_exe(hw_encode 13_hwaccel/hw_encoding.cpp)
create_exe(hw_transcode 13_hwaccel/hw_transcoding.cpp)
if(WIN32)
create_exe(dshow 17_win_dshow/main.cpp)
endif()
add_subdirectory(05_complex_filter)
add_subdirectory(07_audio_player)
add_subdirectory(08_video_player_qt)
add_subdirectory(09_media_player)
add_subdirectory(10_streaming)
add_subdirectory(11_wasapi_capture)
add_subdirectory(12_wasapi_render)
if (DISABLE_WGC)
message(STATUS "FFMPEG-EXAMPLES: 'Window Graphics Capture' example is disabled.")
elseif(NOT DISABLE_WGC)
add_subdirectory(14_windows_wgc)
endif()
add_subdirectory(15_linux_pulse)
add_subdirectory(16_linux_v4l2)