2

I've installed the c++ library pcapplusplus on my linux machine.

Its build system is makefiles and not cmake.

It describes how to compile and an app and provides this makefile about half way down this page.

include /usr/local/etc/PcapPlusPlus.mk

# All Target
all:
    g++ $(PCAPPP_INCLUDES) -c -o main.o main.cpp
    g++ $(PCAPPP_LIBS_DIR) -static-libstdc++ -o Tutorial-HelloWorld main.o $(PCAPPP_LIBS)

# Clean Target
clean:
    rm main.o
    rm Tutorial-HelloWorld

I've created a cmaklists file for my project which is below.

Which cmake command should I use for the command include /usr/local/etc/PcapPlusPlus.mkthat is in the makefile.

cmake_minimum_required(VERSION 2.8.9)
project(networksniffer)
# The version number.
set (networksniffer_VERSION_MAJOR 1)
set (networksniffer_VERSION_MINOR 0)
 
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(PROJECT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)

# The following folder will be included
include_directories("/usr/local/include/pcapplusplus")

#add_executable(networksniffer ${SOURCES})
add_executable(networksniffer ${PROJECT_SOURCE_DIR}/networksniffer.cpp)

target_link_libraries(${PROJECT_NAME} libCommon++.a libPacket++.a libPcap++.a)

This is the contents of .mk file.

### COMMON ###

# includes
PCAPPP_INCLUDES := -I/usr/local/include/pcapplusplus


# libs
PCAPPP_LIBS := -lPcap++ -lPacket++ -lCommon++

# post build
PCAPPP_POST_BUILD :=

# build flags
PCAPPP_BUILD_FLAGS :=

### LINUX ###

# includes
PCAPPP_INCLUDES += -I/usr/include/netinet

# libs
PCAPPP_LIBS += -lpcap -lpthread
seladb
  • 852
  • 1
  • 13
  • 29
netleap tom
  • 143
  • 4
  • 10
  • What are the contents of `/usr/local/etc/PcapPlusPlus.mk` – drescherjm Jan 09 '18 at 14:41
  • @drescherjm I've included the contents in my original post, many thanks – netleap tom Jan 09 '18 at 14:48
  • Now that I see the contents I don't believe you need any of it. You have already added the include directory and set the libraries. – drescherjm Jan 09 '18 at 14:51
  • 4
    Use the `PcapPlusPlus.mk` file as a "template", and translate it into CMake commands that you put in your `CMakeLists.txt` file. – Some programmer dude Jan 09 '18 at 14:52
  • 2
    And to answer your question: Remember that CMake is a generic project and build generator. It can generate different types of output files without knowing beforehand what it is. That means it can't really put arbitrary data in those generated output files. Therefore there are no such commands. – Some programmer dude Jan 09 '18 at 14:53

0 Answers0