简体   繁体   English

如何配置Qmake使用目录结构为项目中的源文件生成Visual Studio解决方案?

[英]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.

相关问题 在Visual Studio解决方案中为所有项目设置目录结构吗? - Set directory structure for all projects in a Visual Studio solution? Visual Studio:解决方案中的某些项目不会生成.exe文件 - Visual Studio: some projects in solution don't generate .exe files Waf生成Visual Studio项目? - Waf generating Visual Studio projects? 具有多个项目的 Visual Studio 解决方案 - Visual studio solution with multiple projects 如何在 Visual Studio 2022 上的单个解决方案中的项目之间共享库文件/包含文件夹? - How to share Library files/ include folders between projects in a single solution on Visual Studio 2022? 如何在Visual Studio中的项目之间共享C ++源代码文件? - How do I share C++ source code files between projects in Visual Studio? 如何将项目放在 Visual Studio 解决方案中的一个文件夹中 - How to put projects in one folder in a Visual Studio solution 在Visual Studio中为单个解决方案编译和使用多个项目 - Compiling and using multiple projects for a single solution in Visual Studio VSPackage使用C ++,如何在Visual Studio中获取当前的工作项目目录? - VSPackage using C++, How to get current working projects directory in visual studio? 使用CMake生成Visual Studio 2017项目 - Generating Visual Studio 2017 projects with CMake
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM