-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathCMakeLists.txt
144 lines (120 loc) · 3.42 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
# CMakeLists.txt
#
# $Id: CMakeLists.txt 31995 2010-02-24 22:32:10Z jmayer $
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <[email protected]>
# Copyright 1998 Gerald Combs
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
project(whatsapp C CXX)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_BACKWARDS_COMPATIBILITY 2.6)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
IF(EXISTS /usr/lib/wireshark/libwireshark1/plugins/)
set(CMAKE_INSTALL_LIBDIR /usr/lib/wireshark/libwireshark1/plugins/)
ELSE()
set(CMAKE_INSTALL_LIBDIR ~/.wireshark)
ENDIF()
INCLUDE(UseMakeDissectorReg)
include(CMakeForceCompiler)
set(GLIB2_MIN_VERSION 2.4.0)
IF(NOT DEFINED ENV{GLIB2_INCLUDE_DIRS})
find_package(GLIB2)
ELSE()
SET(GLIB2_INCLUDE_DIRS $ENV{GLIB2_INCLUDE_DIRS})
ENDIF()
include_directories (${GLIB2_INCLUDE_DIRS})
IF(NOT DEFINED WIRESHARK_INCLUDE_DIRS)
find_package(Wireshark)
ELSE()
SET(GLIB2_INCLUDE_DIRS $ENV{WIRESHARK_INCLUDE_DIRS})
ENDIF()
include_directories (${WIRESHARK_INCLUDE_DIRS})
IF(DEFINED WIRESHARK_LIB_DIR)
link_directories (${WIRESHARK_LIB_DIR})
ENDIF()
IF(NOT DEFINED GCRYPT_INCLUDE_DIR)
find_package(Gcrypt)
ELSE()
SET(GLIB2_INCLUDE_DIRS $ENV{GCRYPT_INCLUDE_DIR})
ENDIF()
include_directories (${GCRYPT_INCLUDE_DIR})
set(LINK_MODE_LIB SHARED)
set(LINK_MODE_MODULE MODULE)
set(DISSECTOR_SRC
packet-whatsapp.c
whatsapp-proto.cc
tinfl.c
)
set(PLUGIN_FILES
plugin.c
${DISSECTOR_SRC}
)
set(CLEAN_FILES
${PLUGIN_FILES}
)
if (WERROR)
set_source_files_properties(
${CLEAN_FILES}
PROPERTIES
COMPILE_FLAGS -Werror
)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
register_dissector_files(plugin.c
plugin
${DISSECTOR_SRC}
)
add_library(whatsapp ${LINK_MODE_MODULE}
${PLUGIN_FILES}
)
set_target_properties(whatsapp PROPERTIES PREFIX "")
set_target_properties(whatsapp PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
IF(DEFINED MANUAL_LINK)
target_link_libraries(whatsapp)
ELSE()
target_link_libraries(whatsapp wireshark gcrypt glib-2.0)
ENDIF()
install(TARGETS whatsapp
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins NAMELINK_SKIP
)
IF(DEFINED GNU_HOST)
CMAKE_FORCE_C_COMPILER( ${GNU_HOST}-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(${GNU_HOST}-g++ GNU)
set(CMAKE_STRIP "${GNU_HOST}-strip")
ENDIF()
IF(DEFINED STATIC_GCC_BUILD)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
ENDIF()
if (WIN32)
if(MINGW)
message(STATUS "Compiling with MINGW!")
# Static link
set(CMAKE_MODULE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -lpthread")
endif(MINGW)
endif (WIN32)
if (WIN32)
add_custom_command(TARGET whatsapp
POST_BUILD
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded whatsapp.dll
)
ELSE()
add_custom_command(TARGET whatsapp
POST_BUILD
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded whatsapp.so
)
ENDIF()