我有一个项目依赖于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已安装)
1条答案
按热度按时间ikfrs5lh1#
正如在评论中已经提到的(为什么不把它作为一个答案写下来呢?),CMake正在寻找静态SFML库,它很可能只是找到了共享库。
或者确保提供了静态库(带有-s后缀的库)。
或者不请求静态库,这可以通过不设置
SFML_STATIC_LIBRARIES
来实现。