1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 19:08:07 +08:00
Files
CMake/Source/cmRulePlaceholderExpander.h
Brad King 4b23359117 ninja: Add experimental infrastructure for C++20 module dependency scanning
Optionally enable this infrastructure through an undocumented
`CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP` variable.  Currently this is
experimental and intended for use by compiler writers to implement their
scanning tools.  Warn as such when the feature is activated.  Later when
compilers provide the needed scanning tools we can enable this variable
from our corresponding compiler information modules.  It is never meant
to be set by project code.

When enabled, generate a build graph similar to what we use for Fortran
module dependencies.  There are some differences needed because we can
scan dependencies without explicit preprocessing, and can directly
compile the original source afterward.

Co-Author: Ben Boeckel <ben.boeckel@kitware.com>
2021-01-05 09:34:55 -05:00

90 lines
2.9 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <string>
class cmOutputConverter;
class cmRulePlaceholderExpander
{
public:
cmRulePlaceholderExpander(
std::map<std::string, std::string> compilers,
std::map<std::string, std::string> variableMappings,
std::string compilerSysroot, std::string linkerSysroot);
void SetTargetImpLib(std::string const& targetImpLib)
{
this->TargetImpLib = targetImpLib;
}
// Create a struct to hold the variables passed into
// ExpandRuleVariables
struct RuleVariables
{
const char* CMTargetName = nullptr;
const char* CMTargetType = nullptr;
const char* TargetPDB = nullptr;
const char* TargetCompilePDB = nullptr;
const char* TargetVersionMajor = nullptr;
const char* TargetVersionMinor = nullptr;
const char* Language = nullptr;
const char* AIXExports = nullptr;
const char* Objects = nullptr;
const char* Target = nullptr;
const char* LinkLibraries = nullptr;
const char* Source = nullptr;
const char* AssemblySource = nullptr;
const char* PreprocessedSource = nullptr;
const char* DynDepFile = nullptr;
const char* Output = nullptr;
const char* Object = nullptr;
const char* ObjectDir = nullptr;
const char* ObjectFileDir = nullptr;
const char* Flags = nullptr;
const char* ObjectsQuoted = nullptr;
const char* SONameFlag = nullptr;
const char* TargetSOName = nullptr;
const char* TargetInstallNameDir = nullptr;
const char* LinkFlags = nullptr;
const char* Manifests = nullptr;
const char* LanguageCompileFlags = nullptr;
const char* Defines = nullptr;
const char* Includes = nullptr;
const char* DependencyFile = nullptr;
const char* DependencyTarget = nullptr;
const char* FilterPrefix = nullptr;
const char* SwiftLibraryName = nullptr;
const char* SwiftModule = nullptr;
const char* SwiftModuleName = nullptr;
const char* SwiftOutputFileMap = nullptr;
const char* SwiftSources = nullptr;
const char* ISPCHeader = nullptr;
const char* Fatbinary = nullptr;
const char* RegisterFile = nullptr;
};
// Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(cmOutputConverter* outputConverter,
std::string& string,
const RuleVariables& replaceValues);
// Expand rule variables in a single string
std::string ExpandRuleVariable(cmOutputConverter* outputConverter,
std::string const& variable,
const RuleVariables& replaceValues);
private:
std::string TargetImpLib;
std::map<std::string, std::string> Compilers;
std::map<std::string, std::string> VariableMappings;
std::string CompilerSysroot;
std::string LinkerSysroot;
};