visual-studio-2010 - 将数据文件添加到 cmake 生成的项目

标签 visual-studio-2010 cmake

我有一个项目,其中源文件在 source/中,一些着色器文件在 data/中(这些文件不是编译的,而是由代码加载的)。我希望这些文件显示在我的 CMake 生成的 VS2010 项目文件中,以便我可以轻松地编辑它们。有什么好方法可以做到这一点?理想情况下,它们应该在一个单独的项目中,但任何有效的方法都是好的。

谢谢!

最佳答案

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

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

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")

SOURCE_GROUP command may be useful, too.



并且

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

关于visual-studio-2010 - 将数据文件添加到 cmake 生成的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7455280/

相关文章:

c++ - 为android创建一个静态c lib

c++ - 对 std::bad_cast::bad_cast() 的 undefined reference

build - 将 CMake 项目指向特定的包含文件

visual-studio-2010 - 计划将VS 2005升级到VS 2010

c++ - 使用cmake和vs2010链接到静态boost lib而不自动链接

c++ - DLL 项目不生成 .exp 和 .lib 文件

visual-studio-2010 - 无法在 Visual Studio 2010(mfc 项目)中添加事件处理程序

c++ - 我的调试器运行的代码似乎与我正在构建的代码不同

cmake - 如何为库编写 CMake 安装?

linux - 如何在cmake中设置库的搜索优先级