|
| 1 | + |
| 2 | + |
| 3 | +INCLUDE(CheckCCompilerFlag) |
| 4 | +INCLUDE(CheckIncludeFile) |
| 5 | +INCLUDE(CheckTypeSize) |
| 6 | + |
| 7 | +# set qt dirs first so we can find depends in qt install dir |
| 8 | +include_directories(${QTDIR}/include) |
| 9 | +set(MODULES Core Gui) |
| 10 | + |
| 11 | +foreach(M ${MODULES}) |
| 12 | + set(mod Qt5${M}) |
| 13 | + # look for the config files in the QtConfigRoot defined above |
| 14 | + set(${mod}_DIR ${QTCONFIGROOT}${M}) |
| 15 | + |
| 16 | + # look for the actual package |
| 17 | + find_package(${mod} REQUIRED) |
| 18 | + |
| 19 | + include_directories(${${mod}_INCLUDE_DIRS}) |
| 20 | + include_directories(${${mod}_PRIVATE_INCLUDE_DIRS}) |
| 21 | + |
| 22 | + list(APPEND QT5_LIBRARIES ${${mod}_LIBRARIES}) |
| 23 | + list(APPEND QT5_CFLAGS ${${mod}_EXECUTABLE_COMPILE_FLAGS}) |
| 24 | +endforeach(M ${MODULES}) |
| 25 | + |
| 26 | +get_target_property(QtCore_location Qt5::Core LOCATION) |
| 27 | +get_filename_component(QTDIR "${QTDIR}" ABSOLUTE) |
| 28 | +#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${QTDIR}/lib") # unix: for extra libs |
| 29 | +CHECK_INCLUDE_FILE(ass/ass.h HAVE_ASS_H) |
| 30 | +#if (HAVE_ASS_H) |
| 31 | + # check link |
| 32 | +#endif() |
| 33 | +CHECK_INCLUDE_FILE(libavfilter/avfilter.h HAVE_AVFILTER_H) |
| 34 | +CHECK_INCLUDE_FILE(libavdevice/avdevice.h HAVE_AVDEVICE_H) |
| 35 | +CHECK_INCLUDE_FILE(libavresample/avresample.h HAVE_AVRESAMPLE_H) |
| 36 | +CHECK_INCLUDE_FILE(libswresample/swresample.h HAVE_SWRESAMPLE_H) |
| 37 | +if (NOT HAVE_SWRESAMPLE_H) |
| 38 | + if (NOT HAVE_AVRESAMPLE_H) |
| 39 | + #message(FATAL_ERROR "swresample or avresample is required") |
| 40 | + endif() |
| 41 | +endif() |
| 42 | + |
| 43 | +set(QTAV_EXTRA_DEFS -DBUILD_QTAV_LIB -DQ_AV_EXPORT -D__STDC_CONSTANT_MACROS) |
| 44 | +set(QTAV_EXTRA_LIBS avcodec avformat avutil swscale) |
| 45 | +if (APPLE) |
| 46 | + set(CMAKE_CXX_SYSTEM_FRAMEWORK_SEARCH_FLAG "-F ") # original is "-iframework", lots of build errors |
| 47 | + set(CMAKE_C_SYSTEM_FRAMEWORK_SEARCH_FLAG "-F ") |
| 48 | + set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) |
| 49 | + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lavcodec) |
| 50 | + check_c_source_compiles( |
| 51 | + "#include <libavcodec/videotoolbox.h> |
| 52 | + int main() { |
| 53 | + av_videotoolbox_alloc_context(); |
| 54 | + return 0; |
| 55 | + }" HAVE_VIDEOTOOLBOX) |
| 56 | + |
| 57 | + if (HAVE_VIDEOTOOLBOX) |
| 58 | + list(APPEND QTAV_EXTRA_DEFS -DQTAV_HAVE_VIDEOTOOLBOX=1) |
| 59 | + list(APPEND QTAV_EXTRA_LIBS "-framework CoreMedia -framework VideoToolbox -framework CoreVideo") |
| 60 | + list(APPEND SOURCES |
| 61 | + codec/video/VideoDecoderVideoToolbox.cpp |
| 62 | + codec/video/SurfaceInteropCV.cpp |
| 63 | + ) |
| 64 | + if (IOS) |
| 65 | + list(APPEND SOURCES |
| 66 | + codec/video/SurfaceInteropCVOpenGLES.mm |
| 67 | + ) |
| 68 | + else() |
| 69 | + list(APPEND SOURCES |
| 70 | + codec/video/SurfaceInteropIOSurface.cpp |
| 71 | + ) |
| 72 | + endif() |
| 73 | + endif() |
| 74 | + set(HAVE_OPENAL_H 1) |
| 75 | + add_definitions(-DHEADER_OPENAL_PREFIX) |
| 76 | + |
| 77 | + list(APPEND SOURCES output/audio/AudioOutputAudioToolbox.cpp) |
| 78 | + list(APPEND QTAV_EXTRA_LIBS "-framework CoreFoundation -framework AudioToolbox -framework OpenGL") |
| 79 | +endif() |
| 80 | + |
| 81 | +set(DEP_H AVRESAMPLE SWRESAMPLE AVDEVICE AVFILTER OPENAL VIDEOTOOLBOX) |
| 82 | +foreach (D ${DEP_H}) |
| 83 | + if (${D}) |
| 84 | + ADD_DEFINITIONS(-DQTAV_HAVE_${D}=1) |
| 85 | + endif() |
| 86 | +endforeach() |
| 87 | + |
| 88 | +if (HAVE_AVFILTER_H) |
| 89 | + list(APPEND QTAV_EXTRA_DEFS -DQTAV_HAVE_AVFILTER=1) |
| 90 | + list(APPEND QTAV_EXTRA_LIBS avfilter) |
| 91 | +endif() |
| 92 | +if (HAVE_AVDEVICE_H) |
| 93 | + list(APPEND QTAV_EXTRA_DEFS -DQTAV_HAVE_AVDEVICE=1) |
| 94 | + list(APPEND QTAV_EXTRA_LIBS avdevice) |
| 95 | +endif() |
| 96 | +if (HAVE_AVRESAMPLE_H) |
| 97 | + list(APPEND QTAV_EXTRA_DEFS -DQTAV_HAVE_AVRESAMPLE=1) |
| 98 | + list(APPEND QTAV_EXTRA_LIBS avresample) |
| 99 | + list(APPEND SOURCES AudioResamplerLibav.cpp) |
| 100 | +endif() |
| 101 | +if (HAVE_SWRESAMPLE_H) |
| 102 | + list(APPEND QTAV_EXTRA_DEFS -DQTAV_HAVE_SWRESAMPLE=1) |
| 103 | + list(APPEND QTAV_EXTRA_LIBS swresample) |
| 104 | + list(APPEND SOURCES AudioResamplerFF.cpp) |
| 105 | +endif() |
| 106 | + |
| 107 | +set(CMAKE_AUTOMOC ON) |
| 108 | + |
| 109 | +set(SDK_HEADERS |
| 110 | + QtAV/QtAV |
| 111 | + QtAV/QtAV.h |
| 112 | + QtAV/dptr.h |
| 113 | + QtAV/QtAV_Global.h |
| 114 | + QtAV/AudioResampler.h |
| 115 | + QtAV/AudioDecoder.h |
| 116 | + QtAV/AudioEncoder.h |
| 117 | + QtAV/AudioFormat.h |
| 118 | + QtAV/AudioFrame.h |
| 119 | + QtAV/AudioOutput.h |
| 120 | + QtAV/AVDecoder.h |
| 121 | + QtAV/AVEncoder.h |
| 122 | + QtAV/AVDemuxer.h |
| 123 | + QtAV/AVMuxer.h |
| 124 | + QtAV/Filter.h |
| 125 | + QtAV/FilterContext.h |
| 126 | + QtAV/LibAVFilter.h |
| 127 | + QtAV/EncodeFilter.h |
| 128 | + QtAV/Frame.h |
| 129 | + QtAV/QPainterRenderer.h |
| 130 | + QtAV/Packet.h |
| 131 | + QtAV/AVError.h |
| 132 | + QtAV/AVPlayer.h |
| 133 | + QtAV/AVTranscoder.h |
| 134 | + QtAV/VideoCapture.h |
| 135 | + QtAV/VideoRenderer.h |
| 136 | + QtAV/VideoOutput.h |
| 137 | + QtAV/MediaIO.h |
| 138 | + QtAV/AVOutput.h |
| 139 | + QtAV/AVClock.h |
| 140 | + QtAV/VideoDecoder.h |
| 141 | + QtAV/VideoEncoder.h |
| 142 | + QtAV/VideoFormat.h |
| 143 | + QtAV/VideoFrame.h |
| 144 | + QtAV/VideoFrameExtractor.h |
| 145 | + QtAV/FactoryDefine.h |
| 146 | + QtAV/Statistics.h |
| 147 | + QtAV/Subtitle.h |
| 148 | + QtAV/SubtitleFilter.h |
| 149 | + QtAV/SurfaceInterop.h |
| 150 | + QtAV/OpenGLVideo.h |
| 151 | + QtAV/OpenGLRendererBase.h |
| 152 | + QtAV/OpenGLWindowRenderer.h |
| 153 | + QtAV/VideoShader.h |
| 154 | + QtAV/VideoShaderObject.h |
| 155 | + QtAV/version.h |
| 156 | + ) |
| 157 | +set(SDK_PRIVATE_HEADERS |
| 158 | + QtAV/private/factory.h |
| 159 | + QtAV/private/mkid.h |
| 160 | + QtAV/private/prepost.h |
| 161 | + QtAV/private/singleton.h |
| 162 | + QtAV/private/PlayerSubtitle.h |
| 163 | + QtAV/private/SubtitleProcessor.h |
| 164 | + QtAV/private/AVCompat.h |
| 165 | + QtAV/private/AudioOutputBackend.h |
| 166 | + QtAV/private/AudioResampler_p.h |
| 167 | + QtAV/private/AVDecoder_p.h |
| 168 | + QtAV/private/AVEncoder_p.h |
| 169 | + QtAV/private/MediaIO_p.h |
| 170 | + QtAV/private/AVOutput_p.h |
| 171 | + QtAV/private/Filter_p.h |
| 172 | + QtAV/private/Frame_p.h |
| 173 | + QtAV/private/VideoShader_p.h |
| 174 | + QtAV/private/VideoRenderer_p.h |
| 175 | + QtAV/private/QPainterRenderer_p.h |
| 176 | + QtAV/private/OpenGLRendererBase_p.h |
| 177 | + ) |
| 178 | + |
| 179 | +list(APPEND SOURCES |
| 180 | + AVCompat.cpp |
| 181 | + QtAV_Global.cpp |
| 182 | + subtitle/CharsetDetector.cpp |
| 183 | + subtitle/PlainText.cpp |
| 184 | + subtitle/PlayerSubtitle.cpp |
| 185 | + subtitle/Subtitle.cpp |
| 186 | + subtitle/SubtitleProcessor.cpp |
| 187 | + subtitle/SubtitleProcessorFFmpeg.cpp |
| 188 | + subtitle/SubImage.cpp |
| 189 | + utils/GPUMemCopy.cpp |
| 190 | + utils/Logger.cpp |
| 191 | + AudioThread.cpp |
| 192 | + utils/internal.cpp |
| 193 | + AVThread.cpp |
| 194 | + AudioFormat.cpp |
| 195 | + AudioFrame.cpp |
| 196 | + AudioResampler.cpp |
| 197 | + AudioResamplerTemplate.cpp |
| 198 | + codec/audio/AudioDecoder.cpp |
| 199 | + codec/audio/AudioDecoderFFmpeg.cpp |
| 200 | + codec/audio/AudioEncoder.cpp |
| 201 | + codec/audio/AudioEncoderFFmpeg.cpp |
| 202 | + codec/AVDecoder.cpp |
| 203 | + codec/AVEncoder.cpp |
| 204 | + AVMuxer.cpp |
| 205 | + AVDemuxer.cpp |
| 206 | + AVDemuxThread.cpp |
| 207 | + ColorTransform.cpp |
| 208 | + Frame.cpp |
| 209 | + filter/Filter.cpp |
| 210 | + filter/FilterContext.cpp |
| 211 | + filter/FilterManager.cpp |
| 212 | + filter/LibAVFilter.cpp |
| 213 | + filter/SubtitleFilter.cpp |
| 214 | + filter/EncodeFilter.cpp |
| 215 | + ImageConverter.cpp |
| 216 | + ImageConverterFF.cpp |
| 217 | + Packet.cpp |
| 218 | + PacketBuffer.cpp |
| 219 | + AVError.cpp |
| 220 | + AVPlayer.cpp |
| 221 | + AVPlayerPrivate.cpp |
| 222 | + AVTranscoder.cpp |
| 223 | + AVClock.cpp |
| 224 | + VideoCapture.cpp |
| 225 | + VideoFormat.cpp |
| 226 | + VideoFrame.cpp |
| 227 | + io/MediaIO.cpp |
| 228 | + io/QIODeviceIO.cpp |
| 229 | + output/audio/AudioOutput.cpp |
| 230 | + output/audio/AudioOutputBackend.cpp |
| 231 | + output/audio/AudioOutputNull.cpp |
| 232 | + output/video/VideoRenderer.cpp |
| 233 | + output/video/VideoOutput.cpp |
| 234 | + output/video/QPainterRenderer.cpp |
| 235 | + output/video/OpenGLRendererBase.cpp |
| 236 | + output/video/OpenGLWindowRenderer.cpp |
| 237 | + output/AVOutput.cpp |
| 238 | + output/OutputSet.cpp |
| 239 | + Statistics.cpp |
| 240 | + codec/video/VideoDecoder.cpp |
| 241 | + codec/video/VideoDecoderFFmpegBase.cpp |
| 242 | + codec/video/VideoDecoderFFmpeg.cpp |
| 243 | + codec/video/VideoDecoderFFmpegHW.cpp |
| 244 | + codec/video/VideoEncoder.cpp |
| 245 | + codec/video/VideoEncoderFFmpeg.cpp |
| 246 | + VideoThread.cpp |
| 247 | + VideoFrameExtractor.cpp |
| 248 | + ) |
| 249 | + |
| 250 | +aux_source_directory(opengl SRC_OPENGL) |
| 251 | +list(APPEND SOURCES ${SRC_OPENGL}) |
| 252 | +list(APPEND HEADERS ${SDK_HEADERS} ${SDK_PRIVATE_HEADERS} |
| 253 | + AVPlayerPrivate.h |
| 254 | + AVDemuxThread.h |
| 255 | + AVThread.h |
| 256 | + AVThread_p.h |
| 257 | + AudioThread.h |
| 258 | + PacketBuffer.h |
| 259 | + VideoThread.h |
| 260 | + ImageConverter.h |
| 261 | + ImageConverter_p.h |
| 262 | + codec/video/VideoDecoderFFmpegBase.h |
| 263 | + codec/video/VideoDecoderFFmpegHW.h |
| 264 | + codec/video/VideoDecoderFFmpegHW_p.h |
| 265 | + filter/FilterManager.h |
| 266 | + subtitle/CharsetDetector.h |
| 267 | + subtitle/PlainText.h |
| 268 | + utils/BlockingQueue.h |
| 269 | + utils/GPUMemCopy.h |
| 270 | + utils/Logger.h |
| 271 | + utils/SharedPtr.h |
| 272 | + utils/ring.h |
| 273 | + utils/internal.h |
| 274 | + output/OutputSet.h |
| 275 | + ColorTransform.h |
| 276 | + ) |
| 277 | + |
| 278 | +SET(RESOURCES QtAV.qrc shaders/shaders.qrc) |
| 279 | +SOURCE_GROUP("Resources" FILES ${RESOURCES}) |
| 280 | +QT5_ADD_RESOURCES(RESOURCES_SOURCES ${RESOURCES}) |
| 281 | +set_source_files_properties(${RESOURCES_SOURCES} PROPERTIES GENERATED ON) |
| 282 | + |
| 283 | +# add HEADERS for moc |
| 284 | +add_library(QtAV SHARED ${SOURCES} ${RESOURCES_SOURCES} ${HEADERS}) |
| 285 | +qt5_use_modules(QtAV Core Gui) |
| 286 | +target_link_libraries(QtAV ${QTAV_EXTRA_LIBS}) |
| 287 | +set_target_properties(QtAV PROPERTIES |
| 288 | + MACOSX_RPATH ON |
| 289 | + FRAMEWORK ON |
| 290 | + VERSION ${PROJECT_VERSION} |
| 291 | + SOVERSION ${SO_VERSION} |
| 292 | + OUTPUT_NAME "QtAV" |
| 293 | + CLEAN_DIRECT_OUTPUT 1 |
| 294 | + #LINK_SEARCH_START_STATIC 1 |
| 295 | +) |
| 296 | + |
| 297 | + |
| 298 | +#http://stackoverflow.com/questions/19866424/cmake-and-qt5-automoc-error |
| 299 | +#http://doc.qt.io/qt-5/cmake-manual.html |
| 300 | +set(CMAKE_INCLUDE_CURRENT_DIR ON) # for .moc |
| 301 | +target_include_directories(QtAV |
| 302 | + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} |
| 303 | + ) |
| 304 | + |
| 305 | +target_compile_definitions(QtAV |
| 306 | + PRIVATE ${QTAV_EXTRA_DEFS} |
| 307 | +) |
0 commit comments