CMakeLists.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ##################################
  2. # DEFINITION OF C++ PROJECT
  3. ##################################
  4. project(cpp-pcapreader)
  5. # Define CMake settings
  6. cmake_minimum_required(VERSION 3.2)
  7. IF(NOT CMAKE_BUILD_TYPE)
  8. SET(CMAKE_BUILD_TYPE "Release")
  9. ENDIF()
  10. IF (CMAKE_BUILD_TYPE MATCHES Debug)
  11. MESSAGE(STATUS "Running Debug configuration.")
  12. ELSEIF (CMAKE_BUILD_TYPE MATCHES Release)
  13. MESSAGE(STATUS "Running Release configuration.")
  14. ENDIF()
  15. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
  16. SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
  17. SET(CMAKE_CXX_STANDARD 11)
  18. SET(CMAKE_CXX_STANDARD_REQUIRED ON)
  19. # Add the library source files
  20. 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 cxx/utilities.h cxx/utilities.cpp)
  21. # Add botnet comm processor source files
  22. SET(BOT_COMM_PROC_SOURCE cxx/botnet_comm_processor.h cxx/botnet_comm_processor.cpp)
  23. # Add the debugging source files
  24. IF (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
  25. SET(DEBUG_FILES cxx/main.cpp cxx/pcap_processor.cpp cxx/pcap_processor.h cxx/statistics.cpp cxx/statistics.h cxx/statistics_db.cpp cxx/statistics_db.h cxx/utilities.h cxx/utilities.cpp)
  26. ENDIF ()
  27. # Include SQLiteCpp library and build it
  28. option(SQLITECPP_RUN_CPPLINT OFF)
  29. include_directories(SQLiteCpp/include)
  30. add_subdirectory(SQLiteCpp)
  31. # Include pybind11
  32. include_directories(pybind11/include)
  33. # Find libtins library
  34. FIND_LIBRARY(TINS_LIBRARY tins)
  35. IF(TINS_LIBRARY)
  36. MESSAGE(STATUS "Tins library found in ${TINS_LIBRARY}")
  37. ELSE()
  38. MESSAGE(FATAL_ERROR "Tins library not found.")
  39. ENDIF()
  40. FIND_PACKAGE(PythonLibs 3.0 REQUIRED)
  41. IF(PYTHONLIBS_FOUND)
  42. INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_DIRS}")
  43. MESSAGE(STATUS "Python includes found in: " ${PYTHON_INCLUDE_DIRS} )
  44. MESSAGE(STATUS "Python libs found in: " ${PYTHON_LIBRARIES} )
  45. ELSE()
  46. MESSAGE(FATAL_ERROR "Unable to find Python libraries.")
  47. ENDIF()
  48. SET_target_properties(sqlite3 PROPERTIES POSITION_INDEPENDENT_CODE ON)
  49. ADD_LIBRARY(pcapreader SHARED ${SOURCE_FILES})
  50. # Libs pthread and dl are prerequisites of SQLiteCpp
  51. TARGET_LINK_LIBRARIES(pcapreader "${TINS_LIBRARY}" ${PYTHON_LIBRARIES} SQLiteCpp sqlite3 pthread dl pcap)
  52. ADD_LIBRARY(botnetcomm SHARED ${BOT_COMM_PROC_SOURCE})
  53. TARGET_LINK_LIBRARIES(botnetcomm ${PYTHON_LIBRARIES})
  54. IF (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
  55. ADD_EXECUTABLE(main ${DEBUG_FILES})
  56. TARGET_LINK_LIBRARIES(main pcapreader ${PYTHON_LIBRARIES})
  57. ENDIF ()
  58. IF (APPLE)
  59. SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
  60. ENDIF ()
  61. # comment this out to build executable (for development)
  62. #ADD_EXECUTABLE(cpp-pcapreader ${SOURCE_FILES})
  63. #TARGET_LINK_LIBRARIES(cpp-pcapreader "${TINS_LIBRARY}" SQLiteCpp sqlite3 pthread dl)