Skip to content

Commit

Permalink
feat(boost): add boost demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Akagi201 committed Mar 27, 2018
1 parent 056679e commit a811f01
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is a simple CMake tutorial project which contains some different scenarios.
* `hello-module`: Demo how to use cmake find module.
* `config-file`: Demo how to work with config.h.
* `hunter-simple`: Demo how to use hunter and gtest.
* `boost`: Demo how to use boost library.

## Build steps
* `cmake -H. -B_builds`
Expand Down
13 changes: 13 additions & 0 deletions boost/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
project(boost_demo)
cmake_minimum_required(VERSION 3.0)

find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_ALL_DYN_LINK ON)

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
15 changes: 15 additions & 0 deletions boost/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <cstdio>

int main(void) {
namespace pt = boost::posix_time;
pt::ptime now = pt::second_clock::local_time();

printf("%s\t->\t%04d-%02d-%02d %02d:%02d:%02d\n", "date '+%Y-%m-%d %H:%M:%S'",
(int)now.date().year(), (int)now.date().month(), (int)now.date().day(),
(int)now.time_of_day().hours(), (int)now.time_of_day().minutes(),
(int)now.time_of_day().seconds());

// getchar();
return 0;
}

0 comments on commit a811f01

Please sign in to comment.