From deb968d53a92c78b0da1331456f8c704614ace31 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Sun, 20 Sep 2015 00:47:02 -0700 Subject: [PATCH] Use c++11 instead of boost This package uses only a small amount of boost for a mutex and scoped_lock. These are replaced with std::mutex and std::lock_guard from c++11. Boost is removed as a dependency and the c++11 compiler flag is added. --- CMakeLists.txt | 11 +++-------- src/console.cpp | 6 +++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a07cfb..56c1bc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,26 +21,21 @@ if (HAS_VISIBILITY) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") endif() -find_package(Boost COMPONENTS system thread REQUIRED) +# Use c++11 compiler flag, since it's needed for console.cpp +# It isn't in a header file, so it doesn't need to be exported +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11") if(MSVC OR MSVC90 OR MSVC10) set(MSVC ON) endif (MSVC OR MSVC90 OR MSVC10) -if(MSVC) - add_definitions(-DBOOST_ALL_NO_LIB) -endif(MSVC) - include_directories(include) -include_directories(${Boost_INCLUDE_DIR}) -link_directories(${Boost_LIBRARY_DIRS}) if(NOT DEFINED BUILD_SHARED_LIBS) option(BUILD_SHARED_LIBS "Build dynamically-linked binaries" ON) endif() add_library(${PROJECT_NAME} src/console.cpp) -target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES}) install(TARGETS ${PROJECT_NAME} DESTINATION lib/) diff --git a/src/console.cpp b/src/console.cpp index 95920a5..fa808bb 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -35,7 +35,7 @@ /* Author: Ryan Luna, Ioan Sucan */ #include "console_bridge/console.h" -#include +#include #include #include #include @@ -55,7 +55,7 @@ struct DefaultOutputHandler console_bridge::OutputHandler *output_handler_; console_bridge::OutputHandler *previous_output_handler_; console_bridge::LogLevel logLevel_; - boost::mutex lock_; // it is likely the outputhandler does some I/O, so we serialize it + std::mutex lock_; // it is likely the outputhandler does some I/O, so we serialize it }; // we use this function because we want to handle static initialization correctly @@ -70,7 +70,7 @@ static DefaultOutputHandler* getDOH(void) #define USE_DOH \ DefaultOutputHandler *doh = getDOH(); \ - boost::mutex::scoped_lock slock(doh->lock_) + std::lock_guard slock(doh->lock_) #define MAX_BUFFER_SIZE 1024