-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
262 lines (216 loc) · 8.03 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
cmake_minimum_required(VERSION 3.28)
if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
endif()
project(LSMASHSource)
option(BUILD_AVS_PLUGIN "Build plugin for AviSynth" ON)
message(STATUS "Build plugin for AviSynth: ${BUILD_AVS_PLUGIN}.")
option(BUILD_VS_PLUGIN "Build plugin for VapourSynth" ON)
message(STATUS "Build plugin for VapourSynth: ${BUILD_VS_PLUGIN}.")
option(ENABLE_DAV1D "Enable dav1d AV1 decoding" ON)
message(STATUS "Enable dav1d AV1 decoding: ${ENABLE_DAV1D}.")
option(ENABLE_MFX "Enable Intel HW decoding" ON)
message(STATUS "Enable Intel HW decoding: ${ENABLE_MFX}.")
option(ENABLE_XML2 "Enable DNXHD support" ON)
message(STATUS "Enable DNXHD support: ${ENABLE_XML2}.")
option(ENABLE_VPX "Enable libvpx support" ON)
message(STATUS "Enable libvpx support: ${ENABLE_VPX}.")
cmake_host_system_information(RESULT sse2 QUERY HAS_SSE2)
option(ENABLE_SSE2 "Enable SSE2 support" ${sse2})
message(STATUS "Enable SSE2 support: ${ENABLE_SSE2}.")
set(sources
${CMAKE_CURRENT_SOURCE_DIR}/common/decode.c
${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash.c
${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_audio.c
${CMAKE_CURRENT_SOURCE_DIR}/common/libavsmash_video.c
${CMAKE_CURRENT_SOURCE_DIR}/common/lwindex.c
${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_audio.c
${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_dec.c
${CMAKE_CURRENT_SOURCE_DIR}/common/lwlibav_video.c
${CMAKE_CURRENT_SOURCE_DIR}/common/osdep.c
${CMAKE_CURRENT_SOURCE_DIR}/common/qsv.c
${CMAKE_CURRENT_SOURCE_DIR}/common/utils.c
${CMAKE_CURRENT_SOURCE_DIR}/common/video_output.c
${CMAKE_CURRENT_SOURCE_DIR}/common/xxhash.c
)
if (ENABLE_SSE2)
set(sources
${sources}
${CMAKE_CURRENT_SOURCE_DIR}/common/planar_yuv_sse2.c
)
endif()
if (BUILD_AVS_PLUGIN)
set(sources
${sources}
${CMAKE_CURRENT_SOURCE_DIR}/common/audio_output.c
${CMAKE_CURRENT_SOURCE_DIR}/common/resample.c
${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/audio_output.cpp
${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/libavsmash_source.cpp
${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/lsmashsource.cpp
${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/lwlibav_source.cpp
${CMAKE_CURRENT_SOURCE_DIR}/AviSynth/video_output.cpp
)
endif()
if (BUILD_VS_PLUGIN)
set(sources
${sources}
${CMAKE_CURRENT_SOURCE_DIR}/VapourSynth/libavsmash_source.c
${CMAKE_CURRENT_SOURCE_DIR}/VapourSynth/lsmashsource.c
${CMAKE_CURRENT_SOURCE_DIR}/VapourSynth/lwlibav_source.c
${CMAKE_CURRENT_SOURCE_DIR}/VapourSynth/video_output.c
)
endif()
find_package(Git)
if (GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count origin/master
OUTPUT_VARIABLE ver
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (WIN32)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.rc"
)
set(sources ${sources} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()
else()
message(STATUS "GIT not found")
endif()
add_library(LSMASHSource SHARED ${sources})
target_include_directories(LSMASHSource PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (APPLE)
target_include_directories(LSMASHSource PRIVATE /usr/local/include)
endif()
if (MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES "")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
find_package(FFMPEG REQUIRED COMPONENTS
avcodec
avformat
swscale
swresample
avutil
)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(zlib zlib)
target_include_directories(LSMASHSource PRIVATE ${zlib_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND)
find_library(libzlib NAMES libz.a z zlib.lib PATHS ${zlib_LIBRARY_DIRS})
message(STATUS "zlib: ${libzlib}")
if (PKG_CONFIG_FOUND)
pkg_check_modules(xxhash libxxhash)
target_include_directories(LSMASHSource PRIVATE ${xxhash_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND)
find_library(libxxhash NAMES libxxhash.a xxhash xxhash.lib PATHS ${xxhash_LIBRARY_DIRS})
message(STATUS "xxhash: ${libxxhash}")
find_path(libopurse_include NAMES obuparse.h)
target_include_directories(LSMASHSource PRIVATE ${libopurse_include})
find_library(libobuparse NAMES libobuparse.a obuparse obuparse.lib)
message(STATUS "obuparse: ${libobuparse}")
if (PKG_CONFIG_FOUND)
pkg_check_modules(lsmash liblsmash)
target_include_directories(LSMASHSource PRIVATE ${lsmash_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND)
find_library(liblsmash NAMES liblsmash.a lsmash liblsmash.lib PATHS ${lsmash_LIBRARY_DIRS})
message(STATUS "lsmash: ${liblsmash}")
target_link_libraries(LSMASHSource PRIVATE
FFMPEG::avcodec
FFMPEG::avformat
FFMPEG::swscale
FFMPEG::swresample
FFMPEG::avutil
${libzlib}
${libxxhash}
${liblsmash}
${libobuparse}
)
if (ENABLE_DAV1D)
if (PKG_CONFIG_FOUND)
pkg_check_modules(dav1d dav1d)
target_include_directories(LSMASHSource PRIVATE ${dav1d_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND)
find_library(libdav1d NAMES libdav1d.a dav1d PATHS ${dav1d_LIBRARY_DIRS})
message(STATUS "dav1d: ${libdav1d}")
target_link_libraries(LSMASHSource PRIVATE ${libdav1d})
endif()
if (ENABLE_MFX)
if (PKG_CONFIG_FOUND)
pkg_check_modules(mfx libmfx)
target_include_directories(LSMASHSource PRIVATE ${mfx_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND)
find_library(libmfx NAMES libmfx.a mfx libmfx.lib PATHS ${mfx_LIBRARY_DIRS})
message(STATUS "mfx: ${libmfx}")
target_link_libraries(LSMASHSource PRIVATE ${libmfx})
endif()
if (ENABLE_XML2)
if (PKG_CONFIG_FOUND)
pkg_check_modules(xml2 libxml-2.0)
target_include_directories(LSMASHSource PRIVATE ${xml2_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND)
find_library(libxml2 NAMES libxml2.a xml2 libxml2s.lib PATH ${xml2_LIBRARY_DIRS})
message(STATUS "xml2: ${libxml2}")
target_link_libraries(LSMASHSource PRIVATE ${libxml2})
if (WIN32)
target_compile_definitions(LSMASHSource PRIVATE "-DLIBXML_STATIC")
endif()
endif()
if (ENABLE_VPX)
if (PKG_CONFIG_FOUND)
pkg_check_modules(vpx vpx)
target_include_directories(LSMASHSource PRIVATE ${vpx_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND)
find_library(libvpx NAMES vpx vpx.lib vpxmd.lib PATHS ${vpx_LIBRARY_DIRS})
message(STATUS "vpx: ${libvpx}")
target_link_libraries(LSMASHSource PRIVATE ${libvpx})
endif()
if (MINGW)
target_link_libraries(LSMASHSource PRIVATE ws2_32)
endif()
if (WIN32)
find_library(bcrypt NAMES bcrypt bcrypt.lib)
message(STATUS "bcrypt: ${bcrypt}")
target_link_libraries(LSMASHSource PRIVATE ${bcrypt})
endif()
target_compile_features(LSMASHSource PRIVATE cxx_std_17)
if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
if (build_type STREQUAL debug)
target_compile_definitions(LSMASHSource PRIVATE DEBUG_BUILD)
else (build_type STREQUAL release)
target_compile_definitions(LSMASHSource PRIVATE RELEASE_BUILD)
endif()
message(STATUS "Build type - ${CMAKE_BUILD_TYPE}")
endif()
if (${sse2})
target_compile_definitions(LSMASHSource PRIVATE SSE2_ENABLED=1)
endif()
if (WIN32)
set_target_properties(LSMASHSource PROPERTIES
PREFIX ""
OUTPUT_NAME "LSMASHSource"
)
else()
if (GIT_FOUND)
set_target_properties(LSMASHSource PROPERTIES OUTPUT_NAME "lsmashsource.${ver}")
endif()
include(GNUInstallDirs)
if (BUILD_AVS_PLUGIN)
INSTALL(TARGETS LSMASHSource LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/avisynth")
endif()
if (BUILD_VS_PLUGIN)
INSTALL(TARGETS LSMASHSource LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/vapoursynth")
endif()
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
endif()