Skip to content

Commit 215bd32

Browse files
committed
[CMAKE] Switched to a CMake based project. Defined JSON Maker as a static library. Currently breaks: Examples, Tests, Makefile based build, CI.
Signed-off-by: Hatim-Pierre FAZILEABASSE <hatim-pierre.fazileabasse@ingenico.com>
1 parent 63cc948 commit 215bd32

File tree

9 files changed

+31
-8
lines changed

9 files changed

+31
-8
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake-build-*
2+
TODO.txt
3+
.idea
4+
**.swp
5+
**.orig

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(json-maker
4+
VERSION 1.1.0.0
5+
DESCRIPTION "JSON Maker is a C library used to code JSON objects in null-terminated strings."
6+
HOMEPAGE_URL "https://github.com/rafagafe/json-maker/blob/master/makefile"
7+
LANGUAGES C
8+
)
9+
10+
add_subdirectory(src)

makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11

22
CC = gcc
33
CFLAGS = -std=c99 -Wall -pedantic
4+
INC=-Isrc/include
45

5-
src = $(wildcard *.c)
6+
src = $(wildcard src/*.c test/src/*.c samples/*.c)
67
obj = $(src:.c=.o)
78
dep = $(obj:.o=.d)
89

@@ -12,19 +13,19 @@ clean:
1213
rm -rf *.d
1314
rm -rf *.o
1415
rm -rf *.exe
15-
16+
1617
all: clean build
1718

1819
test: test.exe
1920
./test.exe
20-
21+
2122
example.exe: example.o json-maker.o
2223
gcc -std=c99 -Wall -o example.exe example.o json-maker.o
2324

2425
test.exe: test.o json-maker.o
2526
gcc -std=c99 -Wall -o test.exe test.o json-maker.o
26-
27+
2728
-include $(dep)
2829

2930
%.d: %.c
30-
$(CC) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
31+
$(CC) $(CFLAGS) $(INC) $< -MM -MT $(@:.d=.o) >$@

example.c renamed to samples/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include <stdio.h>
2727
#include <stdlib.h>
28-
#include "json-maker.h"
28+
#include "json-maker/json-maker.h"
2929

3030
struct weather {
3131
int temp;

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_library(json_maker STATIC)
2+
3+
target_sources(json_maker PUBLIC json-maker.c)
4+
target_include_directories(json_maker PUBLIC include)
File renamed without changes.

json-maker.c renamed to src/json-maker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
#include <stddef.h> // For NULL
27-
#include "json-maker.h"
27+
#include "include/json-maker/json-maker.h"
2828

2929
/** Add a character at the end of a string.
3030
* @param dest Pointer to the null character of the string

test/src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_executable(json_maker_test test.c)
2+
3+
link_libraries(json_maker_test PRIVATE json_maker)

test.c renamed to test/src/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <string.h>
3232
#include <stdint.h>
3333
#include <limits.h>
34-
#include "json-maker.h"
34+
#include "json-maker/json-maker.h"
3535

3636
// ----------------------------------------------------- Test "framework": ---
3737

0 commit comments

Comments
 (0)