一、1. 项目目录结构
我们项目的名称为qt转web项目,假设我们项目的所有文件存放再~/work/web
我们的目录结构如下:
~/web ├─ main.cpp converts.cpp dissector.cpp in_cksum.cpp lowpancmd.cpp packet-6lowpan.cpp packet-data.cpp packet-icmpv6.cpp packet-ieee802154.cpp packet-ipv6.cpp packet-udp.cpp packetdefcmd.cpp packetreceivecmd.cpp packetsendcmd.cpp performance_test_6lowwpan.cpp pipe.cpp pipe_read.cpp proto.cpp reassemble.cpp rplcmd.cpp sendcycle.cpp tclinterpreter.cpp treeitem.cpp tvbuff.cpp uip6cmd.cpp CMakeLists.txt
二、cmake文件代码
cmake_minimum_required (VERSION 2.6)
project (web)
#SET(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})
INCLUDE_DIRECTORIES(/usr/lib)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
SET(SRC_LIST main.cpp
converts.cpp
dissector.cpp
in_cksum.cpp
lowpancmd.cpp
packet-6lowpan.cpp
packet-data.cpp
packet-icmpv6.cpp
packet-ieee802154.cpp
packet-ipv6.cpp
packet-udp.cpp
packetdefcmd.cpp
packetreceivecmd.cpp
packetsendcmd.cpp
performance_test_6lowwpan.cpp
pipe.cpp
pipe_read.cpp
proto.cpp
reassemble.cpp
rplcmd.cpp
sendcycle.cpp
tclinterpreter.cpp
treeitem.cpp
tvbuff.cpp
uip6cmd.cpp
)
ADD_EXECUTABLE(web ${SRC_LIST})
TARGET_LINK_LIBRARIES(web -std=c++11)
INSTALL(TARGETS web
RUNTIME DESTINATION bin
)