Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 从Qt5.pro文件设置Visual Studio 2010解决方案项目依赖项_Visual Studio 2010_Visual Studio_Qt_Qmake_Qt5 - Fatal编程技术网

Visual studio 2010 从Qt5.pro文件设置Visual Studio 2010解决方案项目依赖项

Visual studio 2010 从Qt5.pro文件设置Visual Studio 2010解决方案项目依赖项,visual-studio-2010,visual-studio,qt,qmake,qt5,Visual Studio 2010,Visual Studio,Qt,Qmake,Qt5,是否可以设置TEMPLATE=subdirs.pro文件,以便qmake-tp vc在生成的Visual Studio解决方案中设置项目依赖关系 我尝试过使用CONFIG+=ordered然后按正确顺序使用SUBDIRS+=条目,但这似乎对解决方案属性对话框中的“项目依赖项”设置没有影响 谢谢 我在回答我自己的问题,因为似乎还没有人找到解决办法。据我所知,仍然无法使用QT.pro文件设置VisualStudio项目依赖项。我们正在使用我们开发的可执行文件(也使用Qt)在项目构建完成后手动执行此操

是否可以设置
TEMPLATE=subdirs
.pro文件,以便
qmake-tp vc
在生成的Visual Studio解决方案中设置项目依赖关系

我尝试过使用
CONFIG+=ordered
然后按正确顺序使用
SUBDIRS+=
条目,但这似乎对解决方案属性对话框中的“项目依赖项”设置没有影响


谢谢

我在回答我自己的问题,因为似乎还没有人找到解决办法。据我所知,仍然无法使用QT.pro文件设置VisualStudio项目依赖项。我们正在使用我们开发的可执行文件(也使用Qt)在项目构建完成后手动执行此操作。用于为VisualStudio2010解决方案构建可执行文件的代码如下所示。它相当简单,并更新您的解决方案,使所有包含的项目都依赖于命令行中输入的所有项目。例如,
vcSlnDependencies filename.sln dependency1 dependency2 dependency3
将filename.sln中的所有项目设置为dependency1、dependency2和dependency3。显然,一个项目永远不会依赖于它自己。此代码应易于修改,以允许更复杂的依赖关系结构

#include <QFile>
#include <QDir>
#include <QFileInfo>
#include <QStringList>
#include <QUuid>
#include <QTextStream>

#include <iostream>
#include <vector>
#include <map>

std::map<QString, QString> dependencyGuids;
std::vector<QString> dependencies;

int main(int argc, char *argv[])
{
    if(argc<3)
    {
        std::cout << "Usage:" << std::endl << std::endl << "vcSlnDependencies filename.sln dependency1 dependency2 dependency3 ..." << std::endl;

        return -1;
    }
    else
    {
        for(int i = 2; i < argc; i++)
        {
            dependencies.push_back(argv[i]);
        }
    }

    QFile file(argv[1]);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        std::cout << "Could not open sln file: " << argv[1] << "." << std::endl;
        return -1;
    }

    QFileInfo fileInfo(file);

    std::cout << "Processing " << fileInfo.fileName().toStdString() << std::endl;

    QByteArray fileData;
    fileData = file.readAll();
    file.close();

    QFile outFile(argv[1]);
    if(!outFile.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        std::cout << "Could not open sln file: " << argv[1] << "." << std::endl;
        return -1;
    }

    QTextStream reader(fileData);
    QTextStream writer(&outFile);

    //first populate the dependency guids
    while(!reader.atEnd())
    {
        QString currentLine = reader.readLine();

        for(unsigned int i = 0; i < dependencies.size(); i++)
        {
            if(currentLine.contains(dependencies[i]) && currentLine.contains(".vcxproj") && currentLine.contains("Project(\"{"))
            {
                dependencyGuids[dependencies[i]] = currentLine.right(39).left(38);
                std::cout << "Setting dependency GUID for " << dependencies[i].toLatin1().data() << " to " << currentLine.right(39).left(38).toLatin1().data() << "\n";
            }
        }               
    }
    reader.seek(0);

    //now update other projects with those dependencies
    while(!reader.atEnd())
    {
        QString currentLine = reader.readLine();

        writer << currentLine << "\n";

        if(currentLine.contains(".vcxproj") && currentLine.contains("Project(\"{"))
        {
            QString currentGuid = currentLine.mid(9,38);

            std::vector<QString> currentDependencies;

            for(std::map<QString, QString>::const_iterator iter = dependencyGuids.begin(); iter != dependencyGuids.end(); ++iter)
            {
                if(iter->second != currentGuid)
                {
                    currentDependencies.push_back(iter->second);
                }
            }

            if(currentDependencies.size() > 0)
            {
                writer << "\tProjectSection(ProjectDependencies) = postProject\n";

                for(unsigned int i = 0; i < currentDependencies.size(); i++)
                {
                    writer << "\t\t" << currentDependencies[i] << " = " << currentDependencies[i] << "\n";                  
                }

                writer << "\tEndProjectSection\n";
            }
        }       
    }

    writer.flush();
    outFile.close();

    return 0;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
std::映射依赖GUID;
向量依赖;
int main(int argc,char*argv[])
{

如果(argc您使用的是什么版本的Qt和Visual Studio?我们使用的是Qt5和Visual Studio 2010。我们以前使用的是Qt4.8和VS2008。在该设置中,我们通过运行一个脚本来设置依赖项,该脚本在qmake创建.sln文件后直接更改了该文件。VS2010中的新.sln格式打破了此脚本,我们希望获得更多的支持直接解决方案。