Skip to content
This repository was archived by the owner on Apr 6, 2019. It is now read-only.

Commit 66c9d84

Browse files
authored
Make tacopie optional and remove install_deps.sh (#58)
* download deps from cmakelist * remove install-deps from travis * update tacopie ref * fix windows compilation * update tacopie ref * make network module optional - update ref to tacopie
1 parent 599085b commit 66c9d84

File tree

8 files changed

+51
-37
lines changed

8 files changed

+51
-37
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ before_install:
2727

2828
install:
2929
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
30-
- ./install_deps.sh
3130
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install redis; fi
3231
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then (redis-server&); fi
3332

CMakeLists.txt

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
###
2626
cmake_minimum_required(VERSION 2.8.7)
2727
set(CMAKE_MACOSX_RPATH 1)
28+
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
2829

2930

3031
###
@@ -51,7 +52,7 @@ IF (WIN32)
5152

5253
IF ("${MSVC_RUNTIME_LIBRARY_CONFIG}" STREQUAL "")
5354
set(MSVC_RUNTIME_LIBRARY_CONFIG "/MT")
54-
ENDIF()
55+
ENDIF()
5556

5657
foreach (flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE)
5758
IF ("${MSVC_RUNTIME_LIBRARY_CONFIG}" STREQUAL "/MT")
@@ -75,20 +76,17 @@ ENDIF (WIN32)
7576
###
7677
# variables
7778
###
78-
# gtest
79-
set(GTEST_INCLUDES ${PROJECT_SOURCE_DIR}/deps/src/googletest/googletest/include)
80-
# cpp_redis
8179
set(CPP_REDIS_INCLUDES ${PROJECT_SOURCE_DIR}/includes)
82-
# tacopie
83-
set(TACOPIE_FOLDER ${PROJECT_SOURCE_DIR}/tacopie)
84-
set(TACOPIE_INCLUDES ${TACOPIE_FOLDER}/includes)
85-
80+
set(DEPS_INCLUDES ${PROJECT_SOURCE_DIR}/deps/include)
81+
set(DEPS_LIBRARIES ${PROJECT_SOURCE_DIR}/deps/lib)
82+
IF ("${USE_TACOPIE}" STREQUAL "")
83+
set(USE_TACOPIE "true")
84+
ENDIF ()
8685

8786
###
8887
# includes
8988
###
90-
include_directories(${CPP_REDIS_INCLUDES}
91-
${TACOPIE_INCLUDES})
89+
include_directories(${CPP_REDIS_INCLUDES} ${DEPS_INCLUDES})
9290

9391

9492
###
@@ -104,6 +102,10 @@ foreach(dir ${SRC_DIRS})
104102
# set sources
105103
set(SOURCES ${SOURCES} ${s_${dir}} ${h_${dir}} ${i_${dir}})
106104
endforeach()
105+
# filter tcp_client if no tacopie
106+
IF (NOT USE_TACOPIE)
107+
list(REMOVE_ITEM SRC_DIRS "source/network/tcp_client.cpp" "include/cpp_redis/network/tcp_client.hpp")
108+
ENDIF (NOT USE_TACOPIE)
107109

108110

109111
###
@@ -140,6 +142,11 @@ IF (LOGGING_ENABLED)
140142
set_target_properties(${PROJECT} PROPERTIES COMPILE_DEFINITIONS "__CPP_REDIS_LOGGING_ENABLED=${LOGGING_ENABLED}")
141143
ENDIF (LOGGING_ENABLED)
142144

145+
# __CPP_REDIS_USE_TACOPIE
146+
IF (USE_TACOPIE)
147+
set_target_properties(${PROJECT} PROPERTIES COMPILE_DEFINITIONS "__CPP_REDIS_USE_TACOPIE=${USE_TACOPIE}")
148+
ENDIF (USE_TACOPIE)
149+
143150

144151
###
145152
# install
@@ -156,7 +163,12 @@ install (DIRECTORY ${CPP_REDIS_INCLUDES}/ DESTINATION include USE_SOURCE_PERMISS
156163
###
157164
# tacopie
158165
###
159-
add_subdirectory(tacopie)
166+
IF (USE_TACOPIE)
167+
ExternalProject_Add("tacopie"
168+
GIT_SUBMODULES ""
169+
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/deps"
170+
SOURCE_DIR "${PROJECT_SOURCE_DIR}/tacopie")
171+
ENDIF (USE_TACOPIE)
160172

161173

162174
###
@@ -171,7 +183,7 @@ ENDIF(BUILD_EXAMPLES)
171183
###
172184
IF (BUILD_TESTS)
173185
add_subdirectory(tests)
174-
IF (EXISTS ${PROJECT_SOURCE_DIR}/deps/src/googletest)
175-
add_subdirectory(${PROJECT_SOURCE_DIR}/deps/src/googletest)
176-
ENDIF ()
186+
ExternalProject_Add("googletest"
187+
GIT_REPOSITORY "https://github.com/google/googletest.git"
188+
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/deps")
177189
ENDIF(BUILD_TESTS)

examples/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ ENDIF (NOT WIN32)
3131
###
3232
# includes
3333
###
34-
include_directories(${PROJECT_SOURCE_DIR}/includes
35-
${CPP_REDIS_INCLUDES})
34+
include_directories(${CPP_REDIS_INCLUDES})
35+
36+
37+
###
38+
# libraries
39+
###
40+
link_directories(${DEPS_LIBRARIES})
3641

3742

3843
###

includes/cpp_redis/network/tcp_client.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class tcp_client : public tcp_client_iface {
6262
auto callback = std::move(request.async_read_callback);
6363

6464
m_client.async_read({request.size, [=](tacopie::tcp_client::read_result& result) {
65-
if (not callback) {
65+
if (!callback) {
6666
return;
6767
}
6868

@@ -76,7 +76,7 @@ class tcp_client : public tcp_client_iface {
7676
auto callback = std::move(request.async_write_callback);
7777

7878
m_client.async_write({std::move(request.buffer), [=](tacopie::tcp_client::write_result& result) {
79-
if (not callback) {
79+
if (!callback) {
8080
return;
8181
}
8282

install_deps.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

sources/network/redis_connection.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@
2222

2323
#include <cpp_redis/logger.hpp>
2424
#include <cpp_redis/network/redis_connection.hpp>
25-
#include <cpp_redis/network/tcp_client.hpp>
2625
#include <cpp_redis/redis_error.hpp>
2726

28-
#include <tacopie/tacopie>
27+
#ifdef __CPP_REDIS_USE_TACOPIE
28+
#include <cpp_redis/network/tcp_client.hpp>
29+
#endif /* __CPP_REDIS_USE_TACOPIE */
2930

3031
namespace cpp_redis {
3132

3233
namespace network {
3334

3435
std::function<std::shared_ptr<tcp_client_iface>()> get_tcp_client = []() -> std::shared_ptr<tcp_client_iface> {
36+
#ifdef __CPP_REDIS_USE_TACOPIE
3537
return std::make_shared<tcp_client>();
38+
#else
39+
return nullptr;
40+
#endif /* __CPP_REDIS_USE_TACOPIE */
3641
};
3742

3843
redis_connection::redis_connection(void)

tests/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ ENDIF (NOT WIN32)
3838
###
3939
# includes
4040
###
41-
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/includes
42-
${CPP_REDIS_INCLUDES}
43-
${GTEST_INCLUDES})
41+
include_directories(${DEPS_INCLUDES} ${CPP_REDIS_INCLUDES})
42+
43+
44+
###
45+
# libraries
46+
###
47+
link_directories(${DEPS_LIBRARIES})
48+
4449

4550
###
4651
# sources

0 commit comments

Comments
 (0)