forked from linuxdeepin/dde-dock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
130 lines (108 loc) · 3.94 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
cmake_minimum_required(VERSION 3.7)
if (NOT DEFINED VERSION)
set(VERSION 4.0)
endif()
project(dde-dock)
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 14)
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)
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()
file(GLOB INTERFACES "interfaces/*.h")
#因为单元测试需要直接测试源代码,而主程序代码中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/util
frame/window
frame/window/components
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/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/xcb XCB)
file(GLOB SRC_PATH
${ACCESSIBLE}
${CONTROLLER}
${DBUS}
${SNI}
${DISPLAY}
${ITEM}
${ITEMCOMPONENTS}
${UTIL}
${WINDOW}
${WINDOWCOMPONENTS}
${XCB}
)
add_subdirectory("frame")
add_subdirectory("plugins")
add_subdirectory("tests")
# Install settings
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
## 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_SOURCE_DIR}/cmake/DdeDock/DdeDockConfig.cmake
@ONLY)
install(FILES "cmake/DdeDock/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)
# Address Sanitizer 内存错误检测工具,打开下面的编译选项可以看到调试信息,正常运行时不需要这些信息
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O2")