Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ option(USE_OPTIONAL "Enable the _Optional qualifier" OFF)
option(USE_FORTIFY "Enable Fortify memory-allocation checking" OFF)
option(ENABLE_CLANG_TIDY "Run clang-tidy during compilation" OFF)

FetchContent_Declare(CBUtil GIT_REPOSITORY https://github.com/chrisbazley/CBUtilLib.git GIT_TAG main)

FetchContent_MakeAvailable(CBUtil)

if(USE_OPTIONAL)
if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang")
message(FATAL_ERROR
Expand Down Expand Up @@ -78,13 +82,7 @@ set_target_properties(GKey PROPERTIES
DEBUG_POSTFIX "dbg"
)

if(USE_OPTIONAL)
FetchContent_Declare(CBUtil GIT_REPOSITORY https://github.com/chrisbazley/CBUtilLib.git GIT_TAG main)

FetchContent_MakeAvailable(CBUtil)

target_link_libraries(GKey PRIVATE CBUtil)
endif()
target_link_libraries(GKey PRIVATE CBUtil)

target_include_directories(GKey PUBLIC .)

Expand Down
14 changes: 3 additions & 11 deletions Internal/GKeyMisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
/* History:
CJB: 08-Apr-25: Dogfooding the _Optional qualifier.
CJB: 15-Jun-26: Send the debug log to stderr not stdout.
CJB: 22-Sep-26: Use common macro definitions from CBUtilLib.
*/

#ifndef GKeyMisc_h
#define GKeyMisc_h

#include "MacroUtils.h"

#ifdef FORTIFY
#include "fortify.h"
#endif
Expand Down Expand Up @@ -58,15 +61,4 @@
#define _Optional
#endif

#define LOWEST(a, b) ((a) < (b) ? (a) : (b))

#define FREE_SAFE(memptr) do { \
free(memptr); \
(memptr) = NULL; \
} while (0)

#define NOT_USED(x) ((void)(x))

#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))

#endif /* GKeyMisc_h */
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ files with .c and .h suffixes into subdirectories named 'c' and 'h' and
remove those suffixes from their names. You probably also need to create
'o', 'oz', 'd' and 'debug' subdirectories for compiler output.

You should ensure that the standard C library and CBDebugLib (by the same
author as GKeyLib) are on your header include path (C$Path if using the
supplied make files on RISC OS), otherwise the compiler won't be able to find
the required header files. The dependency on CBDebugLib isn't very strong: it
can be eliminated by modifying the make file so that the macro USE_CBDEBUG is
no longer predefined.
You should ensure that the standard C library, CBUtilLib and CBDebugLib (by
the same author as GKeyLib) are on your header include path (C$Path if using
the supplied make files on RISC OS), otherwise the compiler won't be able to
find the required header files. The dependency on CBDebugLib isn't very strong:
it can be eliminated by modifying the make file so that the macro USE_CBDEBUG
is no longer predefined.

Licence and disclaimer
----------------------
Expand Down
6 changes: 1 addition & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ file(GLOB SOURCES "*.c")
file(GLOB PRIVATE_HEADERS "*.h")

add_executable(GKeyTests ${SOURCES} ${PRIVATE_HEADERS})
target_link_libraries(GKeyTests PRIVATE GKey)
target_link_libraries(GKeyTests PRIVATE GKey CBUtil)
add_test(NAME "GKeyTests" COMMAND GKeyTests)

if(USE_OPTIONAL)
target_link_libraries(GKeyTests PRIVATE CBUtil)
endif()
5 changes: 2 additions & 3 deletions tests/Tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#undef NDEBUG

#include "MacroUtils.h"

#ifdef FORTIFY
#include "fortify.h"
#else
Expand Down Expand Up @@ -50,9 +52,6 @@
#define _Optional
#endif

#define NOT_USED(x) ((void)(x))
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))

extern void GKeyComp_tests(void);
extern void GKeyDecomp_tests(void);
extern void RingBuffer_tests(void);
Expand Down
Loading