CMakeLists.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ##################################
  2. # DEFINITION OF C++ PROJECT
  3. ##################################
  4. project(cpp-pcapreader)
  5. # Define CMake settings
  6. cmake_minimum_required(VERSION 3.5)
  7. IF (CMAKE_BUILD_TYPE MATCHES Debug)
  8. MESSAGE(STATUS "Running DEBUG configuration. Skipping library generation.")
  9. ELSEIF (CMAKE_BUILD_TYPE MATCHES Release)
  10. MESSAGE(STATUS "Running RELEASE configuration. Creating library..")
  11. ENDIF()
  12. #IF(NOT CMAKE_BUILD_TYPE)
  13. # SET(CMAKE_BUILD_TYPE "DEBUG")
  14. #ENDIF()
  15. set(CMAKE_CXX_STANDARD 11)
  16. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  17. # Add source files and build executable cpp-pcapreader
  18. set(SOURCE_FILES cxx/pcap_processor.cpp cxx/pcap_processor.h cxx/statistics.cpp cxx/statistics.h cxx/statistics_db.cpp cxx/statistics_db.h)
  19. # Include SQLiteCpp library and build it
  20. include_directories(SQLiteCpp/include)
  21. add_subdirectory(SQLiteCpp)
  22. # Find libtins library and link it to the executable cpp-pcapreader
  23. # Libs pthread and dl are prerequisites for SQLiteCpp
  24. FIND_LIBRARY(TINS_LIBRARY tins)
  25. # Find and configure BOOST library
  26. FIND_PACKAGE(Boost 1.54.0)
  27. IF (Boost_FOUND AND TINS_LIBRARY)
  28. INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" "/usr/include/python3.4m/")
  29. SET(Boost_USE_STATIC_LIBS OFF)
  30. SET(Boost_USE_MULTITHREADED ON)
  31. SET(Boost_USE_STATIC_RUNTIME OFF)
  32. FIND_PACKAGE(Boost 1.54.0 COMPONENTS "python-py34")
  33. ADD_EXECUTABLE(cpp-pcapreader ${SOURCE_FILES})
  34. ADD_LIBRARY(pcapreader SHARED ${SOURCE_FILES})
  35. # link it to the executable cpp-pcapreader
  36. # Libs pthread and dl are prerequisites for SQLiteCpp
  37. TARGET_LINK_LIBRARIES(pcapreader ${Boost_LIBRARIES} "${TINS_LIBRARY}" SQLiteCpp sqlite3 pthread dl)
  38. TARGET_LINK_LIBRARIES(cpp-pcapreader ${Boost_LIBRARIES} "${TINS_LIBRARY}" SQLiteCpp sqlite3 pthread dl)
  39. ELSE ()
  40. MESSAGE(FATAL_ERROR "Unable to find correct Boost version and/or Libtins library")
  41. ENDIF ()
  42. # Check if GNUCXX compiler is configured
  43. set_target_properties(sqlite3 PROPERTIES POSITION_INDEPENDENT_CODE ON)
  44. IF(CMAKE_COMPILER_IS_GNUCXX)
  45. ADD_DEFINITIONS("-Wall")
  46. #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1") ## Optimize
  47. ELSE()
  48. MESSAGE(FATAL_ERROR "CMakeLists.txt has not been tested...")
  49. ENDIF()