forked from rtlabs-com/p-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
234 lines (193 loc) · 6.97 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
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
226
227
228
229
230
231
232
233
234
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# www.rt-labs.com
# Copyright 2018 rt-labs AB, Sweden.
#
# This software is dual-licensed under GPLv3 and a commercial
# license. See the file LICENSE.md distributed with this software for
# full license information.
#*******************************************************************/
cmake_minimum_required (VERSION 3.13)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
project (PROFINET VERSION 0.1.0)
include(CTest)
include(GenerateExportHeader)
include(CMakeDependentOption)
# Set required standard level
set (CMAKE_C_STANDARD 99)
set (CMAKE_CXX_STANDARD 11)
# Always use standard .o suffix
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
# Options. See options.h.in for more information.
option (BUILD_SHARED_LIBS "Build shared library" OFF)
option (PNET_OPTION_FAST_STARTUP "" ON)
option (PNET_OPTION_PARAMETER_SERVER "" ON)
option (PNET_OPTION_IR "" ON)
option (PNET_OPTION_SR "" ON)
option (PNET_OPTION_REDUNDANCY "" ON)
option (PNET_OPTION_AR_VENDOR_BLOCKS "" ON)
option (PNET_OPTION_RS "" ON)
option (PNET_OPTION_MC_CR "" ON)
option (PNET_OPTION_SRL "" OFF)
# TODO: this should be handled in cc.h
option (PNET_USE_ATOMICS "Enable use of atomic operations (stdatomic.h)" OFF)
set(PNET_MAX_AR 2
CACHE STRING "Number of connections. Must be > 0. 'Automated RT Tester' uses 2")
set(PNET_MAX_API 1
CACHE STRING "Number of Application Processes. Must be > 0")
set(PNET_MAX_CR 2
CACHE STRING "Per AR. 1 input and 1 output")
set(PNET_MAX_MODULES 5
CACHE STRING "Per API. Should be > 1 to allow at least one I/O module")
set(PNET_MAX_SUBMODULES 3
CACHE STRING "Per module (3 needed for DAP)")
set(PNET_MAX_CHANNELS 1
CACHE STRING "Per sub-slot. Used for diagnosis")
set(PNET_MAX_DFP_IOCR 2
CACHE STRING "Allowed values are 0 (zero) or 2")
set(PNET_MAX_PORT 1
CACHE STRING "2 for media redundancy. Currently only 1 is supported")
set(PNET_MAX_LOG_BOOK_ENTRIES 16
CACHE STRING "")
set(PNET_MAX_ALARMS 3
CACHE STRING "Per AR and queue. One queue for high and one for low priority alarms.")
set(PNET_MAX_DIAG_ITEMS 200
CACHE STRING "Total, per device. Max is 65534 items")
set(PNET_MAX_MC_CR 1
CACHE STRING "Par AR")
set(PNET_MAX_AR_VENDOR_BLOCKS 1
CACHE STRING "Must be > 0")
set(PNET_MAX_AR_VENDOR_BLOCK_DATA_LENGTH 512
CACHE STRING "")
set(PNET_MAX_MAN_SPECIFIC_FAST_STARTUP_DATA_LENGTH 0
CACHE STRING "or 512 (bytes")
set(PNET_MAX_SESSION_BUFFER_SIZE 4500
CACHE STRING "Max fragmented RPC request/response length")
set(PNET_MAX_DIRECTORYPATH_LENGTH 240
CACHE STRING "Max length of directory path, including termination")
set(PNET_MAX_FILENAME_LENGTH 30
CACHE STRING "Max length of filenames, including termination. Should be larger than the PNET_FILENAME_ constants.")
set(LOG_STATE_VALUES "ON;OFF")
set(LOG_LEVEL_VALUES "DEBUG;INFO;WARNING;ERROR")
set(LOG_LEVEL ERROR CACHE STRING "default log level")
set_property(CACHE LOG_LEVEL PROPERTY STRINGS ${LOG_LEVEL_VALUES})
set(PF_ETH_LOG ON CACHE STRING "pf_eth log")
set_property(CACHE PF_ETH_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PF_LLDP_LOG ON CACHE STRING "pf_lldp log")
set_property(CACHE PF_LLDP_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PF_CPM_LOG ON CACHE STRING "pf_cpm log")
set_property(CACHE PF_CPM_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PF_PPM_LOG ON CACHE STRING "pf_ppm log")
set_property(CACHE PF_PPM_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PF_DCP_LOG ON CACHE STRING "pf_dcp log")
set_property(CACHE PF_DCP_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PF_RPC_LOG ON CACHE STRING "pf_rpc log")
set_property(CACHE PF_RPC_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PF_ALARM_LOG ON CACHE STRING "pf_alarm log")
set_property(CACHE PF_ALARM_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PF_AL_BUF_LOG ON CACHE STRING "pf_alarm_buffer log")
set_property(CACHE PF_AL_BUF_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
set(PNET_LOG ON CACHE STRING "PNET log")
set_property(CACHE PNET_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
# Default to release build with debug info
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
message (STATUS "Current build type is: ${CMAKE_BUILD_TYPE}")
# Default to installing in build directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${PROFINET_BINARY_DIR}/install
CACHE PATH "Default install path" FORCE)
endif()
message(STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX}")
# Generate version numbers
configure_file (
version.h.in
${PROFINET_BINARY_DIR}/src/version.h
)
# Generate config options
configure_file (
options.h.in
${PROFINET_BINARY_DIR}/src/options.h
)
# Add platform-dependent targets early, so they can be configured by
# platform
add_library(profinet "")
add_executable(pn_dev "")
if (BUILD_TESTING)
add_executable(pf_test "")
endif()
# Platform configuration
include(${CMAKE_SYSTEM_NAME})
message (STATUS "Building for ${CMAKE_SYSTEM_NAME}")
generate_export_header(profinet
BASE_NAME pnet
EXPORT_FILE_NAME ${PROFINET_BINARY_DIR}/include/pnet_export.h
)
target_include_directories(profinet
PUBLIC
$<BUILD_INTERFACE:${PROFINET_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROFINET_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${PROFINET_BINARY_DIR}/src
src
src/common
src/device
)
install (
TARGETS profinet
EXPORT ProfinetConfig
DESTINATION lib
)
install(
EXPORT ProfinetConfig
DESTINATION cmake
)
install (FILES
include/pnet_api.h
${PROFINET_BINARY_DIR}/include/pnet_export.h
DESTINATION include
)
add_subdirectory (src)
add_subdirectory (sample_app)
if (BUILD_TESTING)
add_subdirectory (test)
include(AddGoogleTest)
add_gtest(pf_test)
endif()
# Doxygen configuration
cmake_policy(SET CMP0057 NEW)
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
set(DOXYGEN_TYPEDEF_HIDES_STRUCT YES)
set(DOXYGEN_STRIP_CODE_COMMENTS NO)
set(DOXYGEN_MACRO_EXPANSION YES)
set(DOXYGEN_EXPAND_ONLY_PREDEF YES)
set(DOXYGEN_PREDEFINED PNET_EXPORT)
set(DOXYGEN_EXPAND_AS_DEFINED PNET_EXPORT)
set(DOXYGEN_COLLABORATION_GRAPH NO)
set(DOXYGEN_INCLUDE_GRAPH NO)
set(DOXYGEN_INCLUDED_BY_GRAPH NO)
set(DOXYGEN_RECURSIVE NO)
set(DOXYGEN_GENERATE_XML YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
doxygen_add_docs(docs
README.md
include
src
)
endif (DOXYGEN_FOUND)
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE "${PROFINET_SOURCE_DIR}/LICENSE.md")
set (CPACK_PACKAGE_CONTACT [email protected])
include (CPack)