将数据文件添加到cmake生成的项目 [英] Adding data files to cmake-generated projects

查看:484
本文介绍了将数据文件添加到cmake生成的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中源文件在源/和一些着色器文件在数据/(那些没有编译,而是由代码加载)。我想这些文件显示在我的CMake生成的VS2010项目文件,所以我可以轻松地编辑它们。有什么好办法做到这一点?理想的情况是,他们在一个单独的项目,但任何工作的是好的。

I have a project where the source files are in source/ and some shader files in data/ (those are not compiled, but instead loaded by the code). I'd like these files to show up in my CMake-generated VS2010 project files so I can edit them comfortably. What's a good way to do this? Ideally, they'd be in a separate project, but anything that works is good.

谢谢!

推荐答案

我不能评论(声誉太低),但这是你想要的?
http://www.cmake.org/pipermail/cmake /2006-May/009291.html

I can't comment (reputation too low) but is this what you want ? http://www.cmake.org/pipermail/cmake/2006-May/009291.html

编辑:如果上面的链接在某些时候停止工作,想法是将文件添加到Visual Studio一个普通的源文件。由于IDE没有与其关联的编译工具,因此将被忽略。引用列表的讨论:

if the above link stops working at some time, the idea is to add the files to Visual Studio like an ordinary source file. Since the IDE has no compile tool associated with it, it will be ignored. Quoting the list's discussion:


您可以向目标添加任意文件 - 只要VS没有
自动规则编译它们(例如.cc,.cpp等)
我将.html文件添加到库/可执行文件或使用虚拟目标例如:

You could add arbitrary files to a target - as long as VS has no "automatic" rule to compile them (e.g. .cc, .cpp etc) I am adding .html files to libraries/executable or using a dummy target e.g:

ADD_EXECUTABLE dummy dummy.cpp
$ {CMAKE_CURRENT_BINARY_DIR} /Doc/index.html)

ADD_EXECUTABLE(dummy dummy.cpp "${CMAKE_CURRENT_BINARY_DIR}/Doc/index.html")

SOURCE_GROUP命令也可能有用。

SOURCE_GROUP command may be useful, too.

以及


我想你必须小心只添加到VS IDE
生成器生成,
特别是不生成makefile。

I think you have to take care that they are added only to VS IDE generator builds, in particular NOT to makefiles.

因此,我们使用这样的:

Thus we are using something like this:



IF    (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
  ADD_EXECUTABLE( hello ${SOURCES} ${HEADER} ${DOC})
ELSE  (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")
  ADD_EXECUTABLE( hello ${SOURCES} )
ENDIF (CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)")

贷记Jan Woetzel

Credit to Jan Woetzel

这篇关于将数据文件添加到cmake生成的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