File: CMakeLists.txt

package info (click to toggle)
deepin-terminal 3.2.1.1+ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,764 kB
  • sloc: ansic: 128; exp: 25; sh: 18; makefile: 15
file content (241 lines) | stat: -rw-r--r-- 6,408 bytes parent folder | download
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
project("dterminal" C)

set(target deepin-terminal)

cmake_minimum_required(VERSION 2.6)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(ExternalProject)
include(ValaPrecompile)
include(ValaVersion)
find_package(Vala)
ensure_vala_version("0.22.0" MINIMUM)
find_package(PkgConfig)
find_package(GLib "2.48" REQUIRED)
find_package(JsonGlib)
find_package(Libsecret)
find_package(FontConfig)
find_package(X11)
find_package(Gettext)

pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(GEE REQUIRED gee-0.8)
pkg_check_modules(GIO REQUIRED gio-unix-2.0)
pkg_check_modules(RSVG REQUIRED librsvg-2.0)
pkg_check_modules(WNCK REQUIRED libwnck-3.0)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
pkg_check_modules(GLIB REQUIRED glib-2.0)

option(TEST_BUILD "Build with native testing" ON)
option(USE_VENDOR_LIB "Backport support for debian stretch" ON)

if (NOT USE_VENDOR_LIB)
pkg_check_modules(VTE REQUIRED vte-2.91)
endif()

if (NOT DEFINED VERSION)
find_package(Git)
message("generate version from git")
execute_process(COMMAND ${GIT_EXECUTABLE}
    describe --abbrev=6 --dirty --tags
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    OUTPUT_VARIABLE VERSION
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/lib/constant.vala.in
    ${CMAKE_CURRENT_SOURCE_DIR}/lib/constant.vala
)

if(TEST_BUILD)
message("set project_path to native test")
execute_process(
    COMMAND sed s|@@PROJECT_PATH@@|\"${CMAKE_SOURCE_DIR}\"|g
    OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/project_path.c
    INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/project_path.c.in
)
list(APPEND ARGS_DEFINITIONS "TEST_BUILD")
else()
message("set project_path to ${CMAKE_INSTALL_PREFIX}")
execute_process(
    COMMAND sed s|@@PROJECT_PATH@@|\"${CMAKE_INSTALL_PREFIX}\"|g
    OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/project_path.c
    INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/project_path.c.in
)
endif()

if (USE_VENDOR_LIB)
ExternalProject_Add(Vte-0.52
  SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/vte-0.52.1
  CONFIGURE_COMMAND ./configure --enable-static
  BUILD_COMMAND make
  INSTALL_COMMAND ""
  BUILD_IN_SOURCE 1
  )

ExternalProject_Add(zssh-1.5c
  SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/zssh-1.5c
  CONFIGURE_COMMAND ./configure
  BUILD_COMMAND make
  INSTALL_COMMAND ""
  BUILD_IN_SOURCE 1
  )
endif()

set(CFLAGS
	${GIO_CFLAGS}
	${GTK3_CFLAGS} ${GTK3_CFLAGS_OTHER}
	${GEE_CFLAGS}
	${X11_CFLAGS} ${X11_CFLAGS_OTHER}
	-DWNCK_I_KNOW_THIS_IS_UNSTABLE
	-DGETTEXT_PACKAGE=${target}
	-s -O3 -w
	#	-g
)
add_compile_options(${CFLAGS})
set(INCLUDE_PATHS
	${GIO_INCLUDE_DIRS}
	${GTK3_INCLUDE_DIRS}
	${GEE_INCLUDE_DIRS}
	${WNCK_INCLUDE_DIRS}
	${RSVG_INCLUDE_DIRS}
	${JsonGlib_INCLUDE_DIRS}
	${LIBSECRET_INCLUDE_DIRS}
)

if (USE_VENDOR_LIB)
	list(APPEND INCLUDE_PATHS ${CMAKE_SOURCE_DIR}/3rdparty/vte-0.52.1/src)
	find_library(VTE_LIB NAMES libvte-2.91.a tcmalloc_minimal)
else()
	list(APPEND INCLUDE_PATHS ${VTE_INCLUDE_DIRS})
endif()

include_directories(${INCLUDE_PATHS})
set(LIBS
	${GIO_LIBRARIES}
	${GTK3_LIBRARIES}
	${GEE_LIBRARIES}
	${WNCK_LIBRARIES}
	${RSVG_LIBRARIES}
	${JsonGlib_LIBRARIES}
	${LIBSECRET_LIBRARIES}
	${ZLIB_LIBRARIES}
	${X11_LIBRARIES}
	${XTST_LIBRARIES}
	${FONTCONFIG_LIBRARY}
	${M_LIBRARIES}
	stdc++
	m
	z
	pthread
	gnutls
	pcre2-8
)

