cmake初级入门使用

一、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
)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值