예제 #1
0
static void readAndDeleteLegacyCMakeSettings ()
{
    // restore the legacy cmake
    QSettings *settings = ICore::settings();
    settings->beginGroup(QLatin1String("CMakeSettings"));

    FileName exec = FileName::fromUserInput(settings->value(QLatin1String("cmakeExecutable")).toString());
    if (exec.toFileInfo().isExecutable()) {
        CMakeTool *item = CMakeToolManager::findByCommand(exec);
        if (!item) {
            item = new CMakeTool(CMakeTool::ManualDetection);
            item->setCMakeExecutable(exec);
            item->setDisplayName(CMakeToolManager::tr("CMake at %1").arg(item->cmakeExecutable().toUserOutput()));

            if (!CMakeToolManager::registerCMakeTool(item)) {
                delete item;
                item = 0;
            }
        }

        //this setting used to be the default cmake, make sure it is again
        if (item)
            d->m_defaultCMake = item->id();
    }

    //read the legacy ninja setting, if its not available use the current value
    d->m_preferNinja = settings->value(QLatin1String("preferNinja"), d->m_preferNinja).toBool();

    settings->remove(QString());
    settings->endGroup();
}
예제 #2
0
void CMakeKitInformation::addToMacroExpander(Kit *k, Utils::MacroExpander *expander) const
{
    expander->registerFileVariables("CMake:Executable", tr("Path to the cmake executable"),
                                    [this, k]() -> QString {
                                        CMakeTool *tool = CMakeKitInformation::cmakeTool(k);
                                        return tool ? tool->cmakeExecutable().toString() : QString();
                                    });
}
예제 #3
0
static QList<CMakeTool *> readCMakeTools(const FileName &fileName, Core::Id *defaultId, bool fromSDK)
{
    PersistentSettingsReader reader;
    if (!reader.load(fileName))
        return QList<CMakeTool *>();

    QVariantMap data = reader.restoreValues();

    // Check version
    int version = data.value(QLatin1String(CMAKETOOL_FILE_VERSION_KEY), 0).toInt();
    if (version < 1)
        return QList<CMakeTool *>();

    QList<CMakeTool *> loaded;

    int count = data.value(QLatin1String(CMAKETOOL_COUNT_KEY), 0).toInt();
    for (int i = 0; i < count; ++i) {
        const QString key = QString::fromLatin1(CMAKETOOL_DATA_KEY) + QString::number(i);
        if (!data.contains(key))
            continue;

        const QVariantMap dbMap = data.value(key).toMap();
        CMakeTool *item = new CMakeTool(dbMap,fromSDK);
        if (item->isAutoDetected()) {
            if (!item->cmakeExecutable().toFileInfo().isExecutable()) {
                qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) read from \"%3\" dropped since the command is not executable.")
                              .arg(item->cmakeExecutable().toUserOutput(), item->id().toString(), fileName.toUserOutput());
                delete item;
                continue;
            }
        }

        loaded.append(item);
    }

    *defaultId = Id::fromSetting(data.value(QLatin1String(CMAKETOOL_DEFAULT_KEY), defaultId->toSetting()));
    d->m_preferNinja= data.value(QLatin1String(CMAKETOOL_PREFER_NINJA_KEY), d->m_preferNinja).toBool();

    return loaded;
}
예제 #4
0
void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const
{
    CMakeTool *orig = CMakeToolManager::findById(item->m_id);
    item->m_changed = !orig || orig->displayName() != item->m_name
            || orig->cmakeExecutable() != item->m_executable;

    //make sure the item is marked as changed when the default cmake was changed
    CMakeTool *origDefTool = CMakeToolManager::defaultCMakeTool();
    Core::Id origDefault = origDefTool ? origDefTool->id() : Core::Id();
    if (origDefault != m_defaultItemId) {
        if (item->m_id == origDefault || item->m_id == m_defaultItemId)
            item->m_changed = true;
    }

    item->update(); // Notify views.
}
예제 #5
0
BuildDirReader::Parameters::Parameters(const CMakeBuildConfiguration *bc)
{
    const ProjectExplorer::Kit *k = bc->target()->kit();

    projectName = bc->target()->project()->displayName();

    sourceDirectory = bc->target()->project()->projectDirectory();
    buildDirectory = bc->buildDirectory();

    environment = bc->environment();

    CMakeTool *cmake = CMakeKitInformation::cmakeTool(k);
    cmakeVersion = cmake->version();
    cmakeHasServerMode = cmake->hasServerMode();
    cmakeExecutable = cmake->cmakeExecutable();

    pathMapper = cmake->pathMapper();
    isAutorun = cmake->isAutoRun();

    auto tc = ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::ToolChain::Language::Cxx);
    if (tc)
        cxxToolChainId = tc->id();
    tc = ProjectExplorer::ToolChainKitInformation::toolChain(k, ProjectExplorer::ToolChain::Language::C);
    if (tc)
        cToolChainId = tc->id();
    sysRoot = ProjectExplorer::SysRootKitInformation::sysRoot(k);

    expander = k->macroExpander();

    configuration = bc->cmakeConfiguration();

    generator = CMakeGeneratorKitInformation::generator(k);
    extraGenerator = CMakeGeneratorKitInformation::extraGenerator(k);
    platform = CMakeGeneratorKitInformation::platform(k);
    toolset = CMakeGeneratorKitInformation::toolset(k);
    generatorArguments = CMakeGeneratorKitInformation::generatorArguments(k);
}