if (NOT USE_VENDOR_LIB)
	list(APPEND LIBS ${VTE_LIBRARIES})
endif()

SET(APP_SOURCES, "")
FILE(GLOB valalist LIST_FILES true */*.vala)
FOREACH(child ${valalist})
	file(RELATIVE_PATH
    file_path
    ${CMAKE_SOURCE_DIR}
    ${child}
	)
	set (APP_SOURCES ${APP_SOURCES} ${file_path})
ENDFOREACH()

set(VALA_PRECOMPILE_PACKAGES
	xcb
	gtk+-3.0
	vte-2.91
	gee-0.8
	json-glib-1.0
	gio-2.0
	libwnck-3.0
	posix
	libsecret-1
	gdk-x11-3.0
	glib-2.0
	librsvg-2.0
)

if (USE_VENDOR_LIB)
	list(APPEND VALA_PRECOMPILE_PACKAGES fontconfig)

	vala_precompile(VALA_C
		./main.vala
		${APP_SOURCES}

	OPTIONS
	--vapidir=${CMAKE_SOURCE_DIR}/vapi

	PACKAGES
		${VALA_PRECOMPILE_PACKAGES}
	)
else()
	vala_precompile(VALA_C
		./main.vala
		${APP_SOURCES}

	PACKAGES
		${VALA_PRECOMPILE_PACKAGES}
	)
endif()

add_executable(${target} ${VALA_C} ${CMAKE_SOURCE_DIR}/project_path.c ${CMAKE_SOURCE_DIR}/lib/font.c)

if (USE_VENDOR_LIB)
	target_link_libraries(${target} ${LIBS} ${CMAKE_SOURCE_DIR}/3rdparty/vte-0.52.1/src/.libs/libvte-2.91.a)
	add_dependencies(${target} Vte-0.52)
else()
	target_link_libraries(${target} ${LIBS})
endif()

FILE(GLOB children LIST_DIRECTORIES true po/*)
SET(dirlist "")

FOREACH(child ${children})
	IF(IS_DIRECTORY ${child})
		get_filename_component(childdir ${child} NAME)
		LIST(APPEND dirlist ${childdir})
	ENDIF()
ENDFOREACH()

FOREACH(lang ${dirlist})
	SET(gmoFiles)
	FOREACH(current_PO_FILE po/${lang}/LC_MESSAGES/deepin-terminal.po)
    	  SET(gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}-${target}.gmo)
    	  SET(INSTALL_DESTINATION share/locale/)
    	  ADD_CUSTOM_COMMAND(OUTPUT ${gmoFile}
    	        COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${gmoFile} ${current_PO_FILE}
    	        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    	        DEPENDS ${current_PO_FILE}
    	     )
    	  INSTALL(FILES ${gmoFile} DESTINATION ${INSTALL_DESTINATION}/${lang}/LC_MESSAGES/  RENAME ${target}.mo)

    	  LIST(APPEND gmoFiles ${gmoFile})
    ENDFOREACH(current_PO_FILE)

    ADD_CUSTOM_TARGET(${lang} ALL DEPENDS ${gmoFiles})

ENDFOREACH(lang)

INSTALL (TARGETS ${target} DESTINATION bin)
if (USE_VENDOR_LIB)
	INSTALL (PROGRAMS ${CMAKE_SOURCE_DIR}/3rdparty/ssh_login.sh ${CMAKE_SOURCE_DIR}/3rdparty/zssh-1.5c/zssh DESTINATION lib/${target})
else()
	INSTALL (PROGRAMS ssh_login.sh DESTINATION lib/${target})
endif()
INSTALL (FILES hicolor/32x32/${target}.png DESTINATION share/icons/hicolor/32x32/apps)
INSTALL (FILES hicolor/48x48/${target}.png DESTINATION share/icons/hicolor/48x48/apps)
INSTALL (FILES hicolor/96x96/${target}.png DESTINATION share/icons/hicolor/96x96/apps)
INSTALL (FILES hicolor/128x128/${target}.png DESTINATION share/icons/hicolor/128x128/apps)
INSTALL (FILES hicolor/${target}.svg DESTINATION share/icons/hicolor/scalable/apps)
INSTALL (DIRECTORY image DESTINATION share/${target} FILES_MATCHING PATTERN "*.png")
INSTALL (DIRECTORY image DESTINATION share/${target} FILES_MATCHING PATTERN "*.svg")
INSTALL (DIRECTORY theme DESTINATION share/${target} FILES_MATCHING PATTERN "*")
INSTALL (FILES style.css DESTINATION share/${target})
INSTALL (FILES ${target}.desktop DESTINATION share/applications)