2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-02-14 15:36:04 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-02-14 15:36:04 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2006-02-14 15:36:04 +00:00
|
|
|
#ifndef cmMakefileTargetGenerator_h
|
|
|
|
#define cmMakefileTargetGenerator_h
|
|
|
|
|
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
2012-07-16 15:34:22 +00:00
|
|
|
#include "cmOSXBundleGenerator.h"
|
2006-02-14 15:36:04 +00:00
|
|
|
|
|
|
|
class cmCustomCommand;
|
|
|
|
class cmDependInformation;
|
|
|
|
class cmDepends;
|
2012-03-07 16:54:52 +00:00
|
|
|
class cmGeneratorTarget;
|
2006-02-14 15:36:04 +00:00
|
|
|
class cmGeneratedFileStream;
|
2006-12-14 19:30:41 +00:00
|
|
|
class cmGlobalUnixMakefileGenerator3;
|
2006-02-14 15:36:04 +00:00
|
|
|
class cmLocalUnixMakefileGenerator3;
|
|
|
|
class cmMakefile;
|
|
|
|
class cmTarget;
|
|
|
|
class cmSourceFile;
|
|
|
|
|
|
|
|
/** \class cmMakefileTargetGenerator
|
|
|
|
* \brief Support Routines for writing makefiles
|
|
|
|
*
|
|
|
|
*/
|
2006-03-28 13:54:01 +00:00
|
|
|
class cmMakefileTargetGenerator
|
2006-02-14 15:36:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-02-15 17:32:43 +00:00
|
|
|
// constructor to set the ivars
|
2008-02-18 21:38:34 +00:00
|
|
|
cmMakefileTargetGenerator(cmTarget* target);
|
2012-07-18 10:17:39 +00:00
|
|
|
virtual ~cmMakefileTargetGenerator();
|
2006-02-15 17:32:43 +00:00
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// construct using this factory call
|
2008-02-18 21:38:34 +00:00
|
|
|
static cmMakefileTargetGenerator *New(cmTarget *tgt);
|
2006-02-14 15:36:04 +00:00
|
|
|
|
|
|
|
/* the main entry point for this class. Writes the Makefiles associated
|
|
|
|
with this target */
|
|
|
|
virtual void WriteRuleFiles() = 0;
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2006-07-11 13:55:27 +00:00
|
|
|
/* return the number of actions that have progress reporting on them */
|
|
|
|
virtual unsigned long GetNumberOfProgressActions() {
|
|
|
|
return this->NumberOfProgressActions;}
|
2009-06-25 13:58:51 +00:00
|
|
|
std::string GetProgressFileNameFull()
|
|
|
|
{ return this->ProgressFileNameFull; }
|
2006-07-11 13:55:27 +00:00
|
|
|
|
2007-02-16 21:12:17 +00:00
|
|
|
cmTarget* GetTarget() { return this->Target;}
|
2012-07-18 11:39:14 +00:00
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// create the file and directory etc
|
|
|
|
void CreateRuleFile();
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2006-06-01 15:45:51 +00:00
|
|
|
// outputs the rules for object files and custom commands used by
|
|
|
|
// this target
|
|
|
|
void WriteTargetBuildRules();
|
2006-02-14 15:36:04 +00:00
|
|
|
|
|
|
|
// write some common code at the top of build.make
|
|
|
|
void WriteCommonCodeRules();
|
2006-06-01 15:45:51 +00:00
|
|
|
void WriteTargetLanguageFlags();
|
2006-02-14 15:36:04 +00:00
|
|
|
|
|
|
|
// write the provide require rules for this target
|
|
|
|
void WriteTargetRequiresRules();
|
|
|
|
|
|
|
|
// write the clean rules for this target
|
|
|
|
void WriteTargetCleanRules();
|
|
|
|
|
|
|
|
// write the depend rules for this target
|
|
|
|
void WriteTargetDependRules();
|
|
|
|
|
2008-02-15 16:22:23 +00:00
|
|
|
// write rules for Mac OS X Application Bundle content.
|
2012-07-18 10:17:39 +00:00
|
|
|
struct MacOSXContentGeneratorType :
|
|
|
|
cmOSXBundleGenerator::MacOSXContentGeneratorType
|
2012-07-16 15:34:22 +00:00
|
|
|
{
|
2012-07-18 10:17:39 +00:00
|
|
|
MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) :
|
|
|
|
Generator(gen) {}
|
|
|
|
|
|
|
|
void operator()(cmSourceFile& source, const char* pkgloc);
|
2012-07-16 15:34:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
cmMakefileTargetGenerator* Generator;
|
|
|
|
};
|
2012-07-18 11:39:14 +00:00
|
|
|
friend struct MacOSXContentGeneratorType;
|
2008-02-15 16:22:23 +00:00
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// write the rules for an object
|
|
|
|
void WriteObjectRuleFiles(cmSourceFile& source);
|
|
|
|
|
|
|
|
// write the build rule for an object
|
|
|
|
void WriteObjectBuildFile(std::string &obj,
|
2006-03-28 13:54:01 +00:00
|
|
|
const char *lang,
|
2006-02-14 15:36:04 +00:00
|
|
|
cmSourceFile& source,
|
|
|
|
std::vector<std::string>& depends);
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// write the depend.make file for an object
|
|
|
|
void WriteObjectDependRules(cmSourceFile& source,
|
|
|
|
std::vector<std::string>& depends);
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2006-06-01 15:45:51 +00:00
|
|
|
// write the build rule for a custom command
|
2006-02-14 15:36:04 +00:00
|
|
|
void GenerateCustomRuleFile(const cmCustomCommand& cc);
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2007-03-09 16:29:15 +00:00
|
|
|
// write a rule to drive building of more than one output from
|
|
|
|
// another rule
|
|
|
|
void GenerateExtraOutput(const char* out, const char* in,
|
|
|
|
bool symbolic = false);
|
|
|
|
|
2009-03-16 20:22:13 +00:00
|
|
|
void AppendProgress(std::vector<std::string>& commands);
|
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// write out the variable that lists the objects for this target
|
|
|
|
void WriteObjectsVariable(std::string& variableName,
|
|
|
|
std::string& variableNameExternal);
|
2006-06-15 20:17:11 +00:00
|
|
|
void WriteObjectsString(std::string& buildObjs);
|
2008-01-30 01:46:25 +00:00
|
|
|
void WriteObjectsStrings(std::vector<std::string>& objStrings,
|
|
|
|
std::string::size_type limit = std::string::npos);
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2006-06-01 15:45:51 +00:00
|
|
|
// write the driver rule to build target outputs
|
|
|
|
void WriteTargetDriverRule(const char* main_output, bool relink);
|
|
|
|
|
2006-09-28 20:40:35 +00:00
|
|
|
void DriveCustomCommands(std::vector<std::string>& depends);
|
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// Return the a string with -F flags on apple
|
2013-10-10 12:29:04 +00:00
|
|
|
std::string GetFrameworkFlags(std::string const& l);
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2011-08-31 14:24:43 +00:00
|
|
|
void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source);
|
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// append intertarget dependencies
|
|
|
|
void AppendTargetDepends(std::vector<std::string>& depends);
|
|
|
|
|
2012-03-12 14:54:37 +00:00
|
|
|
// Append object file dependencies.
|
|
|
|
void AppendObjectDepends(std::vector<std::string>& depends);
|
|
|
|
|
2010-11-05 12:33:47 +00:00
|
|
|
// Append link rule dependencies (objects, etc.).
|
|
|
|
void AppendLinkDepends(std::vector<std::string>& depends);
|
|
|
|
|
2011-12-05 21:28:03 +00:00
|
|
|
// Lookup the link rule for this target.
|
|
|
|
std::string GetLinkRule(const char* linkRuleVar);
|
|
|
|
|
2007-12-21 17:22:12 +00:00
|
|
|
/** In order to support parallel builds for custom commands with
|
|
|
|
multiple outputs the outputs are given a serial order, and only
|
|
|
|
the first output actually has the build rule. Other outputs
|
|
|
|
just depend on the first one. The check-build-system step must
|
|
|
|
remove a dependee if the depender is missing to make sure both
|
|
|
|
are regenerated properly. This method is used by the local
|
|
|
|
makefile generators to register such pairs. */
|
|
|
|
void AddMultipleOutputPair(const char* depender, const char* dependee);
|
|
|
|
|
2007-12-28 19:59:06 +00:00
|
|
|
/** Create a script to hold link rules and a command to invoke the
|
|
|
|
script at build time. */
|
|
|
|
void CreateLinkScript(const char* name,
|
|
|
|
std::vector<std::string> const& link_commands,
|
2008-02-20 19:56:29 +00:00
|
|
|
std::vector<std::string>& makefile_commands,
|
|
|
|
std::vector<std::string>& makefile_depends);
|
2007-12-28 19:59:06 +00:00
|
|
|
|
2008-02-27 22:10:45 +00:00
|
|
|
/** Create a response file with the given set of options. Returns
|
|
|
|
the relative path from the target build working directory to the
|
|
|
|
response file name. */
|
|
|
|
std::string CreateResponseFile(const char* name,
|
|
|
|
std::string const& options,
|
|
|
|
std::vector<std::string>& makefile_depends);
|
|
|
|
|
2008-10-15 14:21:14 +00:00
|
|
|
/** Create lists of object files for linking and cleaning. */
|
|
|
|
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
|
|
|
|
bool useResponseFile, std::string& buildObjs,
|
|
|
|
std::vector<std::string>& makefile_depends);
|
|
|
|
|
2011-03-15 18:07:36 +00:00
|
|
|
void AddIncludeFlags(std::string& flags, const char* lang);
|
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
virtual void CloseFileStreams();
|
2006-03-28 13:54:01 +00:00
|
|
|
void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
|
2006-03-14 19:03:16 +00:00
|
|
|
std::string& linkFlags);
|
2006-02-14 15:36:04 +00:00
|
|
|
cmTarget *Target;
|
2012-03-07 16:54:52 +00:00
|
|
|
cmGeneratorTarget* GeneratorTarget;
|
2006-02-14 15:36:04 +00:00
|
|
|
cmLocalUnixMakefileGenerator3 *LocalGenerator;
|
2006-12-14 19:30:41 +00:00
|
|
|
cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
|
2006-02-14 15:36:04 +00:00
|
|
|
cmMakefile *Makefile;
|
2009-07-03 12:41:10 +00:00
|
|
|
const char *ConfigName;
|
2006-03-28 13:54:01 +00:00
|
|
|
|
2007-05-01 17:51:25 +00:00
|
|
|
enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility };
|
|
|
|
CustomCommandDriveType CustomCommandDriver;
|
2006-09-28 20:40:35 +00:00
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// the full path to the build file
|
|
|
|
std::string BuildFileName;
|
|
|
|
std::string BuildFileNameFull;
|
|
|
|
|
2006-07-11 13:55:27 +00:00
|
|
|
// the full path to the progress file
|
|
|
|
std::string ProgressFileNameFull;
|
|
|
|
unsigned long NumberOfProgressActions;
|
2009-03-16 20:55:58 +00:00
|
|
|
bool NoRuleMessages;
|
2006-07-11 13:55:27 +00:00
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
// the path to the directory the build file is in
|
|
|
|
std::string TargetBuildDirectory;
|
|
|
|
std::string TargetBuildDirectoryFull;
|
|
|
|
|
|
|
|
// the stream for the build file
|
|
|
|
cmGeneratedFileStream *BuildFileStream;
|
|
|
|
|
|
|
|
// the stream for the flag file
|
|
|
|
std::string FlagFileNameFull;
|
|
|
|
cmGeneratedFileStream *FlagFileStream;
|
2011-03-15 18:07:36 +00:00
|
|
|
class StringList: public std::vector<std::string> {};
|
|
|
|
std::map<cmStdString, StringList> FlagFileDepends;
|
2006-02-14 15:36:04 +00:00
|
|
|
|
|
|
|
// the stream for the info file
|
|
|
|
std::string InfoFileNameFull;
|
|
|
|
cmGeneratedFileStream *InfoFileStream;
|
|
|
|
|
|
|
|
// files to clean
|
|
|
|
std::vector<std::string> CleanFiles;
|
|
|
|
|
|
|
|
// objects used by this target
|
|
|
|
std::vector<std::string> Objects;
|
|
|
|
std::vector<std::string> ExternalObjects;
|
|
|
|
|
|
|
|
// Set of object file names that will be built in this directory.
|
2006-03-15 16:02:08 +00:00
|
|
|
std::set<cmStdString> ObjectFiles;
|
2006-02-14 15:36:04 +00:00
|
|
|
|
2008-02-15 16:22:23 +00:00
|
|
|
// Set of extra output files to be driven by the build.
|
|
|
|
std::set<cmStdString> ExtraFiles;
|
|
|
|
|
2007-12-21 17:22:12 +00:00
|
|
|
typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
|
|
|
|
MultipleOutputPairsType MultipleOutputPairs;
|
2006-02-14 15:36:04 +00:00
|
|
|
|
2008-02-18 21:38:34 +00:00
|
|
|
// Target name info.
|
|
|
|
std::string TargetNameOut;
|
|
|
|
std::string TargetNameSO;
|
|
|
|
std::string TargetNameReal;
|
|
|
|
std::string TargetNameImport;
|
|
|
|
std::string TargetNamePDB;
|
|
|
|
|
|
|
|
// Mac OS X content info.
|
2008-04-08 04:06:47 +00:00
|
|
|
std::set<cmStdString> MacContentFolders;
|
2012-07-16 15:34:22 +00:00
|
|
|
cmOSXBundleGenerator* OSXBundleGenerator;
|
2012-07-18 10:17:39 +00:00
|
|
|
MacOSXContentGeneratorType* MacOSXContentGenerator;
|
2008-02-18 21:38:34 +00:00
|
|
|
|
2011-05-17 12:50:55 +00:00
|
|
|
typedef std::map<cmStdString, cmStdString> ByLanguageMap;
|
2011-01-13 04:06:25 +00:00
|
|
|
std::string GetFlags(const std::string &l);
|
2011-05-17 12:50:55 +00:00
|
|
|
ByLanguageMap FlagsByLanguage;
|
2011-01-13 04:06:25 +00:00
|
|
|
std::string GetDefines(const std::string &l);
|
2011-05-17 12:50:55 +00:00
|
|
|
ByLanguageMap DefinesByLanguage;
|
2011-01-13 04:06:25 +00:00
|
|
|
|
2007-12-30 21:11:38 +00:00
|
|
|
// Target-wide Fortran module output directory.
|
|
|
|
bool FortranModuleDirectoryComputed;
|
|
|
|
std::string FortranModuleDirectory;
|
|
|
|
const char* GetFortranModuleDirectory();
|
|
|
|
|
|
|
|
// Compute target-specific Fortran language flags.
|
|
|
|
void AddFortranFlags(std::string& flags);
|
|
|
|
|
2009-09-29 20:39:07 +00:00
|
|
|
// Helper to add flag for windows .def file.
|
|
|
|
void AddModuleDefinitionFlag(std::string& flags);
|
|
|
|
|
2009-10-02 17:51:49 +00:00
|
|
|
// Add language feature flags.
|
|
|
|
void AddFeatureFlags(std::string& flags, const char* lang);
|
|
|
|
|
2009-10-02 17:52:01 +00:00
|
|
|
// Feature query methods.
|
|
|
|
const char* GetFeature(const char* feature);
|
|
|
|
bool GetFeatureAsBool(const char* feature);
|
|
|
|
|
2006-02-14 15:36:04 +00:00
|
|
|
//==================================================================
|
2006-03-28 13:54:01 +00:00
|
|
|
// Convenience routines that do nothing more than forward to
|
2006-02-14 15:36:04 +00:00
|
|
|
// implementaitons
|
2006-03-28 13:54:01 +00:00
|
|
|
std::string Convert(const char* source,
|
|
|
|
cmLocalGenerator::RelativeRoot relative,
|
|
|
|
cmLocalGenerator::OutputFormat output =
|
2006-02-14 15:36:04 +00:00
|
|
|
cmLocalGenerator::UNCHANGED,
|
2006-03-28 13:54:01 +00:00
|
|
|
bool optional = false)
|
2006-02-14 15:36:04 +00:00
|
|
|
{
|
|
|
|
return this->LocalGenerator->Convert(source, relative, output, optional);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|