Skip to content

Commit

Permalink
Merge pull request #25 from scpeters/cpp11
Browse files Browse the repository at this point in the history
Use c++11 instead of boost
  • Loading branch information
scpeters committed Dec 18, 2015
2 parents 964a9a7 + 17e17d0 commit f375f48
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ compiler:
env:
- BUILD_TYPE=Debug
- BUILD_TYPE=RelWithDebInfo
install:
- sudo apt-get update -qq
- sudo apt-get install -qq -y libboost-system-dev libboost-thread-dev
script:
- mkdir build
- cd build
Expand Down
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ if (HAS_VISIBILITY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()

find_package(Boost COMPONENTS system thread REQUIRED)
if(NOT WIN32)
# 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 -Wall -Wextra")
endif()

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})
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION
${CONSOLE_BRIDGE_MAJOR_VERSION}.${CONSOLE_BRIDGE_MINOR_VERSION})

install(TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
Expand Down
10 changes: 6 additions & 4 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
/* Author: Ryan Luna, Ioan Sucan */

#include "console_bridge/console.h"
#include <boost/thread/mutex.hpp>
#include <iostream>

#include <cstdio>
#include <cstdarg>

#include <iostream>
#include <mutex>

/// @cond IGNORE

struct DefaultOutputHandler
Expand All @@ -55,7 +57,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
Expand All @@ -70,7 +72,7 @@ static DefaultOutputHandler* getDOH(void)

#define USE_DOH \
DefaultOutputHandler *doh = getDOH(); \
boost::mutex::scoped_lock slock(doh->lock_)
std::lock_guard<std::mutex> lock_guard(doh->lock_)

#define MAX_BUFFER_SIZE 1024

Expand Down

0 comments on commit f375f48

Please sign in to comment.