CMake找不到SFML库

pcww981p  于 2022-11-11  发布在  其他
关注(0)|答案(1)|浏览(257)

我有一个项目依赖于C++上的SFML库。我试图使它与CMake。CMakeLists.txt是:

cmake_minimum_required(VERSION 3.16.3)
project(3D_Renderer_from_scratch)

set(CMAKE_CXX_STANDARD 17)

include_directories(headers source)

set(SFML_STATIC_LIBRARIES TRUE)

find_package(SFML COMPONENTS window graphics system)

set(SOURCES
        Main.cpp
        source/Application.cpp
        source/Box.cpp
        source/Camera.cpp
        source/FileReader.cpp
        source/KeyboardHandler.cpp
        source/Sphere.cpp
        source/Triangle.cpp
        source/Window.cpp
        source/World.cpp
        )

add_executable(executable ${SOURCES})

target_link_libraries(executable ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})

运行cmake .后,出现以下错误:

$ cmake .
-- Requested SFML configuration (Static) was not found
CMake Warning at CMakeLists.txt:10 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/mcjohn974/3D_Renderer_from_scratch

如何修复?(sfml lib已安装)

ikfrs5lh

ikfrs5lh1#

正如在评论中已经提到的(为什么不把它作为一个答案写下来呢?),CMake正在寻找静态SFML库,它很可能只是找到了共享库。
或者确保提供了静态库(带有-s后缀的库)。
或者不请求静态库,这可以通过不设置SFML_STATIC_LIBRARIES来实现。

相关问题