Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help: add redis++ lib to app, 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_STATIC_LIB #63

Closed
chris-shenzhen-china opened this issue Jun 10, 2020 · 6 comments

Comments

@chris-shenzhen-china
Copy link

add redis++ lib to app, 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_STATIC_LIB

@sewenew
Copy link
Owner

sewenew commented Jun 10, 2020

Hi @chris-shenzhen-china

redis-plus-plus depends on hiredis, and you need to install hiredis first.

It seems that you didn't install hiredis or installed hiredis at a user-defined path, and cmake cannot locate it. If you already installed hiredis at a user-defined path, you can use the -DCMAKE_PREFIX_PATH=/path/to/hiredis parameter to tell cmake where to find hiredis.

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/path/to/hiredis ..

Please check this section for detail.

If you still have any problem with redis-plus-plus, feel free to let me know :)

Regards

@chris-shenzhen-china
Copy link
Author

D:\project-vs\framework\test>cmake -DCMAKE_PREFIX_PATH=D:\project-vs\vcpkg\vcpkg\packages\hiredis_x64-windows
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.

-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The CXX compiler identification is MSVC 19.26.28806.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include any
-- Looking for C++ include any - found
-- Looking for C++ include string_view
-- Looking for C++ include string_view - found
CMake Error at CMakeLists.txt:25 (find_package):
Could not find a package configuration file provided by "Drogon" with any
of the following names:

DrogonConfig.cmake
drogon-config.cmake

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

@sewenew
Copy link
Owner

sewenew commented Jun 10, 2020

You need to specify the path to CMakeLists.txt file of redis-plus-plus:

D:\project-vs\framework\test>cmake -DCMAKE_PREFIX_PATH=D:\project-vs\vcpkg\vcpkg\packages\hiredis_x64-windows path-to-CMakeLists.txt

Regards

@chris-shenzhen-china
Copy link
Author

chris-shenzhen-china commented Jun 13, 2020

I hava already add the path to CMacklist.txt like this below:
set(CMAKE_PREFIX_PATH "D:/project-vs/vcpkg/vcpkg/packages/hiredis_x64-windows")

but, cmake error here too:

@sewenew
Copy link
Owner

sewenew commented Jun 14, 2020

Hi @chris-shenzhen-china

If you set CMAKE_PREFIX_PATH with command line arguments, both redis-plus-plus library and the corresponding test can be built correctly.

However, if you set this variable by modifying CMakeLists.txt, you should modify 2 CMakeLists.txt files. It seems that you only set CMAKE_PREFIX_PATH for the CMakeLists.txt file that builds redis-plus-plus library. You should also set CMAKE_PREFIX_PATH for the CMakeLists.txt file that builds the test: redis-plus-plus/test/CMakeLists.txt.

Regards

@chris-shenzhen-china
Copy link
Author

I changed the CMakeLists.txt in test dir, and it works well

hiredis dependency

find_path(HIREDIS_HEADER hiredis)
target_include_directories(${PROJECT_NAME} PUBLIC ${HIREDIS_HEADER})

find_library(HIREDIS_LIB hiredis)
target_link_libraries(${PROJECT_NAME} ${HIREDIS_LIB})

redis++ dependency

target_include_directories(${PROJECT_NAME} PUBLIC ../src)

solaris socket dependency

IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
target_link_libraries(${PROJECT_NAME} -lsocket)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )

find_package(Threads REQUIRED)

#target_link_libraries(${PROJECT_NAME} ${REDIS_PLUS_PLUS_LIB} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} redis++ ws2_32.lib ${CMAKE_THREAD_LIBS_INIT})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants