CMake在macOS上找不到libevent

问题描述 投票:0回答:1

我已经在macOS上安装了libevent-

$ brew install libevent

我正在尝试将其导入我的CMakeLists.txt-

cmake_minimum_required(VERSION 3.14)
project(xyz)
set(CMAKE_CXX_STANDARD 17)
find_package(libevent REQUIRED)

我收到以下CMake错误-

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

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

    libeventConfig.cmake
    libevent-config.cmake

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

有人可以告诉我如何导入CMake系统中安装的libevent吗?

cmake libevent
1个回答
0
投票

我也有同样的麻烦,但是我通过添加来解决这个问题:

link_directories(
  /usr/local/lib
  /usr/lib
)
INCLUDE_DIRECTORIES(
  /usr/local/include/
  /usr/include
)

它只是告诉Makefile在哪里可以找到libevent标头和库。

© www.soinside.com 2019 - 2024. All rights reserved.