c++ 无法设置CMAKE_PREFIX_PATH

a9wyjsp7  于 2023-02-26  发布在  其他
关注(0)|答案(2)|浏览(206)

下面是我的CMakeLists文件:

set(LibName "VibraniumEngine")
set(RAYLIB_VERSION 4.2.0)
list(APPEND CMAKE_PREFIX_PATH "/dep/raylib/lib")
find_package(raylib)

if(NOT raylib)
    message(FATAL_ERROR "RayLib library not found")
else()
    message( "RayLib library found!")
endif()

这是我下载并尝试添加为依赖项的预构建raylib库的文件/文件夹结构:

正如您所看到的,我正在执行list(APPEND CMAKE_PREFIX_PATH "/dep/raylib/lib"),给出可以找到raylib的确切目录。
但是,我仍然收到此错误:

CMake Warning at Source/VibraniumEngine/CMakeLists.txt:4 (find_package):
  By not providing "Findraylib.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "raylib", but
  CMake did not find one.

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

    raylibConfig.cmake
    raylib-config.cmake

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

CMake Error at Source/VibraniumEngine/CMakeLists.txt:7 (message):
  RayLib library not found

你知道为什么吗?我该怎么修?

ldioqlga

ldioqlga1#

看起来您(无意中)使用了一个不存在的绝对路径。
你使用list(APPEND CMAKE_PREFIX_PATH "/dep/raylib/lib"),这是你写绝对路径的方式(除非你在windows上)。你可能想使用更像list(APPEND CMAKE_PREFIX_PATH "${<PROJECT_NAME>_SOURCE_DIR}/dep/raylib/lib")docs)或list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dep/raylib/lib")docs)的东西。根据需要进行选择和调整。你的屏幕截图和CMakeLists.txt片段没有显示足够的上下文来给予你一个100%完整的答案。

qncylg1j

qncylg1j2#

认为问题不在于路径本身,而在于"找不到" raylib "提供的包配置文件"。
参见:https://github.com/raysan5/raylib/tree/master/cmake

相关问题