Skip to content

Commit b70f1bd

Browse files
committed
Support CMake.
1 parent de3e866 commit b70f1bd

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

CMakeLists.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(json-parser VERSION 1.5.2)
3+
4+
set(CMAKE_C_STANDARD 99)
5+
set(CMAKE_C_STANDARD_REQUIRED ON)
6+
set(CMAKE_C_EXTENSIONS OFF)
7+
8+
if(NOT CMAKE_BUILD_TYPE)
9+
set(CMAKE_BUILD_TYPE "Release")
10+
endif()
11+
12+
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
13+
set(CMAKE_C_FLAGS_RELEASE "-O2")
14+
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
15+
set(CMAKE_C_FLAGS_MINSIZEREL "-Os")
16+
17+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
18+
19+
message(STATUS "Using C compiler: ${CMAKE_C_COMPILER_ID}")
20+
message(STATUS "Compiler path: ${CMAKE_C_COMPILER}")
21+
22+
add_library(json-parser STATIC
23+
json_parser.c
24+
)
25+
26+
add_executable(parse_json
27+
test.c
28+
)
29+
30+
target_link_libraries(parse_json json-parser)
31+
32+
add_executable(test_speed
33+
test_speed.c
34+
)
35+
36+
target_link_libraries(test_speed json-parser)

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
CFLAGS = -g -Wall -std=c99
1+
CFLAGS = -std=c99 -Wall
22
ifeq ($(DEBUG), y)
3-
CFLAGS += -O0
3+
CFLAGS += -O0 -g
44
else
55
CFLAGS += -O2
66
endif
7-
CC = gcc
8-
LD = gcc
7+
8+
LD = cc
99

1010
all: test_speed parse_json
1111

0 commit comments

Comments
 (0)