2017-09-28 11:32:39 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
**
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
**
|
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "builddirparameters.h"
|
|
|
|
|
|
|
|
#include "cmakebuildconfiguration.h"
|
2022-04-25 14:20:12 +02:00
|
|
|
#include "cmakebuildsystem.h"
|
2017-09-28 11:32:39 +02:00
|
|
|
#include "cmakekitinformation.h"
|
2018-05-24 16:57:31 +02:00
|
|
|
#include "cmaketoolmanager.h"
|
2017-09-28 11:32:39 +02:00
|
|
|
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
2020-04-17 15:30:05 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2017-09-28 11:32:39 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2020-04-17 15:30:05 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2017-09-28 11:32:39 +02:00
|
|
|
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/algorithm.h>
|
2020-04-09 15:23:01 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2018-08-30 09:48:33 +02:00
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
BuildDirParameters::BuildDirParameters() = default;
|
|
|
|
|
2022-04-25 14:20:12 +02:00
|
|
|
BuildDirParameters::BuildDirParameters(CMakeBuildSystem *buildSystem)
|
2017-09-28 11:32:39 +02:00
|
|
|
{
|
2022-04-25 14:20:12 +02:00
|
|
|
QTC_ASSERT(buildSystem, return);
|
|
|
|
auto bc = buildSystem->cmakeBuildConfiguration();
|
|
|
|
QTC_ASSERT(bc, return);
|
2017-09-28 11:32:39 +02:00
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
const Utils::MacroExpander *expander = bc->macroExpander();
|
|
|
|
|
2022-05-02 18:02:37 +02:00
|
|
|
const QStringList expandedArguments = Utils::transform(buildSystem->initialCMakeArguments(),
|
2021-02-04 14:53:42 +01:00
|
|
|
[expander](const QString &s) {
|
|
|
|
return expander->expand(s);
|
|
|
|
});
|
|
|
|
initialCMakeArguments = Utils::filtered(expandedArguments,
|
|
|
|
[](const QString &s) { return !s.isEmpty(); });
|
2022-05-02 18:02:37 +02:00
|
|
|
configurationChangesArguments = Utils::transform(buildSystem->configurationChangesArguments(),
|
2021-12-28 21:42:29 +01:00
|
|
|
[expander](const QString &s) {
|
|
|
|
return expander->expand(s);
|
|
|
|
});
|
2022-05-02 18:02:37 +02:00
|
|
|
additionalCMakeArguments = Utils::transform(buildSystem->additionalCMakeArguments(),
|
2021-12-28 21:42:29 +01:00
|
|
|
[expander](const QString &s) {
|
|
|
|
return expander->expand(s);
|
|
|
|
});
|
2020-04-03 10:20:05 +02:00
|
|
|
const Target *t = bc->target();
|
|
|
|
const Kit *k = t->kit();
|
|
|
|
const Project *p = t->project();
|
2017-09-28 11:32:39 +02:00
|
|
|
|
2020-04-03 10:20:05 +02:00
|
|
|
projectName = p->displayName();
|
2017-09-28 11:32:39 +02:00
|
|
|
|
2020-12-02 19:16:40 +01:00
|
|
|
sourceDirectory = bc->sourceDirectory();
|
|
|
|
if (sourceDirectory.isEmpty())
|
|
|
|
sourceDirectory = p->projectDirectory();
|
2017-09-28 11:32:39 +02:00
|
|
|
buildDirectory = bc->buildDirectory();
|
|
|
|
|
2022-05-02 18:02:37 +02:00
|
|
|
cmakeBuildType = buildSystem->cmakeBuildType();
|
2021-01-14 16:38:55 +01:00
|
|
|
|
2022-08-10 19:12:40 +02:00
|
|
|
environment = bc->configureEnvironment();
|
2018-08-30 09:48:33 +02:00
|
|
|
// Disable distributed building for configuration runs. CMake does not do those in parallel,
|
|
|
|
// so there is no win in sending data over the network.
|
|
|
|
// Unfortunately distcc does not have a simple environment flag to turn it off:-/
|
|
|
|
if (Utils::HostOsInfo::isAnyUnixHost())
|
|
|
|
environment.set("ICECC", "no");
|
2017-09-28 11:32:39 +02:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
cmakeToolId = CMakeKitAspect::cmakeToolId(k);
|
2017-09-28 11:32:39 +02:00
|
|
|
}
|
|
|
|
|
2020-04-03 10:20:05 +02:00
|
|
|
bool BuildDirParameters::isValid() const
|
|
|
|
{
|
|
|
|
return cmakeTool();
|
|
|
|
}
|
2018-05-24 16:57:31 +02:00
|
|
|
|
|
|
|
CMakeTool *BuildDirParameters::cmakeTool() const
|
|
|
|
{
|
|
|
|
return CMakeToolManager::findById(cmakeToolId);
|
|
|
|
}
|
2017-09-28 11:32:39 +02:00
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
} // namespace CMakeProjectManager
|