I am developing a project in C++ that utilizes RediSearch. I would like to be able to call RediSearch functions in a form similar to #include <redisearch/document.h>
utilizing CMake without having to alter the RediSearch project.
This question should be applicable to using CMake with any external CMake project, but all I have found is very specific to a certain set of projects or simply do not work.
Attempts
I have attempted to use ExternalProject
such as in this project, using Config files and find_package()
as in this project, directly using add_subdirectory
and target_link_libraries
, linking to the src/ folder directly, etc.
I have also tried including the following lines in my CMakeLists.txt
set(RS_INCLUDE_DIR libs/RediSearch/src)
set(GCC_COVERAGE_COMPILE_FLAGS "-I${RS_INCLUDE_DIR} -Wall -g -fPIC -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
include_directories(${RS_INCLUDE_DIR})
but receive the following error:
CMakeFiles/prjct.dir/src/main.cpp.o: In function `RedisModule_Init':
....
collect2: error: 1d returned 1 exit status
....
Resulting errors include but are not limited to:
- Not being able to locate the package when using
find_package
(as described in the aforementioned projects) and presenting an error such as:CMake Error at /opt/cmake-3.13.3-Linux-x86_64/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 Could NOT find RediSearch (missing: RediSearch_INCLUDE_DIR) Call Stack (most recent call first): /opt/cmake-3.13.3-Linux-x86_64/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) cmake/FindRediSearch.cmake:27 (find_package_handle_standard_args) CMakeLists.txt:48 (find_package)
- If CMake does not give any errors, then on make:
redisearch/document.h: No such file or directory
To detail my project structure:
prjct
| src/
| | main.cpp
| include/
| | prjct/
| | | myheader.hpp
| libs/
| | RediSearch/ <- As git submodule
| cmake/
| | prjctConfig.cmake.in
| CMakeLists.txt
I want to, from any src/
file such as main.cpp
, utilize RediSearch (or for that matter any project which would be built with CMake) in the form #include <redisearch/document.h>
. I do not want to alter RediSearch files or configuration at all - everything should be conducted through my project.
Note: I am using cmake version 3.13.3