@@ -15,16 +15,35 @@ option(BUILD_GUI "Build the GTK UI" ON)
15
15
option (BUILD_CLI "Build the CLI" ON )
16
16
17
17
set (CMAKE_C_STANDARD 11)
18
- set (CMAKE_C_FLAGS "-Wall -Wextra -O2 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong -Wundef -Wmissing-format-attribute" )
19
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code" )
20
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align" )
21
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare" )
22
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" )
18
+ set (COMMON_C_FLAGS
19
+ "-Wall -Wextra -O3 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong"
20
+ "-Wundef -Wmissing-format-attribute -fdiagnostics-color=always"
21
+ "-Wstrict-prototypes -Wunreachable-code -Wchar-subscripts"
22
+ "-Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align"
23
+ "-Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare"
24
+ "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
25
+ )
26
+
23
27
if (CMAKE_COMPILER_IS_GNUCC)
24
- set (CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -pie -fPIE" )
28
+ list ( APPEND COMMON_C_FLAGS " -pie -fPIE" )
25
29
endif ()
30
+
26
31
if (IS_FLATPAK)
27
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIS_FLATPAK" )
32
+ list (APPEND COMMON_C_FLAGS "-DIS_FLATPAK" )
33
+ endif ()
34
+
35
+ string (REPLACE ";" " " COMMON_C_FLAGS "${COMMON_C_FLAGS} " )
36
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_C_FLAGS} " )
37
+
38
+ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" )
39
+ set (COMMON_LINKER_FLAGS
40
+ "-Wl,--no-add-needed -Wl,--as-needed -Wl,--no-undefined"
41
+ "-Wl,-z,relro,-z,now"
42
+ )
43
+
44
+ string (REPLACE ";" " " COMMON_LINKER_FLAGS "${COMMON_LINKER_FLAGS} " )
45
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${COMMON_LINKER_FLAGS} " )
46
+ set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${COMMON_LINKER_FLAGS} " )
28
47
endif ()
29
48
30
49
add_definitions (-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE} \")
@@ -83,22 +102,22 @@ if(BUILD_GUI)
83
102
set_target_properties (${PROJECT_NAME} PROPERTIES OUTPUT_NAME "otpclient" )
84
103
85
104
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
86
-
87
105
install (FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/applications)
106
+ install (FILES man/otpclient.1.gz DESTINATION share/man/man1)
88
107
89
- install ( FILES
108
+ set (GUI_UI_FILES
90
109
src/gui/ui/otpclient.ui
91
110
src/gui/ui/add_popover.ui
92
111
src/gui/ui/settings_popover.ui
93
112
src/gui/ui/shortcuts.ui
94
- DESTINATION share/otpclient)
95
-
96
- install (FILES man/otpclient.1.gz DESTINATION share/man/man1)
113
+ )
114
+ install (FILES ${GUI_UI_FILES} DESTINATION share/otpclient)
97
115
98
- install ( FILES
116
+ set (GUI_ICON_FILES
99
117
data/icons/com.github.paolostivanin.OTPClient.svg
100
118
data/icons/com.github.paolostivanin.OTPClient-symbolic .svg
101
- DESTINATION share/icons/hicolor/scalable/apps)
119
+ )
120
+ install (FILES ${GUI_ICON_FILES} DESTINATION share/icons/hicolor/scalable/apps)
102
121
endif ()
103
122
104
123
if (BUILD_CLI)
@@ -109,7 +128,6 @@ if(BUILD_CLI)
109
128
set_target_properties (${PROJECT_NAME} -cli PROPERTIES OUTPUT_NAME "otpclient-cli" )
110
129
111
130
install (TARGETS ${PROJECT_NAME} -cli DESTINATION bin)
112
-
113
131
install (FILES man/otpclient-cli.1.gz DESTINATION share/man/man1)
114
132
endif ()
115
133
0 commit comments