-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
240 lines (218 loc) · 6.84 KB
/
Copy pathCMakeLists.txt
File metadata and controls
240 lines (218 loc) · 6.84 KB
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
cmake_minimum_required(VERSION 3.24)
project(DualSynth
VERSION 0.1.0
DESCRIPTION "Dual-host modern C++ SDK/runtime for VapourSynth and AviSynth+ plugins"
LANGUAGES CXX
)
option(DS_BUILD_TESTS "Build DualSynth tests" ON)
option(DS_BUILD_ACCEPTANCE_PLUGIN "Build DualSynth acceptance plugin" ON)
option(
DS_BUILD_AVISYNTH_POSIX_ACCEPTANCE_PLUGIN
"Build the AviSynth+ acceptance plugin entry on POSIX hosts"
OFF
)
set(DS_MSVC_RUNTIME_LIBRARY "" CACHE STRING
"Optional MSVC runtime library override for DualSynth targets. Leave empty to use the toolchain or parent project default."
)
set_property(CACHE DS_MSVC_RUNTIME_LIBRARY PROPERTY STRINGS
""
"MultiThreaded"
"MultiThreadedDebug"
"MultiThreadedDLL"
"MultiThreadedDebugDLL"
"MultiThreaded$<$<CONFIG:Debug>:Debug>"
"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(DualSynthCompilerOptions)
include(FetchContent)
include(CheckCXXSourceCompiles)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
check_cxx_source_compiles([=[
#include <array>
#include <cstddef>
#include <mdspan>
int main() {
int storage[4]{};
std::mdspan<
int,
std::dextents<std::size_t, 2>,
std::layout_stride
> view{
storage,
std::layout_stride::mapping<std::dextents<std::size_t, 2>>{
std::dextents<std::size_t, 2>{2, 2},
std::array<std::size_t, 2>{2, 1}
}
};
view[1, 1] = 1;
return storage[3] == 1 ? 0 : 1;
}
]=] DS_HAVE_STD_MDSPAN)
if(NOT DS_HAVE_STD_MDSPAN)
FetchContent_Declare(
Mdspan
GIT_REPOSITORY https://github.com/kokkos/mdspan.git
GIT_TAG stable
)
FetchContent_GetProperties(Mdspan)
if(NOT mdspan_POPULATED)
if(POLICY CMP0169)
cmake_policy(PUSH)
cmake_policy(SET CMP0169 OLD)
endif()
FetchContent_Populate(Mdspan)
if(POLICY CMP0169)
cmake_policy(POP)
endif()
endif()
add_library(dualsynth_mdspan_polyfill INTERFACE)
target_include_directories(dualsynth_mdspan_polyfill
INTERFACE
"${mdspan_SOURCE_DIR}/include"
)
target_compile_definitions(dualsynth_mdspan_polyfill
INTERFACE
MDSPAN_USE_BRACKET_OPERATOR=1
MDSPAN_USE_PAREN_OPERATOR=0
)
endif()
add_library(dualsynth STATIC
src/dualsynth/error.cpp
src/dualsynth/format.cpp
src/dualsynth/frame.cpp
src/dualsynth/param.cpp
src/dualsynth/video_bridge.cpp
)
add_library(DualSynth::dualsynth ALIAS dualsynth)
set_target_properties(dualsynth PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
if(MSVC AND DS_MSVC_RUNTIME_LIBRARY)
set_property(TARGET dualsynth PROPERTY
MSVC_RUNTIME_LIBRARY "${DS_MSVC_RUNTIME_LIBRARY}"
)
endif()
target_compile_features(dualsynth PUBLIC cxx_std_23)
target_include_directories(dualsynth
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
ds_apply_compiler_options(dualsynth)
target_compile_definitions(dualsynth
PUBLIC
DS_USE_STD_MDSPAN=$<BOOL:${DS_HAVE_STD_MDSPAN}>
)
if(TARGET dualsynth_mdspan_polyfill)
target_link_libraries(dualsynth PUBLIC dualsynth_mdspan_polyfill)
endif()
if(DS_BUILD_ACCEPTANCE_PLUGIN)
set(DS_VAPOURSYNTH_SDK "" CACHE PATH "Optional path to a VapourSynth SDK")
set(_ds_vapoursynth_include_hints)
if(DS_VAPOURSYNTH_SDK)
list(APPEND _ds_vapoursynth_include_hints
"${DS_VAPOURSYNTH_SDK}/include"
"${DS_VAPOURSYNTH_SDK}"
)
endif()
if(DEFINED ENV{VAPOURSYNTH_SDK})
list(APPEND _ds_vapoursynth_include_hints
"$ENV{VAPOURSYNTH_SDK}/include"
"$ENV{VAPOURSYNTH_SDK}"
)
endif()
find_path(DS_VAPOURSYNTH_INCLUDE_DIR
NAMES vapoursynth/VapourSynth4.h
HINTS ${_ds_vapoursynth_include_hints}
)
unset(_ds_vapoursynth_include_hints)
if(NOT DS_VAPOURSYNTH_INCLUDE_DIR)
FetchContent_Declare(
VapourSynth
URL https://github.com/vapoursynth/vapoursynth/archive/refs/tags/R73.zip
URL_HASH SHA256=7c6b1eb2ec4aeae078675a29cf5e77c6ca1ab8b1dd322677c66e1ca6b76c511d
)
FetchContent_GetProperties(VapourSynth)
if(NOT vapoursynth_POPULATED)
if(POLICY CMP0169)
cmake_policy(PUSH)
cmake_policy(SET CMP0169 OLD)
endif()
FetchContent_Populate(VapourSynth)
if(POLICY CMP0169)
cmake_policy(POP)
endif()
endif()
set(_ds_vapoursynth_sdk_include_dir "${CMAKE_CURRENT_BINARY_DIR}/_deps/vapoursynth-sdk/include")
file(MAKE_DIRECTORY "${_ds_vapoursynth_sdk_include_dir}/vapoursynth")
configure_file(
"${vapoursynth_SOURCE_DIR}/include/VapourSynth4.h"
"${_ds_vapoursynth_sdk_include_dir}/vapoursynth/VapourSynth4.h"
COPYONLY
)
set(DS_VAPOURSYNTH_INCLUDE_DIR
"${_ds_vapoursynth_sdk_include_dir}"
CACHE PATH "Path to a directory containing vapoursynth/VapourSynth4.h"
FORCE
)
unset(_ds_vapoursynth_sdk_include_dir)
endif()
endif()
set(DS_CAN_BUILD_AVISYNTH_ACCEPTANCE_PLUGIN OFF)
set(DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS "disabled")
if(DS_BUILD_ACCEPTANCE_PLUGIN)
if(WIN32)
if(MSVC)
set(DS_CAN_BUILD_AVISYNTH_ACCEPTANCE_PLUGIN ON)
set(DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS "windows-msvc-verified")
else()
set(DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS "windows-non-msvc-unsupported")
endif()
elseif(APPLE)
set(DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS "macos-unverified")
if(DS_BUILD_AVISYNTH_POSIX_ACCEPTANCE_PLUGIN)
set(DS_CAN_BUILD_AVISYNTH_ACCEPTANCE_PLUGIN ON)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS "linux-verified")
if(DS_BUILD_AVISYNTH_POSIX_ACCEPTANCE_PLUGIN)
set(DS_CAN_BUILD_AVISYNTH_ACCEPTANCE_PLUGIN ON)
endif()
elseif(UNIX)
set(DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS "posix-other-unverified")
if(DS_BUILD_AVISYNTH_POSIX_ACCEPTANCE_PLUGIN)
set(DS_CAN_BUILD_AVISYNTH_ACCEPTANCE_PLUGIN ON)
endif()
else()
set(DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS "unsupported")
endif()
message(STATUS "AviSynth+ acceptance plugin platform status: ${DS_AVISYNTH_ACCEPTANCE_PLATFORM_STATUS}")
endif()
if(DS_BUILD_ACCEPTANCE_PLUGIN AND DS_CAN_BUILD_AVISYNTH_ACCEPTANCE_PLUGIN)
FetchContent_Declare(
AviSynthPlus
URL https://github.com/AviSynth/AviSynthPlus/archive/refs/tags/v3.7.5.zip
URL_HASH SHA256=b60cd796886a91d32e4f495ac29df19f14c99988dfdc5ef002ebb5fc4b1f0042
)
FetchContent_GetProperties(AviSynthPlus)
if(NOT avisynthplus_POPULATED)
if(POLICY CMP0169)
cmake_policy(PUSH)
cmake_policy(SET CMP0169 OLD)
endif()
FetchContent_Populate(AviSynthPlus)
if(POLICY CMP0169)
cmake_policy(POP)
endif()
endif()
set(DS_AVISYNTH_INCLUDE_DIR "${avisynthplus_SOURCE_DIR}/avs_core/include")
endif()
if(DS_BUILD_ACCEPTANCE_PLUGIN AND (DS_VAPOURSYNTH_INCLUDE_DIR OR DS_AVISYNTH_INCLUDE_DIR))
add_subdirectory(plugins/acceptance)
endif()
if(DS_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()