c++ - 如何在解决方案资源管理器中保留源文件夹层次结构?

标签 c++ visual-studio cmake visual-studio-2015 solution-explorer

我在 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/

相关文章:

c++ - 如何在单个删除语句中删除多个动态分配的数组?

c++ - Boost::Spirit 简单语法示例

c++ - 为什么编译器不能优化0浮点加法?

c++ - Visual Studio 2015中的C++调试器可执行文件在哪里?

c# - 断点绑定(bind)失败 - Visual Studio 2015

cmake - CMakeLists.txt中应该在哪里调用find_package?

c++ - Qt5:派生QQuickWidget以获取小部件

c# - 如何在 VS 中进行单元测试?

c++ - SFML 未静态链接到 openal32(静态链接到所有其他依赖项)

c++ - 使用 Cmake-gui 和 vcpkg