-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
135 lines (108 loc) · 4.8 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
cmake_minimum_required(VERSION 3.14)
set(CMAKE_C_FLAGS_DEBUG_INIT
"-Wall -Wextra -Wpedantic -Wformat=2 -Wno-unused-parameter -Wshadow \
-Wwrite-strings -Wstrict-prototypes -Wold-style-definition \
-Wredundant-decls -Wnested-externs -Wmissing-include-dirs \
-Wjump-misses-init -Wlogical-op -fsanitize=address")
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-Wall -g -O0 -fsanitize=address")
set(CMAKE_C_FLAGS_RELEASE_INIT "-Wall")
# library declaration
project(cschc
VERSION 1.0.0
DESCRIPTION "C implementation of Static Context Header Compression (SCHC), RFC 8724"
LANGUAGES C
)
include_directories(
${PROJECT_SOURCE_DIR}/include/
${PROJECT_SOURCE_DIR}/include/utils/
${PROJECT_SOURCE_DIR}/include/protocols/
${PROJECT_SOURCE_DIR}/include/core/
)
add_library(cschc
# Utils
${PROJECT_SOURCE_DIR}/source/utils/log.c
${PROJECT_SOURCE_DIR}/source/utils/binary.c
${PROJECT_SOURCE_DIR}/source/utils/memory.c
# Headers
${PROJECT_SOURCE_DIR}/source/protocols/headers.c
# Core
${PROJECT_SOURCE_DIR}/source/core/rule_descriptor.c
${PROJECT_SOURCE_DIR}/source/core/rule_field_descriptor.c
${PROJECT_SOURCE_DIR}/source/core/matching_operators.c
${PROJECT_SOURCE_DIR}/source/core/actions.c
${PROJECT_SOURCE_DIR}/source/core/context.c
${PROJECT_SOURCE_DIR}/source/core/compression.c
${PROJECT_SOURCE_DIR}/source/core/decompression.c
)
add_executable(main ${PROJECT_SOURCE_DIR}/source/main.c)
target_link_libraries(main PUBLIC cschc)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
# Tests
enable_testing()
# - Binary
add_executable(test-binary ${PROJECT_SOURCE_DIR}/test/test_binary.c)
target_link_libraries(test-binary PRIVATE cschc)
add_test(NAME test-binary COMMAND $<TARGET_FILE:test-binary>)
# - Memory
add_executable(test-memory ${PROJECT_SOURCE_DIR}/test/test_memory.c)
target_link_libraries(test-memory PRIVATE cschc)
add_test(NAME test-memory COMMAND $<TARGET_FILE:test-memory>)
# - Headers
add_executable(test-headers ${PROJECT_SOURCE_DIR}/test/test_headers.c)
target_link_libraries(test-headers PRIVATE cschc)
add_test(NAME test-headers COMMAND $<TARGET_FILE:test-headers>)
# - Rule Descriptor
add_executable(test-rule-descriptor ${PROJECT_SOURCE_DIR}/test/test_rule_descriptor.c)
target_link_libraries(test-rule-descriptor PRIVATE cschc)
add_test(NAME test-rule-descriptor COMMAND $<TARGET_FILE:test-rule-descriptor>)
# - Rule Field Descriptor
add_executable(test-rule-field-descriptor ${PROJECT_SOURCE_DIR}/test/test_rule_field_descriptor.c)
target_link_libraries(test-rule-field-descriptor PRIVATE cschc)
add_test(NAME test-rule-field-descriptor COMMAND $<TARGET_FILE:test-rule-field-descriptor>)
# - Matching Operators
add_executable(test-matching-operators ${PROJECT_SOURCE_DIR}/test/test_matching_operators.c)
target_link_libraries(test-matching-operators PRIVATE cschc)
add_test(NAME test-matching-operators COMMAND $<TARGET_FILE:test-matching-operators>)
# - Compression Decompression Actions
add_executable(test-comp-decomp-actions ${PROJECT_SOURCE_DIR}/test/test_actions.c)
target_link_libraries(test-comp-decomp-actions PRIVATE cschc)
add_test(NAME test-comp-decomp-actions COMMAND $<TARGET_FILE:test-comp-decomp-actions>)
# - Compression
add_executable(test-compression ${PROJECT_SOURCE_DIR}/test/test_compression.c)
target_link_libraries(test-compression PRIVATE cschc)
add_test(NAME test-compression COMMAND $<TARGET_FILE:test-compression>)
# - Decompression
add_executable(test-decompression ${PROJECT_SOURCE_DIR}/test/test_decompression.c)
target_link_libraries(test-decompression PRIVATE cschc)
add_test(NAME test-decompression COMMAND $<TARGET_FILE:test-decompression>)
endif()
# documentation
find_package( Doxygen )
if ( DOXYGEN_FOUND )
set( DOXYGEN_OUTPUT_DIRECTORY doxygen )
set( DOXYGEN_COLLABORATION_GRAPH YES )
set( DOXYGEN_EXTRACT_ALL YES )
set( DOXYGEN_CLASS_DIAGRAMS YES )
set( DOXYGEN_HIDE_UNDOC_RELATIONS NO )
set( DOXYGEN_HAVE_DOT YES )
set( DOXYGEN_CLASS_GRAPH YES )
set( DOXYGEN_CALL_GRAPH YES )
set( DOXYGEN_CALLER_GRAPH YES )
set( DOXYGEN_COLLABORATION_GRAPH YES )
set( DOXYGEN_BUILTIN_STL_SUPPORT YES )
set( DOXYGEN_EXTRACT_PRIVATE YES )
set( DOXYGEN_EXTRACT_PACKAGE YES )
set( DOXYGEN_EXTRACT_STATIC YES )
set( DOXYGEN_EXTRACT_LOCALMETHODS YES )
set( DOXYGEN_UML_LOOK YES )
set( DOXYGEN_UML_LIMIT_NUM_FIELDS 50 )
set( DOXYGEN_TEMPLATE_RELATIONS YES )
set( DOXYGEN_DOT_GRAPH_MAX_NODES 100 )
set( DOXYGEN_MAX_DOT_GRAPH_DEPTH 0 )
set( DOXYGEN_DOT_TRANSPARENT YES )
doxygen_add_docs( doxygen ${PROJECT_SOURCE_DIR}/source
${PROJECT_SOURCE_DIR}/include
)
else()
message( "Doxygen need to be installed to generate the doxygen documentation" )
endif()