C++ CMake-查找外部库
我有一个具有以下结构的项目:C++ CMake-查找外部库,c++,cmake,C++,Cmake,我有一个具有以下结构的项目: projectName-master/ data/ source/ thirdparty/ (here is placed FindSFML.cmake file) .gitignore CMakeLists.txt README.md
projectName-master/
data/
source/
thirdparty/ (here is placed FindSFML.cmake file)
.gitignore
CMakeLists.txt
README.md
SOURCES.md
TODO.md
我使用CMake 2.8.11.1(CMake gui)生成visual studio sln文件。路径的设置方式如下:
- 其中是源代码:E:/projectName master
- 在何处构建二进制文件:E:/projectName master/source(1.我可以选择其他目录,还是应该将其设置为包含源文件的目录:h、cpp等?)
CMake Error at thirdparty/FindSFML.cmake:165 (message):
Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
SFML_AUDIO_LIBRARY SFML_NETWORK_LIBRARY SFML_GRAPHICS_LIBRARY)
Call Stack (most recent call first):
CMakeLists.txt:63 (find_package)
我下载了SFML并设置了SFML_INCLUDE_DIR(在cmakegui中):C:/OpenGL/SFML-2.1/INCLUDE/SFML,但我仍然得到了那个错误。2.如何解决这个问题?那么lib文件和dll呢
Edit1:
我从
项目中的FindSFML.cmake不包含任何SFML\u根条目,但SFML\u INCLUDE\u DIR如下所示:
# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
PATH_SUFFIXES include
PATHS
${SFMLDIR}
$ENV{SFMLDIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/
/usr/
/sw # Fink
/opt/local/ # DarwinPorts
/opt/csw/ # Blastwave
/opt/)
那么如何设置SFML_根呢?我需要向该文件添加一些条目(记录)吗?会是什么样子
Edit2:新FindSFML.cmake的一部分,具有到SFML的路径(C:/OpenGL/SFML-2.1/)
首先,
SFML
不是CMake标准模块,所以最好提供到源代码的链接。我希望你是说。请查看该文件:
因此,您可能只需要设置SFML\u ROOT
变量,而不是SFML\u INCLUDE\u DIR
那么lib文件和dll呢
我认为这可能会有所帮助:
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
我可以选择其他目录,还是应该设置为包含源文件的目录:h、cpp等
强烈建议。我在项目位置添加了一个新的FindSFML.cmake,路径为SFML-Edit2。这就是你的意思吗?但是我必须如何以及在哪里定义SFML_根呢?我使用的是CMake Gui。@Irbis只需点击
addentry
按钮。将类型
设置为路径
,名称
设置为SFML\u根
,值
设置为目录路径
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
# to tell CMake where SFML is.
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).