在C++中创建Zookeeper

5ktev3wc  于 12个月前  发布在  Apache
关注(0)|答案(1)|浏览(188)

我有一个C的应用程序,它用this library连接C的zookeeper。现在我正在努力将它与我的C++应用程序集成。
CMakeLists.txt如下:

cmake_minimum_required(VERSION 3.22)

project(meta-flare-cpp)
set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/lib/zookeeper")

add_executable(meta-flare src/main.cpp src/ZooKeeperConnector/ZooKeeperConnector.cpp)

# Link against ZooKeeper library
find_package(ZooKeeper REQUIRED)
target_link_libraries(meta-flare ZooKeeper::ZooKeeper)

# Include directories
target_include_directories(meta-flare PRIVATE ${ZooKeeper_INCLUDE_DIRS})

字符串
我不知道我犯了什么错误,我有这样的目录结构。
这是项目结构

--- Folder Structure ---
CMakeCache.txt
CMakeLists.txt
[cmake]
    └── [Modules]
        └── FindZooKeeper.cmake
[src]
  ├── [ZooKeeperConnector]
    ├── ZooKeeperConnector.cpp
    └── ZooKeeperConnector.h
  └── main.cpp

[lib]
    └── [zookeeper]
        ├── zookeeper_github_clone


当我做cmake .它给出以下错误->

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

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

ZooKeeperConfig.cmake
zookeeper-config.cmake

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


我做错了什么?

fv2wmkja

fv2wmkja1#

您需要将FindZooKeeper.cmake的目录添加到CMAKE_MODULE_PATH
假设你的FindZooKeeper.cmake在这个位置,cmake/Modules/FindZooKeeper.cmake
您可以设置

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")

字符串
来源:https://cmake.org/cmake/help/latest/command/find_package.html#id6

相关问题