-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
155 lines (118 loc) · 4.2 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
cmake_minimum_required(VERSION 3.20)
project(rtmp_audio_live)
#include(FetchContent)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
#set(CMAKE_WIN32_EXECUTABLE ON)
# 设置QT路径
#set(QT_BIN_DIR C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin)
#
#set(Qt5_DIR C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib/cmake/Qt5)
set(QT_BIN_DIR D:/Qt/Qt5.12.12/5.12.12/msvc2017_64/bin)
#
set(Qt5_DIR D:/Qt/Qt5.12.12/5.12.12/msvc2017_64/lib/cmake/Qt5)
set(CMAKE_BUILD_TYPE Debug)
if (CMAKE_CL_64)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(BUILD_TYPE "x64-Debug")
else()
set(BUILD_TYPE "x64-Release")
endif()
else()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(BUILD_TYPE "x86-Debug")
else()
set(BUILD_TYPE "x86-Release")
endif()
endif()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_STANDARD 17)
set(SDK_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (NOT EXISTS ${SDK_DIR}/4rd/fdk-aac/libAACenc/include/aacenc_lib.h22)
#怎么自动下载依赖?
#FetchContent_Declare(fdk-aac
#GIT_REPOSITORY https://github.com/mstorsjo/fdk-aac.git)
#message("bbb")
#execute_process(
# COMMAND cd 4rd
# COMMAND git clone https://github.com/mstorsjo/fdk-aac.git
# COMMAND cd ..)
#https://github.com/PortAudio/portaudio
#https://github.com/mstorsjo/fdk-aac
#FetchContent_MakeAvailable(fdk-aac ${${SDK_DIR}/3rd})
endif()
set(BUILD_SHARED_LIBS OFF)
#set(LIBRARY_BUILD_TYPE STATIC)
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/out/build/${BUILD_TYPE})
message(STATUS ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/bin)
set(FFMPEG_PATH ${SDK_DIR}/3rd/ffmpeg-n6.0-win64-lgpl)
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DWIN32)
add_definitions(-D_WIN32)
add_definitions(-DWIN_GETPID)
endif()
include_directories(${SDK_DIR})
include_directories(${SDK_DIR}/3rd/librtmp)
include_directories(${SDK_DIR}/3rd/fdk-aac/libAACdec/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libAACenc/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libArithCoding/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libDRCdec/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libFDK/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libSACdec/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libSACenc/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libSBRdec/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libSBRenc/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/libSYS/include)
include_directories(${SDK_DIR}/3rd/fdk-aac/win32)
include_directories(${SDK_DIR}/3rd/portaudio/include)
include_directories(${FFMPEG_PATH}/include)
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
link_directories(${FFMPEG_PATH}/lib)
file(GLOB SRCS
./*.cpp
./capture/*.cpp
./capture/*.h
./enc/*.cpp
./enc/*.h
)
set(OTHER_LIBS
librtmp.lib
portaudio.lib
fdk-aac.lib
avcodec.lib
avformat.lib
avutil.lib
swresample.lib
)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
add_executable(${PROJECT_NAME} WIN32 ${SRCS})
target_link_libraries(${PROJECT_NAME}
Qt5::Widgets
${OTHER_LIBS}
)
#set_target_properties(${PROJECT_NAME} PROPERTIES
# WIN32_EXECUTABLE ON
#)
add_subdirectory(./3rd/librtmp)
add_subdirectory(./3rd/portaudio)
#set(BUILD_SHARED_LIBS OFF CACHE STRING "Build shared libraries" FORCE)
add_subdirectory(./3rd/fdk-aac)
if (EXISTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translations/qt_zh_CN.qm)
message("file exists")
else ()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${QT_BIN_DIR}/windeployqt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
file(GLOB FFMPEG_DEP_FILE
${FFMPEG_PATH}/bin/*.dll
)
if (EXISTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/avutil-58.dll)
message("file exists")
else ()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${FFMPEG_DEP_FILE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()