-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
140 lines (115 loc) · 4.26 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
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
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
#FFMpeg配置
#FFmpeg配置目录
set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../src/main/jniLibs)
# 编解码(最重要的库)
add_library(
avcodec
STATIC
IMPORTED)
set_target_properties(
avcodec
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libavcodec.a)
# 滤镜特效处理库
add_library(
avfilter
STATIC
IMPORTED)
set_target_properties(
avfilter
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libavfilter.a)
# 封装格式处理库
add_library(
avformat
STATIC
IMPORTED)
set_target_properties(
avformat
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libavformat.a)
# 工具库(大部分库都需要这个库的支持)
add_library(
avutil
STATIC
IMPORTED)
set_target_properties(
avutil
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libavutil.a)
add_library(
postproc
STATIC
IMPORTED)
set_target_properties(
postproc
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libpostproc.a)
# 音频采样数据格式转换库
add_library(
swresample
STATIC
IMPORTED)
set_target_properties(
swresample
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libswresample.a)
# 视频像素数据格式转换
add_library(
swscale
STATIC
IMPORTED)
set_target_properties(
swscale
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libswscale.a)
add_library(
x264
STATIC
IMPORTED)
set_target_properties(
x264
PROPERTIES IMPORTED_LOCATION
../../../../src/main/jniLibs/armeabi/libx264.a)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
#判断编译器类型,如果是gcc编译器,则在编译选项中加入c++11支持
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
message(STATUS "optional:-std=c++11")
endif(CMAKE_COMPILER_IS_GNUCXX)
#配置编译的头文件
include_directories(src/main/jniLibs/include)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
#设置生成的so动态库最后输出的路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI})
add_library( # Sets the name of the library.
live
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/live.cpp )
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
live avcodec avfilter avformat avutil postproc swresample swscale x264
# Links the target library to the log library
# included in the NDK.
${log-lib} )