-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathCMakeLists.txt
168 lines (143 loc) · 5.35 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
cmake_minimum_required(VERSION 3.16)
if (NOT DEFINED VERSION)
set(VERSION 6.0.37)
endif()
project(dde-dock)
find_package(DtkTools REQUIRED)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_PTHREADS_INIT 1)
set(CMAKE_PREFER_PTHREAD_FLAG ON)
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_FLAGS "-g -Wall")
# 增加安全编译参数
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all")
set(CMAKE_EXE_LINKER_FLAGS "-z relro -z now -z noexecstack -pie")
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -fPIE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
# generate a compile commands file as complete database for vim-YouCompleteMe or some other similar tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Install settings
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
include(GNUInstallDirs)
if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
# generate qm
execute_process(COMMAND bash "translate_generation.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif ()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_DEBUG")
# Test architecture
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "sw_64")
# add compiler flags -mieee for mathmatic
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee")
add_definitions(-DDISABLE_SHOW_ANIMATION)
endif()
function(generation_dbus_interface xmldir outdir)
IF(EXISTS ${outdir})
file(REMOVE_RECURSE ${outdir})
ENDIF()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${outdir})
file(GLOB_RECURSE allXmls ${xmldir}/*.xml)
foreach(XMLFILE ${allXmls})
string(FIND ${XMLFILE} "/" INDEX REVERSE)
string(SUBSTRING ${XMLFILE} ${INDEX} -1 classname)
string(REPLACE "/" "" classname ${classname})
string(REPLACE ".xml" "" classname ${classname})
string(REPLACE "." "_" classname ${classname})
string(TOLOWER ${classname} filename)
execute_process(COMMAND ${DTK_XML2CPP} -c ${classname} -p ${outdir}/${filename} ${XMLFILE}
WORKING_DIRECTORY ${outdir})
endforeach()
endfunction(generation_dbus_interface)
file(GLOB INTERFACES "interfaces/*.h")
add_definitions(-DCVERSION="${VERSION}")
#因为单元测试需要直接测试源代码,而主程序代码中include的单元使用了相对路径
#单元测试的CMakeLists和主程序的CMakeLists路径不同,编译单元测试时会提示找不到文件
#因此设置搜索路径
include_directories(
frame/accessible
frame/controller
frame/dbus
frame/dbus/sni
frame/display
frame/item
frame/item/components
frame/item/resources
frame/model
frame/util
frame/window
frame/window/components
frame/window/tray
frame/window/tray/widgets
frame/xcb
../widgets
../interfaces
)
aux_source_directory(frame/accessible ACCESSIBLE)
aux_source_directory(frame/controller CONTROLLER)
aux_source_directory(frame/dbus DBUS)
aux_source_directory(frame/dbus/sni SNI)
aux_source_directory(frame/display DISPLAY)
aux_source_directory(frame/item ITEM)
aux_source_directory(frame/model MODEL)
aux_source_directory(frame/item/components ITEMCOMPONENTS)
aux_source_directory(frame/item/resources RESOURCES)
aux_source_directory(frame/util UTIL)
aux_source_directory(frame/window WINDOW)
aux_source_directory(frame/window/components WINDOWCOMPONENTS)
aux_source_directory(frame/window/tray WINDOWTRAY)
aux_source_directory(frame/window/tray/widgets WINDOWTRAYWIDGET)
aux_source_directory(frame/xcb XCB)
file(GLOB SRC_PATH
${ACCESSIBLE}
${CONTROLLER}
${DBUS}
${SNI}
${DISPLAY}
${ITEM}
${MODEL}
${ITEMCOMPONENTS}
${UTIL}
${WINDOW}
${WINDOWCOMPONENTS}
${WINDOWTRAY}
${WINDOWTRAYWIDGET}
${XCB}
)
add_subdirectory("frame")
add_subdirectory("plugins")
#add_subdirectory("tests")
## qm files
file(GLOB QM_FILES "translations/*.qm")
install(FILES ${QM_FILES}
DESTINATION share/dde-dock/translations)
## dev files
install(FILES ${INTERFACES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dde-dock)
configure_file(dde-dock.pc.in dde-dock.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/dde-dock.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
configure_file(
${CMAKE_SOURCE_DIR}/cmake/DdeDock/DdeDockConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/DdeDockConfig.cmake
@ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/DdeDockConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DdeDock)
install(FILES gschema/com.deepin.dde.dock.module.gschema.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
#dconfig
file(GLOB DCONFIG_FILES "configs/*.json")
install(FILES ${DCONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/dde-dock/)
# Address Sanitizer 内存错误检测工具,打开下面的编译选项可以看到调试信息,正常运行时不需要这些信息
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O2")