cmake学习使用笔记

cmake 引用boost库


project(forcoroutine) cmake_minimum_required(VERSION 2.8)
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(BOOST_ROOT "/opt/boost_1_60_0")
find_package(Boost REQUIRED COMPONENTS filesystem system coroutine)

if(NOT Boost_FOUND)
  message(FATAL_ERROR "未发现Boost")
endif()
include_directories(${Boost_INCLUDE_DIRS})


aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})


target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})







你可能感兴趣的:(cmake学习使用笔记)