[英]How to config qmake generating Visual Studio solution using directory-structure for source files in projects?
I would like to create a Visual Studio project with qmake out of a makefile. 我想用makefile的qmake创建一个Visual Studio项目。 So far that works fine with qmake AllProjects.pro -r -spec win32-msvc2013 -tp vc "CONFIG+=debug_and_release" -o %CD%/$(VC13PROJ)/AllProjects.sln
. 到目前为止,它可以与qmake AllProjects.pro -r -spec win32-msvc2013 -tp vc "CONFIG+=debug_and_release" -o %CD%/$(VC13PROJ)/AllProjects.sln
。 The problem is, that every project has it's header and source-filters with those files plain at top level. 问题是,每个项目都有其标头和源过滤器,而这些文件在顶层是普通的。 I'm using Qt5.5.1. 我正在使用Qt5.5.1。
But what I like to have is that the files are structured like in the directory, because they are group there logically and giving a better overview on project structure. 但是我想拥有的是文件的结构像在目录中一样,因为它们在逻辑上进行了分组,并为项目结构提供了更好的概览。 Is there a possibility to config the qmake using directory-structure instead of putting all files plain at top-level? 是否可以使用目录结构配置qmake,而不是将所有文件放在顶层?
Directory structure: 目录结构:
source/
dir1/
file1.h
file1.cpp
dir2/
file2.h
file2.cpp
Problem: Project structure in Visual Studio, looks like: 问题:Visual Studio中的项目结构如下:
project/
header/
file1.h
file1.h
source/
file1.cpp
file2.cpp
I would like to have a structure inside Visual Studio like: 我想在Visual Studio中有一个结构,例如:
project/
header-filter/
dir1/
file1.h
dir2/
file2.h
source-filter/
dir1/
file1.cpp
dir2/
file2.cpp
alternative that is also fine: 也可以的替代方案:
project/
dir1/
file1.h
file1.cpp
dir2/
file2.h
file2.cpp
For something like 30+ files in source and header, getting an overview is difficult if everything is together at top-level. 对于源文件和标题中的30多个文件,如果所有内容都在顶层,则很难获得概述。
EDIT: CONFIG-=flat
as qmake
-option seems to give a structure relative to the vcxproj-file. 编辑: CONFIG-=flat
作为qmake
-option似乎提供了相对于vcxproj文件的结构。
project/
header-filter/
../
../
source/
dir1/
file1.h
dir2/
file2.h
source-filter/
../
../
source/
dir1/
file1.cpp
dir2/
file2.cpp
So the question remains, if it is possible to get rid of the starting relative path: 因此,问题仍然存在,如果有可能摆脱起始的相对路径:
../
../
source/
(Posted solution on behalf of the OP) . (代表OP发布解决方案) 。
I solved the problem by writing a python script parsing the .vcxproj.filters-files
of the created solution. 我通过编写一个python脚本来解析创建的解决方案的.vcxproj.filters-files
来解决了这个问题。 It searches for the created filter groups replaces them and afterwards adapting the assigned filter groups of all items in a filter. 它搜索创建的过滤器组以替换它们,然后调整过滤器中所有项目的分配过滤器组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.