简体   繁体   English

“ CMakeLists.txt”似乎丢失了

[英]“CMakeLists.txt” seems to be missing

I was trying to build SFML in order to start developing 2d-games in c++. 我试图构建SFML,以便开始使用c ++开发2D游戏。 I put the source-code directory inside C: (the directory itself is called 'SFML'). 我将源代码目录放在C:中(目录本身称为'SFML')。 while trying to generate .cbp files using CMake, I ran into an error: 尝试使用CMake生成.cbp文件时,我遇到了一个错误:

"The source directory "C:/SFML" does not appear to contain CMakeLists.txt" “源目录“ C:/ SFML”似乎不包含CMakeLists.txt”

It seems like there is a missing file that CMake didn't create. 似乎有一个缺少的文件,CMake没有创建。 I am using Cmake 3.10.1, the installation file can be found in https://cmake.org/download/ under the title: "Windows win32-x86 Installer" . 我正在使用Cmake 3.10.1,可以在https://cmake.org/download/下找到安装文件,其标题为: “ Windows win32-x86 Installer”

I tried to build SFML 2.4.2, using the generator of Codeblocks - MinGW makefiles. 我尝试使用代码块生成器-MinGW makefiles构建SFML 2.4.2。 The version of codeblocks used is: codeblocks-16.01mingw-setup.exe , found in http://www.codeblocks.org/downloads/26 使用的代码块版本为: codeblocks-16.01mingw-setup.exe ,可在http://www.codeblocks.org/downloads/26找到

Did someone encounter the same problem before and knows how to overcome it? 有人曾经遇到过同样的问题,并且知道如何解决吗? If not - Is there an already-built, ready to use, libray of this version? 如果不是,是否存在此版本的已构建的,可供使用的库? (2.4.2) (2.4.2)

If not.. do you know about a version of SFML that is usable in visual studio 2017? 如果不是,您是否知道Visual Studio 2017中可用的SFML版本?

And another question (That is the last one, I promise...) - maybe you can recommend me about another library for c++, that is usable to develop 2d-games? 还有另一个问题(我保证这是最后一个问题 -也许您可以向我推荐另一个可用于开发2D游戏的c ++库?

edt: note: I am completely new to all this building thing edt:注意:我对这栋建筑完全陌生

the containments of SFML: maybe it's the binary version? SFML的限制: 也许是二进制版本?

lib contains some static libraries, bin contains some .dll s lib包含一些静态库,bin包含一些.dll

You probably downloaded something wrong or potentially extracted the SFML source into a sub folder or something like that. 您可能下载了错误的东西,或者可能将SFML源提取到了子文件夹中或类似的东西。

Since you've mentioned Visual Studio: SFML is 100% compatible with Visual Studio and you can build it from source any time without having to worry about dependencies (everything included in the repository). 既然您已经提到Visual Studio:SFML与Visual Studio 100%兼容,那么您可以随时从源代码构建它,而不必担心依赖关系(存储库中包含的所有内容)。

The steps to compile are pretty easy. 编译步骤非常简单。 I'd recommend you install Git to clone the latest source from the SFML repository. 我建议您安装Git来从SFML存储库中克隆最新的源。 In addition you'll need CMake , which you obviously got already. 另外,您将需要CMake ,您显然已经知道了。

  • Open a Command Prompt and change your directory to C:\\SFML . 打开命令提示符 ,并将目录更改为C:\\SFML
  • Clone the official repository using Git : git clone https://github.com/SFML/SFML.git source (note the trailing .) 使用Git克隆官方存储库: git clone https://github.com/SFML/SFML.git source (请注意结尾处。)
  • Wait for the source to be checked out to the source sub directory. 等待源签出到source子目录。
  • Create a new directory called build : md build && cd build 创建一个名为build的新目录: md build && cd build
  • Now invoke CMake , pointing to the source directory and also defining your install path: cmake -DCMAKE_INSTALL_PREFIX=C:/SFML ../source 现在调用CMake ,指向源目录并定义您的安装路径: cmake -DCMAKE_INSTALL_PREFIX=C:/SFML ../source
  • Build and install a debug build of SFML: cmake --build . --target install --config debug 生成并安装SFML的调试版本: cmake --build . --target install --config debug cmake --build . --target install --config debug
  • Build and install a release build of SFML: cmake --build . --target install --config release 构建并安装SFML的发行版本: cmake --build . --target install --config release cmake --build . --target install --config release
  • Alternatively you can just open the generated Visual Studio solution and build the INSTALL project on your own. 或者,您可以只打开生成的Visual Studio解决方案并自行构建INSTALL项目。

(You shouldn't have to define a build tool or anything; CMake should notice Visual Studio being installed and pick it up automatically.) (您不必定义构建工具或其他任何东西; CMake应该注意到正在安装Visual Studio并自动将其拾取。)

I have experienced this using cmake version 3.10 when using the -S command line option. 使用-S命令行选项时,我使用cmake版本3.10遇到了这种情况。 On cmake version 3.15.4 it behaves as expected - so if you update cmake then it might just work. 在cmake版本3.15.4上,它的行为符合预期-因此,如果更新cmake,则它可能会正常工作。

Note that the -S command line option was not supported before version 3.13: https://cmake.org/cmake/help/v3.13/release/3.13.html#command-line 请注意,版本3.13之前不支持-S命令行选项: https : //cmake.org/cmake/help/v3.13/release/3.13.html#command-line

Normally cmake is called from a "build" subdirectory of a project root, the project root contains CMakelists.txt. 通常,从项目根目录的“ build”子目录中调用cmake,该项目根目录包含CMakelists.txt。 So you would create a "build" directory, change to it, and submit "cmake ..". 因此,您将创建一个“ build”目录,进行更改,然后提交“ cmake ..”。 This would pull in CMakelists.txt from the project root, and use the "build" subdirectory that you are in as the build directory. 这将从项目根目录中提取CMakelists.txt,并将您所在的“ build”子目录用作构建目录。 We say "build", what it actually does is generate makefiles which can then used by the "native" build system (eg "make" or Visual Studio) to perform the actual compilation and linking. 我们说“构建”,实际上它是生成makefile,然后供“本机”构建系统(例如“ make”或Visual Studio)使用该文件执行实际的编译和链接。 This arrangement is not always convenient, hence the introduction of the -S and -B command line options. 这种安排并不总是很方便,因此引入了-S和-B命令行选项。

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

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