我在 Linux 上做了一个 C++ 项目,我将源文件分组在许多目录中以自己组织。
我使用 CMake 编译,每个子目录下有一个 CMakeFiles.txt。
srcs
|--folderA
| |--Toto.cpp
| |--Tata.cpp
|
|--folderB
| |--Foo.cpp
| |--Bar.cpp
[...]
最近,我用 Visual Studio 2015 打开它,它找到了每个源文件,但只是将整个列表放在解决方案资源管理器的“源文件”文件夹中。
Source Files
|--Toto.cpp
|--Tata.cpp
|--Foo.cpp
|--Bar.cpp
我打算有大量的文件,很快就会很难找到一个。
有没有办法明确告诉它遵守解决方案资源管理器上的文件夹层次结构?
最佳答案
使用 source_group
命令。
source_group(
<name>
[FILES<src>...
] [REGULAR_EXPRESSION<regex>
])Defines a group into which sources will be placed in project files. This is intended to set up file tabs in Visual Studio. The options are:
FILES Any source file specified explicitly will be placed in group . Relative paths are interpreted with respect to the current source directory.
REGULAR_EXPRESSION Any source file whose name matches the regular expression will be placed in group .
关于c++ - 如何在解决方案资源管理器中保留源文件夹层次结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32576434/