aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cmakeprojectmanager/presetsmacros.h
blob: 49e47a71b1c076a17a039f7968660e98c4ee51cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <utils/environmentfwd.h>

namespace Utils {
class Environment;
class FilePath;
}

namespace CMakeProjectManager::Internal {

namespace PresetsDetails {
class ConfigurePreset;
}

namespace CMakePresets::Macros {
/**
 * Expands the CMakePresets Macros using Utils::Environment as target and source for parent environment values.
 * $penv{PATH} is taken from Utils::Environment
 */
template<class PresetType>
void expand(const PresetType &preset,
            Utils::Environment &env,
            const Utils::FilePath &sourceDirectory);

/**
 * Expands the CMakePresets Macros using Utils::Environment as target
 * $penv{PATH} is replaced with Qt Creator macros ${PATH}
 */
template<class PresetType>
void expand(const PresetType &preset,
            Utils::EnvironmentItems &envItems,
            const Utils::FilePath &sourceDirectory);

/**
 * Expands the CMakePresets macros inside the @value QString parameter.
 */
template<class PresetType>
void expand(const PresetType &preset,
            const Utils::Environment &env,
            const Utils::FilePath &sourceDirectory,
            QString &value);

/**
 * Updates the cacheVariables parameter of the configurePreset with the expandned toolchainFile parameter.
 * Including macro expansion and relative paths resolving.
 */
void updateToolchainFile(PresetsDetails::ConfigurePreset &configurePreset,
                         const Utils::Environment &env,
                         const Utils::FilePath &sourceDirectory,
                         const Utils::FilePath &buildDirectory);

/**
 * Updates the cacheVariables parameter of the configurePreset with the expanded installDir parameter.
 * Including macro expansion and relative paths resolving.
 */
void updateInstallDir(PresetsDetails::ConfigurePreset &configurePreset,
                      const Utils::Environment &env,
                      const Utils::FilePath &sourceDirectory);

/**
 * Updates the cacheVariables parameter of the configurePreset with the expanded prameter values.
 * Including macro expansion and relative paths resolving.
 */
void updateCacheVariables(PresetsDetails::ConfigurePreset &configurePreset,
                          const Utils::Environment &env,
                          const Utils::FilePath &sourceDirectory);
/**
 * Expands the condition values and then evaluates the condition object of the preset and returns
 * the boolean result.
 */
template<class PresetType>
bool evaluatePresetCondition(const PresetType &preset, const Utils::FilePath &sourceDirectory);

} // namespace CMakePresets::Macros

} // namespace CMakeProjectManager::Internal