-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
166 lines (138 loc) · 4.85 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
156
157
158
159
160
161
162
163
164
165
166
cmake_minimum_required(VERSION 3.18)
project(AVPStudio VERSION 0.3.2 LANGUAGES CXX)
# Link ffmpeg
if(WIN32)
set(FFMPEG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/ffmpeg)
set(FFMPEG_VERSION 6.1.1)
# Download ffmpeg gyan.dev builds from GitHub
if(NOT EXISTS ${FFMPEG_PATH})
file(DOWNLOAD
https://github.com/GyanD/codexffmpeg/releases/download/${FFMPEG_VERSION}/ffmpeg-${FFMPEG_VERSION}-full_build-shared.zip
${CMAKE_CURRENT_SOURCE_DIR}/external/ffmpeg.zip
SHOW_PROGRESS
)
file(ARCHIVE_EXTRACT
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/external/ffmpeg.zip
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/external
)
file(RENAME
${CMAKE_CURRENT_SOURCE_DIR}/external/ffmpeg-${FFMPEG_VERSION}-full_build-shared
${FFMPEG_PATH}
)
file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/external/ffmpeg.zip)
endif()
endif(WIN32)
find_library(LIBAVUTIL_PATH avutil ${FFMPEG_PATH}/lib)
find_library(LIBAVCODEC_PATH avcodec ${FFMPEG_PATH}/lib)
find_library(LIBAVFORMAT_PATH avformat ${FFMPEG_PATH}/lib)
find_library(LIBAVFILTER_PATH avfilter ${FFMPEG_PATH}/lib)
find_library(LIBSWSCALE_PATH swscale ${FFMPEG_PATH}/lib)
find_library(LIBSWRESAMPLE_PATH swresample ${FFMPEG_PATH}/lib)
include_directories(${FFMPEG_PATH}/include)
# Link SDL
add_subdirectory(external/SDL)
include_directories(external/SDL/include)
# Copy cinema list
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cinemalist.xml
${CMAKE_CURRENT_BINARY_DIR}/cinemalist.xml
@ONLY
)
# Necessary Qt settings
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Add Qt packages
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools Multimedia MultimediaWidgets Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools Multimedia MultimediaWidgets NetWork)
# Set multi-language TS files
set(TS_FILES ts/AVPStudio_zh_CN.ts)
# Set project sources
set(FORMS_DIRECTORY src/forms)
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*)
set(PROJECT_SOURCES
${SOURCES}
${TS_FILES}
res/resources.qrc
)
if(WIN32)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/res/resources_win.rc.in
${CMAKE_CURRENT_BINARY_DIR}/res/resources_win.rc
@ONLY
)
list(APPEND
PROJECT_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/res/resources_win.rc
)
endif(WIN32)
#Pass version number
add_definitions(
/DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
/DPROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR}
/DPROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH}
)
# Set Qt executables
qt_add_executable(AVPStudio
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
qt_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# Configure executable include rules
target_include_directories(AVPStudio PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(AVPStudio PRIVATE ${FORMS_DIRECTORY})
# MacOS settings for Qt < 6.1.0 (For Qt > 6.1.0 this is configured automatically)
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER tech.izwb.AVPStudio)
endif()
# Modify Qt executable properties
set_target_properties(AVPStudio PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
# GNU include
include(GNUInstallDirs)
# Link libraries
target_link_libraries(AVPStudio PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Multimedia
Qt${QT_VERSION_MAJOR}::MultimediaWidgets
Qt${QT_VERSION_MAJOR}::Network
${LIBAVUTIL_PATH}
${LIBAVCODEC_PATH}
${LIBAVFORMAT_PATH}
${LIBAVFILTER_PATH}
${LIBSWSCALE_PATH}
${LIBSWRESAMPLE_PATH}
)
# Build tools
add_subdirectory(tools)
# Set install rules
install(TARGETS AVPStudio wavgenerator imageorganizer mxlplayer
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Qt finalize executable
qt_finalize_executable(AVPStudio)
# Copy windows installer script
option(BUILD_WINDOWS_INSTALLER "Build Windows Inno Setup installer script or not" ON)
if(WIN32 AND BUILD_WINDOWS_INSTALLER)
set(INNOSETUP_APPID "{C3203E73-539C-40AE-9075-2AE99E78AB59}")
set(WINDOWS_INSTALLER_GENERATE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../AVPStudio-installer)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/setup/windows/LICENSE_zh_CN.txt.in
${WINDOWS_INSTALLER_GENERATE_PATH}/LICENSE_zh_CN.txt
COPYONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/setup/windows/winsetup.iss.in
${WINDOWS_INSTALLER_GENERATE_PATH}/winsetup.iss
@ONLY
)
endif(WIN32 AND BUILD_WINDOWS_INSTALLER)