我有一个项目,其中源文件在 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/