2007-08-31 11:51:34 +00:00
#
# VERMONT build scripts for CMake
# Copyright (C) 2007 Christoph Sommer <christoph.sommer@informatik.uni-erlangen.de>
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
PROJECT ( VERMONT )
### CMake configuration
# allow building with old CMake. Use some bundled modules as a fallback
CMAKE_MINIMUM_REQUIRED ( VERSION 2.3.5 )
SET ( CMAKE_MODULE_PATH ${ CMAKE_ROOT } /Modules ${ CMAKE_SOURCE_DIR } /cmake/modules )
# move some config clutter to the advanced section
MARK_AS_ADVANCED (
C M A K E _ B A C K W A R D S _ C O M P A T I B I L I T Y
C M A K E _ B U I L D _ T Y P E
C M A K E _ I N S T A L L _ P R E F I X
E X E C U T A B L E _ O U T P U T _ P A T H
L I B R A R Y _ O U T P U T _ P A T H
)
### basic modules
SUBDIRS ( common concentrator ipfixlolib sampler )
ADD_EXECUTABLE ( vermont
c o l l e c t o r _ c o n f i g u r a t i o n . c c
e x p o r t e r _ c o n f i g u r a t i o n . c c
m e t e r i n g _ c o n f i g u r a t i o n . c c
o b s e r v e r _ c o n f i g u r a t i o n . c c
v e r m o n t . c c
i p f i x _ c o n f i g u r a t i o n . c c
v e r m o n t m a i n _ c o n f i g u r a t i o n . c c
p a c k e t s e l e c t i o n _ c o n f i g u r a t i o n . c c
p a c k e t r e p o r t i n g _ c o n f i g u r a t i o n . c c
f l o w m e t e r i n g _ c o n f i g u r a t i o n . c c
d b w r i t e r _ c o n f i g u r a t i o n . c c
d b r e a d e r _ c o n f i g u r a t i o n . c c
)
INCLUDE_DIRECTORIES ( ${ VERMONT_SOURCE_DIR } )
INCLUDE_DIRECTORIES ( ${ VERMONT_SOURCE_DIR } /common )
INCLUDE_DIRECTORIES ( ${ VERMONT_SOURCE_DIR } /concentrator )
INCLUDE_DIRECTORIES ( ${ VERMONT_SOURCE_DIR } /ipfixlolib )
INCLUDE_DIRECTORIES ( ${ VERMONT_SOURCE_DIR } /sampler )
TARGET_LINK_LIBRARIES ( vermont
c o n c e n t r a t o r
s a m p l e r
i p f i x l o l i b
c o m m o n
)
INSTALL ( TARGETS vermont
R U N T I M E D E S T I N A T I O N b i n
)
INSTALL ( FILES README CONFIGURATION LICENSE
D E S T I N A T I O N s h a r e / d o c / v e r m o n t
)
INSTALL ( FILES ipfix-config-schema.xsd
D E S T I N A T I O N s h a r e / v e r m o n t
)
2007-09-06 19:02:01 +00:00
# INSTALL(DIRECTORY requires cmake 2.5
#INSTALL(DIRECTORY configs/
# DESTINATION share/vermont/configs
# PATTERN ".svn" EXCLUDE
#)
2007-08-31 11:51:34 +00:00
### doxygen
FIND_PACKAGE ( Doxygen REQUIRED )
### threads
FIND_PACKAGE ( Threads REQUIRED )
TARGET_LINK_LIBRARIES ( vermont
$ { C M A K E _ T H R E A D _ L I B S _ I N I T }
)
### boost
FIND_PACKAGE ( Boost REQUIRED )
MARK_AS_ADVANCED (
B o o s t _ I N C L U D E _ D I R
B o o s t _ R E G E X _ L I B R A R Y
B o o s t _ F I L E S Y S T E M _ L I B R A R Y
B o o s t _ U N I T _ T E S T _ F R A M E W O R K _ L I B R A R Y
)
IF ( Boost_FOUND )
MESSAGE ( STATUS "Found boost libraries" )
ADD_DEFINITIONS ( -DHAVE_BOOST_FILESYSTEM )
INCLUDE_DIRECTORIES ( ${ Boost_INCLUDE_DIRS } )
FIND_LIBRARY ( Boost_REGEX_LIBRARY NAMES boost_regex-mt boost_regex PATHS ${ Boost_LIBRARY_DIRS } )
2008-01-08 09:46:54 +00:00
IF ( NOT Boost_REGEX_LIBRARY )
MESSAGE ( FATAL_ERROR "Could not find boost regex library" )
ENDIF ( NOT Boost_REGEX_LIBRARY )
2007-08-31 11:51:34 +00:00
FIND_LIBRARY ( Boost_FILESYSTEM_LIBRARY NAMES boost_filesystem-mt boost_filesystem PATHS ${ Boost_LIBRARY_DIRS } )
2008-01-08 09:46:54 +00:00
IF ( NOT Boost_FILESYSTEM_LIBRARY )
MESSAGE ( FATAL_ERROR "Could not find boost filesystem library" )
ENDIF ( NOT Boost_FILESYSTEM_LIBRARY )
2007-08-31 11:51:34 +00:00
FIND_LIBRARY ( Boost_UNIT_TEST_FRAMEWORK_LIBRARY NAMES boost_unit_test_framework-mt boost_unit_test_framework PATHS ${ Boost_LIBRARY_DIRS } )
2008-01-08 09:46:54 +00:00
IF ( NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY )
MESSAGE ( FATAL_ERROR "Could not find boost unit test framework" )
ENDIF ( NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY )
2007-08-31 11:51:34 +00:00
TARGET_LINK_LIBRARIES ( vermont
$ { B o o s t _ R E G E X _ L I B R A R Y }
$ { B o o s t _ F I L E S Y S T E M _ L I B R A R Y }
)
ELSE ( Boost_FOUND )
MESSAGE ( FATAL_ERROR "Could not find boost libraries" )
REMOVE_DEFINITIONS ( -DHAVE_BOOST_FILESYSTEM )
ENDIF ( Boost_FOUND )
### libxml2
FIND_PACKAGE ( LibXml2 REQUIRED )
MARK_AS_ADVANCED (
L I B X M L 2 _ I N C L U D E _ D I R
L I B X M L 2 _ L I B R A R I E S
)
IF ( LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES )
MESSAGE ( STATUS "Found libxml2 libraries" )
INCLUDE_DIRECTORIES ( ${ LIBXML2_INCLUDE_DIR } )
TARGET_LINK_LIBRARIES ( vermont
$ { L I B X M L 2 _ L I B R A R I E S }
)
ELSE ( LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES )
MESSAGE ( FATAL_ERROR "Could not find libxml2 libraries" )
ENDIF ( LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES )
### debug
OPTION ( DEBUG "Enable debug code. Vermont will run significantly slower if enabled." OFF )
IF ( DEBUG )
message ( STATUS "Configuring build process for debug version" )
REMOVE_DEFINITIONS ( -O3 )
ADD_DEFINITIONS ( -O0 -g -pg -Wall -Werror -DDEBUG )
ELSE ( DEBUG )
REMOVE_DEFINITIONS ( -O0 -g -pg -Wall -Werror -DDEBUG )
ADD_DEFINITIONS ( -O3 )
ENDIF ( DEBUG )
### IP_HEADER_OFFSET
SET ( IP_HEADER_OFFSET 14 CACHE STRING "Start position of the IP header in an ethernet frame in Bytes. This value needs to be adjusted according to the network monitored. The default value is 14 for ethernet devices. Other common values are 4 (BSD loop back device) and 18 (Ethernet VLAN)" )
ADD_DEFINITIONS ( -DIP_HEADER_OFFSET= ${ IP_HEADER_OFFSET } )
2007-09-05 12:12:07 +00:00
### PCAP_MAX_CAPTURE_LENGTH
SET ( PCAP_MAX_CAPTURE_LENGTH 128 CACHE STRING "Maximum PCAP packet capture length (this amount of bytes is always allocated for each packet, the smaller the better!)" )
ADD_DEFINITIONS ( -DPCAP_MAX_CAPTURE_LENGTH= ${ PCAP_MAX_CAPTURE_LENGTH } )
2007-08-31 11:51:34 +00:00
### SUPPORT_NETFLOWV9
OPTION ( SUPPORT_NETFLOWV9 "Enable NetFlow version 9 support" ON )
IF ( SUPPORT_NETFLOWV9 )
ADD_DEFINITIONS ( -DSUPPORT_NETFLOWV9 )
ELSE ( SUPPORT_NETFLOWV9 )
REMOVE_DEFINITIONS ( -DSUPPORT_NETFLOWV9 )
ENDIF ( SUPPORT_NETFLOWV9 )
### MySQL
OPTION ( SUPPORT_MYSQL "Enable dbwriter/dbreader support" ON )
IF ( SUPPORT_MYSQL )
FIND_PACKAGE ( MySQL REQUIRED )
MARK_AS_ADVANCED (
M Y S Q L _ A D D _ I N C L U D E _ D I R
M Y S Q L _ A D D _ L I B R A R Y
M Y S Q L _ C O N F I G
M Y S Q L _ C O N F I G _ P R E F E R _ P A T H
)
2007-08-31 12:46:18 +00:00
IF ( NOT MYSQL_FOUND )
MESSAGE ( STATUS "Could not find MySQL libraries. Disabling dbwriter/dbreader support." )
ENDIF ( NOT MYSQL_FOUND )
2007-08-31 11:51:34 +00:00
ENDIF ( SUPPORT_MYSQL )
2007-08-31 12:46:18 +00:00
IF ( MYSQL_FOUND )
MESSAGE ( STATUS "Found MySQL libraries" )
ADD_DEFINITIONS ( -DDB_SUPPORT_ENABLED )
INCLUDE_DIRECTORIES ( ${ MYSQL_INCLUDE_DIR } )
TARGET_LINK_LIBRARIES ( vermont
$ { M Y S Q L _ L I B R A R I E S }
)
ELSE ( MYSQL_FOUND )
REMOVE_DEFINITIONS ( -DDB_SUPPORT_ENABLED )
ENDIF ( MYSQL_FOUND )
2007-08-31 11:51:34 +00:00
### libpcap-mmap
OPTION ( USE_PCAPMMAP "Use libpcap-mmap." OFF )
MARK_AS_ADVANCED (
P C A P _ L I B R A R Y _ R E G U L A R
P C A P _ L I B R A R Y _ M M A P
)
2007-09-03 10:18:07 +00:00
2007-08-31 11:51:34 +00:00
IF ( USE_PCAPMMAP )
2007-09-03 10:18:07 +00:00
FIND_LIBRARY ( PCAP_LIBRARY_MMAP NAMES pcap pcap-mmap PATHS ${ VERMONT_SOURCE_DIR } ${ VERMONT_SOURCE_DIR } /../libpcap-mmap ${ VERMONT_SOURCE_DIR } /../../../trunk/libpcap-mmap NO_DEFAULT_PATH )
SET ( PCAP_LIBRARY "${PCAP_LIBRARY_MMAP}" )
IF ( PCAP_LIBRARY_MMAP )
SET ( PCAP_LIBRARY "${PCAP_LIBRARY_MMAP}" )
ELSE ( PCAP_LIBRARY_MMAP )
MESSAGE ( FATAL_ERROR "Could not find libpcap-mmap" )
ENDIF ( PCAP_LIBRARY_MMAP )
2007-08-31 11:51:34 +00:00
ELSE ( USE_PCAPMMAP )
2007-09-03 10:18:07 +00:00
FIND_LIBRARY ( PCAP_LIBRARY_REGULAR NAMES pcap )
IF ( PCAP_LIBRARY_REGULAR )
SET ( PCAP_LIBRARY "${PCAP_LIBRARY_REGULAR}" )
ELSE ( PCAP_LIBRARY_REGULAR )
MESSAGE ( FATAL_ERROR "Could not find libpcap" )
ENDIF ( PCAP_LIBRARY_REGULAR )
2007-08-31 11:51:34 +00:00
ENDIF ( USE_PCAPMMAP )
TARGET_LINK_LIBRARIES ( vermont ${ PCAP_LIBRARY } )
### tools
OPTION ( WITH_TOOLS "Build misc tools." ON )
IF ( WITH_TOOLS )
SUBDIRS ( tools )
ELSE ( WITH_TOOLS )
ENDIF ( WITH_TOOLS )
### tests
OPTION ( WITH_TESTS "Build unit tests." ON )
IF ( WITH_TESTS )
SUBDIRS ( tests )
ELSE ( WITH_TESTS )
ENDIF ( WITH_TESTS )