-
Notifications
You must be signed in to change notification settings - Fork 64
/
CMakeLists.txt
190 lines (160 loc) · 7.03 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
# CMakeLists.txt
cmake_minimum_required(VERSION 3.1.0)
file(STRINGS "${CMAKE_SOURCE_DIR}/makespec/VERSION" VERSION)
file(STRINGS "${CMAKE_SOURCE_DIR}/makespec/BUILDVERSION" BUILD_VERSION)
file(STRINGS "${CMAKE_SOURCE_DIR}/makespec/VERSIONSUFFIX" VERSION_SUFFIX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(notepanda)
set(VERSION_STRING "${VERSION}${VERSION_SUFFIX}")
set(VERSION_LIST ${VERSION})
string(REPLACE "." ";" VERSION_LIST ${VERSION_LIST})
separate_arguments(VERSION_LIST)
list(GET VERSION_LIST 0 CMAKE_PROJECT_VERSION_MAJOR)
list(GET VERSION_LIST 1 CMAKE_PROJECT_VERSION_MINOR)
list(GET VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)
add_definitions(-DVERSION_STRING="${VERSION_STRING}")
add_definitions(-DXTOSTRUCT_QT)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
# =======================
# Notepanda Build Message
# =======================
message(" ")
message("Notepanda Version: ${VERSION_STRING}")
message("Notepanda Build Version: ${BUILD_VERSION}")
message("Notepanda Build Type: ${CMAKE_BUILD_TYPE}")
message("|-------------------------------------------------|")
message("| Notepanda, A Cross Platform Notepad. |")
message("| Based on C++ & Qt. |")
message("| Licenced under MIT |")
message("| |")
message("| You may only use this program to the extent |")
message("| permitted by local law. |")
message("| |")
message("| See: https://opensource.org/licenses/MIT |")
message("|-------------------------------------------------|")
message("| GitHub: https://github.com/ChungZH/notepanda |")
message("| Welcome to contribute! |")
message("|-------------------------------------------------|")
message(" ")
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
find_package(KF5SyntaxHighlighting REQUIRED)
if(WIN32)
set(GUI_TYPE WIN32)
elseif(APPLE)
set(GUI_TYPE MACOSX_BUNDLE)
endif()
# =============================
# Notepanda Sources and Headers
# =============================
set(SOURCES
src/main.cpp
src/ui/aboutwindow.cpp
src/ui/aboutwindow.h
src/ui/aboutwindow.ui
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/linenumberarea.h
src/ui/preferenceswindow.cpp
src/ui/preferenceswindow.h
src/ui/preferenceswindow.ui
src/core/configmanager.cpp
src/core/configmanager.h
src/core/texteditor.cpp
src/core/texteditor.h
assets/notepanda.rc
${CMAKE_SOURCE_DIR}/resources.qrc
)
add_executable(notepanda
${GUI_TYPE}
${SOURCES}
)
if(UNIX AND NOT APPLE AND NOT WIN32)
install(TARGETS notepanda RUNTIME DESTINATION bin)
install(FILES assets/notepanda.desktop DESTINATION share/applications)
install(FILES images/notepanda.png DESTINATION share/icons/hicolor/256x256/apps)
endif()
# Directories to look for dependencies
set(DIRS "${CMAKE_BINARY_DIR}")
# Path used for searching by FIND_XXX(), with appropriate suffixes added
if(CMAKE_PREFIX_PATH)
foreach(dir ${CMAKE_PREFIX_PATH})
list(APPEND DIRS "${dir}/bin" "${dir}/lib")
endforeach()
endif()
# =========
# Packaging
# =========
set(CPACK_PACKAGE_NAME "Notepanda")
set(CPACK_PACKAGE_VENDOR "ChungZH")
set(CPACK_PACKAGE_VERSION ${VERSION_STRING})
set(CPACK_PACKAGE_DESCRIPTION "A simple cross-platform notepad.")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/ChungZH/notepanda")
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/images/panda.ico")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.md")
if(MSVC)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
endif()
include(InstallRequiredSystemLibraries)
if(WIN32)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION .)
if (BUILD_NSIS)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND windeployqt ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.exe --compiler-runtime --no-translations --verbose 2 --dir ${CMAKE_BINARY_DIR}/winqt/
)
install(DIRECTORY ${CMAKE_BINARY_DIR}/winqt/ DESTINATION .)
endif()
set(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.exe")
endif()
if(WIN32)
if(BUILD_NSIS)
set(CPACK_GENERATOR "NSIS")
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/images\\\\panda.ico")
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/images/panda.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/images/panda.ico")
set(CPACK_NSIS_DISPLAY_NAME "Notepanda")
set(CPACK_NSIS_PACKAGE_NAME "Notepanda")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
CreateShortCut \\\"$DESKTOP\\\\Notepanda.lnk\\\" \\\"$INSTDIR\\\\notepanda.exe\\\"
CreateDirectory \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Notepanda\\\"
CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Notepanda\\\\Notepanda.lnk\\\" \\\"$INSTDIR\\\\notepanda.exe\\\"
WriteRegStr HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\notepanda\\\" \\\"DisplayIcon\\\" \\\"$INSTDIR\\\\notepanda.exe\\\"
WriteRegStr HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\notepanda\\\" \\\"HelpLink\\\" \\\"https://github.com/ChungZH/notepanda\\\"
WriteRegStr HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\notepanda\\\" \\\"InstallLocation\\\" \\\"$INSTDIR\\\"
WriteRegStr HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\notepanda\\\" \\\"URLUpdateInfo\\\" \\\"https://github.com/ChungZH/notepanda/releases\\\"
WriteRegStr HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\notepanda\\\" \\\"URLInfoAbout\\\" \\\"https://github.com/ChungZH/notepanda\\\"
")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
Delete \\\"$DESKTOP\\\\Notepanda.lnk\\\"
Delete \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Notepanda\\\\Notepanda.lnk\\\"
RMDir \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Notepanda\\\"
DeleteRegKey HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\notepanda\\\"
")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "notepanda")
endif()
endif()
if(UNIX)
if(BUILD_DEB)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_NAME "Notepanda")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ChungZH")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "qtbase5-dev, qttools5-dev, libkf5syntaxhighlighting-dev")
endif()
#if(BUILD_RPM)
# set(CPACK_GENERATOR "RPM")
# set(CPACK_RPM_PACKAGE_LICENSE "MIT")
#endif()
endif()
if(WIN32)
list(APPEND DIRS "${KF5SyntaxHighlighting_DIR}/../../../bin/")
install(CODE "include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")")
endif()
include(CPack)
target_link_libraries(notepanda Qt5::Core Qt5::Gui Qt5::Widgets KF5::SyntaxHighlighting)