简体   繁体   English

CMake 找不到 SFML 库

[英]CMake can not find SFML lib

I have a project depends on SFML lib on C++.我有一个项目依赖于 C++ 上的 SFML 库。 I trying to make it with CMake.我试图用 CMake 来制作它。 CMakeLists.txt is: 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})

After running cmake.运行cmake. I have the following error:我有以下错误:

$ 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

How can I fix it?我该如何解决? (sfml lib is already installed) (已安装 sfml 库)

As already mentioned in the comments (why not write it as an answer?), CMake was looking for static SFML libraries and it most likely just found shared libraries.正如评论中已经提到的(为什么不把它写成答案?),CMake 正在寻找 static SFML 库,它很可能只是找到了共享库。

Either make sure that static libraries (the ones with the -s suffix) are provided.要么确保提供了 static 库(带有 -s 后缀的库)。
Or don't request static libraries, which you can achieve be not setting SFML_STATIC_LIBRARIES .或者不要请求 static 库,您可以通过不设置SFML_STATIC_LIBRARIES来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM