sewenew/redis-plus-plus

[BUG] -DCMAKE_PREFIX_PATH not finding hiredis

aka-mj opened this issue · 2 comments

I'm using ExternalProject_Add in CMake to build hiredis and then build redis++. The source code is vendored so it can be included in the project. I'm installing hiredis in a non-standard location, so I'm passing -DCMAKE_PREFIX_PATH to redis++ as specified in the documentation. However, it appears redis++ is not finding hiredis.

Here is the snippet from my CMakeLists.txt

set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)

ExternalProject_Add(hiredis
    PREFIX ${EXTERNAL_INSTALL_LOCATION}/hiredis
    SOURCE_DIR ${CMAKE_SOURCE_DIR}/vendor/hiredis
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}/hiredis -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
	BUILD_ALWAYS TRUE
	BUILD_IN_SOURCE FALSE
)
set(HIREDIS_HEADER ${EXTERNAL_INSTALL_LOCATION}/hiredis/include)
message(STATUS "HIREDIS_HEADER: ${HIREDIS_HEADER}")

set(HIREDIS_LIB ${EXTERNAL_INSTALL_LOCATION}/hiredis/lib/libhiredis.a)
message(STATUS "HIREDIS_LIB: ${HIREDIS_LIB}")

set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};${EXTERNAL_INSTALL_LOCATION}/hiredis/include")
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${EXTERNAL_INSTALL_LOCATION}/hiredis/lib")

# --- Add redis-plus-plus library ---
ExternalProject_Add(redis-plus-plus
    PREFIX ${EXTERNAL_INSTALL_LOCATION}/hiredis
    SOURCE_DIR ${CMAKE_SOURCE_DIR}/vendor/redis-plus-plus
    CMAKE_ARGS 
        -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}/hiredis
        -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
        -DCMAKE_PREFIX_PATH=${EXTERNAL_INSTALL_LOCATION}/hiredis
        -DREDIS_PLUS_PLUS_BUILD_TEST=OFF
    BUILD_ALWAYS TRUE
    BUILD_IN_SOURCE FALSE
)

This is the error from CMake:

-- redis-plus-plus version: 1.3.13
-- The CXX compiler identification is Clang 13.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/mjohn/workspace/cm/apps/settings/cross/bin/x86_64-linux-musl-clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- redis-plus-plus build type: Release
-- redis-plus-plus build with CXX standard: c++17
-- redis-plus-plus TLS support: OFF
-- redis-plus-plus check hiredis features
-- Looking for redisEnableKeepAliveWithInterval
-- Looking for redisEnableKeepAliveWithInterval - not found
-- redis-plus-plus build static library: ON
-- redis-plus-plus build static library with position independent code: ON
-- redis-plus-plus build shared library: ON
-- redis-plus-plus build test: OFF
-- Debian package name: .deb
-- Configuring done (0.2s)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
HIREDIS_LIB
    linked by target "redis++" in directory /home/mjohn/workspace/cm/apps/settings/vendor/redis-plus-plus

CMake Error in CMakeLists.txt:
  Found relative path while evaluating include directories of
  "redis++_static":

    "HIREDIS_HEADER-NOTFOUND"



CMake Error in CMakeLists.txt:
  Found relative path while evaluating include directories of "redis++":

    "HIREDIS_HEADER-NOTFOUND"

Any ideas on what I could troubleshoot?

I'm not an expert on CMAKE, but you can take this issue for reference. With the solution mentioned in the issue, you should solve the problem.

Regards

Since there's no update, I'll close this issue.

Regards