forked from arthurzam/dukto-qt5
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
202 lines (177 loc) · 5.86 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
200
201
202
project(dukto)
cmake_minimum_required(VERSION 3.1.0)
OPTION(USE_UPDATER "Add updater for application" OFF)
OPTION(USE_SINGLE_APP "Enable only single instance" OFF)
OPTION(USE_NOTIFY_NATIVE_TRAY "For notifications use System Tray's Native" OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
if(UNIX)
FIND_PACKAGE(PkgConfig)
if(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(LIBNOTIFY libnotify)
if(LIBNOTIFY_FOUND)
OPTION(USE_NOTIFY_LIBNOTIFY "For notifications use libnotify" OFF)
endif(LIBNOTIFY_FOUND)
endif(PKG_CONFIG_FOUND)
endif(UNIX)
if(USE_UPDATER)
add_definitions("-DUPDATER")
endif()
if(USE_SINGLE_APP)
add_definitions("-DSINGLE_APP")
endif()
if(USE_NOTIFY_NATIVE_TRAY)
add_definitions("-DNOTIFY_NATIVE_TRAY")
endif()
if(UNIX)
if(USE_NOTIFY_LIBNOTIFY)
add_definitions("-DNOTIFY_LIBNOTIFY")
include_directories(${LIBNOTIFY_INCLUDE_DIRS})
list(APPEND DUKTO_LIBS ${LIBNOTIFY_LIBRARIES})
endif(USE_NOTIFY_LIBNOTIFY)
endif(UNIX)
if(NOT QT_DEFAULT_MAJOR_VERSION)
find_package(Qt6 QUIET COMPONENTS Core)
if (NOT Qt6_FOUND)
find_package(Qt5 COMPONENTS Core REQUIRED)
set(QT_DEFAULT_MAJOR_VERSION 5)
else()
set(QT_DEFAULT_MAJOR_VERSION 6)
endif(NOT Qt6_FOUND)
endif(NOT QT_DEFAULT_MAJOR_VERSION)
set(QT_COMPONENTS Gui Network Qml QuickWidgets)
set(QT_LIBRARIES "")
foreach(temp ${QT_COMPONENTS})
list(APPEND QT_LIBRARIES "Qt${QT_DEFAULT_MAJOR_VERSION}::${temp}")
endforeach()
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions("-DQT_NO_DEBUG_OUTPUT")
endif()
add_definitions("-DUNICODE")
set(DUKTO_HDR
buddylistitemmodel.h
destinationbuddy.h
duktoprotocol.h
duktowindow.h
guibehind.h
ipaddressitemmodel.h
peer.h
platform.h
recentlistitemmodel.h
settings.h
systemtray.h
theme.h
)
set(DUKTO_SRC
buddylistitemmodel.cpp
destinationbuddy.cpp
duktoprotocol.cpp
duktowindow.cpp
guibehind.cpp
ipaddressitemmodel.cpp
main.cpp
platform.cpp
recentlistitemmodel.cpp
settings.cpp
systemtray.cpp
theme.cpp
)
set(DUKTO_RESOURCES
qml.qrc
qml/common/common.qrc
)
if(Qt6_FOUND OR Qt5Core_VERSION VERSION_GREATER "5.15.0" OR Qt5Core_VERSION VERSION_EQUAL "5.15.0")
list(APPEND DUKTO_RESOURCES "qml/new/main.qrc")
else()
list(APPEND DUKTO_RESOURCES "qml/old/main.qrc")
endif()
if(USE_UPDATER)
list(APPEND DUKTO_SRC updateschecker.cpp)
list(APPEND DUKTO_HDR updateschecker.h)
endif()
if(WIN32)
list(APPEND DUKTO_SRC ecwin7.cpp)
list(APPEND DUKTO_HDR ecwin7.h)
list(APPEND DUKTO_RESOURCES dukto.rc)
endif()
if(USE_SINGLE_APP)
set(QAPPLICATION_CLASS "QApplication")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/modules/SingleApplication)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/modules/SingleApplication)
endif()
if(ANDROID)
add_library(${PROJECT_NAME} SHARED
${DUKTO_HDR}
${DUKTO_SRC}
${DUKTO_RESOURCES})
include(modules/qt-android-cmake/AddQtAndroidApk.cmake)
add_qt_android_apk(${PROJECT_NAME}_apk ${PROJECT_NAME})
else()
add_executable(${PROJECT_NAME}
${DUKTO_HDR}
${DUKTO_SRC}
${DUKTO_RESOURCES})
endif()
if(USE_SINGLE_APP)
add_dependencies(${PROJECT_NAME} SingleApplication)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/modules/SingleApplication)
target_link_libraries(${PROJECT_NAME} SingleApplication)
endif()
target_link_libraries(${PROJECT_NAME} ${DUKTO_LIBS} ${QT_LIBRARIES})
# Retrieve the absolute path to qmake and then use that path to find
# the binaries
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}")
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")
if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE True
)
target_link_libraries(${PROJECT_NAME} Ws2_32 ole32 user32)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Visual Studio C++
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# gcc
target_link_options(${PROJECT_NAME} PRIVATE -mwindows)
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif(WIN32)
If (APPLE)
SET( MACOSX_BUNDLE_ICON_FILE dukto.icns )
SET_SOURCE_FILES_PROPERTIES( "dukto.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
target_sources(${PROJECT_NAME} PRIVATE ${MACOSX_BUNDLE_ICON_FILE})
#set_property(TARGET ${PROJECT_NAME} PROPERTY MACOSX_BUNDLE 1)
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME "Dukto"
MACOSX_BUNDLE TRUE
MACOSX_RPATH TRUE
MACOSX_FRAMEWORK_IDENTIFIER msec.it.dukto
XCODE_ATTRIBUTE_EXECUTABLE_NAME "Dukto"
)
find_library(CORE_SERVICES CoreServices REQUIRED)
target_link_options(${PROJECT_NAME} PRIVATE "${CORE_SERVICES}/CoreServices.tbd")
if (MACDEPLOYQT_EXECUTABLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND "${MACDEPLOYQT_EXECUTABLE}"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/../.."
-qmldir="${CMAKE_CURRENT_SOURCE_DIR}/qml"
-always-overwrite
COMMENT "Running macdeployqt..."
)
endif()
endif()
if(UNIX AND NOT APPLE)
install(TARGETS ${PROJECT_NAME}
DESTINATION bin)
install(FILES dukto.png
DESTINATION share/pixmaps/)
install(FILES dukto.desktop
DESTINATION share/applications/)
endif()