Add boost example (#70)

* add unit tests

* added boost

* cleanup

* add pthread

* Update README.md
This commit is contained in:
Lars Melchior
2019-07-01 20:30:21 +02:00
committed by GitHub
parent 1e8d8d43c7
commit 25a9158448
4 changed files with 59 additions and 1 deletions

View File

@@ -130,6 +130,17 @@ CPMAddPackage(
)
```
### [Boost (via boost-cmake)](https://github.com/Orphis/boost-cmake)
```CMake
CPMAddPackage(
NAME boost-cmake
GITHUB_REPOSITORY Orphis/boost-cmake
VERSION 1.67.0
)
```
### [google/benchmark](https://github.com/google/benchmark)
```cmake

View File

@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# ---- Create binary ----
add_executable(CPMExampleBoost main.cpp)
set_target_properties(CPMExampleBoost PROPERTIES CXX_STANDARD 17)
# ---- Dependencies ----
include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME boost
GITHUB_REPOSITORY Orphis/boost-cmake
VERSION 1.67.0
)
target_link_libraries(CPMExampleBoost PRIVATE Boost::system pthread)

30
examples/boost/main.cpp Normal file
View File

@@ -0,0 +1,30 @@
//
// timer.cpp
// ~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
void print(const boost::system::error_code& /*e*/)
{
std::cout << "Hello, world!" << std::endl;
}
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(1));
t.async_wait(&print);
io.run();
return 0;
}

View File

@@ -10,5 +10,4 @@ foreach(test ${tests})
NAME ${test}
COMMAND ${CMAKE_COMMAND} -DCPM_PATH=${CMAKE_CURRENT_SOURCE_DIR}/../cmake -P "${test}"
)
endforeach()