Cleaning: Fixes #115, Enable strict compiler options in CMake

This commit is contained in:
Rory Fewell
2022-03-22 22:32:06 +00:00
parent 17382009d9
commit eadb283718
23 changed files with 371 additions and 235 deletions

View File

@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.0)
project(wintc-comgtk VERSION 1.0 DESCRIPTION "Windows Total Conversion common GLib/GTK utilities.")
project(
wintc-comgtk
VERSION 1.0
DESCRIPTION "Windows Total Conversion common GLib/GTK utilities."
)
include(GNUInstallDirs)
@@ -18,15 +22,8 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(
${GLIB_INCLUDE_DIRS}
${GTK3_INCLUDE_DIRS})
link_directories(
${GLIB_LIBRARY_DIRS}
${GTK3_LIBRARY_DIRS})
add_library(wintc-comgtk
add_library(
wintc-comgtk
src/debug.h
src/errors.c
src/errors.h
@@ -43,24 +40,52 @@ add_library(wintc-comgtk
src/styles.c
src/styles.h
src/window.c
src/window.h)
src/window.h
)
set_target_properties(wintc-comgtk PROPERTIES
set_target_properties(
wintc-comgtk
PROPERTIES
PUBLIC_HEADER public/wintc-comgtk.h
SOVERSION 1
VERSION ${PROJECT_VERSION})
VERSION ${PROJECT_VERSION}
)
configure_file(../debian-control.in debian-control @ONLY)
configure_file(wintc-comgtk.pc.in wintc-comgtk.pc @ONLY)
configure_file(public/wintc-comgtk.h wintc-comgtk.h COPYONLY)
target_compile_options(
wintc-comgtk
PRIVATE -Wall -Wextra -Wpedantic -Werror
)
target_link_libraries(wintc-comgtk
target_include_directories(
wintc-comgtk
SYSTEM
PRIVATE ${GLIB_INCLUDE_DIRS}
PRIVATE ${GTK3_INCLUDE_DIRS}
)
target_link_directories(
wintc-comgtk
PRIVATE ${GLIB_LIBRARY_DIRS}
PRIVATE ${GTK3_LIBRARY_DIRS}
)
target_link_libraries(
wintc-comgtk
PRIVATE ${GLIB_LIBRARIES}
PRIVATE ${GTK3_LIBRARIES})
PRIVATE ${GTK3_LIBRARIES}
)
install(TARGETS wintc-comgtk
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
configure_file(../debian-control.in debian-control @ONLY)
configure_file(wintc-comgtk.pc.in wintc-comgtk.pc @ONLY)
configure_file(public/wintc-comgtk.h wintc-comgtk.h COPYONLY)
install(FILES ${CMAKE_BINARY_DIR}/wintc-comgtk.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
install(
TARGETS wintc-comgtk
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES ${CMAKE_BINARY_DIR}/wintc-comgtk.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig
)

View File

@@ -16,6 +16,8 @@
#define WINTC_SAFE_REF_CLEAR(ref) if (ref != NULL) { *ref = NULL; }
#define WINTC_SAFE_REF_SET(ref, value) if (ref != NULL) { *ref = value; }
#define WINTC_UNUSED(arg) __attribute__((unused)) arg
//
// gchar-related
//
@@ -121,7 +123,7 @@ gint wintc_strstr_count(
const gchar* needle
);
gboolean wintc_strsteal(
void wintc_strsteal(
gchar** dest,
gchar** src
);

View File

@@ -94,7 +94,7 @@ gchar* wintc_list_implode_strings(
g_string_append_printf(
str,
"%s",
iter->data
(gchar*) iter->data
);
first = FALSE;
@@ -104,7 +104,7 @@ gchar* wintc_list_implode_strings(
g_string_append_printf(
str,
"\n%s",
iter->data
(gchar*) iter->data
);
}
@@ -159,7 +159,7 @@ GList* wintc_list_read_from_string(
lines = g_strsplit(str, "\n", -1);
count = g_strv_length(lines);
for (int i = 0; i < count; i++)
for (guint i = 0; i < count; i++)
{
list =
g_list_append(

View File

@@ -4,4 +4,6 @@
#define WINTC_SAFE_REF_CLEAR(ref) if (ref != NULL) { *ref = NULL; }
#define WINTC_SAFE_REF_SET(ref, value) if (ref != NULL) { *ref = value; }
#define WINTC_UNUSED(arg) __attribute__((unused)) arg
#endif

View File

@@ -11,9 +11,9 @@ gint wintc_strstr_count(
const gchar* needle
)
{
gint advance = strlen(needle);
gint count;
gchar* pchar = haystack;
gint advance = strlen(needle);
gint count;
const gchar* pchar = haystack;
while (pchar != NULL)
{
@@ -29,7 +29,7 @@ gint wintc_strstr_count(
return count;
}
gboolean wintc_strsteal(
void wintc_strsteal(
gchar** dest,
gchar** src
)
@@ -49,16 +49,16 @@ gchar* wintc_strsubst(
const gchar* replacewith
)
{
gchar* buffer;
gint findsize = strlen(findwhat);
gint replacecount = wintc_strstr_count(str, findwhat);
gint replacesize = strlen(replacewith);
gchar* pbuffer;
gchar* pchar = str;
gchar* pnext = NULL;
gint required;
gint strsize = strlen(str);
gint tocopy;
gchar* buffer;
gint findsize = strlen(findwhat);
gint replacecount = wintc_strstr_count(str, findwhat);
gint replacesize = strlen(replacewith);
gchar* pbuffer;
const gchar* pchar = str;
const gchar* pnext = NULL;
gint required;
gint strsize = strlen(str);
gint tocopy;
// Work out how much space we need
//

View File

@@ -11,7 +11,7 @@ gint wintc_strstr_count(
const gchar* needle
);
gboolean wintc_strsteal(
void wintc_strsteal(
gchar** dest,
gchar** src
);