forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
102 lines (93 loc) · 2.79 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
set(MODULE QtAVWidgets)
set(EXTRA_DEFS -DBUILD_QTAVWIDGETS_LIB)
list(APPEND EXTRA_DEFS -DQTAV_HAVE_GL=1)
set(HAVE_QT5OPENGL 0)
if(BUILD_QT5OPENGL)
find_package(Qt5OpenGL)
if(Qt5OpenGL_FOUND)
set(HAVE_QT5OPENGL 1)
endif()
endif()
set(SDK_HEADERS
QtAVWidgets/global.h
QtAVWidgets/GraphicsItemRenderer.h
QtAVWidgets/OpenGLWidgetRenderer.h
QtAVWidgets/QtAVWidgets
QtAVWidgets/QtAVWidgets.h
QtAVWidgets/version.h
QtAVWidgets/VideoPreviewWidget.h
QtAVWidgets/WidgetRenderer.h
)
file(GLOB SDK_PRIVATE_HEADERS QtAVWidgets/*.h)
set(SOURCES
global.cpp
GraphicsItemRenderer.cpp
OpenGLWidgetRenderer.cpp
VideoPreviewWidget.cpp
WidgetRenderer.cpp
)
if(HAVE_QT5OPENGL)
list(APPEND SDK_HEADERS QtAVWidgets/GLWidgetRenderer2.h)
list(APPEND SOURCES GLWidgetRenderer2.cpp)
endif()
# TODO: Qt5Gui_OPENGL_IMPLEMENTATION?
if(Qt5Gui_VERSION VERSION_LESS 5.4.0)
list(APPEND SDK_HEADERS QtAVWidgets/QOpenGLWidget.h)
list(APPEND SOURCES QOpenGLWidget.cpp)
endif()
set(HEADERS ${SDK_HEADERS})
if(WIN32)
set(RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.rc)
configure_file(${QTAV_SOURCE_DIR}/cmake/QtAV.rc.in ${RC_FILE})
endif()
# add HEADERS for moc
add_library(${MODULE} SHARED ${SOURCES} ${RESOURCES_SOURCES} ${HEADERS} ${RC_FILE})
target_link_libraries(${MODULE}
LINK_PRIVATE ${EXTRA_LIBS}
LINK_PUBLIC QtAV Qt5::Widgets
)
if(HAVE_QT5OPENGL)
target_link_libraries(${MODULE} LINK_PUBLIC Qt5::OpenGL)
endif()
set_target_properties(${MODULE} PROPERTIES
MACOSX_RPATH ON
FRAMEWORK ON
VERSION ${PROJECT_VERSION}
SOVERSION ${SO_VERSION}
OUTPUT_NAME ${MODULE}
CLEAN_DIRECT_OUTPUT 1
#LINK_SEARCH_START_STATIC 1
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
#http://stackoverflow.com/questions/19866424/cmake-and-qt5-automoc-error
#http://doc.qt.io/qt-5/cmake-manual.html
set(CMAKE_INCLUDE_CURRENT_DIR ON) # for .moc
target_include_directories(${MODULE}
PUBLIC $<INSTALL_INTERFACE:include>
PUBLIC $<INSTALL_INTERFACE:include/${MODULE}>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}>
PRIVATE ${EXTRA_INCLUDE}
)
target_compile_definitions(${MODULE} PRIVATE ${EXTRA_DEFS})
install(FILES
${SDK_HEADERS}
DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}
)
install(FILES
${SDK_PRIVATE_HEADERS}
DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}/private
)
install(TARGETS ${MODULE}
EXPORT ${MODULE}-targets
#PUBLIC_HEADER DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}
#PRIVATE_HEADER DESTINATION ${QTAV_INSTALL_HEADERS}/${MODULE}/private
RUNTIME DESTINATION ${QTAV_INSTALL_BINS}
LIBRARY DESTINATION ${QTAV_INSTALL_LIBS}
ARCHIVE DESTINATION ${QTAV_INSTALL_LIBS}
FRAMEWORK DESTINATION ${QTAV_INSTALL_LIBS}
)
install(EXPORT ${MODULE}-targets
DESTINATION ${QTAV_INSTALL_LIBS}/cmake/${MODULE}
FILE ${MODULE}-config.cmake
)