Skip to content

Commit a765780

Browse files
committed
added cmake tacopie
1 parent 96a56ca commit a765780

File tree

12 files changed

+397
-458
lines changed

12 files changed

+397
-458
lines changed

CMakeLists.txt

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,23 @@ endif ()
8383
###
8484
# variables
8585
###
86-
ExternalProject_Add(tacopieGit
87-
PREFIX tacopie
88-
GIT_REPOSITORY https://github.com/Cylix/tacopie.git
89-
GIT_TAG origin/master
90-
UPDATE_DISCONNECTED ON
91-
)
92-
93-
SET(TACOPIE_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/tacopie/includes)
94-
SET(TACOPIE_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/lib)
95-
96-
add_library(tacopie SHARED IMPORTED)
97-
set_target_properties(tacopie PROPERTIES IMPORTED_LOCATION ${TACOPIE_LIBRARY}/tacopie.a)
86+
set(VENDOR_DIR ${PROJECT_SOURCE_DIR}/vendor)
87+
set(VENDOR_INCLUDES ${VENDOR_DIR}/include)
88+
set(VENDOR_LIBRARY_DIR ${VENDOR_DIR}/lib ${VENDOR_DIR}/lib64)
9889

9990
# find_path(TACOPIE_INCLUDE_DIR tacopie/tacopie PATHS ${PROJECT_SOURCE_DIR}/tacopie/includes/)
10091
# find_library(TACOPIE_LIBRARY tacopie)
10192
set(CPP_REDIS_INCLUDES ${PROJECT_SOURCE_DIR}/includes)
102-
set(DEPS_INCLUDES ${PROJECT_SOURCE_DIR}/deps/include)
10393

10494
if (NOT USE_CUSTOM_TCP_CLIENT)
105-
set(DEPS_INCLUDES ${DEPS_INCLUDES} ${TACOPIE_INCLUDE_DIR})
95+
set(VENDOR_INCLUDES ${VENDOR_INCLUDES} ${TACOPIE_INCLUDE_DIR})
10696
endif ()
10797

108-
set(DEPS_LIBRARIES ${PROJECT_SOURCE_DIR}/deps/lib)
109-
11098

11199
###
112100
# includes
113101
###
114-
include_directories(${CPP_REDIS_INCLUDES} ${DEPS_INCLUDES})
115-
102+
include_directories(${CPP_REDIS_INCLUDES} ${VENDOR_INCLUDES})
116103

117104
###
118105
# sources
@@ -161,9 +148,14 @@ configure_file("cpp_redis.pc.in" "${CMAKE_PKGCONFIG_OUTPUT_DIRECTORY}/cpp_redis.
161148
###
162149
# executable
163150
###
164-
add_library(${PROJECT} ${SOURCES})
151+
add_library(${PROJECT} STATIC ${SOURCES})
165152
set_property(TARGET ${PROJECT} PROPERTY POSITION_INDEPENDENT_CODE ON)
166153

154+
###
155+
# add tacopie as dependency to force clone
156+
###
157+
#add_dependencies(${PROJECT} ${TACOPIE_LIBRARY})
158+
167159
if (WIN32)
168160
set_target_properties(${PROJECT}
169161
PROPERTIES COMPILE_PDB_NAME ${PROJECT}
@@ -177,7 +169,8 @@ else ()
177169
endif ()
178170

179171
if (TACOPIE_LIBRARY)
180-
target_link_libraries(${PROJECT} ${TACOPIE_LIBRARY})
172+
target_link_libraries(${PROJECT} tacopie)
173+
target_include_directories(${PROJECT} PUBLIC ${VENDOR_INCLUDES})
181174
else ()
182175
target_link_libraries(${PROJECT} tacopie)
183176
endif ()
@@ -210,6 +203,20 @@ install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ DESTINATION lib USE_SOURCE_
210203
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ DESTINATION bin USE_SOURCE_PERMISSIONS)
211204
install(DIRECTORY ${CPP_REDIS_INCLUDES}/ DESTINATION include USE_SOURCE_PERMISSIONS)
212205

206+
###
207+
# tacopie
208+
###
209+
if (NOT TACOPIE_LIBRARY AND NOT USE_CUSTOM_TCP_CLIENT)
210+
ExternalProject_Add(tacopiegit
211+
GIT_REPOSITORY "https://github.com/Cylix/tacopie.git"
212+
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${VENDOR_DIR}"
213+
UPDATE_DISCONNECTED OFF
214+
)
215+
216+
SET(TACOPIE_INCLUDE_DIR ${VENDOR_INCLUDES})
217+
SET(TACOPIE_LIBRARY_DIR ${VENDOR_LIBRARY_DIR})
218+
SET(TACOPIE_LIBRARY tacopie)
219+
endif ()
213220

214221
###
215222
# examples
@@ -228,16 +235,8 @@ if (BUILD_TESTS)
228235
add_subdirectory(tests)
229236
ExternalProject_Add("googletest"
230237
GIT_REPOSITORY "https://github.com/google/googletest.git"
231-
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/deps")
238+
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${VENDOR_DIR}"
239+
UPDATE_DISCONNECTED ON)
232240
# Reset variable to false to ensure tacopie does no build tests
233241
set(BUILD_TESTS false)
234242
endif ()
235-
236-
237-
###
238-
# tacopie
239-
###
240-
if (NOT TACOPIE_LIBRARY AND NOT USE_CUSTOM_TCP_CLIENT)
241-
set(SOURCES) # reset the SOURCES var so that the tacopie project won't include the cpp_redis sources too
242-
add_subdirectory(tacopie)
243-
endif ()

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ include_directories(${CPP_REDIS_INCLUDES})
3737
###
3838
# libraries
3939
###
40-
link_directories(${DEPS_LIBRARIES})
40+
link_directories(${VENDOR_LIBRARY_DIR})
4141

4242
set(EXAMPLES cpp_redis_client
4343
cpp_redis_consumer

0 commit comments

Comments
 (0)