summaryrefslogtreecommitdiff
path: root/examples/qmlplayer/CMakeLists.txt
blob: 1add76b5b2d81dd13d2af6a48aef693e65e798b1 (plain)
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
project(qtgst-example-qmlplayer)

if (NOT BUILDING_QTGSTREAMER)
    find_package(Qt4 COMPONENTS QtCore QtGui QtDeclarative REQUIRED)
    find_package(QtGStreamer REQUIRED)
    find_package(OpenGL)

    # Use a relative module path to avoid copying FindOpenGLES2.cmake here
    set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules)
    find_package(OpenGLES2)

    set(CMAKE_AUTOMOC ON)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
else()
    # allow the example to run from the build tree without installing QtGStreamer
    add_definitions(
        -DQTVIDEOSINK_PATH="${QtGStreamer_BINARY_DIR}/elements/gstqtvideosink"
        -DUNINSTALLED_IMPORTS_DIR="${QtGStreamer_BINARY_DIR}/src/qml"
    )
endif()

include_directories(${QTGSTREAMER_INCLUDES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}")
add_definitions(${QTGSTREAMER_DEFINITIONS})

if (QT_QTOPENGL_FOUND AND (OPENGL_FOUND OR OPENGLES2_FOUND))
    set(qmlplayer_gl_libs ${QT_QTOPENGL_LIBRARY})
    if (OPENGLES2_FOUND)
        include_directories(${OPENGLES2_INCLUDE_DIR})
    else()
        include_directories(${OPENGL_INCLUDE_DIR})
    endif()
else()
    add_definitions(-DQMLPLAYER_NO_OPENGL)
endif()

set(qmlplayer_SOURCES main.cpp player.cpp)
qt_helper_add_resources(qmlplayer_rcc_SOURCES qmlplayer.qrc)

add_executable(qmlplayer
    ${qmlplayer_SOURCES}
    ${qmlplayer_rcc_SOURCES}
)
target_link_libraries(qmlplayer
    ${QTGSTREAMER_UI_LIBRARIES}
    ${QT_QTDECLARATIVE_LIBRARY}
    ${qmlplayer_gl_libs}
)