Cylix / cpp_redis

C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform - NO LONGER MAINTAINED - Please check https://github.com/cpp-redis/cpp_redis
MIT License
1.25k stars 554 forks source link

Use cpp_redis in a linux CMake project #179

Open HerbertKoelman opened 6 years ago

HerbertKoelman commented 6 years ago

Hello,

Is there an easy way to use cpp_redis in cmake projects ?

I want to know if there is a way to use this kind of cmake feature:

find_package(cpp_redis REQUIRED)

When I use this macro, cmake complains and returns this:

CMake Error at CMakeLists.txt:20 (find_package):
  By not providing "Findcpp_redis.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "cpp_redis", but CMake did not find one.

  Could not find a package configuration file provided by "cpp_redis" with
  any of the following names:

    cpp_redisConfig.cmake
    cpp_redis-config.cmake

  Add the installation prefix of "cpp_redis" to CMAKE_PREFIX_PATH or set
  "cpp_redis_DIR" to a directory containing one of the above files.  If
  "cpp_redis" provides a separate development package or SDK, be sure it has
  been installed.

-- Configuring incomplete, errors occurred!

Any clue ?

ghost commented 6 years ago

Hello, You can use add_subdirectory(path/to/cpp_redis/submodule) NOTE: apparently cpp_redis's CMakeLists.txt does not set the public include paths for the library, so do it yourself:

# (use the correct paths)
add_subdirectory(3rdparty/cpp_redis)
target_include_directories(cpp_redis PUBLIC 
    "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cpp_redis/includes"
    "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cpp_redis/tacopie/includes"
)

and then link your lib/exe with cpp_redis:

target_link_libraries(my_lib
        cpp_redis
    )

You could also use ExternalProject_Add.