-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
104 lines (75 loc) · 2.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
cmake_minimum_required(VERSION 3.10)
project (alpha0 LANGUAGES C)
include(GNUInstallDirs)
enable_testing()
set(ALPHA0_SOURCES
./src/rbuf.c
./src/udict.c
./src/json2/j2dynstr.c
./src/json2/j2parse.c
./src/json2/j2print.c
./src/json2/j2value.c
./contrib/mur32.c
./src/prefixkv/pkvpair.c
./src/prefixkv/prefixkv16.c
./src/prefixkv/prfpriv.h
./src/prefixkv/prefixkv.c
)
set(CMAKE_C_STANDARD 99)
add_library(alpha0 STATIC ${ALPHA0_SOURCES})
if(ALPHA0_CHECK_COVERAGE)
target_compile_options(alpha0 PUBLIC
--coverage
)
endif(ALPHA0_CHECK_COVERAGE)
target_include_directories(alpha0 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS alpha0 EXPORT alpha0-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ./include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT alpha0-config DESTINATION share/cmake)
export(TARGETS alpha0 FILE alpha0-config.cmake)
add_executable(rbuf-udict-test test/rbuf-udict-test.c)
target_link_libraries(rbuf-udict-test PRIVATE
alpha0
)
if(ALPHA0_CHECK_COVERAGE)
target_link_libraries(rbuf-udict-test PRIVATE
--coverage
)
endif(ALPHA0_CHECK_COVERAGE)
add_test(NAME rbuf-udict-test COMMAND ./rbuf-udict-test)
add_executable(json2-test
test/json2-test.c
test/j2parser-test.c
test/j2printer-test.c
contrib/CuTest.c)
target_include_directories(json2-test PRIVATE
./contrib
)
target_link_libraries(json2-test PRIVATE
alpha0
)
if(ALPHA0_CHECK_COVERAGE)
target_link_libraries(json2-test PRIVATE
--coverage
)
endif(ALPHA0_CHECK_COVERAGE)
add_test(NAME json2-test COMMAND ./json2-test)
add_executable(js-valid
test/js-valid.c
)
target_link_libraries(js-valid PRIVATE
alpha0
)
if(ALPHA0_CHECK_COVERAGE)
target_link_libraries(js-valid PRIVATE
--coverage
)
endif(ALPHA0_CHECK_COVERAGE)
add_test(NAME js-valid
COMMAND ./js-valid ${CMAKE_CURRENT_SOURCE_DIR}/share/sample.jsn)