diff options
Diffstat (limited to 'Source/cmMakefile.h')
-rw-r--r-- | Source/cmMakefile.h | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1dc83b4..3a17aaf 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -20,6 +20,7 @@ #include <cm/string_view> #include "cmAlgorithms.h" +#include "cmCustomCommandTypes.h" #include "cmListFileCache.h" #include "cmMessageType.h" #include "cmNewLineStyle.h" @@ -28,7 +29,10 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" -#include "cmTarget.h" + +// IWYU does not see that 'std::unordered_map<std::string, cmTarget>' +// will not compile without the complete type. +#include "cmTarget.h" // IWYU pragma: keep #if !defined(CMAKE_BOOTSTRAP) # include "cmSourceGroup.h" @@ -164,22 +168,21 @@ public: */ void FinalPass(); - /** How to handle custom commands for object libraries */ - enum ObjectLibraryCommands - { - RejectObjectLibraryCommands, - AcceptObjectLibraryCommands - }; + /** + * Get the target for PRE_BUILD, PRE_LINK, or POST_BUILD commands. + */ + cmTarget* GetCustomCommandTarget( + const std::string& target, cmObjectLibraryCommands objLibCommands) const; /** Add a custom command to the build. */ cmTarget* AddCustomCommandToTarget( const std::string& target, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", const std::string& job_pool = "", bool command_expand_lists = false, - ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands); + cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject); cmSourceFile* AddCustomCommandToOutput( const std::string& output, const std::vector<std::string>& depends, const std::string& main_dependency, @@ -209,6 +212,19 @@ public: const cmCustomCommandLines& commandLines); /** + * Add target byproducts. + */ + void AddTargetByproducts(cmTarget* target, + const std::vector<std::string>& byproducts); + + /** + * Add source file outputs. + */ + void AddSourceOutputs(cmSourceFile* source, + const std::vector<std::string>& outputs, + const std::vector<std::string>& byproducts); + + /** * Add a define flag to the build. */ void AddDefineFlag(std::string const& definition); @@ -225,6 +241,10 @@ public: cmTarget* AddNewTarget(cmStateEnums::TargetType type, const std::string& name); + /** Create a target instance for the utility. */ + cmTarget* AddNewUtilityTarget(const std::string& utilityName, + cmCommandOrigin origin, bool excludeFromAll); + /** * Add an executable to the build. */ @@ -232,26 +252,19 @@ public: const std::vector<std::string>& srcs, bool excludeFromAll = false); - /** Where the target originated from. */ - enum class TargetOrigin - { - Project, - Generator - }; + /** + * Return the utility target output source file name and the CMP0049 name. + */ + cmUtilityOutput GetUtilityOutput(cmTarget* target); /** * Add a utility to the build. A utility target is a command that * is run every time the target is built. */ cmTarget* AddUtilityCommand( - const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, - const char* workingDirectory, const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, - const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false, const std::string& job_pool = ""); - cmTarget* AddUtilityCommand( - const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, - const char* workingDirectory, const std::vector<std::string>& byproducts, + const std::string& utilityName, cmCommandOrigin origin, + bool excludeFromAll, const char* workingDirectory, + const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, @@ -455,6 +468,12 @@ public: const std::string& sourceName, bool generated = false, cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous); + /** Get a cmSourceFile pointer for a given source name and always mark the + * file as generated, if the name is not found, then create the source file + * and return it. + */ + cmSourceFile* GetOrCreateGeneratedSource(const std::string& sourceName); + void AddTargetObject(std::string const& tgtName, std::string const& objFile); /** @@ -1036,13 +1055,12 @@ private: friend bool cmCMakePolicyCommand(std::vector<std::string> const& args, cmExecutionStatus& status); class IncludeScope; - friend class IncludeScope; - class ListFileScope; + class ListFileScope; friend class ListFileScope; - class BuildsystemFileScope; + class BuildsystemFileScope; friend class BuildsystemFileScope; // CMP0053 == old @@ -1061,10 +1079,12 @@ private: bool ValidateCustomCommand(const cmCustomCommandLines& commandLines) const; + void CreateGeneratedSources(const std::vector<std::string>& outputs); + void CommitCustomCommandToTarget( cmTarget* target, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, bool command_expand_lists); @@ -1083,8 +1103,7 @@ private: const cmImplicitDependsList& implicit_depends, const cmCustomCommandLines& commandLines); - void CommitUtilityCommand(cmTarget* target, const std::string& force, - const std::string& forceCMP0049, + void CommitUtilityCommand(cmTarget* target, const cmUtilityOutput& force, const char* workingDirectory, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, @@ -1093,9 +1112,6 @@ private: bool uses_terminal, bool command_expand_lists, const std::string& job_pool); - void CreateGeneratedSource(const std::string& output); - void CreateGeneratedSources(const std::vector<std::string>& outputs); - /** * See LinearGetSourceFileWithOutput for background information */ @@ -1120,12 +1136,7 @@ private: using OutputToSourceMap = std::unordered_map<std::string, SourceEntry>; OutputToSourceMap OutputToSource; - void UpdateOutputToSourceMap(std::vector<std::string> const& byproducts, - cmTarget* target); void UpdateOutputToSourceMap(std::string const& byproduct, cmTarget* target); - - void UpdateOutputToSourceMap(std::vector<std::string> const& outputs, - cmSourceFile* source, bool byproduct); void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source, bool byproduct); |