boost 库CMakeLists.txt配置

环境:ubuntu14.04 64bit,这是在学习C++并发实战配置的。

cmake_minimum_required(VERSION 3.3)
project(Concurrent)

find_package(Boost REQUIRED COMPONENTS system thread)
include_directories( include ${Boost_INCLUDE_DIRS})
link_libraries( ${Boost_LIBRARIES})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
set(SOURCE_FILES main.cpp)

add_executable(Concurrent ${SOURCE_FILES})
#include <iostream>
#include <boost/thread.hpp>
#include <unistd.h>
#include <sys/syscall.h>

using namespace std;

void show()
{
    cout<<"hello world "<<syscall(SYS_gettid)<<endl;
}

int main() {
    cout << "Hello, World!" << endl;
    boost::thread t(show);
    cout<<"main thread"<<syscall(SYS_gettid)<<" "<<t.get_id()<<endl;

    if(!t.joinable())
    {
        cout<<"thread unjoined\n";
    }
    else
    {
        cout<<"thread joinable\n";
        t.join();
    }
    return 0;
}

你可能感兴趣的:(boost,Planner)