-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
225 lines (205 loc) · 6.7 KB
/
CMakeLists.txt
File metadata and controls
225 lines (205 loc) · 6.7 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
cmake_minimum_required(VERSION 3.15)
set(FLEXPTP_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src/flexptp)
# Hardware port selection
set(FLEXPTP_HWPORT_OK 1)
if (FLEXPTP_HWPORT MATCHES "^H74[35]_LWIP$")
set(FLEXPTP_HWPORT_SRC
port/example_ports/ptp_port_stm32h743_lwip.c
port/example_ports/ptp_port_stm32h743_lwip.h
)
set(FLEXPTP_HWPORT_BASE "H743_LWIP")
elseif(FLEXPTP_HWPORT MATCHES "^H74[35]_ETHERLIB$")
set(FLEXPTP_HWPORT_SRC
port/example_ports/ptp_port_stm32h743_etherlib.c
port/example_ports/ptp_port_stm32h743_etherlib.h
)
set(FLEXPTP_HWPORT_BASE "H743_ETHERLIB")
elseif(FLEXPTP_HWPORT MATCHES "^F[47][0-9][0-9]_LWIP$") # STM32F4xx
set(FLEXPTP_HWPORT_SRC
port/example_ports/ptp_port_stm32f407_lwip.c
port/example_ports/ptp_port_stm32f407_lwip.h
)
set(FLEXPTP_HWPORT_BASE "F407_LWIP")
elseif(FLEXPTP_HWPORT MATCHES "^F[47][0-9][0-9]_ETHERLIB$")
set(FLEXPTP_HWPORT_SRC
port/example_ports/ptp_port_stm32f407_etherlib.c
port/example_ports/ptp_port_stm32f407_etherlib.h
)
set(FLEXPTP_HWPORT_BASE "F407_ETHERLIB")
elseif(FLEXPTP_HWPORT STREQUAL "CH32F207_ETHERLIB")
set(FLEXPTP_HWPORT_SRC
port/example_ports/ptp_port_ch32f207_etherlib.c
port/example_ports/ptp_port_ch32f207_etherlib.h
)
set(FLEXPTP_HWPORT_BASE "CH32F207_ETHERLIB")
elseif(FLEXPTP_HWPORT STREQUAL "TM4C1294_LWIP")
set(FLEXPTP_HWPORT_SRC
port/example_ports/ptp_port_tiva_tm4c1294.c
port/example_ports/ptp_port_tiva_tm4c1294.h
)
set(FLEXPTP_HWPORT_BASE "TM4C1294_LWIP")
elseif(FLEXPTP_HWPORT STREQUAL "LINUX")
set(FLEXPTP_HWPORT_SRC
port/example_ports/ptp_port_linux.c
port/example_ports/ptp_port_linux.h
)
set(FLEXPTP_HWPORT_BASE "LINUX")
else()
set(FLEXPTP_HWPORT_OK 0)
endif()
if (FLEXPTP_HWPORT_OK)
message("flexPTP: '" ${FLEXPTP_HWPORT} "' hardware port selected")
if (NOT FLEXPTP_HWPORT STREQUAL FLEXPTP_HWPORT_BASE)
message("flexPTP: hardware port is automatically derived from '${FLEXPTP_HWPORT_BASE}'")
endif()
list(TRANSFORM FLEXPTP_HWPORT_SRC PREPEND "${FLEXPTP_SRC_DIR}/")
else()
if (FLEXPTP_HWPORT_SRC)
message("flexPTP: custom hardware port defined")
else()
message("flexPTP: Unknown or undefined hardware port: '" ${FLEXPTP_HWPORT} "', "
"please populate FLEXPTP_HWPORT_SRC with the files of your custom "
"hardware port or pick a predefined one!")
endif()
endif()
# Selecting Network Stack Driver
set(FLEXPTP_NSD_OK 1)
if (FLEXPTP_NSD STREQUAL "LWIP")
set(FLEXPTP_NSD_SRC
port/example_netstack_drivers/nsd_lwip.c
)
set(FLEXPTP_NETWORK_STACK lwipcore)
elseif(FLEXPTP_NSD STREQUAL "ETHERLIB")
set(FLEXPTP_NSD_SRC
port/example_netstack_drivers/nsd_etherlib.c
)
set(FLEXPTP_NETWORK_STACK etherlib)
elseif (FLEXPTP_NSD STREQUAL "LINUX")
set(FLEXPTP_NSD_SRC
port/example_netstack_drivers/nsd_linux.c
port/example_netstack_drivers/nsd_linux.h
)
set(FLEXPTP_NETWORK_STACK)
else()
set(FLEXPTP_NSD_OK 0)
endif()
if (FLEXPTP_NSD_OK)
message("flexPTP: '" ${FLEXPTP_NSD} "' network stack driver selected")
list(TRANSFORM FLEXPTP_NSD_SRC PREPEND "${FLEXPTP_SRC_DIR}/")
else()
if (FLEXPTP_NSD_SRC)
message("flexPTP: custom network stack driver defined")
else()
message("flexPTP: Unknown or undefined network stack driver: '" ${FLEXPTP_NSD} "', "
"please populate FLEXPTP_NSD_SRC with the files of your custom network stack "
"driver and FLEXPTP_NETWORK_STACK with the name of the custom network stack "
"library or pick a predefined one!")
endif()
endif()
# Selecting the Servo
set(FLEXPTP_SERVO_OK 1)
if (FLEXPTP_SERVO STREQUAL "PID")
set(FLEXPTP_SERVO_SRC
servo/pid_controller.c
servo/pid_controller.h)
elseif (FLEXPTP_SERVO STREQUAL "KALMAN")
set(FLEXPTP_SERVO_SRC
servo/kalman_filter.c
servo/kalman_filter.h)
elseif (FLEXPTP_SERVO STREQUAL "DEBUG")
set(FLEXPTP_SERVO_SRC
servo/debug_servo.c
servo/debug_servo.h)
else()
set(FLEXPTP_SERVO_OK 0)
endif()
if (FLEXPTP_SERVO_OK)
message("flexPTP: '" ${FLEXPTP_SERVO} "' clock servo selected")
list(TRANSFORM FLEXPTP_SERVO_SRC PREPEND "${FLEXPTP_SRC_DIR}/")
else()
if (NOT FLEXPTP_SERVO_SRC)
message("flexPTP: WARNING! No clock servo defined! If this is a mistake, then "
"populate FLEXPTP_SERVO_SRC with the list of the clock servo module.")
endif()
endif()
# Customizing compile target
set(FLEXPTP_TARGET flexptp)
if (FLEXPTP_TARGET_TAG)
set(FLEXPTP_TARGET "${FLEXPTP_TARGET}_${FLEXPTP_TARGET_TAG}")
message("Custom flexPTP target: ${FLEXPTP_TARGET}")
endif()
set(FLEXPTP_SRC
cli_cmds.c
cli_cmds.h
clock_utils.c
clock_utils.h
common.c
common.h
config.c
config.h
critical.h
event.c
event.h
format_utils.c
format_utils.h
logging.c
logging.h
master.c
master.h
msg_buf.c
msg_buf.h
msg_utils.c
msg_utils.h
network_stack_driver.h
profiles.c
profiles.h
ptp_core.c
ptp_core.h
ptp_defs.c
ptp_defs.h
ptp_profile_presets.c
ptp_profile_presets.h
ptp_servo_types.h
ptp_sync_cycle_data.h
ptp_types.h
bmca.c
bmca.h
servo
settings_interface.c
settings_interface.h
slave.c
slave.h
stats.c
stats.h
task_ptp.c
task_ptp.h
timeutils.c
timeutils.h
tlv.c
tlv.h
port/osless/fifo.c
port/osless/fifo.h
)
list(TRANSFORM FLEXPTP_SRC PREPEND "${FLEXPTP_SRC_DIR}/")
list(APPEND FLEXPTP_SRC ${FLEXPTP_HWPORT_SRC} ${FLEXPTP_NSD_SRC} ${FLEXPTP_SERVO_SRC})
set(FLEXPTP_LOCAL_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/src)
set(FLEXPTP_INCLUDE_EXPORT ${FLEXPTP_LOCAL_INCLUDES} PARENT_SCOPE) # Export the location of the flexPTP headers
add_library(${FLEXPTP_TARGET} STATIC ${FLEXPTP_SRC})
target_include_directories(${FLEXPTP_TARGET} PRIVATE ${FLEXPTP_INCLUDES} ${FLEXPTP_LOCAL_INCLUDES})
target_compile_options(${FLEXPTP_TARGET} PRIVATE ${FLEXPTP_CPU_PARAMS})
target_compile_definitions(${FLEXPTP_TARGET} PRIVATE ${FLEXPTP_COMPILE_DEFS})
target_link_libraries(${FLEXPTP_TARGET} m)
if (FLEXPTP_NETWORK_STACK)
message("flexPTP: linking against '" ${FLEXPTP_NETWORK_STACK} "' network library")
if (NOT FLEXPTP_DONT_LINK_NETWORK_LIB)
target_link_libraries(${FLEXPTP_TARGET} ${FLEXPTP_NETWORK_STACK})
endif()
elseif()
message("flexPTP: No network stack defined to link against! "
"Please set FLEXPTP_NETWORK_STACK to a chosen network stack library!")
endif()
add_custom_target(
flexptp-docs
COMMAND doxygen
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)