Skip to content

Commit

Permalink
cmake: add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jan 23, 2017
1 parent 079172f commit 71806f3
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 11 deletions.
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,23 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden) #use with -fdata-sections -ffunction-sec
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) # for .moc

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

add_subdirectory(src)
find_package(Qt5Widgets)
if(Qt5Widgets_FOUND)
add_subdirectory(widgets)
endif()

#set(CMAKE_REQUIRED_INCLUDES ${Qt5WebEngine_INCLUDE_DIRS};${Qt5WebEngine_PRIVATE_INCLUDE_DIRS})
#set(CMAKE_REQUIRED_LIBRARIES ${QT5_LIBRARIES})
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_TESTS "Build tests" ON)

if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()


141 changes: 141 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@

set(COMMON_SRC
common/common.cpp
common/Config.cpp
common/qoptions.cpp
)
set(COMMON_HEADERS
common/common.h
common/Config.h
common/qoptions.h
common/ScreenSaver.h
common/common_export.h
)
if(NOT IOS)
list(APPEND COMMON_SRC common/ScreenSaver.cpp)
if(APPLE)
list(APPEND COMMON_LIBS "-framework CoreServices")
endif()
endif()

SET(COMMON_QRC common/theme/theme.qrc)
SOURCE_GROUP("Resources" FILES ${COMMON_QRC})
qt5_add_resources(COMMON_RES ${COMMON_QRC})
set_source_files_properties(${COMMON_RES} PROPERTIES GENERATED ON)

