diff --git a/CMakeLists.txt b/CMakeLists.txt index b96dc68..9a1f496 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,11 @@ PROJECT(beanstalkpp) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +FIND_PACKAGE( Boost COMPONENTS system filesystem regex iostreams REQUIRED ) +link_directories(${Boost_LIBRARY_DIR}) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ) +INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} ) ADD_LIBRARY( beanstalkpp SHARED tokenizedstream.cpp serverexception.cpp exception.cpp client.cpp job.cpp @@ -13,29 +17,32 @@ ADD_LIBRARY( ADD_EXECUTABLE( test test.cpp ) -TARGET_LINK_LIBRARIES(test boost_iostreams boost_system beanstalkpp boost_regex pthread) +TARGET_LINK_LIBRARIES(test ${Boost_LIBRARIES} beanstalkpp pthread) ADD_EXECUTABLE( beansreserve beansreserve.cpp ) -TARGET_LINK_LIBRARIES(beansreserve boost_iostreams boost_system beanstalkpp boost_regex pthread) +TARGET_LINK_LIBRARIES(beansreserve ${Boost_LIBRARIES} beanstalkpp pthread) ADD_EXECUTABLE( beansput beansput.cpp ) -TARGET_LINK_LIBRARIES(beansput boost_iostreams boost_system beanstalkpp boost_regex pthread) +TARGET_LINK_LIBRARIES(beansput ${Boost_LIBRARIES} beanstalkpp pthread) ADD_EXECUTABLE( listtubes listtubes.cpp ) -TARGET_LINK_LIBRARIES(listtubes boost_iostreams boost_system beanstalkpp boost_regex pthread) +TARGET_LINK_LIBRARIES(listtubes ${Boost_LIBRARIES} beanstalkpp pthread) ADD_EXECUTABLE( beanspeek beanspeek.cpp ) -TARGET_LINK_LIBRARIES(beanspeek boost_iostreams boost_system beanstalkpp boost_regex pthread) +TARGET_LINK_LIBRARIES(beanspeek ${Boost_LIBRARIES} beanstalkpp pthread) INSTALL(TARGETS beanstalkpp DESTINATION lib) +if(APPLE) + set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") +endif(APPLE) INSTALL(DIRECTORY . DESTINATION include/beanstalk++ FILES_MATCHING PATTERN "*.h" PATTERN "beanstalkpp.h" EXCLUDE PATTERN "*~" EXCLUDE PATTERN "*.git*" EXCLUDE PATTERN "*build*" EXCLUDE) INSTALL(FILES "beanstalkpp.h" DESTINATION include) diff --git a/client.cpp b/client.cpp index 6fdec57..e0fa78a 100644 --- a/client.cpp +++ b/client.cpp @@ -126,8 +126,9 @@ bool Beanstalkpp::Client::peekReady(Beanstalkpp::job_p_t& jobPtr) { job_id_t jobId; size_t payloadSize; char *payload; + std::stringstream s("peek-ready\r\n"); - this->sendCommand(std::stringstream("peek-ready\r\n")); + this->sendCommand(s); std::string response = this->tokenStream.nextString(); if(response.compare("NOT_FOUND") == 0) { @@ -197,8 +198,9 @@ size_t Beanstalkpp::Client::watch(const std::string& tube) { vector< string > Beanstalkpp::Client::listTubes() { vector ret; + stringstream s("list-tubes\r\n"); - this->sendCommand(stringstream("list-tubes\r\n")); + this->sendCommand(s); this->tokenStream.expectString("OK"); size_t payloadSize = this->tokenStream.expectInt(); diff --git a/client.h b/client.h index a09c32b..edc31c0 100644 --- a/client.h +++ b/client.h @@ -91,8 +91,9 @@ class Client { job_id_t jobId; size_t payloadSize; char *payload; - - this->sendCommand(std::stringstream("reserve\r\n")); + std::stringstream s("reserve\r\n"); + + this->sendCommand(s); this->tokenStream.expectString("RESERVED"); jobId = this->tokenStream.expectInt();