Skip to content

Commit

Permalink
Update CMakeLists.txt and update UI
Browse files Browse the repository at this point in the history
  • Loading branch information
paolostivanin committed Mar 13, 2024
1 parent fef9759 commit afbb18b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
48 changes: 33 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,35 @@ option(BUILD_GUI "Build the GTK UI" ON)
option(BUILD_CLI "Build the CLI" ON)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "-Wall -Wextra -O2 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong -Wundef -Wmissing-format-attribute")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2")
set(COMMON_C_FLAGS
"-Wall -Wextra -O3 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong"
"-Wundef -Wmissing-format-attribute -fdiagnostics-color=always"
"-Wstrict-prototypes -Wunreachable-code -Wchar-subscripts"
"-Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align"
"-Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare"
"-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
)

if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pie -fPIE")
list(APPEND COMMON_C_FLAGS "-pie -fPIE")
endif()

if(IS_FLATPAK)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIS_FLATPAK")
list(APPEND COMMON_C_FLAGS "-DIS_FLATPAK")
endif()

string(REPLACE ";" " " COMMON_C_FLAGS "${COMMON_C_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_C_FLAGS}")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(COMMON_LINKER_FLAGS
"-Wl,--no-add-needed -Wl,--as-needed -Wl,--no-undefined"
"-Wl,-z,relro,-z,now"
)

string(REPLACE ";" " " COMMON_LINKER_FLAGS "${COMMON_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${COMMON_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${COMMON_LINKER_FLAGS}")
endif()

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

install(TARGETS ${PROJECT_NAME} DESTINATION bin)

install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/applications)
install(FILES man/otpclient.1.gz DESTINATION share/man/man1)

install(FILES
set(GUI_UI_FILES
src/gui/ui/otpclient.ui
src/gui/ui/add_popover.ui
src/gui/ui/settings_popover.ui
src/gui/ui/shortcuts.ui
DESTINATION share/otpclient)

install(FILES man/otpclient.1.gz DESTINATION share/man/man1)
)
install(FILES ${GUI_UI_FILES} DESTINATION share/otpclient)

install(FILES
set(GUI_ICON_FILES
data/icons/com.github.paolostivanin.OTPClient.svg
data/icons/com.github.paolostivanin.OTPClient-symbolic.svg
DESTINATION share/icons/hicolor/scalable/apps)
)
install(FILES ${GUI_ICON_FILES} DESTINATION share/icons/hicolor/scalable/apps)
endif ()

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

install(TARGETS ${PROJECT_NAME}-cli DESTINATION bin)

install(FILES man/otpclient-cli.1.gz DESTINATION share/man/man1)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/gui/gui-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ decode_migration_data (const gchar *encoded_uri)
return NULL;
}
encoded_uri_copy += 33;
gsize out_len;
gsize out_len = 0;
gchar *unesc_str = g_uri_unescape_string_secure (encoded_uri_copy, NULL);
guchar *data = g_base64_decode_secure (unesc_str, &out_len);
gcry_free (unesc_str);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ui/otpclient.ui
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@
<property name="window-position">center</property>
<property name="type-hint">dialog</property>
<property name="gravity">center</property>
<property name="default-width">400</property>
<property name="default-height">200</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
Expand Down

0 comments on commit afbb18b

Please sign in to comment.