-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
169 lines (138 loc) · 4.44 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
#
# WireShark Dissectors to Support Debug/Development of the V2G
# protocols (ISO 15118) standards.
#
cmake_minimum_required(VERSION 3.14)
cmake_policy(SET CMP0048 NEW)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Please remove CMakeCache.txt and the CMakeFiles/ "
"directory then build out-of-source.")
endif()
# NOTE: The wireshark plugin build assumes major.minor.patch.tweak
project(wireshark-v2g VERSION 0.8.0.0)
# Set the default C/C++ standards
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
if(APPLE)
set(CMAKE_MACOSX_RPATH True)
set(CMAKE_SKIP_BUILD_RPATH False)
set(CMAKE_INSTALL_NAME_DIR "@rpath/")
set(CMAKE_BUILD_WITH_INSTALL_RPATH False)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH False)
endif()
# Add some cmake modules
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(BuildType)
# Add external dependencies (should be included first)
include(extern/dependencies.cmake)
set(DISSECTOR_SRC
src/packet-v2gexi.c
src/packet-v2gdin.c
src/packet-v2giso2.c
src/packet-v2giso20.c
src/packet-v2giso20_ac.c
src/packet-v2giso20_dc.c
)
set_source_files_properties(${DISSECTOR_SRC}
PROPERTIES
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
)
# Add the wireshark plugins
find_package(Wireshark)
if(Wireshark_FOUND)
message(STATUS "Wireshark found in ${Wireshark_LIB_DIR}")
if(NOT Wireshark_PLUGINS_ENABLED)
message(WARNING "Wireshark was compiled without support for plugins")
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${Wireshark_INSTALL_PREFIX}"
CACHE PATH "Installation prefix" FORCE)
endif()
# External plugins must define HAVE_SSIZE_T for the plugin toolchain.
include(CheckTypeSize)
check_type_size("ssize_t" SSIZE_T)
add_compile_definitions(
VERSION=\"${CMAKE_PROJECT_VERSION}\"
$<$<BOOL:${HAVE_SSIZE_T}>:HAVE_SSIZE_T>
)
add_compile_options(-Wall -Werror)
find_package(GLIB2 2.4.0)
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories(${Wireshark_INCLUDE_DIR})
link_directories(${Wireshark_LIB_DIR})
if(APPLE)
link_directories(/usr/local/lib)
endif(APPLE)
add_library(v2gexi MODULE
src/v2gplugin.c
${DISSECTOR_SRC}
)
set_target_properties(v2gexi
PROPERTIES
PREFIX ""
DEFINE_SYMBOL ""
LINK_FLAGS "${WS_LINK_FLAGS}"
FOLDER "Plugins"
)
target_link_libraries(v2gexi epan
cbv2g::din
cbv2g::iso2
cbv2g::iso20
${GLIB2_LIBRARY})
install(TARGETS v2gexi
LIBRARY DESTINATION "${Wireshark_PLUGIN_LIBDIR}/epan" NAMELINK_SKIP
)
install(FILES dissector/v2g.lua
DESTINATION "${Wireshark_PLUGIN_LIBDIR}/.." NAMELINK_SKIP
)
else(Wireshark_FOUND)
message(STATUS "In-tree Wireshark plug-in build")
include(WiresharkPlugin)
# Plugin name and version info (major minor micro extra)
set_module_info(v2gexi
${PROJECT_VERSION_MAJOR}
${PROJECT_VERSION_MINOR}
${PROJECT_VERSION_PATCH}
${PROJECT_VERSION_TWEAK}
)
set(PLUGIN_FILES
plugin.c
${DISSECTOR_SRC}
)
# Keep in sync with standalone build
register_plugin_files(plugin.c
plugin
${DISSECTOR_SRC}
)
add_wireshark_plugin_library(v2gexi epan)
target_link_libraries(v2gexi epan
cbv2g::din
cbv2g::iso2
cbv2g::iso20)
install_plugin(v2gexi epan)
install(FILES dissector/v2g.lua
DESTINATION ${PLUGIN_INSTALL_VERSION_LIBDIR}/epan NAMELINK_SKIP
)
if(APPLE)
add_custom_target(v2glua
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/dissector/v2g.lua
${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/PlugIns/wireshark
DEPENDS v2gexi
)
add_dependencies(plugins v2glua)
endif()
file(GLOB PLUGIN_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h")
CHECKAPI(
NAME
v2gexi
SWITCHES
-g abort -g termoutput
SOURCES
${DISSECTOR_SRC}
${DISSECTOR_HEADERS}
)
endif(Wireshark_FOUND)