-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
137 lines (117 loc) · 3.71 KB
/
CMakeLists.txt
File metadata and controls
137 lines (117 loc) · 3.71 KB
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
#
# see http://qt-project.org/doc/qt-5/cmake-manual.html
# see also http://www.kdab.com/using-cmake-with-qt-5/
# see also http://stackoverflow.com/questions/16245147/unable-to-include-a-ui-form-header-of-qt5-in-cmake
# see also http://www.qtcentre.org/wiki/index.php?title=Compiling_Qt4_apps_with_CMake
#
cmake_minimum_required(VERSION 3.10.2)
project(qgit)
include(GNUInstallDirs)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Select the Qt major version and its dependencies\
set(QT_PACKAGE "Qt6" CACHE STRING "Major Qt version")
set_property(CACHE QT_PACKAGE PROPERTY STRINGS "Qt6" "Qt5" "Qt4")
find_package(QT NAMES ${QT_PACKAGE} REQUIRED)
set(QT Qt${QT_VERSION_MAJOR})
message(STATUS "Using ${QT}")
if (QT_VERSION_MAJOR EQUAL 6)
set(QT_MIN_VERSION 6.2.4)
set(QT_MODULES Core Gui Widgets Core5Compat)
set(QT_LIBRARIES Qt6::Widgets Qt6::Core5Compat)
elseif (QT_VERSION_MAJOR EQUAL 5)
set(QT_MIN_VERSION 5.11.0)
set(QT_MODULES Core Gui Widgets)
set(QT_LIBRARIES Qt5::Widgets)
elseif (QT_MAJOR_VERSION EQUAL 4)
set(QT_MODULES QtCore QtGui)
include(${QT_USE_FILE})
endif()
find_package(${QT} ${QT_MIN_VERSION} REQUIRED COMPONENTS ${QT_MODULES})
if (QT_VERSION VERSION_LESS 5.15)
if (QT_VERSION_MAJOR EQUAL 4)
macro(qt_wrap_ui)
qt4_wrap_ui(${ARGN})
endmacro()
macro(qt_add_resources)
qt4_add_resources(${ARGN})
endmacro()
elseif(QT_VERSION_MAJOR EQUAL 5)
macro(qt_wrap_ui)
qt5_wrap_ui(${ARGN})
endmacro()
macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()
endif()
endif()
# Sources
include_directories(
${CMAKE_SOURCE_DIR}/src
)
set(CPP_SOURCES
src/annotate.cpp
src/cache.cpp
src/commitimpl.cpp
src/common.cpp
src/consoleimpl.cpp
src/customactionimpl.cpp
src/dataloader.cpp
src/domain.cpp
src/exceptionmanager.cpp
src/filecontent.cpp
src/FileHistory.cc
src/filelist.cpp
src/fileview.cpp
src/git.cpp
src/lanes.cpp
src/listview.cpp
src/inputdialog.cpp
src/mainimpl.cpp
src/myprocess.cpp
src/namespace_def.cpp
src/patchcontent.cpp
src/patchview.cpp
src/qgit.cpp
src/rangeselectimpl.cpp
src/revdesc.cpp
src/revsview.cpp
src/settingsimpl.cpp
src/smartbrowse.cpp
src/treeview.cpp
)
# UIS_HDRS will be used later in add_executable
qt_wrap_ui(UIS_HDRS
src/commit.ui
src/console.ui
src/customaction.ui
src/fileview.ui
src/help.ui
src/mainview.ui
src/patchview.ui
src/rangeselect.ui
src/revsview.ui
src/settings.ui
)
# and finally an resource file
set(RESOURCE_FILES
src/icons.qrc
)
# this command will generate rules that will run rcc on all files from SAMPLE_RCS
# in result SAMPLE_RC_SRCS variable will contain paths to files produced by rcc
qt_add_resources(RC_SRCS ${RESOURCE_FILES})
add_executable(qgit ${CPP_SOURCES} ${UIS_HDRS} ${RC_SRCS})
target_link_libraries(qgit ${QT_LIBRARIES})
install(TARGETS qgit DESTINATION bin)
if (UNIX)
install(FILES src/resources/qgit.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps)
install(FILES src/resources/qgit.svg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps)
install(FILES qgit.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
install(FILES qgit.appdata.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo)
endif()
# kate: indent-width 4; replace-tabs on;
# notes:
# http://stackoverflow.com/questions/15054117/aligning-qgraphicsitems-to-a-grid-when-dragging-and-dropping