Skip to content

Commit afbb18b

Browse files
committed
Update CMakeLists.txt and update UI
1 parent fef9759 commit afbb18b

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

CMakeLists.txt

+33-15
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,35 @@ option(BUILD_GUI "Build the GTK UI" ON)
1515
option(BUILD_CLI "Build the CLI" ON)
1616

1717
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+
2327
if(CMAKE_COMPILER_IS_GNUCC)
24-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pie -fPIE")
28+
list(APPEND COMMON_C_FLAGS "-pie -fPIE")
2529
endif()
30+
2631
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}")
2847
endif()
2948

3049
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
@@ -83,22 +102,22 @@ if(BUILD_GUI)
83102
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "otpclient")
84103

85104
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
86-
87105
install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/applications)
106+
install(FILES man/otpclient.1.gz DESTINATION share/man/man1)
88107

89-
install(FILES
108+
set(GUI_UI_FILES
90109
src/gui/ui/otpclient.ui
91110
src/gui/ui/add_popover.ui
92111
src/gui/ui/settings_popover.ui
93112
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)
97115

98-
install(FILES
116+
set(GUI_ICON_FILES
99117
data/icons/com.github.paolostivanin.OTPClient.svg
100118
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)
102121
endif ()
103122

104123
if(BUILD_CLI)
@@ -109,7 +128,6 @@ if(BUILD_CLI)
109128
set_target_properties(${PROJECT_NAME}-cli PROPERTIES OUTPUT_NAME "otpclient-cli")
110129

111130
install(TARGETS ${PROJECT_NAME}-cli DESTINATION bin)
112-
113131
install(FILES man/otpclient-cli.1.gz DESTINATION share/man/man1)
114132
endif()
115133

src/gui/gui-misc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ decode_migration_data (const gchar *encoded_uri)
193193
return NULL;
194194
}
195195
encoded_uri_copy += 33;
196-
gsize out_len;
196+
gsize out_len = 0;
197197
gchar *unesc_str = g_uri_unescape_string_secure (encoded_uri_copy, NULL);
198198
guchar *data = g_base64_decode_secure (unesc_str, &out_len);
199199
gcry_free (unesc_str);

src/gui/ui/otpclient.ui

+2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@
265265
<property name="window-position">center</property>
266266
<property name="type-hint">dialog</property>
267267
<property name="gravity">center</property>
268+
<property name="default-width">400</property>
269+
<property name="default-height">200</property>
268270
<child internal-child="vbox">
269271
<object class="GtkBox">
270272
<property name="can-focus">False</property>

0 commit comments

Comments
 (0)