forked from iEvgeny/cctv-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
134 lines (105 loc) · 4.8 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
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
cmake_minimum_required(VERSION 3.14)
set(VER_MAJ 0)
set(VER_MIN 1)
set(VER_PAT 8)
set(REL_STATUS "alpha")
set(APP_NAME "CCTV Viewer")
set(ORG_NAME "CCTV Viewer")
set(ORG_DOMAIN "cctv-viewer.org")
set(VERSION "${VER_MAJ}.${VER_MIN}")
if(${VER_PAT} GREATER 0)
set(VERSION "${VERSION}.${VER_PAT}")
endif()
project(cctv-viewer VERSION ${VERSION} HOMEPAGE_URL "https://github.com/iEvgeny/cctv-viewer" LANGUAGES C CXX)
if(DEFINED REL_STATUS)
set(VERSION "${VERSION}-${REL_STATUS}")
endif()
add_definitions(-DAPP_NAME="${APP_NAME}" -DAPP_VERSION="${VERSION}" -DORG_NAME="${ORG_NAME}" -DORG_DOMAIN="${ORG_DOMAIN}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Disable use of C++ API deprecated in Qt 5.15
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check https://doc.qt.io/qt/deployment-android.html for more information.
# They need to be set before the find_package(...) calls below.
#if(ANDROID)
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
# if (ANDROID_ABI STREQUAL "armeabi-v7a")
# set(ANDROID_EXTRA_LIBS
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
# endif()
#endif()
set(QT_LINK_DEPENDENCIES Core Quick Multimedia)
set(FFMPEG_LINK_DEPENDENCIES avformat avcodec avutil swscale swresample avdevice)
if (ANDROID)
list(APPEND QT_LINK_DEPENDENCIES Svg)
set(ANDROID_EXTRA_LIBS
"${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib/libavformat.so"
"${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib/libavcodec.so"
"${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib/libavutil.so"
"${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib/libswscale.so"
"${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib/libswresample.so"
"${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib/libavdevice.so"
"${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib/libavfilter.so"
)
endif()
find_package(QT NAMES Qt6 Qt5 COMPONENTS ${QT_LINK_DEPENDENCIES} LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.12 COMPONENTS ${QT_LINK_DEPENDENCIES} LinguistTools REQUIRED)
file(GLOB TS_FILES "${CMAKE_SOURCE_DIR}/translations/*.ts")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if (${QT_VERSION_MAJOR} GREATER 5)
qt_add_resources(RESOURCES cctv-viewer.qrc)
else()
qt5_add_resources(RESOURCES cctv-viewer.qrc)
endif()
else()
find_package(Qt5QuickCompiler REQUIRED)
qtquick_compiler_add_resources(RESOURCES cctv-viewer.qrc)
endif()
set(PROJ_FILES
src/main.cpp
src/global.h
src/singleapplication.h
src/config.h src/config.cpp
src/context.h src/context.cpp
src/context.cpp src/context.h
src/viewportslayoutmodel.cpp src/viewportslayoutmodel.h
src/viewportslayoutscollectionmodel.cpp src/viewportslayoutscollectionmodel.h
${RESOURCES}
${TS_FILES}
)
set(QML_IMPORT_PATH "${CMAKE_SOURCE_DIR}/src/imports" CACHE STRING "Additional import path used to resolve QML modules in Qt Creator's code model")
add_subdirectory(src/qmlav)
if (ANDROID)
add_library(cctv-viewer SHARED ${PROJ_FILES} ${QMLAV_FILES})
target_include_directories(cctv-viewer PRIVATE "${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/include")
target_link_directories(cctv-viewer PRIVATE "${CMAKE_SOURCE_DIR}/src/qmlav/3rd/FFmpeg/ffbuild/${ANDROID_ABI}/lib")
else()
add_executable(cctv-viewer ${PROJ_FILES} ${QMLAV_FILES})
endif()
target_include_directories(cctv-viewer PRIVATE ${QMLAV_INCLUDE})
target_compile_definitions(cctv-viewer
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
foreach (ITEM ${QT_LINK_DEPENDENCIES})
target_link_libraries(cctv-viewer PRIVATE Qt${QT_VERSION_MAJOR}::${ITEM})
endforeach()
target_link_libraries(cctv-viewer PRIVATE ${FFMPEG_LINK_DEPENDENCIES})
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM true)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_SOURCE_DIR}/translations")
if (${QT_VERSION_MAJOR} GREATER 5)
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
if (UNIX AND NOT ANDROID)
include(GNUInstallDirs)
set(CMAKE_INSTALL_PREFIX "/usr")
install(TARGETS cctv-viewer DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES "images/cctv-viewer.svg" DESTINATION "/usr/share/pixmaps")
install(FILES "cctv-viewer.desktop" DESTINATION "/usr/share/applications")
endif()