# add HEADERS for moc
add_library(common STATIC ${COMMON_SRC} ${COMMON_RES} ${COMMON_HEADERS})
qt5_use_modules(common LINK_PUBLIC Core Gui Sql)
target_compile_definitions(common
PUBLIC -DBUILD_COMMON_STATIC
)
target_include_directories(common
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(common LINK_PUBLIC ${COMMON_LIBS})

set(PLAYER_SRC
player/main.cpp
player/MainWindow.cpp
player/ClickableMenu.cpp
player/StatisticsView.cpp
player/Slider.cpp
player/TVView.cpp
player/EventFilter.cpp
player/config/ConfigDialog.cpp
player/config/ConfigPageBase.cpp
player/config/CaptureConfigPage.cpp
player/config/VideoEQConfigPage.cpp
player/config/DecoderConfigPage.cpp
player/config/MiscPage.cpp
player/filters/OSD.cpp
player/filters/OSDFilter.cpp
player/playlist/PlayListModel.cpp
player/playlist/PlayListItem.cpp
player/playlist/PlayListDelegate.cpp
player/playlist/PlayList.cpp
player/config/PropertyEditor.cpp
player/config/AVFormatConfigPage.cpp
player/config/AVFilterConfigPage.cpp
player/config/ShaderPage.cpp
player/filters/AVFilterSubtitle.cpp
)
set(PLAYER_HEADERS
player/MainWindow.h
player/ClickableMenu.h
player/StatisticsView.h
player/Slider.h
player/TVView.h
player/EventFilter.h
player/config/ConfigDialog.h
player/config/ConfigPageBase.h
player/config/CaptureConfigPage.h
player/config/VideoEQConfigPage.h
player/config/DecoderConfigPage.h
player/config/MiscPage.h
player/filters/OSD.h
player/filters/OSDFilter.h
player/playlist/PlayListModel.h
player/playlist/PlayListItem.h
player/playlist/PlayListDelegate.h
player/playlist/PlayList.h
player/config/PropertyEditor.h
player/config/AVFormatConfigPage.h
player/config/AVFilterConfigPage.h
player/config/ShaderPage.h
player/filters/AVFilterSubtitle.h
)
SET(PLAYER_QRC player/res/player.qrc)
SOURCE_GROUP("Resources" FILES ${PLAYER_QRC})
qt5_add_resources(PLAYER_RES ${PLAYER_QRC})
set_source_files_properties(${PLAYER_RES} PROPERTIES GENERATED ON)

if(Qt5Widgets_FOUND)
add_executable(Player ${PLAYER_SRC} ${PLAYER_HEADERS} ${PLAYER_RES})
target_link_libraries(Player QtAVWidgets common)

SET(FILTERS_QRC filters/res.qrc)
SOURCE_GROUP("Resources" FILES ${FILTERS_QRC})
qt5_add_resources(FILTERS_RES ${FILTERS_QRC})
set_source_files_properties(${FILTERS_RES} PROPERTIES GENERATED ON)
add_executable(filters filters/main.cpp filters/SimpleFilter.cpp ${FILTERS_RES})
target_link_libraries(filters QtAVWidgets)

add_executable(glslfilter glslfilter/main.cpp)
target_link_libraries(glslfilter QtAVWidgets)

add_executable(shader shader/main.cpp)
target_link_libraries(shader QtAVWidgets)

add_executable(sharedoutput sharedoutput/main.cpp sharedoutput/widget.cpp)
target_link_libraries(sharedoutput QtAVWidgets)

add_executable(simpleplayer simpleplayer/main.cpp simpleplayer/playerwindow.cpp)
target_link_libraries(simpleplayer QtAVWidgets)

add_executable(videocapture videocapture/main.cpp videocapture/playerwindow.cpp)
target_link_libraries(videocapture QtAVWidgets)

add_executable(videographicsitem videographicsitem/main.cpp videographicsitem/videoplayer.cpp)
target_link_libraries(videographicsitem QtAVWidgets)

add_executable(videogroup videogroup/main.cpp videogroup/videogroup.cpp)
target_link_libraries(videogroup QtAVWidgets)

add_executable(videowall videowall/main.cpp videowall/VideoWall.cpp)
target_link_libraries(videowall QtAVWidgets)

add_executable(simpletranscode simpletranscode/main.cpp)
target_link_libraries(simpletranscode QtAV)
endif()

add_executable(audiopipeline audiopipeline/main.cpp)
target_link_libraries(audiopipeline QtAV)

add_executable(framereader framereader/main.cpp)
target_link_libraries(framereader QtAV)

add_executable(window window/main.cpp)
target_link_libraries(window QtAV)


4 changes: 2 additions & 2 deletions examples/simpletranscode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <QApplication>
#include <QCoreApplication>
#include <QtCore/QDir>
#include <QtAV>
#include <QtAV/AVTranscoder.h>
Expand All @@ -28,7 +28,7 @@ using namespace QtAV;

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication a(argc, argv);
qDebug("QtAV simpletranscode");
qDebug("./simpletranscode -i infile -o outfile [-async] [-c:v video_codec (default: libx264)] [-hwdev dev] [-f format] [-an] [-ss HH:mm:ss.z]");
qDebug("-an: disable audio");
Expand Down
4 changes: 0 additions & 4 deletions examples/simpletranscode/simpletranscode.pro
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
TEMPLATE = app
CONFIG -= app_bundle
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
include($$PROJECTROOT/widgets/libQtAVWidgets.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES += main.cpp

11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(MODULE QtAV)
# TODO: translations, rpath, rc template

INCLUDE(CheckCCompilerFlag)
INCLUDE(CheckIncludeFile)
Expand Down Expand Up @@ -77,7 +78,7 @@ if (NOT HAVE_SWRESAMPLE)
endif()
endif()

list(APPEND EXTRA_DEFS -DBUILD_QTAV_LIB -DQ_AV_EXPORT -D__STDC_CONSTANT_MACROS)
list(APPEND EXTRA_DEFS -DBUILD_QTAV_LIB -D__STDC_CONSTANT_MACROS)

check_include_file(ass/ass.h HAVE_ASS_H)
if(HAVE_ASS_H)
Expand Down Expand Up @@ -217,9 +218,11 @@ set(SDK_HEADERS
QtAV/AVMuxer.h
QtAV/Filter.h
QtAV/FilterContext.h
QtAV/GLSLFilter.h
QtAV/LibAVFilter.h
QtAV/EncodeFilter.h
QtAV/Frame.h
QtAV/FrameReader.h
QtAV/QPainterRenderer.h
QtAV/Packet.h
QtAV/AVError.h
Expand All @@ -238,6 +241,7 @@ set(SDK_HEADERS
QtAV/VideoFrameExtractor.h
QtAV/FactoryDefine.h
QtAV/Statistics.h
QtAV/SubImage.h
QtAV/Subtitle.h
QtAV/SubtitleFilter.h
QtAV/SurfaceInterop.h
Expand Down Expand Up @@ -300,9 +304,11 @@ list(APPEND SOURCES
AVDemuxThread.cpp
ColorTransform.cpp
Frame.cpp
FrameReader.cpp
filter/Filter.cpp
filter/FilterContext.cpp
filter/FilterManager.cpp
filter/GLSLFilter.cpp
filter/LibAVFilter.cpp
filter/SubtitleFilter.cpp
filter/EncodeFilter.cpp
Expand Down Expand Up @@ -369,6 +375,7 @@ list(APPEND HEADERS ${SDK_HEADERS} ${SDK_PRIVATE_HEADERS}
ColorTransform.h
)

# TODO: rc template
SET(RESOURCES ${MODULE}.qrc shaders/shaders.qrc)
SOURCE_GROUP("Resources" FILES ${RESOURCES})
QT5_ADD_RESOURCES(RESOURCES_SOURCES ${RESOURCES})
Expand All @@ -387,6 +394,7 @@ set_target_properties(${MODULE} PROPERTIES
OUTPUT_NAME ${MODULE}
CLEAN_DIRECT_OUTPUT 1
#LINK_SEARCH_START_STATIC 1
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)


Expand All @@ -395,6 +403,7 @@ set_target_properties(${MODULE} PROPERTIES
set(CMAKE_INCLUDE_CURRENT_DIR ON) # for .moc
target_include_directories(${MODULE}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/QtAV
PRIVATE ${EXTRA_INCLUDE}
)

Expand Down
7 changes: 5 additions & 2 deletions widgets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
set(MODULE QtAVWidgets)
set(EXTRA_DEFS -DBUILD_QTAVWIDGETS_LIB)
list(APPEND EXTRA_DEFS -DQTAV_HAVE_GL=1)
set(SDK_HEADERS
QtAVWidgets/global.h
QtAVWidgets/GLWidgetRenderer2.h #TODO: check opengl
Expand Down Expand Up @@ -32,6 +34,7 @@ set_target_properties(${MODULE} PROPERTIES
OUTPUT_NAME ${MODULE}
CLEAN_DIRECT_OUTPUT 1
#LINK_SEARCH_START_STATIC 1
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)


Expand All @@ -40,10 +43,10 @@ set_target_properties(${MODULE} PROPERTIES
set(CMAKE_INCLUDE_CURRENT_DIR ON) # for .moc
target_include_directories(${MODULE}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_SOURCE_DIR}/src
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/QtAVWidgets
PRIVATE ${EXTRA_INCLUDE}
)

target_compile_definitions(QtAV
target_compile_definitions(${MODULE}
PRIVATE ${EXTRA_DEFS}
)

0 comments on commit 71806f3

Please sign in to comment.