我应该使用什么cmake命令将.mk文件包含在cmakelists.txt文件中

时间:2018-01-09 14:38:02

标签: c++ makefile cmake

我在我的linux机器上安装了c ++库pcapplusplus

它的构建系统是makefile而不是cmake。

它介绍了如何编译和应用程序,并在this页面的中间提供了这个makefile。

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

我为我的项目创建了一个cmaklists文件,位于下面。

我应该将哪个cmake命令用于makefile中的命令include /usr/local/etc/PcapPlusPlus.mk

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)

这是.mk文件的内容。

### 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

0 个答案:

没有答案