-
Notifications
You must be signed in to change notification settings - Fork 84
/
CMakeLists.txt
177 lines (158 loc) · 5.7 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
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
set(PROJECT_NAME "GitQlient")
project(${PROJECT_NAME} LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "-Wall -Werror -pedantic-errors")
execute_process(
COMMAND
git -C ${PROJECT_SOURCE_DIR} rev-parse --short HEAD
RESULT_VARIABLE
GQ_SHA_RESULT
OUTPUT_VARIABLE
GQ_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT DEFINED VERSION OR "${VERSION}" STREQUAL "")
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(VERSION "0.0.0")
else()
set(VERSION ${GQ_SHA})
endif()
endif()
add_compile_definitions(SHA_VER="${GQ_SHA}")
add_compile_definitions(VER="${VERSION}")
add_compile_definitions(QT_DEPRECATED_WARNINGS)
list(APPEND CPP_FLAGS "-Wall")
if (CMAKE_BUILD_TYPE EQUAL "DEBUG" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
list(APPEND CPP_FLAGS "-Wextra" "-Wpedantic")
endif()
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/src/AuxiliarCustomWidgets/.git" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/src/QLogger/.git" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/src/QPinnableTabWidget/.git" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/src/git/.git")
message(STATUS "Submodule update:")
execute_process(COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(MACOSX_BUNDLE_ICON_FILE icon.icns)
set(MACOS_APP_ICON_GITQLIENT "${PROJECT_SOURCE_DIR}/src/resources/icon.icns")
set_source_files_properties(${MACOS_APP_ICON_GITQLIENT} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()
file(GLOB SRC_FILES
${MACOS_APP_ICON_GITQLIENT}
${PROJECT_SOURCE_DIR}/src/main.cpp
${PROJECT_SOURCE_DIR}/src/GitQlient.qrc
${PROJECT_SOURCE_DIR}/src/AuxiliarCustomWidgets/*.cpp
${PROJECT_SOURCE_DIR}/src/AuxiliarCustomWidgets/*.h
${PROJECT_SOURCE_DIR}/src/AuxiliarCustomWidgets/*.ui
${PROJECT_SOURCE_DIR}/src/AuxiliarCustomWidgets/*.qrc
${PROJECT_SOURCE_DIR}/src/aux_widgets/*.cpp
${PROJECT_SOURCE_DIR}/src/aux_widgets/*.h
${PROJECT_SOURCE_DIR}/src/aux_widgets/*.ui
${PROJECT_SOURCE_DIR}/src/big_widgets/*.cpp
${PROJECT_SOURCE_DIR}/src/big_widgets/*.h
${PROJECT_SOURCE_DIR}/src/big_widgets/*.ui
${PROJECT_SOURCE_DIR}/src/branches/*.cpp
${PROJECT_SOURCE_DIR}/src/branches/*.h
${PROJECT_SOURCE_DIR}/src/branches/*.ui
${PROJECT_SOURCE_DIR}/src/cache/*.cpp
${PROJECT_SOURCE_DIR}/src/cache/*.h
${PROJECT_SOURCE_DIR}/src/cache/*.ui
${PROJECT_SOURCE_DIR}/src/commits/*.cpp
${PROJECT_SOURCE_DIR}/src/commits/*.h
${PROJECT_SOURCE_DIR}/src/commits/*.ui
${PROJECT_SOURCE_DIR}/src/config/*.cpp
${PROJECT_SOURCE_DIR}/src/config/*.h
${PROJECT_SOURCE_DIR}/src/config/*.ui
${PROJECT_SOURCE_DIR}/src/diff/*.cpp
${PROJECT_SOURCE_DIR}/src/diff/*.h
${PROJECT_SOURCE_DIR}/src/diff/*.ui
${PROJECT_SOURCE_DIR}/src/git/*.cpp
${PROJECT_SOURCE_DIR}/src/git/*.h
${PROJECT_SOURCE_DIR}/src/git/*.ui
${PROJECT_SOURCE_DIR}/src/git_server/*.cpp
${PROJECT_SOURCE_DIR}/src/git_server/*.h
${PROJECT_SOURCE_DIR}/src/git_server/*.ui
${PROJECT_SOURCE_DIR}/src/history/*.cpp
${PROJECT_SOURCE_DIR}/src/history/*.h
${PROJECT_SOURCE_DIR}/src/history/*.ui
${PROJECT_SOURCE_DIR}/src/jenkins/*.cpp
${PROJECT_SOURCE_DIR}/src/jenkins/*.h
${PROJECT_SOURCE_DIR}/src/jenkins/*.ui
${PROJECT_SOURCE_DIR}/src/QLogger/*.cpp
${PROJECT_SOURCE_DIR}/src/QLogger/*.h
${PROJECT_SOURCE_DIR}/src/QLogger/*.ui
${PROJECT_SOURCE_DIR}/src/QPinnableTabWidget/*.cpp
${PROJECT_SOURCE_DIR}/src/QPinnableTabWidget/*.h
${PROJECT_SOURCE_DIR}/src/QPinnableTabWidget/*.ui
${PROJECT_SOURCE_DIR}/src/terminal/*.cpp
${PROJECT_SOURCE_DIR}/src/terminal/*.h
${PROJECT_SOURCE_DIR}/src/terminal/*.ui
)
qt_add_executable(
${PROJECT_NAME}
${SRC_FILES})
target_include_directories(
${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/AuxiliarCustomWidgets
${PROJECT_SOURCE_DIR}/src/aux_widgets
${PROJECT_SOURCE_DIR}/src/big_widgets
${PROJECT_SOURCE_DIR}/src/branches
${PROJECT_SOURCE_DIR}/src/cache
${PROJECT_SOURCE_DIR}/src/commits
${PROJECT_SOURCE_DIR}/src/config
${PROJECT_SOURCE_DIR}/src/diff
${PROJECT_SOURCE_DIR}/src/git
${PROJECT_SOURCE_DIR}/src/git_server
${PROJECT_SOURCE_DIR}/src/history
${PROJECT_SOURCE_DIR}/src/jenkins
${PROJECT_SOURCE_DIR}/src/QLogger
${PROJECT_SOURCE_DIR}/src/QPinnableTabWidget
${PROJECT_SOURCE_DIR}/src/terminal
)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
AUTOMOC TRUE
AUTOUIC TRUE
AUTORCC TRUE
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/src/resources/Info.plist"
)
else()
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE TRUE
AUTOMOC TRUE
AUTOUIC TRUE
AUTORCC TRUE
)
endif()
target_link_libraries(
${PROJECT_NAME}
PUBLIC
Qt::Core
Qt::Widgets
Qt::Network
)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(${PROJECT_NAME} PUBLIC "-no-pie")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
endif()
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}"
BUNDLE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}"
LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}"
)