【发布时间】:2018-05-04 12:29:47
【问题描述】:
就像在 CLion 中一样,我想将 SFML 与 Visual Studio 2017 一起使用,但我仍在学习 cmake,我根本不知道 cmake 如何工作的命令或逻辑。我刚刚看了一些帖子,得到了这个小脚本。
注意:我在提供的链接中下载了最新版本的 sfml,我只是将提取的目录放在我的文件夹中的 CMakeLists.txt 旁边
#sets up the minimum version of cmake
cmake_minimum_required(VERSION 3.9)
#how the project will be called
project (space_impact)
#set c++11 standard
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" -std=c++11)
#set source files
set (SOURCE_FILES main.cpp)
#we add the executable of the program
add_executable (space_impact ${SOURCE_FILES})
#taked from a mac-clion tutorial, doesn't work
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/SFML/cmake-modules/")
find_package (SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(space_impact ${SFML_LIBRARIES})
endif()
那件事给了我错误:
Error CMake Error at SFML/cmake-modules/FindSFML.cmake:355 (message):
Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
SFML_GRAPHICS_LIBRARY SFML_NETWORK_LIBRARY SFML_AUDIO_LIBRARY) SFML/cmake-modules/FindSFML.cmake
我希望一切都是动态的,但我不知道该怎么做..
所以我的问题是我应该怎么做才能在 Visual Studio 中使用 Cmake 正确设置 SFML。
我不想要官方网站上的老式方法
问题是……FindSFML.cmake 脚本不起作用……
我应该移动哪些文件才能使其正常工作?
【问题讨论】:
-
该错误表示找不到SFML。您是否安装了 SFML?如果有,在哪里?
-
@Tsyvarev 正如我所说..所有库都在我提供的链接中的同一个文件夹 SFML 中,在它之外......是我的 main.cpp
-
尝试将
SFML_ROOT设置为C:/Users/ramm32/Documents/SFML/(见下面我的回答)。这应该可以正常工作。
标签: c++ cmake visual-studio-2017 sfml