-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
199 lines (148 loc) · 5.61 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
cmake_minimum_required(VERSION 3.5)
project(webrtc-ui LANGUAGES CXX)
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)
add_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.
#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()
#find_package(PkgConfig)
#pkg_check_modules(GSTREAMER REQUIRED
# glib-2.0
# json-glib-1.0
# libsoup-2.4
# gstreamer-1.0
# gstreamer-video-1.0
# gstreamer-sdp-1.0
# gstreamer-rtp-1.0
# gstreamer-webrtc-1.0
#)
#message("GSTREAMER_INCLUDE_DIRS: ${GSTREAMER_INCLUDE_DIRS}")
#message("GSTREAMER_LIBRARY_DIRS: ${GSTREAMER_LIBRARY_DIRS}")
#link_directories(${GSTREAMER_LIBRARY_DIRS})
include(cmake/detect_gstreamer.cmake)
if (HAVE_GSTREAMER)
message (" GStreamer: (${GSTREAMER_VERSION})")
else()
message( FATAL_ERROR "GStreamer not found." )
endif()
find_package(crossguid CONFIG REQUIRED)
find_package(curl CONFIG REQUIRED)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
# Generate rules for building source files from the resources
qt5_add_resources(QRCS resources.qrc)
if(ANDROID)
add_library(webrtc-ui SHARED
main.cpp
globals.h
mainwindow.cpp
mainwindow.h
mainwindow.ui
maintoolbar.cpp
maintoolbar.h
maintoolbar.ui
preferences.cpp
preferences.h
preferences.ui
cameraman.cpp
cameraman.h
http.cpp
http.h
isendrecv.h
sendrecv.cpp
sendrecv.h
signaling_connection.cpp
signaling_connection.h
${QRCS}
)
else()
add_executable(webrtc-ui
main.cpp
globals.h
mainwindow.cpp
mainwindow.h
mainwindow.ui
maintoolbar.cpp
maintoolbar.h
maintoolbar.ui
preferences.cpp
preferences.h
preferences.ui
cameraman.cpp
cameraman.h
http.cpp
http.h
sendrecv.cpp
sendrecv.h
signaling_connection.cpp
signaling_connection.h
${QRCS}
)
endif()
target_include_directories(webrtc-ui PUBLIC ${GSTREAMER_INCLUDE_DIRS})
target_link_libraries(webrtc-ui PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${GSTREAMER_LIBRARIES} crossguid CURL::libcurl)
# Add a custom target to run the shell script before building the project
add_custom_target(update_version_file
COMMAND ${CMAKE_SOURCE_DIR}/update_version.sh
)
# Add dependencies for the custom target so that the script runs before building
add_dependencies(webrtc-ui update_version_file)
if(MSVC)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/bin")
set(BINARY_INSTALL_DIR .)
install(TARGETS ${PROJECT_NAME} DESTINATION ${BINARY_INSTALL_DIR})
set(BINARY_FILE "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.exe")
message( STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}" )
get_filename_component(CMAKE_TOOLCHAIN_DIRECTORY ${CMAKE_TOOLCHAIN_FILE} DIRECTORY)
#install(CODE "execute_process(COMMAND \"powershell\" \"-noprofile\" \"-executionpolicy\" \"Bypass\" \"-file\" \"${CMAKE_TOOLCHAIN_DIRECTORY}/msbuild/applocal.ps1\" \"-targetBinary\" \"${BINARY_FILE}\" \"-installedDir\" \"$ENV{GSTREAMER_ROOT_X86_64}/bin\" \"-OutVariable\" \"out\")")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set( CMAKE_INSTALL_PLATFORM "x64-windows" )
else ()
set( CMAKE_INSTALL_PLATFORM "x86-windows" )
endif ()
install(CODE "execute_process(COMMAND \"powershell\" \"-noprofile\" \"-executionpolicy\" \"Bypass\" \"-file\" \"${CMAKE_TOOLCHAIN_DIRECTORY}/msbuild/applocal.ps1\" \"-targetBinary\" \"${BINARY_FILE}\" \"-installedDir\" \"${CMAKE_TOOLCHAIN_DIRECTORY}/../../installed/${CMAKE_INSTALL_PLATFORM}/bin\" \"-OutVariable\" \"out\")")
# Install CRT
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
#if(DEVELOPER_FEATURES)
# set(CMAKE_INSTALL_DEBUG_LIBRARIES ON)
#endif(DEVELOPER_FEATURES)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
include (InstallRequiredSystemLibraries)
# Retrieve the absolute path to qmake and then use that path to find
# the windeployqt binary
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
install(CODE "execute_process(COMMAND \"${WINDEPLOYQT_EXECUTABLE}\" \"${BINARY_FILE}\" WORKING_DIRECTORY \"${_qt_bin_dir}\")")
#if (QT_QMAKE_EXECUTABLE)
# get_filename_component(QT_BIN_DIRECTORY ${QT_QMAKE_EXECUTABLE} DIRECTORY)
# install(CODE "execute_process(COMMAND \"${QT_BIN_DIRECTORY}/windeployqt\" \"${BINARY_FILE}\" WORKING_DIRECTORY \"${QT_BIN_DIRECTORY}\")")
#else()
# install(CODE "execute_process(COMMAND \"windeployqt\" \"${BINARY_FILE}\" )")
#endif()
#if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# install(DIRECTORY "$ENV{GSTREAMER_ROOT_X86_64}/bin/" DESTINATION .)
#else ()
# install(DIRECTORY "$ENV{GSTREAMER_ROOT_X86}/bin/" DESTINATION .)
#endif ()
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
install(DIRECTORY "$ENV{GSTREAMER_1_0_ROOT_MSVC_X86_64}/" DESTINATION gst PATTERN "*.pdb" EXCLUDE)
else ()
install(DIRECTORY "$ENV{GSTREAMER_1_0_ROOT_MSVC_X86}/" DESTINATION gst PATTERN "*.pdb" EXCLUDE)
endif ()
install(FILES run.cmd DESTINATION .)
endif()