2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2009-09-28 19:43:28 +04: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 18:36:04 +03:00
|
|
|
#include "cmMakefileTargetGenerator.h"
|
|
|
|
|
2012-03-07 20:54:52 +04:00
|
|
|
#include "cmGeneratorTarget.h"
|
2006-02-14 18:36:04 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
2006-04-11 19:06:19 +04:00
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
2006-02-14 18:36:04 +03:00
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSourceFile.h"
|
|
|
|
#include "cmTarget.h"
|
2006-06-14 20:28:32 +04:00
|
|
|
#include "cmake.h"
|
2008-05-22 03:57:35 +04:00
|
|
|
#include "cmComputeLinkInformation.h"
|
2014-03-10 23:47:19 +04:00
|
|
|
#include "cmCustomCommandGenerator.h"
|
2013-08-28 02:20:29 +04:00
|
|
|
#include "cmGeneratorExpression.h"
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
#include "cmMakefileExecutableTargetGenerator.h"
|
|
|
|
#include "cmMakefileLibraryTargetGenerator.h"
|
|
|
|
#include "cmMakefileUtilityTargetGenerator.h"
|
|
|
|
|
2013-11-16 00:41:11 +04:00
|
|
|
#include <ctype.h>
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2008-02-19 00:38:34 +03:00
|
|
|
cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target)
|
2012-07-16 19:34:22 +04:00
|
|
|
: OSXBundleGenerator(0)
|
2012-07-18 14:17:39 +04:00
|
|
|
, MacOSXContentGenerator(0)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
|
|
|
this->BuildFileStream = 0;
|
|
|
|
this->InfoFileStream = 0;
|
2006-02-16 00:35:16 +03:00
|
|
|
this->FlagFileStream = 0;
|
2007-05-01 21:51:25 +04:00
|
|
|
this->CustomCommandDriver = OnBuild;
|
2007-12-31 00:11:38 +03:00
|
|
|
this->FortranModuleDirectoryComputed = false;
|
2008-02-19 00:38:34 +03:00
|
|
|
this->Target = target;
|
|
|
|
this->Makefile = this->Target->GetMakefile();
|
|
|
|
this->LocalGenerator =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>(
|
|
|
|
this->Makefile->GetLocalGenerator());
|
2009-07-03 16:41:10 +04:00
|
|
|
this->ConfigName = this->LocalGenerator->ConfigurationName.c_str();
|
2008-02-19 00:38:34 +03:00
|
|
|
this->GlobalGenerator =
|
|
|
|
static_cast<cmGlobalUnixMakefileGenerator3*>(
|
|
|
|
this->LocalGenerator->GetGlobalGenerator());
|
2012-03-07 20:54:52 +04:00
|
|
|
this->GeneratorTarget = this->GlobalGenerator->GetGeneratorTarget(target);
|
2009-03-16 23:22:19 +03:00
|
|
|
cmake* cm = this->GlobalGenerator->GetCMakeInstance();
|
2009-03-16 23:55:58 +03:00
|
|
|
this->NoRuleMessages = false;
|
|
|
|
if(const char* ruleStatus = cm->GetProperty("RULE_MESSAGES"))
|
2009-03-16 23:22:19 +03:00
|
|
|
{
|
2009-03-16 23:55:58 +03:00
|
|
|
this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus);
|
2009-03-16 23:22:19 +03:00
|
|
|
}
|
2012-07-18 14:17:39 +04:00
|
|
|
MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmMakefileTargetGenerator::~cmMakefileTargetGenerator()
|
|
|
|
{
|
|
|
|
delete MacOSXContentGenerator;
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmMakefileTargetGenerator *
|
2012-10-10 23:32:37 +04:00
|
|
|
cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
|
|
|
cmMakefileTargetGenerator *result = 0;
|
|
|
|
|
|
|
|
switch (tgt->GetType())
|
|
|
|
{
|
|
|
|
case cmTarget::EXECUTABLE:
|
2008-02-19 00:38:34 +03:00
|
|
|
result = new cmMakefileExecutableTargetGenerator(tgt);
|
2006-02-14 18:36:04 +03:00
|
|
|
break;
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
2012-03-12 18:54:37 +04:00
|
|
|
case cmTarget::OBJECT_LIBRARY:
|
2008-02-19 00:38:34 +03:00
|
|
|
result = new cmMakefileLibraryTargetGenerator(tgt);
|
2006-02-14 18:36:04 +03:00
|
|
|
break;
|
|
|
|
case cmTarget::UTILITY:
|
2008-02-19 00:38:34 +03:00
|
|
|
result = new cmMakefileUtilityTargetGenerator(tgt);
|
2006-02-14 18:36:04 +03:00
|
|
|
break;
|
|
|
|
default:
|
2006-02-16 21:42:58 +03:00
|
|
|
return result;
|
2006-08-01 19:38:42 +04:00
|
|
|
// break; /* unreachable */
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::CreateRuleFile()
|
|
|
|
{
|
|
|
|
// Create a directory for this target.
|
2006-07-10 15:52:35 +04:00
|
|
|
this->TargetBuildDirectory =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->GetTargetDirectory(*this->Target);
|
2006-07-10 15:52:35 +04:00
|
|
|
this->TargetBuildDirectoryFull =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->ConvertToFullPath(this->TargetBuildDirectory);
|
|
|
|
cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull.c_str());
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Construct the rule file name.
|
|
|
|
this->BuildFileName = this->TargetBuildDirectory;
|
|
|
|
this->BuildFileName += "/build.make";
|
|
|
|
this->BuildFileNameFull = this->TargetBuildDirectoryFull;
|
|
|
|
this->BuildFileNameFull += "/build.make";
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-07-11 17:55:27 +04:00
|
|
|
// Construct the rule file name.
|
|
|
|
this->ProgressFileNameFull = this->TargetBuildDirectoryFull;
|
|
|
|
this->ProgressFileNameFull += "/progress.make";
|
|
|
|
|
|
|
|
// reset the progress count
|
|
|
|
this->NumberOfProgressActions = 0;
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Open the rule file. This should be copy-if-different because the
|
|
|
|
// rules may depend on this file itself.
|
2006-07-10 15:52:35 +04:00
|
|
|
this->BuildFileStream =
|
2006-02-14 18:36:04 +03:00
|
|
|
new cmGeneratedFileStream(this->BuildFileNameFull.c_str());
|
|
|
|
this->BuildFileStream->SetCopyIfDifferent(true);
|
|
|
|
if(!this->BuildFileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream);
|
|
|
|
this->LocalGenerator->WriteSpecialTargetsTop(*this->BuildFileStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-06-01 19:45:51 +04:00
|
|
|
void cmMakefileTargetGenerator::WriteTargetBuildRules()
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
|
|
|
// write the custom commands for this target
|
|
|
|
// Look for files registered for cleaning in this directory.
|
|
|
|
if(const char* additional_clean_files =
|
|
|
|
this->Makefile->GetProperty
|
|
|
|
("ADDITIONAL_MAKE_CLEAN_FILES"))
|
|
|
|
{
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
|
2013-08-28 02:20:29 +04:00
|
|
|
cmListFileBacktrace lfbt;
|
|
|
|
cmGeneratorExpression ge(lfbt);
|
|
|
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
|
|
|
|
ge.Parse(additional_clean_files);
|
|
|
|
|
|
|
|
cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config,
|
|
|
|
false, this->Target, 0, 0),
|
2006-02-14 18:36:04 +03:00
|
|
|
this->CleanFiles);
|
2006-07-10 15:52:35 +04:00
|
|
|
}
|
2006-06-01 19:45:51 +04:00
|
|
|
|
|
|
|
// add custom commands to the clean rules?
|
2006-07-10 15:52:35 +04:00
|
|
|
const char* clean_no_custom =
|
2006-06-01 19:45:51 +04:00
|
|
|
this->Makefile->GetProperty("CLEAN_NO_CUSTOM");
|
|
|
|
bool clean = cmSystemTools::IsOff(clean_no_custom);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
// First generate the object rule files. Save a list of all object
|
|
|
|
// files for this target.
|
2013-11-10 14:22:44 +04:00
|
|
|
std::vector<cmSourceFile*> customCommands;
|
|
|
|
this->GeneratorTarget->GetCustomCommands(customCommands);
|
2012-03-07 20:54:52 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator
|
2013-11-10 14:22:44 +04:00
|
|
|
si = customCommands.begin();
|
|
|
|
si != customCommands.end(); ++si)
|
2006-06-01 19:45:51 +04:00
|
|
|
{
|
2014-03-10 23:47:19 +04:00
|
|
|
cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(),
|
|
|
|
this->ConfigName,
|
|
|
|
this->Makefile);
|
|
|
|
this->GenerateCustomRuleFile(ccg);
|
2012-03-07 20:54:52 +04:00
|
|
|
if (clean)
|
2006-06-01 19:45:51 +04:00
|
|
|
{
|
2014-03-10 23:47:19 +04:00
|
|
|
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
2012-03-07 20:54:52 +04:00
|
|
|
for(std::vector<std::string>::const_iterator o = outputs.begin();
|
|
|
|
o != outputs.end(); ++o)
|
2006-06-01 19:45:51 +04:00
|
|
|
{
|
2012-03-07 20:54:52 +04:00
|
|
|
this->CleanFiles.push_back
|
2014-03-11 03:04:11 +04:00
|
|
|
(this->Convert(*o,
|
2012-03-07 20:54:52 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::UNCHANGED));
|
2006-06-01 19:45:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-10 14:22:44 +04:00
|
|
|
std::vector<cmSourceFile*> headerSources;
|
|
|
|
this->GeneratorTarget->GetHeaderSources(headerSources);
|
2012-07-16 19:34:22 +04:00
|
|
|
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
|
2013-11-10 14:22:44 +04:00
|
|
|
headerSources,
|
2012-07-18 14:17:39 +04:00
|
|
|
this->MacOSXContentGenerator);
|
2013-11-10 14:22:44 +04:00
|
|
|
std::vector<cmSourceFile*> extraSources;
|
|
|
|
this->GeneratorTarget->GetExtraSources(extraSources);
|
2012-07-16 19:34:22 +04:00
|
|
|
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
|
2013-11-10 14:22:44 +04:00
|
|
|
extraSources,
|
2012-07-18 14:17:39 +04:00
|
|
|
this->MacOSXContentGenerator);
|
2013-11-10 14:22:44 +04:00
|
|
|
std::vector<cmSourceFile*> externalObjects;
|
|
|
|
this->GeneratorTarget->GetExternalObjects(externalObjects);
|
2012-03-07 20:54:52 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator
|
2013-11-10 14:22:44 +04:00
|
|
|
si = externalObjects.begin();
|
|
|
|
si != externalObjects.end(); ++si)
|
2012-03-07 20:54:52 +04:00
|
|
|
{
|
|
|
|
this->ExternalObjects.push_back((*si)->GetFullPath());
|
|
|
|
}
|
2013-11-10 14:22:44 +04:00
|
|
|
std::vector<cmSourceFile*> objectSources;
|
|
|
|
this->GeneratorTarget->GetObjectSources(objectSources);
|
2012-03-07 20:54:52 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator
|
2013-11-10 14:22:44 +04:00
|
|
|
si = objectSources.begin(); si != objectSources.end(); ++si)
|
2012-03-07 20:54:52 +04:00
|
|
|
{
|
|
|
|
// Generate this object file's rule file.
|
|
|
|
this->WriteObjectRuleFiles(**si);
|
|
|
|
}
|
2012-03-12 22:40:58 +04:00
|
|
|
|
|
|
|
// Add object library contents as external objects.
|
|
|
|
this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::WriteCommonCodeRules()
|
|
|
|
{
|
2010-06-10 19:15:31 +04:00
|
|
|
const char* root = (this->Makefile->IsOn("CMAKE_MAKE_INCLUDE_FROM_ROOT")?
|
|
|
|
"$(CMAKE_BINARY_DIR)/" : "");
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Include the dependencies for the target.
|
|
|
|
std::string dependFileNameFull = this->TargetBuildDirectoryFull;
|
|
|
|
dependFileNameFull += "/depend.make";
|
|
|
|
*this->BuildFileStream
|
|
|
|
<< "# Include any dependencies generated for this target.\n"
|
2010-06-10 19:15:31 +04:00
|
|
|
<< this->LocalGenerator->IncludeDirective << " " << root
|
2014-03-11 03:04:11 +04:00
|
|
|
<< this->Convert(dependFileNameFull,
|
2006-07-11 17:55:27 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT,
|
|
|
|
cmLocalGenerator::MAKEFILE)
|
|
|
|
<< "\n\n";
|
2009-03-16 23:22:19 +03:00
|
|
|
|
2009-03-16 23:55:58 +03:00
|
|
|
if(!this->NoRuleMessages)
|
2009-03-16 23:22:19 +03:00
|
|
|
{
|
|
|
|
// Include the progress variables for the target.
|
|
|
|
*this->BuildFileStream
|
|
|
|
<< "# Include the progress variables for this target.\n"
|
2010-06-10 19:15:31 +04:00
|
|
|
<< this->LocalGenerator->IncludeDirective << " " << root
|
2014-03-11 03:04:11 +04:00
|
|
|
<< this->Convert(this->ProgressFileNameFull,
|
2009-03-16 23:22:19 +03:00
|
|
|
cmLocalGenerator::HOME_OUTPUT,
|
|
|
|
cmLocalGenerator::MAKEFILE)
|
|
|
|
<< "\n\n";
|
|
|
|
}
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// make sure the depend file exists
|
|
|
|
if (!cmSystemTools::FileExists(dependFileNameFull.c_str()))
|
|
|
|
{
|
|
|
|
// Write an empty dependency file.
|
|
|
|
cmGeneratedFileStream depFileStream(dependFileNameFull.c_str());
|
|
|
|
depFileStream
|
|
|
|
<< "# Empty dependencies file for " << this->Target->GetName() << ".\n"
|
|
|
|
<< "# This may be replaced when dependencies are built." << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open the flags file. This should be copy-if-different because the
|
|
|
|
// rules may depend on this file itself.
|
|
|
|
this->FlagFileNameFull = this->TargetBuildDirectoryFull;
|
|
|
|
this->FlagFileNameFull += "/flags.make";
|
2006-07-10 15:52:35 +04:00
|
|
|
this->FlagFileStream =
|
2006-02-14 18:36:04 +03:00
|
|
|
new cmGeneratedFileStream(this->FlagFileNameFull.c_str());
|
|
|
|
this->FlagFileStream->SetCopyIfDifferent(true);
|
|
|
|
if(!this->FlagFileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->LocalGenerator->WriteDisclaimer(*this->FlagFileStream);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Include the flags for the target.
|
|
|
|
*this->BuildFileStream
|
|
|
|
<< "# Include the compile flags for this target's objects.\n"
|
2010-06-10 19:15:31 +04:00
|
|
|
<< this->LocalGenerator->IncludeDirective << " " << root
|
2014-03-11 03:04:11 +04:00
|
|
|
<< this->Convert(this->FlagFileNameFull,
|
2006-07-10 15:52:35 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT,
|
2006-02-14 18:36:04 +03:00
|
|
|
cmLocalGenerator::MAKEFILE)
|
|
|
|
<< "\n\n";
|
2006-06-01 19:45:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2011-05-17 16:50:55 +04:00
|
|
|
std::string cmMakefileTargetGenerator::GetFlags(const std::string &l)
|
|
|
|
{
|
|
|
|
ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
|
|
|
|
if (i == this->FlagsByLanguage.end())
|
|
|
|
{
|
|
|
|
std::string flags;
|
2011-01-15 01:28:38 +03:00
|
|
|
const char *lang = l.c_str();
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2011-01-15 01:28:38 +03:00
|
|
|
// Add language feature flags.
|
|
|
|
this->AddFeatureFlags(flags, lang);
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2012-09-16 03:16:43 +04:00
|
|
|
this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget,
|
2011-01-15 01:28:38 +03:00
|
|
|
lang, this->ConfigName);
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2011-01-15 01:28:38 +03:00
|
|
|
// Fortran-specific flags computed for this target.
|
|
|
|
if(l == "Fortran")
|
|
|
|
{
|
|
|
|
this->AddFortranFlags(flags);
|
|
|
|
}
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2012-11-05 15:46:26 +04:00
|
|
|
this->LocalGenerator->AddCMP0018Flags(flags, this->Target,
|
|
|
|
lang, this->ConfigName);
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2013-05-18 14:12:18 +04:00
|
|
|
this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target,
|
|
|
|
lang);
|
|
|
|
|
2011-01-15 01:28:38 +03:00
|
|
|
// Add include directory flags.
|
|
|
|
this->AddIncludeFlags(flags, lang);
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2011-01-15 01:28:38 +03:00
|
|
|
// Append old-style preprocessor definition flags.
|
|
|
|
this->LocalGenerator->
|
|
|
|
AppendFlags(flags, this->Makefile->GetDefineFlags());
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2011-01-15 01:28:38 +03:00
|
|
|
// Add include directory flags.
|
|
|
|
this->LocalGenerator->
|
2013-10-10 16:29:04 +04:00
|
|
|
AppendFlags(flags,this->GetFrameworkFlags(l).c_str());
|
2011-05-17 16:50:55 +04:00
|
|
|
|
2013-06-27 20:04:02 +04:00
|
|
|
// Add target-specific flags.
|
|
|
|
this->LocalGenerator->AddCompileOptions(flags, this->Target,
|
|
|
|
lang, this->ConfigName);
|
|
|
|
|
2011-05-17 16:50:55 +04:00
|
|
|
ByLanguageMap::value_type entry(l, flags);
|
|
|
|
i = this->FlagsByLanguage.insert(entry).first;
|
|
|
|
}
|
|
|
|
return i->second;
|
2011-01-13 07:06:25 +03:00
|
|
|
}
|
|
|
|
|
2011-05-17 16:50:55 +04:00
|
|
|
std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
|
|
|
|
{
|
|
|
|
ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
|
|
|
|
if (i == this->DefinesByLanguage.end())
|
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
std::set<std::string> defines;
|
2011-01-15 01:28:38 +03:00
|
|
|
const char *lang = l.c_str();
|
|
|
|
// Add the export symbol definition for shared library objects.
|
|
|
|
if(const char* exportMacro = this->Target->GetExportMacro())
|
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
this->LocalGenerator->AppendDefines(defines, exportMacro);
|
2011-01-15 01:28:38 +03:00
|
|
|
}
|
2011-01-13 07:06:25 +03:00
|
|
|
|
2011-01-15 01:28:38 +03:00
|
|
|
// Add preprocessor definitions for this target and configuration.
|
2013-06-06 20:13:35 +04:00
|
|
|
this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
|
2014-03-11 03:04:11 +04:00
|
|
|
this->LocalGenerator->ConfigurationName);
|
2011-05-17 16:50:55 +04:00
|
|
|
|
2012-08-09 11:44:15 +04:00
|
|
|
std::string definesString;
|
|
|
|
this->LocalGenerator->JoinDefines(defines, definesString, lang);
|
|
|
|
|
|
|
|
ByLanguageMap::value_type entry(l, definesString);
|
2011-05-17 16:50:55 +04:00
|
|
|
i = this->DefinesByLanguage.insert(entry).first;
|
|
|
|
}
|
|
|
|
return i->second;
|
2011-01-13 07:06:25 +03:00
|
|
|
}
|
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
|
|
|
{
|
2006-02-14 18:36:04 +03:00
|
|
|
// write language flags for target
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> languages;
|
2007-08-02 21:38:39 +04:00
|
|
|
this->Target->GetLanguages(languages);
|
2014-02-17 14:14:18 +04:00
|
|
|
// put the compiler in the rules.make file so that if it changes
|
2007-12-13 23:54:29 +03:00
|
|
|
// things rebuild
|
2014-02-10 09:21:34 +04:00
|
|
|
for(std::set<std::string>::const_iterator l = languages.begin();
|
2007-12-13 23:54:29 +03:00
|
|
|
l != languages.end(); ++l)
|
|
|
|
{
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string compiler = "CMAKE_";
|
2007-12-13 23:54:29 +03:00
|
|
|
compiler += *l;
|
|
|
|
compiler += "_COMPILER";
|
2014-03-11 16:35:32 +04:00
|
|
|
*this->FlagFileStream << "# compile " << *l << " with " <<
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetSafeDefinition(compiler) << "\n";
|
2007-12-13 23:54:29 +03:00
|
|
|
}
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
for(std::set<std::string>::const_iterator l = languages.begin();
|
2007-08-02 21:38:39 +04:00
|
|
|
l != languages.end(); ++l)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2011-01-13 07:06:25 +03:00
|
|
|
*this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n";
|
|
|
|
*this->FlagFileStream << *l << "_DEFINES = " << this->GetDefines(*l) <<
|
|
|
|
"\n\n";
|
2007-02-01 19:33:30 +03:00
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
2012-05-07 23:24:16 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2012-07-16 19:34:22 +04:00
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
|
|
|
|
(cmSourceFile& source, const char* pkgloc)
|
2008-02-15 19:22:23 +03:00
|
|
|
{
|
2008-02-19 00:38:34 +03:00
|
|
|
// Skip OS X content when not building a Framework or Bundle.
|
2013-05-06 06:19:05 +04:00
|
|
|
if(!this->Generator->GetTarget()->IsBundleOnApple())
|
2008-02-19 00:38:34 +03:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-17 01:03:40 +04:00
|
|
|
std::string macdir =
|
|
|
|
this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc);
|
2008-04-08 08:06:47 +04:00
|
|
|
|
2008-02-15 19:22:23 +03:00
|
|
|
// Get the input file location.
|
|
|
|
std::string input = source.GetFullPath();
|
|
|
|
|
|
|
|
// Get the output file location.
|
|
|
|
std::string output = macdir;
|
|
|
|
output += "/";
|
|
|
|
output += cmSystemTools::GetFilenameName(input);
|
2012-07-16 19:34:22 +04:00
|
|
|
this->Generator->CleanFiles.push_back(
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Generator->Convert(output,
|
2012-07-16 19:34:22 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT));
|
2014-03-11 03:04:11 +04:00
|
|
|
output = this->Generator->Convert(output,
|
2012-07-16 19:34:22 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT);
|
2008-02-15 19:22:23 +03:00
|
|
|
|
|
|
|
// Create a rule to copy the content into the bundle.
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
depends.push_back(input);
|
2008-02-19 00:38:34 +03:00
|
|
|
std::string copyEcho = "Copying OS X content ";
|
2008-02-15 19:22:23 +03:00
|
|
|
copyEcho += output;
|
2012-07-16 19:34:22 +04:00
|
|
|
this->Generator->LocalGenerator->AppendEcho(
|
|
|
|
commands, copyEcho.c_str(),
|
|
|
|
cmLocalUnixMakefileGenerator3::EchoBuild);
|
2008-02-15 19:22:23 +03:00
|
|
|
std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
|
2014-03-11 03:04:11 +04:00
|
|
|
copyCommand += this->Generator->Convert(input,
|
2012-07-16 19:34:22 +04:00
|
|
|
cmLocalGenerator::NONE,
|
|
|
|
cmLocalGenerator::SHELL);
|
2008-02-15 19:22:23 +03:00
|
|
|
copyCommand += " ";
|
2014-03-11 03:04:11 +04:00
|
|
|
copyCommand += this->Generator->Convert(output,
|
2012-07-16 19:34:22 +04:00
|
|
|
cmLocalGenerator::NONE,
|
|
|
|
cmLocalGenerator::SHELL);
|
2008-02-15 19:22:23 +03:00
|
|
|
commands.push_back(copyCommand);
|
2012-07-16 19:34:22 +04:00
|
|
|
this->Generator->LocalGenerator->WriteMakeRule(
|
|
|
|
*this->Generator->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
output,
|
2012-07-16 19:34:22 +04:00
|
|
|
depends, commands, false);
|
|
|
|
this->Generator->ExtraFiles.insert(output);
|
2008-02-15 19:22:23 +03:00
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
|
|
|
|
{
|
|
|
|
// Identify the language of the source file.
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang =
|
|
|
|
this->LocalGenerator->GetSourceFileLanguage(source);
|
|
|
|
if(lang.empty())
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2006-04-21 05:54:35 +04:00
|
|
|
// don't know anything about this file so skip it
|
2006-02-14 18:36:04 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the full path name of the object file.
|
2013-11-10 14:22:44 +04:00
|
|
|
std::string const& objectName = this->GeneratorTarget
|
|
|
|
->GetObjectName(&source);
|
2012-03-07 23:01:46 +04:00
|
|
|
std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target);
|
|
|
|
obj += "/";
|
|
|
|
obj += objectName;
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Avoid generating duplicate rules.
|
2006-03-15 19:02:08 +03:00
|
|
|
if(this->ObjectFiles.find(obj) == this->ObjectFiles.end())
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
this->ObjectFiles.insert(obj);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream err;
|
|
|
|
err << "Warning: Source file \""
|
2007-06-18 19:59:23 +04:00
|
|
|
<< source.GetFullPath()
|
2006-07-10 15:52:35 +04:00
|
|
|
<< "\" is listed multiple times for target \""
|
2006-02-14 18:36:04 +03:00
|
|
|
<< this->Target->GetName()
|
|
|
|
<< "\".";
|
|
|
|
cmSystemTools::Message(err.str().c_str(), "Warning");
|
|
|
|
return;
|
|
|
|
}
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Create the directory containing the object file. This may be a
|
|
|
|
// subdirectory under the target's directory.
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string dir = cmSystemTools::GetFilenamePath(obj);
|
2006-02-14 18:36:04 +03:00
|
|
|
cmSystemTools::MakeDirectory
|
|
|
|
(this->LocalGenerator->ConvertToFullPath(dir).c_str());
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Save this in the target's list of object files.
|
|
|
|
this->Objects.push_back(obj);
|
2007-08-02 17:37:10 +04:00
|
|
|
this->CleanFiles.push_back(obj);
|
2006-07-07 00:04:49 +04:00
|
|
|
|
|
|
|
// TODO: Remove
|
2006-07-10 15:52:35 +04:00
|
|
|
//std::string relativeObj
|
|
|
|
//= this->LocalGenerator->GetHomeRelativeOutputPath();
|
2006-07-07 00:04:49 +04:00
|
|
|
//relativeObj += obj;
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// we compute some depends when writing the depend.make that we will also
|
|
|
|
// use in the build.make, same with depMakeFile
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::string depMakeFile;
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// generate the build rule file
|
|
|
|
this->WriteObjectBuildFile(obj, lang, source, depends);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// The object file should be checked for dependency integrity.
|
2007-08-07 21:57:13 +04:00
|
|
|
std::string objFullPath = this->Makefile->GetCurrentOutputDirectory();
|
|
|
|
objFullPath += "/";
|
|
|
|
objFullPath += obj;
|
|
|
|
objFullPath =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(objFullPath, cmLocalGenerator::FULL);
|
2007-08-07 21:57:13 +04:00
|
|
|
std::string srcFullPath =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(source.GetFullPath(), cmLocalGenerator::FULL);
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->
|
2007-08-07 21:57:13 +04:00
|
|
|
AddImplicitDepends(*this->Target, lang,
|
|
|
|
objFullPath.c_str(),
|
|
|
|
srcFullPath.c_str());
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
2011-08-31 18:24:43 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source)
|
|
|
|
{
|
|
|
|
const char* srcfmt = source.GetProperty("Fortran_FORMAT");
|
|
|
|
cmLocalGenerator::FortranFormat format =
|
|
|
|
this->LocalGenerator->GetFortranFormat(srcfmt);
|
|
|
|
if(format == cmLocalGenerator::FortranFormatNone)
|
|
|
|
{
|
|
|
|
const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT");
|
|
|
|
format = this->LocalGenerator->GetFortranFormat(tgtfmt);
|
|
|
|
}
|
|
|
|
const char* var = 0;
|
|
|
|
switch (format)
|
|
|
|
{
|
|
|
|
case cmLocalGenerator::FortranFormatFixed:
|
|
|
|
var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break;
|
|
|
|
case cmLocalGenerator::FortranFormatFree:
|
|
|
|
var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
if(var)
|
|
|
|
{
|
|
|
|
this->LocalGenerator->AppendFlags(
|
|
|
|
flags, this->Makefile->GetDefinition(var));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::WriteObjectBuildFile(std::string &obj,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang,
|
2006-02-14 18:36:04 +03:00
|
|
|
cmSourceFile& source,
|
|
|
|
std::vector<std::string>& depends)
|
|
|
|
{
|
2006-07-10 15:52:35 +04:00
|
|
|
this->LocalGenerator->AppendRuleDepend(depends,
|
2006-05-12 20:29:09 +04:00
|
|
|
this->FlagFileNameFull.c_str());
|
2011-03-15 21:07:36 +03:00
|
|
|
this->LocalGenerator->AppendRuleDepends(depends,
|
|
|
|
this->FlagFileDepends[lang]);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// generate the depend scanning rule
|
|
|
|
this->WriteObjectDependRules(source, depends);
|
|
|
|
|
|
|
|
std::string relativeObj = this->LocalGenerator->GetHomeRelativeOutputPath();
|
|
|
|
relativeObj += obj;
|
|
|
|
// Write the build rule.
|
2006-02-20 20:48:56 +03:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Build the set of compiler flags.
|
|
|
|
std::string flags;
|
2006-02-20 20:48:56 +03:00
|
|
|
|
|
|
|
// Add language-specific flags.
|
|
|
|
std::string langFlags = "$(";
|
|
|
|
langFlags += lang;
|
|
|
|
langFlags += "_FLAGS)";
|
|
|
|
this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
|
|
|
|
|
2013-05-16 16:59:04 +04:00
|
|
|
std::string configUpper =
|
|
|
|
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
|
|
|
|
|
2011-08-31 18:24:43 +04:00
|
|
|
// Add Fortran format flags.
|
2014-02-04 06:20:56 +04:00
|
|
|
if(lang == "Fortran")
|
2011-08-31 18:24:43 +04:00
|
|
|
{
|
|
|
|
this->AppendFortranFormatFlags(flags, source);
|
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Add flags from source file properties.
|
|
|
|
if (source.GetProperty("COMPILE_FLAGS"))
|
|
|
|
{
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->AppendFlags
|
|
|
|
(flags, source.GetProperty("COMPILE_FLAGS"));
|
2006-02-14 18:36:04 +03:00
|
|
|
*this->FlagFileStream << "# Custom flags: "
|
|
|
|
<< relativeObj << "_FLAGS = "
|
|
|
|
<< source.GetProperty("COMPILE_FLAGS")
|
|
|
|
<< "\n"
|
|
|
|
<< "\n";
|
|
|
|
}
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2008-01-14 17:20:58 +03:00
|
|
|
// Add language-specific defines.
|
2012-08-09 11:44:15 +04:00
|
|
|
std::set<std::string> defines;
|
2008-01-14 17:20:58 +03:00
|
|
|
|
|
|
|
// Add source-sepcific preprocessor definitions.
|
|
|
|
if(const char* compile_defs = source.GetProperty("COMPILE_DEFINITIONS"))
|
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
this->LocalGenerator->AppendDefines(defines, compile_defs);
|
2008-01-14 17:20:58 +03:00
|
|
|
*this->FlagFileStream << "# Custom defines: "
|
|
|
|
<< relativeObj << "_DEFINES = "
|
|
|
|
<< compile_defs << "\n"
|
|
|
|
<< "\n";
|
|
|
|
}
|
2008-01-16 05:02:00 +03:00
|
|
|
std::string defPropName = "COMPILE_DEFINITIONS_";
|
|
|
|
defPropName += configUpper;
|
2008-01-14 17:20:58 +03:00
|
|
|
if(const char* config_compile_defs =
|
2014-03-11 03:04:11 +04:00
|
|
|
source.GetProperty(defPropName))
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
this->LocalGenerator->AppendDefines(defines, config_compile_defs);
|
2008-01-14 17:20:58 +03:00
|
|
|
*this->FlagFileStream
|
|
|
|
<< "# Custom defines: "
|
|
|
|
<< relativeObj << "_DEFINES_" << configUpper
|
|
|
|
<< " = " << config_compile_defs << "\n"
|
|
|
|
<< "\n";
|
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Get the output paths for source and object files.
|
|
|
|
std::string sourceFile = source.GetFullPath();
|
2006-03-15 19:02:08 +03:00
|
|
|
if(this->LocalGenerator->UseRelativePaths)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
sourceFile = this->Convert(sourceFile,
|
2008-10-09 23:30:07 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
2014-03-11 03:04:11 +04:00
|
|
|
sourceFile = this->Convert(sourceFile,
|
2006-05-12 20:29:09 +04:00
|
|
|
cmLocalGenerator::NONE,
|
|
|
|
cmLocalGenerator::SHELL);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Construct the build message.
|
|
|
|
std::vector<std::string> no_commands;
|
|
|
|
std::vector<std::string> commands;
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-05-23 17:11:46 +04:00
|
|
|
// add in a progress call if needed
|
2009-03-16 23:22:13 +03:00
|
|
|
this->AppendProgress(commands);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2009-03-16 23:55:58 +03:00
|
|
|
if(!this->NoRuleMessages)
|
|
|
|
{
|
|
|
|
std::string buildEcho = "Building ";
|
|
|
|
buildEcho += lang;
|
|
|
|
buildEcho += " object ";
|
|
|
|
buildEcho += relativeObj;
|
|
|
|
this->LocalGenerator->AppendEcho
|
|
|
|
(commands, buildEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild);
|
|
|
|
}
|
2006-06-12 20:18:59 +04:00
|
|
|
|
2013-03-21 22:31:57 +04:00
|
|
|
std::string targetOutPathReal;
|
2007-02-02 00:56:36 +03:00
|
|
|
std::string targetOutPathPDB;
|
2014-02-24 23:15:21 +04:00
|
|
|
std::string targetOutPathCompilePDB;
|
2007-02-02 00:56:36 +03:00
|
|
|
{
|
2013-03-21 22:31:57 +04:00
|
|
|
std::string targetFullPathReal;
|
2007-02-02 00:56:36 +03:00
|
|
|
std::string targetFullPathPDB;
|
2014-02-24 23:15:21 +04:00
|
|
|
std::string targetFullPathCompilePDB;
|
2007-03-08 22:57:28 +03:00
|
|
|
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
|
|
|
|
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
|
|
|
|
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
|
|
|
|
this->Target->GetType() == cmTarget::MODULE_LIBRARY)
|
2007-02-02 00:56:36 +03:00
|
|
|
{
|
2013-03-21 22:31:57 +04:00
|
|
|
targetFullPathReal =
|
|
|
|
this->Target->GetFullPath(this->ConfigName, false, true);
|
2012-09-25 05:30:42 +04:00
|
|
|
targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName);
|
2007-03-08 22:57:28 +03:00
|
|
|
targetFullPathPDB += "/";
|
2009-07-03 16:41:10 +04:00
|
|
|
targetFullPathPDB += this->Target->GetPDBName(this->ConfigName);
|
2007-02-02 00:56:36 +03:00
|
|
|
}
|
2014-02-24 23:15:21 +04:00
|
|
|
if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
|
|
|
|
{
|
|
|
|
targetFullPathCompilePDB =
|
|
|
|
this->Target->GetCompilePDBPath(this->ConfigName);
|
|
|
|
if(targetFullPathCompilePDB.empty())
|
|
|
|
{
|
|
|
|
targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
targetOutPathReal = this->Convert(targetFullPathReal,
|
2013-03-21 22:31:57 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::SHELL);
|
2007-02-02 00:56:36 +03:00
|
|
|
targetOutPathPDB =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
|
2007-03-08 18:31:03 +03:00
|
|
|
cmLocalGenerator::SHELL);
|
2014-02-24 23:15:21 +04:00
|
|
|
targetOutPathCompilePDB =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(targetFullPathCompilePDB,
|
2014-02-24 23:15:21 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::SHELL);
|
2007-02-02 00:56:36 +03:00
|
|
|
}
|
2006-02-20 21:42:18 +03:00
|
|
|
cmLocalGenerator::RuleVariables vars;
|
2009-02-10 16:51:15 +03:00
|
|
|
vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
|
|
|
|
vars.CMTarget = this->Target;
|
2014-02-04 06:20:56 +04:00
|
|
|
vars.Language = lang.c_str();
|
2013-03-21 22:31:57 +04:00
|
|
|
vars.Target = targetOutPathReal.c_str();
|
2007-02-02 00:56:36 +03:00
|
|
|
vars.TargetPDB = targetOutPathPDB.c_str();
|
2014-02-24 23:15:21 +04:00
|
|
|
vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
|
2006-02-20 21:42:18 +03:00
|
|
|
vars.Source = sourceFile.c_str();
|
2007-11-21 21:37:14 +03:00
|
|
|
std::string shellObj =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(obj,
|
2007-11-21 21:37:14 +03:00
|
|
|
cmLocalGenerator::NONE,
|
2014-03-11 03:04:11 +04:00
|
|
|
cmLocalGenerator::SHELL);
|
2007-11-21 21:37:14 +03:00
|
|
|
vars.Object = shellObj.c_str();
|
2013-12-23 18:41:45 +04:00
|
|
|
std::string objectDir = this->Target->GetSupportDirectory();
|
2014-03-11 03:04:11 +04:00
|
|
|
objectDir = this->Convert(objectDir,
|
2008-04-11 21:13:15 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::SHELL);
|
2006-04-17 22:01:22 +04:00
|
|
|
vars.ObjectDir = objectDir.c_str();
|
2006-02-20 21:42:18 +03:00
|
|
|
vars.Flags = flags.c_str();
|
2012-08-09 11:44:15 +04:00
|
|
|
|
|
|
|
std::string definesString = "$(";
|
|
|
|
definesString += lang;
|
|
|
|
definesString += "_DEFINES)";
|
|
|
|
|
|
|
|
this->LocalGenerator->JoinDefines(defines, definesString, lang);
|
|
|
|
|
|
|
|
vars.Defines = definesString.c_str();
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2014-02-04 06:20:56 +04:00
|
|
|
bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX"));
|
2011-01-13 07:39:13 +03:00
|
|
|
|
2009-02-02 21:28:17 +03:00
|
|
|
// Construct the compile rules.
|
|
|
|
{
|
|
|
|
std::string compileRuleVar = "CMAKE_";
|
|
|
|
compileRuleVar += lang;
|
|
|
|
compileRuleVar += "_COMPILE_OBJECT";
|
|
|
|
std::string compileRule =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetRequiredDefinition(compileRuleVar);
|
2009-02-02 21:28:17 +03:00
|
|
|
std::vector<std::string> compileCommands;
|
|
|
|
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
|
|
|
|
|
2011-01-15 02:16:11 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
|
|
|
|
lang_is_c_or_cxx && compileCommands.size() == 1)
|
2011-01-13 07:39:13 +03:00
|
|
|
{
|
|
|
|
std::string compileCommand = compileCommands[0];
|
|
|
|
this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);
|
|
|
|
std::string workingDirectory =
|
|
|
|
this->LocalGenerator->Convert(
|
|
|
|
this->Makefile->GetStartOutputDirectory(), cmLocalGenerator::FULL);
|
|
|
|
compileCommand.replace(compileCommand.find(langFlags),
|
|
|
|
langFlags.size(), this->GetFlags(lang));
|
|
|
|
std::string langDefines = std::string("$(") + lang + "_DEFINES)";
|
|
|
|
compileCommand.replace(compileCommand.find(langDefines),
|
|
|
|
langDefines.size(), this->GetDefines(lang));
|
|
|
|
this->GlobalGenerator->AddCXXCompileCommand(
|
|
|
|
source.GetFullPath(), workingDirectory, compileCommand);
|
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Expand placeholders in the commands.
|
2009-02-02 21:28:17 +03:00
|
|
|
for(std::vector<std::string>::iterator i = compileCommands.begin();
|
|
|
|
i != compileCommands.end(); ++i)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
this->LocalGenerator->ExpandRuleVariables(*i, vars);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
2009-02-02 21:28:17 +03:00
|
|
|
// Change the command working directory to the local build tree.
|
|
|
|
this->LocalGenerator->CreateCDCommand
|
|
|
|
(compileCommands,
|
|
|
|
this->Makefile->GetStartOutputDirectory(),
|
|
|
|
cmLocalGenerator::HOME_OUTPUT);
|
|
|
|
commands.insert(commands.end(),
|
|
|
|
compileCommands.begin(), compileCommands.end());
|
|
|
|
}
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Write the rule.
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
relativeObj,
|
2006-02-16 00:35:16 +03:00
|
|
|
depends, commands, false);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2007-09-13 21:37:45 +04:00
|
|
|
// Check for extra outputs created by the compilation.
|
|
|
|
if(const char* extra_outputs_str =
|
|
|
|
source.GetProperty("OBJECT_OUTPUTS"))
|
|
|
|
{
|
|
|
|
std::vector<std::string> extra_outputs;
|
|
|
|
cmSystemTools::ExpandListArgument(extra_outputs_str, extra_outputs);
|
|
|
|
for(std::vector<std::string>::const_iterator eoi = extra_outputs.begin();
|
|
|
|
eoi != extra_outputs.end(); ++eoi)
|
|
|
|
{
|
|
|
|
// Register this as an extra output for the object file rule.
|
|
|
|
// This will cause the object file to be rebuilt if the extra
|
|
|
|
// output is missing.
|
|
|
|
this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false);
|
|
|
|
|
|
|
|
// Register this as an extra file to clean.
|
2014-03-11 03:04:11 +04:00
|
|
|
this->CleanFiles.push_back(*eoi);
|
2007-09-13 21:37:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-15 20:00:27 +04:00
|
|
|
bool do_preprocess_rules = lang_is_c_or_cxx &&
|
2006-08-08 07:25:21 +04:00
|
|
|
this->LocalGenerator->GetCreatePreprocessedSourceRules();
|
2006-08-15 20:00:27 +04:00
|
|
|
bool do_assembly_rules = lang_is_c_or_cxx &&
|
2006-08-08 07:25:21 +04:00
|
|
|
this->LocalGenerator->GetCreateAssemblySourceRules();
|
|
|
|
if(do_preprocess_rules || do_assembly_rules)
|
|
|
|
{
|
|
|
|
std::vector<std::string> force_depends;
|
|
|
|
force_depends.push_back("cmake_force");
|
|
|
|
std::string::size_type dot_pos = relativeObj.rfind(".");
|
|
|
|
std::string relativeObjBase = relativeObj.substr(0, dot_pos);
|
2007-11-21 21:37:14 +03:00
|
|
|
dot_pos = obj.rfind(".");
|
|
|
|
std::string objBase = obj.substr(0, dot_pos);
|
2006-08-08 07:25:21 +04:00
|
|
|
|
|
|
|
if(do_preprocess_rules)
|
|
|
|
{
|
|
|
|
commands.clear();
|
2006-08-09 19:43:35 +04:00
|
|
|
std::string relativeObjI = relativeObjBase + ".i";
|
2007-11-21 21:37:14 +03:00
|
|
|
std::string objI = objBase + ".i";
|
2006-08-08 07:25:21 +04:00
|
|
|
|
|
|
|
std::string preprocessEcho = "Preprocessing ";
|
|
|
|
preprocessEcho += lang;
|
|
|
|
preprocessEcho += " source to ";
|
2007-11-21 21:37:14 +03:00
|
|
|
preprocessEcho += objI;
|
2006-08-08 07:25:21 +04:00
|
|
|
this->LocalGenerator->AppendEcho(
|
|
|
|
commands, preprocessEcho.c_str(),
|
|
|
|
cmLocalUnixMakefileGenerator3::EchoBuild
|
|
|
|
);
|
|
|
|
|
|
|
|
std::string preprocessRuleVar = "CMAKE_";
|
|
|
|
preprocessRuleVar += lang;
|
|
|
|
preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE";
|
|
|
|
if(const char* preprocessRule =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(preprocessRuleVar))
|
2006-08-08 07:25:21 +04:00
|
|
|
{
|
2007-11-21 21:37:14 +03:00
|
|
|
std::vector<std::string> preprocessCommands;
|
|
|
|
cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands);
|
2009-02-02 21:28:17 +03:00
|
|
|
|
2009-02-02 22:36:53 +03:00
|
|
|
std::string shellObjI =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(objI,
|
2009-02-02 22:36:53 +03:00
|
|
|
cmLocalGenerator::NONE,
|
2014-03-11 03:04:11 +04:00
|
|
|
cmLocalGenerator::SHELL);
|
2009-02-02 22:36:53 +03:00
|
|
|
vars.PreprocessedSource = shellObjI.c_str();
|
|
|
|
|
2009-02-02 21:28:17 +03:00
|
|
|
// Expand placeholders in the commands.
|
|
|
|
for(std::vector<std::string>::iterator i = preprocessCommands.begin();
|
|
|
|
i != preprocessCommands.end(); ++i)
|
|
|
|
{
|
|
|
|
this->LocalGenerator->ExpandRuleVariables(*i, vars);
|
|
|
|
}
|
|
|
|
|
2007-11-21 21:37:14 +03:00
|
|
|
this->LocalGenerator->CreateCDCommand
|
|
|
|
(preprocessCommands,
|
|
|
|
this->Makefile->GetStartOutputDirectory(),
|
2008-10-09 23:30:07 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT);
|
2007-11-21 21:37:14 +03:00
|
|
|
commands.insert(commands.end(),
|
|
|
|
preprocessCommands.begin(),
|
|
|
|
preprocessCommands.end());
|
2006-08-08 07:25:21 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable ";
|
|
|
|
cmd += preprocessRuleVar;
|
|
|
|
commands.push_back(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
relativeObjI,
|
2006-08-08 07:25:21 +04:00
|
|
|
force_depends, commands, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(do_assembly_rules)
|
|
|
|
{
|
|
|
|
commands.clear();
|
2006-08-09 19:43:35 +04:00
|
|
|
std::string relativeObjS = relativeObjBase + ".s";
|
2007-11-21 21:37:14 +03:00
|
|
|
std::string objS = objBase + ".s";
|
2006-08-08 07:25:21 +04:00
|
|
|
|
|
|
|
std::string assemblyEcho = "Compiling ";
|
|
|
|
assemblyEcho += lang;
|
|
|
|
assemblyEcho += " source to assembly ";
|
2007-11-21 21:37:14 +03:00
|
|
|
assemblyEcho += objS;
|
2006-08-08 07:25:21 +04:00
|
|
|
this->LocalGenerator->AppendEcho(
|
|
|
|
commands, assemblyEcho.c_str(),
|
|
|
|
cmLocalUnixMakefileGenerator3::EchoBuild
|
|
|
|
);
|
|
|
|
|
|
|
|
std::string assemblyRuleVar = "CMAKE_";
|
|
|
|
assemblyRuleVar += lang;
|
|
|
|
assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE";
|
|
|
|
if(const char* assemblyRule =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(assemblyRuleVar))
|
2006-08-08 07:25:21 +04:00
|
|
|
{
|
2007-11-21 21:37:14 +03:00
|
|
|
std::vector<std::string> assemblyCommands;
|
|
|
|
cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands);
|
2009-02-02 21:28:17 +03:00
|
|
|
|
2009-02-02 22:36:53 +03:00
|
|
|
std::string shellObjS =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(objS,
|
2009-02-02 22:36:53 +03:00
|
|
|
cmLocalGenerator::NONE,
|
2014-03-11 03:04:11 +04:00
|
|
|
cmLocalGenerator::SHELL);
|
2009-02-02 22:36:53 +03:00
|
|
|
vars.AssemblySource = shellObjS.c_str();
|
|
|
|
|
2009-02-02 21:28:17 +03:00
|
|
|
// Expand placeholders in the commands.
|
|
|
|
for(std::vector<std::string>::iterator i = assemblyCommands.begin();
|
|
|
|
i != assemblyCommands.end(); ++i)
|
|
|
|
{
|
|
|
|
this->LocalGenerator->ExpandRuleVariables(*i, vars);
|
|
|
|
}
|
|
|
|
|
2007-11-21 21:37:14 +03:00
|
|
|
this->LocalGenerator->CreateCDCommand
|
|
|
|
(assemblyCommands,
|
|
|
|
this->Makefile->GetStartOutputDirectory(),
|
2008-10-09 23:30:07 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT);
|
2007-11-21 21:37:14 +03:00
|
|
|
commands.insert(commands.end(),
|
|
|
|
assemblyCommands.begin(),
|
|
|
|
assemblyCommands.end());
|
2006-08-08 07:25:21 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable ";
|
|
|
|
cmd += assemblyRuleVar;
|
|
|
|
commands.push_back(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
relativeObjS,
|
2006-08-08 07:25:21 +04:00
|
|
|
force_depends, commands, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// If the language needs provides-requires mode, create the
|
|
|
|
// corresponding targets.
|
|
|
|
std::string objectRequires = relativeObj;
|
|
|
|
objectRequires += ".requires";
|
|
|
|
std::vector<std::string> p_depends;
|
|
|
|
// always provide an empty requires target
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
objectRequires, p_depends,
|
2006-02-16 00:35:16 +03:00
|
|
|
no_commands, true);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// write a build rule to recursively build what this obj provides
|
|
|
|
std::string objectProvides = relativeObj;
|
|
|
|
objectProvides += ".provides";
|
|
|
|
std::string temp = relativeObj;
|
|
|
|
temp += ".provides.build";
|
|
|
|
std::vector<std::string> r_commands;
|
2006-07-10 15:52:35 +04:00
|
|
|
std::string tgtMakefileName =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
|
|
|
|
tgtMakefileName += "/build.make";
|
|
|
|
r_commands.push_back
|
2006-05-12 20:29:09 +04:00
|
|
|
(this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(),
|
2014-03-11 03:04:11 +04:00
|
|
|
temp));
|
2006-05-12 20:29:09 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
p_depends.clear();
|
|
|
|
p_depends.push_back(objectRequires);
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
objectProvides, p_depends,
|
2006-02-16 00:35:16 +03:00
|
|
|
r_commands, true);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// write the provides.build rule dependency on the obj file
|
|
|
|
p_depends.clear();
|
|
|
|
p_depends.push_back(relativeObj);
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
temp, p_depends, no_commands,
|
2010-12-07 00:43:04 +03:00
|
|
|
false);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::WriteTargetRequiresRules()
|
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> no_commands;
|
|
|
|
|
|
|
|
// Construct the name of the dependency generation target.
|
2006-07-10 15:52:35 +04:00
|
|
|
std::string depTarget =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
|
|
|
|
depTarget += "/requires";
|
|
|
|
|
|
|
|
// This target drives dependency generation for all object files.
|
|
|
|
std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
|
|
|
|
std::string objTarget;
|
|
|
|
for(std::vector<std::string>::const_iterator obj = this->Objects.begin();
|
|
|
|
obj != this->Objects.end(); ++obj)
|
|
|
|
{
|
|
|
|
objTarget = relPath;
|
|
|
|
objTarget += *obj;
|
|
|
|
objTarget += ".requires";
|
|
|
|
depends.push_back(objTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
depTarget,
|
2006-02-16 00:35:16 +03:00
|
|
|
depends, no_commands, true);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::WriteTargetCleanRules()
|
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
|
|
|
|
// Construct the clean target name.
|
2006-07-10 15:52:35 +04:00
|
|
|
std::string cleanTarget =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
|
|
|
|
cleanTarget += "/clean";
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Construct the clean command.
|
2006-03-09 22:30:35 +03:00
|
|
|
this->LocalGenerator->AppendCleanCommand(commands, this->CleanFiles,
|
|
|
|
*this->Target);
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->CreateCDCommand
|
|
|
|
(commands,
|
|
|
|
this->Makefile->GetStartOutputDirectory(),
|
2008-10-09 23:30:07 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Write the rule.
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
cleanTarget,
|
2006-02-16 00:35:16 +03:00
|
|
|
depends, commands, true);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::WriteTargetDependRules()
|
|
|
|
{
|
|
|
|
// must write the targets depend info file
|
|
|
|
std::string dir = this->LocalGenerator->GetTargetDirectory(*this->Target);
|
|
|
|
this->InfoFileNameFull = dir;
|
|
|
|
this->InfoFileNameFull += "/DependInfo.cmake";
|
2006-07-10 15:52:35 +04:00
|
|
|
this->InfoFileNameFull =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->ConvertToFullPath(this->InfoFileNameFull);
|
2006-07-10 15:52:35 +04:00
|
|
|
this->InfoFileStream =
|
2006-02-14 18:36:04 +03:00
|
|
|
new cmGeneratedFileStream(this->InfoFileNameFull.c_str());
|
|
|
|
this->InfoFileStream->SetCopyIfDifferent(true);
|
|
|
|
if(!*this->InfoFileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->LocalGenerator->
|
|
|
|
WriteDependLanguageInfo(*this->InfoFileStream,*this->Target);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2007-12-21 20:22:12 +03:00
|
|
|
// Store multiple output pairs in the depend info file.
|
|
|
|
if(!this->MultipleOutputPairs.empty())
|
|
|
|
{
|
|
|
|
*this->InfoFileStream
|
|
|
|
<< "\n"
|
|
|
|
<< "# Pairs of files generated by the same build rule.\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
|
2007-12-21 20:22:12 +03:00
|
|
|
for(MultipleOutputPairsType::const_iterator pi =
|
|
|
|
this->MultipleOutputPairs.begin();
|
|
|
|
pi != this->MultipleOutputPairs.end(); ++pi)
|
|
|
|
{
|
2008-05-11 02:39:06 +04:00
|
|
|
*this->InfoFileStream
|
2014-03-11 03:04:11 +04:00
|
|
|
<< " " << this->LocalGenerator->EscapeForCMake(pi->first)
|
|
|
|
<< " " << this->LocalGenerator->EscapeForCMake(pi->second)
|
2008-05-11 02:39:06 +04:00
|
|
|
<< "\n";
|
2007-12-21 20:22:12 +03:00
|
|
|
}
|
|
|
|
*this->InfoFileStream << " )\n\n";
|
|
|
|
}
|
|
|
|
|
2007-12-28 19:49:46 +03:00
|
|
|
// Store list of targets linked directly or transitively.
|
|
|
|
{
|
|
|
|
*this->InfoFileStream
|
|
|
|
<< "\n"
|
|
|
|
<< "# Targets to which this target links.\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_TARGET_LINKED_INFO_FILES\n";
|
2007-12-28 19:49:46 +03:00
|
|
|
std::set<cmTarget const*> emitted;
|
2008-09-15 21:30:17 +04:00
|
|
|
const char* cfg = this->LocalGenerator->ConfigurationName.c_str();
|
2012-11-05 19:14:02 +04:00
|
|
|
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg))
|
2007-12-28 19:49:46 +03:00
|
|
|
{
|
2008-09-15 21:30:17 +04:00
|
|
|
cmComputeLinkInformation::ItemVector const& items = cli->GetItems();
|
|
|
|
for(cmComputeLinkInformation::ItemVector::const_iterator
|
|
|
|
i = items.begin(); i != items.end(); ++i)
|
2007-12-28 19:49:46 +03:00
|
|
|
{
|
2008-09-15 21:30:17 +04:00
|
|
|
cmTarget const* linkee = i->Target;
|
2012-11-02 18:47:40 +04:00
|
|
|
if(linkee && !linkee->IsImported()
|
|
|
|
// We can ignore the INTERFACE_LIBRARY items because
|
|
|
|
// Target->GetLinkInformation already processed their
|
|
|
|
// link interface and they don't have any output themselves.
|
|
|
|
&& linkee->GetType() != cmTarget::INTERFACE_LIBRARY
|
|
|
|
&& emitted.insert(linkee).second)
|
2007-12-28 19:49:46 +03:00
|
|
|
{
|
|
|
|
cmMakefile* mf = linkee->GetMakefile();
|
|
|
|
cmLocalGenerator* lg = mf->GetLocalGenerator();
|
|
|
|
std::string di = mf->GetStartOutputDirectory();
|
|
|
|
di += "/";
|
|
|
|
di += lg->GetTargetDirectory(*linkee);
|
|
|
|
di += "/DependInfo.cmake";
|
|
|
|
*this->InfoFileStream << " \"" << di << "\"\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*this->InfoFileStream
|
|
|
|
<< " )\n";
|
|
|
|
}
|
|
|
|
|
2007-12-31 00:11:38 +03:00
|
|
|
// Check for a target-specific module output directory.
|
|
|
|
if(const char* mdir = this->GetFortranModuleDirectory())
|
|
|
|
{
|
|
|
|
*this->InfoFileStream
|
|
|
|
<< "\n"
|
|
|
|
<< "# Fortran module output directory.\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_Fortran_TARGET_MODULE_DIR \"" << mdir << "\")\n";
|
2007-12-31 00:11:38 +03:00
|
|
|
}
|
|
|
|
|
2011-11-05 19:17:49 +04:00
|
|
|
// Target-specific include directories:
|
|
|
|
*this->InfoFileStream
|
|
|
|
<< "\n"
|
|
|
|
<< "# The include file search paths:\n";
|
|
|
|
*this->InfoFileStream
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_C_TARGET_INCLUDE_PATH\n";
|
2011-11-05 19:17:49 +04:00
|
|
|
std::vector<std::string> includes;
|
2012-10-15 12:42:42 +04:00
|
|
|
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config =
|
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2012-09-16 12:03:42 +04:00
|
|
|
this->LocalGenerator->GetIncludeDirectories(includes,
|
2012-10-15 12:42:42 +04:00
|
|
|
this->GeneratorTarget,
|
|
|
|
"C", config);
|
2011-11-05 19:17:49 +04:00
|
|
|
for(std::vector<std::string>::iterator i = includes.begin();
|
|
|
|
i != includes.end(); ++i)
|
|
|
|
{
|
|
|
|
*this->InfoFileStream
|
|
|
|
<< " \""
|
2014-03-11 03:04:11 +04:00
|
|
|
<< this->LocalGenerator->Convert(*i,
|
2011-11-05 19:17:49 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT)
|
|
|
|
<< "\"\n";
|
|
|
|
}
|
|
|
|
*this->InfoFileStream
|
|
|
|
<< " )\n";
|
|
|
|
*this->InfoFileStream
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_CXX_TARGET_INCLUDE_PATH "
|
2011-11-05 19:17:49 +04:00
|
|
|
<< "${CMAKE_C_TARGET_INCLUDE_PATH})\n";
|
|
|
|
*this->InfoFileStream
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_Fortran_TARGET_INCLUDE_PATH "
|
2011-11-05 19:17:49 +04:00
|
|
|
<< "${CMAKE_C_TARGET_INCLUDE_PATH})\n";
|
|
|
|
*this->InfoFileStream
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_ASM_TARGET_INCLUDE_PATH "
|
2011-11-05 19:17:49 +04:00
|
|
|
<< "${CMAKE_C_TARGET_INCLUDE_PATH})\n";
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// and now write the rule to use it
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
|
|
|
|
// Construct the name of the dependency generation target.
|
2006-07-10 15:52:35 +04:00
|
|
|
std::string depTarget =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
|
|
|
|
depTarget += "/depend";
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Add a command to call CMake to scan dependencies. CMake will
|
|
|
|
// touch the corresponding depends file after scanning dependencies.
|
|
|
|
cmOStringStream depCmd;
|
|
|
|
// TODO: Account for source file properties and directory-level
|
|
|
|
// definitions when scanning for dependencies.
|
2006-04-27 18:41:37 +04:00
|
|
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
// This platform supports symlinks, so cmSystemTools will translate
|
|
|
|
// paths. Make sure PWD is set to the original name of the home
|
|
|
|
// output directory to help cmSystemTools to create the same
|
|
|
|
// translation table for the dependency scanning process.
|
|
|
|
depCmd << "cd "
|
|
|
|
<< (this->LocalGenerator->Convert(
|
|
|
|
this->Makefile->GetHomeOutputDirectory(),
|
|
|
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL))
|
|
|
|
<< " && ";
|
|
|
|
#endif
|
2006-05-25 17:47:30 +04:00
|
|
|
// Generate a call this signature:
|
|
|
|
//
|
|
|
|
// cmake -E cmake_depends <generator>
|
|
|
|
// <home-src-dir> <start-src-dir>
|
|
|
|
// <home-out-dir> <start-out-dir>
|
2007-12-20 01:15:41 +03:00
|
|
|
// <dep-info> --color=$(COLOR)
|
2006-05-25 17:47:30 +04:00
|
|
|
//
|
|
|
|
// This gives the dependency scanner enough information to recreate
|
|
|
|
// the state of our local generator sufficiently for its needs.
|
|
|
|
depCmd << "$(CMAKE_COMMAND) -E cmake_depends \""
|
2006-02-14 18:36:04 +03:00
|
|
|
<< this->GlobalGenerator->GetName() << "\" "
|
2006-05-25 17:47:30 +04:00
|
|
|
<< this->Convert(this->Makefile->GetHomeDirectory(),
|
|
|
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
|
2006-02-14 18:36:04 +03:00
|
|
|
<< " "
|
2006-05-25 17:47:30 +04:00
|
|
|
<< this->Convert(this->Makefile->GetStartDirectory(),
|
|
|
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
|
|
|
|
<< " "
|
|
|
|
<< this->Convert(this->Makefile->GetHomeOutputDirectory(),
|
|
|
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
|
|
|
|
<< " "
|
|
|
|
<< this->Convert(this->Makefile->GetStartOutputDirectory(),
|
|
|
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
|
2006-02-14 18:36:04 +03:00
|
|
|
<< " "
|
2014-03-11 03:04:11 +04:00
|
|
|
<< this->Convert(this->InfoFileNameFull,
|
2008-10-15 18:40:57 +04:00
|
|
|
cmLocalGenerator::FULL, cmLocalGenerator::SHELL);
|
|
|
|
if(this->LocalGenerator->GetColorMakefile())
|
|
|
|
{
|
|
|
|
depCmd << " --color=$(COLOR)";
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
commands.push_back(depCmd.str());
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-08-31 22:09:56 +04:00
|
|
|
// Make sure all custom command outputs in this target are built.
|
2007-05-01 21:51:25 +04:00
|
|
|
if(this->CustomCommandDriver == OnDepends)
|
2006-09-29 00:40:35 +04:00
|
|
|
{
|
|
|
|
this->DriveCustomCommands(depends);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
depTarget,
|
2007-12-21 19:00:03 +03:00
|
|
|
depends, commands, true);
|
2006-09-29 00:40:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::DriveCustomCommands(std::vector<std::string>& depends)
|
|
|
|
{
|
|
|
|
// Depend on all custom command outputs.
|
2013-07-14 20:22:57 +04:00
|
|
|
std::vector<cmSourceFile*> sources;
|
|
|
|
this->Target->GetSourceFiles(sources);
|
2006-08-31 22:09:56 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
|
|
|
|
source != sources.end(); ++source)
|
|
|
|
{
|
|
|
|
if(cmCustomCommand* cc = (*source)->GetCustomCommand())
|
|
|
|
{
|
2014-03-10 23:47:19 +04:00
|
|
|
cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile);
|
|
|
|
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
2006-08-31 22:09:56 +04:00
|
|
|
for(std::vector<std::string>::const_iterator o = outputs.begin();
|
|
|
|
o != outputs.end(); ++o)
|
|
|
|
{
|
|
|
|
depends.push_back(*o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator
|
|
|
|
::WriteObjectDependRules(cmSourceFile& source,
|
|
|
|
std::vector<std::string>& depends)
|
|
|
|
{
|
|
|
|
// Create the list of dependencies known at cmake time. These are
|
|
|
|
// shared between the object file and dependency scanning rule.
|
|
|
|
depends.push_back(source.GetFullPath());
|
|
|
|
if(const char* objectDeps = source.GetProperty("OBJECT_DEPENDS"))
|
|
|
|
{
|
|
|
|
std::vector<std::string> deps;
|
|
|
|
cmSystemTools::ExpandListArgument(objectDeps, deps);
|
|
|
|
for(std::vector<std::string>::iterator i = deps.begin();
|
|
|
|
i != deps.end(); ++i)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
depends.push_back(*i);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator
|
2014-03-10 23:47:19 +04:00
|
|
|
::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
|
|
|
// Collect the commands.
|
|
|
|
std::vector<std::string> commands;
|
2014-03-10 23:47:19 +04:00
|
|
|
std::string comment = this->LocalGenerator->ConstructComment(ccg);
|
2006-04-11 19:06:19 +04:00
|
|
|
if(!comment.empty())
|
|
|
|
{
|
2006-07-13 22:03:56 +04:00
|
|
|
// add in a progress call if needed
|
2009-03-16 23:22:13 +03:00
|
|
|
this->AppendProgress(commands);
|
2009-03-16 23:55:58 +03:00
|
|
|
if(!this->NoRuleMessages)
|
|
|
|
{
|
|
|
|
this->LocalGenerator
|
|
|
|
->AppendEcho(commands, comment.c_str(),
|
|
|
|
cmLocalUnixMakefileGenerator3::EchoGenerate);
|
|
|
|
}
|
2006-04-11 19:06:19 +04:00
|
|
|
}
|
2008-06-03 17:55:28 +04:00
|
|
|
|
|
|
|
// Now append the actual user-specified commands.
|
2009-02-02 21:28:12 +03:00
|
|
|
cmOStringStream content;
|
2014-03-10 23:47:19 +04:00
|
|
|
this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false,
|
2009-02-02 21:28:12 +03:00
|
|
|
cmLocalGenerator::HOME_OUTPUT,
|
|
|
|
&content);
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Collect the dependencies.
|
|
|
|
std::vector<std::string> depends;
|
2014-03-10 23:47:19 +04:00
|
|
|
this->LocalGenerator->AppendCustomDepend(depends, ccg);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2006-10-02 18:20:53 +04:00
|
|
|
// Check whether we need to bother checking for a symbolic output.
|
|
|
|
bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Write the rule.
|
2014-03-10 23:47:19 +04:00
|
|
|
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
2006-04-11 19:06:19 +04:00
|
|
|
std::vector<std::string>::const_iterator o = outputs.begin();
|
2006-10-02 18:20:53 +04:00
|
|
|
{
|
|
|
|
bool symbolic = false;
|
|
|
|
if(need_symbolic)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
if(cmSourceFile* sf = this->Makefile->GetSource(*o))
|
2006-10-02 18:20:53 +04:00
|
|
|
{
|
|
|
|
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
|
|
|
|
}
|
|
|
|
}
|
2006-04-11 19:06:19 +04:00
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2014-03-11 03:04:11 +04:00
|
|
|
*o, depends, commands,
|
2006-10-02 18:20:53 +04:00
|
|
|
symbolic);
|
2008-06-03 00:44:58 +04:00
|
|
|
|
|
|
|
// If the rule has changed make sure the output is rebuilt.
|
|
|
|
if(!symbolic)
|
|
|
|
{
|
2014-03-10 23:47:19 +04:00
|
|
|
this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str());
|
2008-06-03 00:44:58 +04:00
|
|
|
}
|
2006-10-02 18:20:53 +04:00
|
|
|
}
|
2006-04-11 19:06:19 +04:00
|
|
|
|
2007-03-09 19:29:15 +03:00
|
|
|
// Write rules to drive building any outputs beyond the first.
|
|
|
|
const char* in = o->c_str();
|
2006-04-11 19:06:19 +04:00
|
|
|
for(++o; o != outputs.end(); ++o)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2006-10-02 18:20:53 +04:00
|
|
|
bool symbolic = false;
|
|
|
|
if(need_symbolic)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
if(cmSourceFile* sf = this->Makefile->GetSource(*o))
|
2006-10-02 18:20:53 +04:00
|
|
|
{
|
|
|
|
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
|
|
|
|
}
|
|
|
|
}
|
2007-03-09 19:29:15 +03:00
|
|
|
this->GenerateExtraOutput(o->c_str(), in, symbolic);
|
|
|
|
}
|
2007-09-17 18:50:46 +04:00
|
|
|
|
|
|
|
// Setup implicit dependency scanning.
|
|
|
|
for(cmCustomCommand::ImplicitDependsList::const_iterator
|
2014-03-10 23:47:19 +04:00
|
|
|
idi = ccg.GetCC().GetImplicitDepends().begin();
|
|
|
|
idi != ccg.GetCC().GetImplicitDepends().end(); ++idi)
|
2007-09-17 18:50:46 +04:00
|
|
|
{
|
|
|
|
std::string objFullPath =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(outputs[0], cmLocalGenerator::FULL);
|
2007-09-17 18:50:46 +04:00
|
|
|
std::string srcFullPath =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(idi->second, cmLocalGenerator::FULL);
|
2007-09-17 18:50:46 +04:00
|
|
|
this->LocalGenerator->
|
2014-03-11 03:04:11 +04:00
|
|
|
AddImplicitDepends(*this->Target, idi->first,
|
2007-09-17 18:50:46 +04:00
|
|
|
objFullPath.c_str(),
|
|
|
|
srcFullPath.c_str());
|
|
|
|
}
|
2007-03-09 19:29:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::GenerateExtraOutput(const char* out, const char* in, bool symbolic)
|
|
|
|
{
|
|
|
|
// Add a rule to build the primary output if the extra output needs
|
|
|
|
// to be created.
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
std::vector<std::string> depends;
|
2007-05-16 21:24:17 +04:00
|
|
|
std::string emptyCommand = this->GlobalGenerator->GetEmptyRuleHackCommand();
|
2007-03-09 19:29:15 +03:00
|
|
|
if(!emptyCommand.empty())
|
|
|
|
{
|
|
|
|
commands.push_back(emptyCommand);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
2007-03-09 19:29:15 +03:00
|
|
|
depends.push_back(in);
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
|
|
|
out, depends, commands,
|
|
|
|
symbolic);
|
|
|
|
|
|
|
|
// Register the extra output as paired with the first output so that
|
|
|
|
// the check-build-system step will remove the primary output if any
|
|
|
|
// extra outputs are missing. This forces the rule to regenerate
|
|
|
|
// all outputs.
|
2007-12-21 20:22:12 +03:00
|
|
|
this->AddMultipleOutputPair(out, in);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
2009-03-16 23:22:13 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands)
|
|
|
|
{
|
|
|
|
this->NumberOfProgressActions++;
|
2009-03-16 23:55:58 +03:00
|
|
|
if(this->NoRuleMessages)
|
2009-03-16 23:22:19 +03:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-03-16 23:22:13 +03:00
|
|
|
std::string progressDir = this->Makefile->GetHomeOutputDirectory();
|
|
|
|
progressDir += cmake::GetCMakeFilesDirectory();
|
|
|
|
cmOStringStream progCmd;
|
|
|
|
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
|
2014-03-11 03:04:11 +04:00
|
|
|
progCmd << this->LocalGenerator->Convert(progressDir,
|
2009-03-16 23:22:13 +03:00
|
|
|
cmLocalGenerator::FULL,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
progCmd << " $(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";
|
|
|
|
commands.push_back(progCmd.str());
|
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::WriteObjectsVariable(std::string& variableName,
|
|
|
|
std::string& variableNameExternal)
|
|
|
|
{
|
|
|
|
// Write a make variable assignment that lists all objects for the
|
|
|
|
// target.
|
2006-07-10 15:52:35 +04:00
|
|
|
variableName =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->LocalGenerator->CreateMakeVariable(this->Target->GetName(),
|
2006-05-12 20:29:09 +04:00
|
|
|
"_OBJECTS");
|
2006-02-14 18:36:04 +03:00
|
|
|
*this->BuildFileStream
|
|
|
|
<< "# Object files for target " << this->Target->GetName() << "\n"
|
2014-03-11 16:35:32 +04:00
|
|
|
<< variableName << " =";
|
2006-02-14 18:36:04 +03:00
|
|
|
std::string object;
|
2006-07-10 15:52:35 +04:00
|
|
|
const char* objName =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS");
|
2006-07-10 15:52:35 +04:00
|
|
|
const char* lineContinue =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE");
|
|
|
|
if(!lineContinue)
|
|
|
|
{
|
|
|
|
lineContinue = "\\";
|
|
|
|
}
|
|
|
|
for(std::vector<std::string>::const_iterator i = this->Objects.begin();
|
|
|
|
i != this->Objects.end(); ++i)
|
|
|
|
{
|
|
|
|
*this->BuildFileStream << " " << lineContinue << "\n";
|
|
|
|
if(objName)
|
|
|
|
{
|
2006-07-10 15:52:35 +04:00
|
|
|
*this->BuildFileStream <<
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(*i, cmLocalGenerator::START_OUTPUT,
|
2006-02-14 18:36:04 +03:00
|
|
|
cmLocalGenerator::MAKEFILE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-10 15:52:35 +04:00
|
|
|
*this->BuildFileStream <<
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*this->BuildFileStream << "\n";
|
|
|
|
|
|
|
|
// Write a make variable assignment that lists all external objects
|
|
|
|
// for the target.
|
2006-07-10 15:52:35 +04:00
|
|
|
variableNameExternal =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->LocalGenerator->CreateMakeVariable(this->Target->GetName(),
|
2006-05-12 20:29:09 +04:00
|
|
|
"_EXTERNAL_OBJECTS");
|
2006-02-14 18:36:04 +03:00
|
|
|
*this->BuildFileStream
|
|
|
|
<< "\n"
|
2006-07-10 15:52:35 +04:00
|
|
|
<< "# External object files for target "
|
2006-05-12 20:29:09 +04:00
|
|
|
<< this->Target->GetName() << "\n"
|
2014-03-11 16:35:32 +04:00
|
|
|
<< variableNameExternal << " =";
|
2006-07-10 15:52:35 +04:00
|
|
|
for(std::vector<std::string>::const_iterator i =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->ExternalObjects.begin();
|
|
|
|
i != this->ExternalObjects.end(); ++i)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
object = this->Convert(*i,cmLocalGenerator::START_OUTPUT);
|
2006-02-14 18:36:04 +03:00
|
|
|
*this->BuildFileStream
|
|
|
|
<< " " << lineContinue << "\n"
|
|
|
|
<< this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME");
|
|
|
|
if(objName)
|
|
|
|
{
|
2006-07-10 15:52:35 +04:00
|
|
|
*this->BuildFileStream <<
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Convert(*i, cmLocalGenerator::START_OUTPUT,
|
2006-05-12 20:29:09 +04:00
|
|
|
cmLocalGenerator::MAKEFILE);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-10 15:52:35 +04:00
|
|
|
*this->BuildFileStream <<
|
2006-02-14 18:36:04 +03:00
|
|
|
this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*this->BuildFileStream << "\n" << "\n";
|
|
|
|
}
|
|
|
|
|
2006-06-16 00:17:11 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::WriteObjectsString(std::string& buildObjs)
|
|
|
|
{
|
2008-01-30 04:46:25 +03:00
|
|
|
std::vector<std::string> objStrings;
|
|
|
|
this->WriteObjectsStrings(objStrings);
|
|
|
|
buildObjs = objStrings[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class cmMakefileTargetGeneratorObjectStrings
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings,
|
|
|
|
cmLocalUnixMakefileGenerator3* lg,
|
|
|
|
std::string::size_type limit):
|
2012-06-21 00:55:37 +04:00
|
|
|
Strings(strings), LocalGenerator(lg), LengthLimit(limit)
|
2006-06-16 00:17:11 +04:00
|
|
|
{
|
2008-01-30 04:46:25 +03:00
|
|
|
this->Space = "";
|
|
|
|
}
|
|
|
|
void Feed(std::string const& obj)
|
|
|
|
{
|
|
|
|
// Construct the name of the next object.
|
2008-02-24 22:05:21 +03:00
|
|
|
this->NextObject =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->LocalGenerator->Convert(obj,
|
2008-02-24 22:05:21 +03:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
2010-03-11 16:49:05 +03:00
|
|
|
cmLocalGenerator::RESPONSE);
|
2008-01-30 04:46:25 +03:00
|
|
|
|
|
|
|
// Roll over to next string if the limit will be exceeded.
|
|
|
|
if(this->LengthLimit != std::string::npos &&
|
|
|
|
(this->CurrentString.length() + 1 + this->NextObject.length()
|
|
|
|
> this->LengthLimit))
|
2006-06-16 00:17:11 +04:00
|
|
|
{
|
2008-01-30 04:46:25 +03:00
|
|
|
this->Strings.push_back(this->CurrentString);
|
|
|
|
this->CurrentString = "";
|
|
|
|
this->Space = "";
|
2006-06-16 00:17:11 +04:00
|
|
|
}
|
2008-01-30 04:46:25 +03:00
|
|
|
|
|
|
|
// Separate from previous object.
|
|
|
|
this->CurrentString += this->Space;
|
|
|
|
this->Space = " ";
|
|
|
|
|
|
|
|
// Append this object.
|
|
|
|
this->CurrentString += this->NextObject;
|
|
|
|
}
|
|
|
|
void Done()
|
|
|
|
{
|
|
|
|
this->Strings.push_back(this->CurrentString);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
std::vector<std::string>& Strings;
|
|
|
|
cmLocalUnixMakefileGenerator3* LocalGenerator;
|
|
|
|
std::string::size_type LengthLimit;
|
|
|
|
std::string CurrentString;
|
|
|
|
std::string NextObject;
|
|
|
|
const char* Space;
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::WriteObjectsStrings(std::vector<std::string>& objStrings,
|
|
|
|
std::string::size_type limit)
|
|
|
|
{
|
|
|
|
cmMakefileTargetGeneratorObjectStrings
|
2012-06-21 00:55:37 +04:00
|
|
|
helper(objStrings, this->LocalGenerator, limit);
|
2008-01-30 04:46:25 +03:00
|
|
|
for(std::vector<std::string>::const_iterator i = this->Objects.begin();
|
|
|
|
i != this->Objects.end(); ++i)
|
|
|
|
{
|
|
|
|
helper.Feed(*i);
|
2006-06-16 00:17:11 +04:00
|
|
|
}
|
|
|
|
for(std::vector<std::string>::const_iterator i =
|
|
|
|
this->ExternalObjects.begin();
|
|
|
|
i != this->ExternalObjects.end(); ++i)
|
|
|
|
{
|
2008-01-30 04:46:25 +03:00
|
|
|
helper.Feed(*i);
|
2006-06-16 00:17:11 +04:00
|
|
|
}
|
2008-01-30 04:46:25 +03:00
|
|
|
helper.Done();
|
2006-06-16 00:17:11 +04:00
|
|
|
}
|
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2014-02-25 05:32:55 +04:00
|
|
|
void cmMakefileTargetGenerator::WriteTargetDriverRule(
|
|
|
|
const std::string& main_output,
|
|
|
|
bool relink)
|
2006-06-01 19:45:51 +04:00
|
|
|
{
|
|
|
|
// Compute the name of the driver target.
|
2006-10-10 05:25:58 +04:00
|
|
|
std::string dir =
|
|
|
|
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
|
2006-06-01 19:45:51 +04:00
|
|
|
std::string buildTargetRuleName = dir;
|
|
|
|
buildTargetRuleName += relink?"/preinstall":"/build";
|
2014-03-11 03:04:11 +04:00
|
|
|
buildTargetRuleName = this->Convert(buildTargetRuleName,
|
2006-06-01 19:45:51 +04:00
|
|
|
cmLocalGenerator::HOME_OUTPUT,
|
2007-02-19 20:26:32 +03:00
|
|
|
cmLocalGenerator::UNCHANGED);
|
2006-06-01 19:45:51 +04:00
|
|
|
|
|
|
|
// Build the list of target outputs to drive.
|
|
|
|
std::vector<std::string> depends;
|
2014-02-25 05:32:55 +04:00
|
|
|
depends.push_back(main_output);
|
2006-06-01 19:45:51 +04:00
|
|
|
|
|
|
|
const char* comment = 0;
|
|
|
|
if(relink)
|
|
|
|
{
|
|
|
|
// Setup the comment for the preinstall driver.
|
|
|
|
comment = "Rule to relink during preinstall.";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Setup the comment for the main build driver.
|
|
|
|
comment = "Rule to build all files generated by this target.";
|
2006-09-29 00:40:35 +04:00
|
|
|
|
|
|
|
// Make sure all custom command outputs in this target are built.
|
2007-05-01 21:51:25 +04:00
|
|
|
if(this->CustomCommandDriver == OnBuild)
|
2006-09-29 00:40:35 +04:00
|
|
|
{
|
|
|
|
this->DriveCustomCommands(depends);
|
|
|
|
}
|
2008-02-15 19:22:23 +03:00
|
|
|
|
|
|
|
// Make sure the extra files are built.
|
2014-02-10 09:21:34 +04:00
|
|
|
for(std::set<std::string>::const_iterator i = this->ExtraFiles.begin();
|
2008-02-15 19:22:23 +03:00
|
|
|
i != this->ExtraFiles.end(); ++i)
|
|
|
|
{
|
|
|
|
depends.push_back(*i);
|
|
|
|
}
|
2006-06-01 19:45:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Write the driver rule.
|
|
|
|
std::vector<std::string> no_commands;
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment,
|
2014-03-11 03:04:11 +04:00
|
|
|
buildTargetRuleName,
|
2006-06-01 19:45:51 +04:00
|
|
|
depends, no_commands, true);
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2013-10-10 16:29:04 +04:00
|
|
|
std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2010-05-01 16:29:13 +04:00
|
|
|
if(!this->Makefile->IsOn("APPLE"))
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2013-10-10 16:29:04 +04:00
|
|
|
std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG";
|
|
|
|
const char* fwSearchFlag =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(fwSearchFlagVar);
|
2013-10-10 16:29:04 +04:00
|
|
|
if(!(fwSearchFlag && *fwSearchFlag))
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> emitted;
|
2010-05-01 16:29:13 +04:00
|
|
|
#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */
|
2007-03-30 18:53:02 +04:00
|
|
|
emitted.insert("/System/Library/Frameworks");
|
2010-05-03 23:28:12 +04:00
|
|
|
#endif
|
2006-02-14 18:36:04 +03:00
|
|
|
std::vector<std::string> includes;
|
2012-10-15 12:42:42 +04:00
|
|
|
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config =
|
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2012-09-16 12:03:42 +04:00
|
|
|
this->LocalGenerator->GetIncludeDirectories(includes,
|
2012-10-15 12:42:42 +04:00
|
|
|
this->GeneratorTarget,
|
|
|
|
"C", config);
|
2006-02-14 18:36:04 +03:00
|
|
|
// check all include directories for frameworks as this
|
|
|
|
// will already have added a -F for the framework
|
2012-12-07 22:27:52 +04:00
|
|
|
for(std::vector<std::string>::iterator i = includes.begin();
|
|
|
|
i != includes.end(); ++i)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
if(this->Target->NameResolvesToFramework(*i))
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
|
|
|
std::string frameworkDir = *i;
|
|
|
|
frameworkDir += "/../";
|
|
|
|
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
|
|
|
|
emitted.insert(frameworkDir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string flags;
|
2012-12-07 22:27:52 +04:00
|
|
|
const char* cfg = this->LocalGenerator->ConfigurationName.c_str();
|
|
|
|
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg))
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2012-12-07 22:27:52 +04:00
|
|
|
std::vector<std::string> const& frameworks = cli->GetFrameworkPaths();
|
|
|
|
for(std::vector<std::string>::const_iterator i = frameworks.begin();
|
|
|
|
i != frameworks.end(); ++i)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2012-12-07 22:27:52 +04:00
|
|
|
if(emitted.insert(*i).second)
|
|
|
|
{
|
2013-10-10 16:29:04 +04:00
|
|
|
flags += fwSearchFlag;
|
2014-03-11 03:04:11 +04:00
|
|
|
flags += this->Convert(*i,
|
2012-12-07 22:27:52 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::SHELL, true);
|
|
|
|
flags += " ";
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator
|
|
|
|
::AppendTargetDepends(std::vector<std::string>& depends)
|
|
|
|
{
|
|
|
|
// Static libraries never depend on anything for linking.
|
|
|
|
if(this->Target->GetType() == cmTarget::STATIC_LIBRARY)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loop over all library dependencies.
|
2008-05-22 03:57:35 +04:00
|
|
|
const char* cfg = this->LocalGenerator->ConfigurationName.c_str();
|
2012-11-05 19:14:02 +04:00
|
|
|
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg))
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
2008-05-22 03:57:35 +04:00
|
|
|
std::vector<std::string> const& libDeps = cli->GetDepends();
|
|
|
|
for(std::vector<std::string>::const_iterator j = libDeps.begin();
|
|
|
|
j != libDeps.end(); ++j)
|
2006-11-28 00:13:41 +03:00
|
|
|
{
|
2008-05-22 03:57:35 +04:00
|
|
|
depends.push_back(*j);
|
2006-09-12 18:03:57 +04:00
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-05 15:33:47 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator
|
2012-03-12 18:54:37 +04:00
|
|
|
::AppendObjectDepends(std::vector<std::string>& depends)
|
2010-11-05 15:33:47 +03:00
|
|
|
{
|
|
|
|
// Add dependencies on the compiled object files.
|
|
|
|
std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
|
|
|
|
std::string objTarget;
|
|
|
|
for(std::vector<std::string>::const_iterator obj = this->Objects.begin();
|
|
|
|
obj != this->Objects.end(); ++obj)
|
|
|
|
{
|
|
|
|
objTarget = relPath;
|
|
|
|
objTarget += *obj;
|
|
|
|
depends.push_back(objTarget);
|
|
|
|
}
|
|
|
|
|
2012-03-12 18:54:37 +04:00
|
|
|
// Add dependencies on the external object files.
|
|
|
|
for(std::vector<std::string>::const_iterator obj
|
|
|
|
= this->ExternalObjects.begin();
|
|
|
|
obj != this->ExternalObjects.end(); ++obj)
|
|
|
|
{
|
|
|
|
depends.push_back(*obj);
|
|
|
|
}
|
2010-11-05 15:33:47 +03:00
|
|
|
|
|
|
|
// Add a dependency on the rule file itself.
|
|
|
|
this->LocalGenerator->AppendRuleDepend(depends,
|
|
|
|
this->BuildFileNameFull.c_str());
|
2012-03-12 18:54:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator
|
|
|
|
::AppendLinkDepends(std::vector<std::string>& depends)
|
|
|
|
{
|
|
|
|
this->AppendObjectDepends(depends);
|
|
|
|
|
|
|
|
// Add dependencies on targets that must be built first.
|
|
|
|
this->AppendTargetDepends(depends);
|
2010-11-05 15:33:47 +03:00
|
|
|
|
2010-12-15 19:30:57 +03:00
|
|
|
// Add a dependency on the link definitions file, if any.
|
2014-02-14 13:23:23 +04:00
|
|
|
std::string def = this->GeneratorTarget->GetModuleDefinitionFile();
|
|
|
|
if(!def.empty())
|
2010-12-15 19:30:57 +03:00
|
|
|
{
|
2014-02-14 13:23:23 +04:00
|
|
|
depends.push_back(def);
|
2010-12-15 19:30:57 +03:00
|
|
|
}
|
|
|
|
|
2010-11-05 16:05:08 +03:00
|
|
|
// Add user-specified dependencies.
|
|
|
|
if(const char* linkDepends =
|
|
|
|
this->Target->GetProperty("LINK_DEPENDS"))
|
|
|
|
{
|
|
|
|
cmSystemTools::ExpandListArgument(linkDepends, depends);
|
|
|
|
}
|
2010-11-05 15:33:47 +03:00
|
|
|
}
|
|
|
|
|
2011-12-06 01:28:03 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2014-02-05 01:06:56 +04:00
|
|
|
std::string cmMakefileTargetGenerator::GetLinkRule(
|
2014-02-07 02:31:47 +04:00
|
|
|
const std::string& linkRuleVar)
|
2011-12-06 01:28:03 +04:00
|
|
|
{
|
|
|
|
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
|
2011-12-06 01:39:07 +04:00
|
|
|
if(this->Target->HasImplibGNUtoMS())
|
|
|
|
{
|
|
|
|
std::string ruleVar = "CMAKE_";
|
|
|
|
ruleVar += this->Target->GetLinkerLanguage(this->ConfigName);
|
|
|
|
ruleVar += "_GNUtoMS_RULE";
|
2014-03-11 03:04:11 +04:00
|
|
|
if(const char* rule = this->Makefile->GetDefinition(ruleVar))
|
2011-12-06 01:39:07 +04:00
|
|
|
{
|
|
|
|
linkRule += rule;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 01:28:03 +04:00
|
|
|
return linkRule;
|
|
|
|
}
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator
|
|
|
|
::CloseFileStreams()
|
|
|
|
{
|
|
|
|
delete this->BuildFileStream;
|
|
|
|
delete this->InfoFileStream;
|
|
|
|
delete this->FlagFileStream;
|
|
|
|
}
|
2006-03-14 22:03:16 +03:00
|
|
|
|
|
|
|
void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& linkLang,
|
|
|
|
std::string& linkFlags)
|
2006-03-14 22:03:16 +03:00
|
|
|
{
|
|
|
|
// check for language flags that are not allowed at link time, and
|
|
|
|
// remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool
|
|
|
|
// which fails, there may be more]
|
2006-07-10 15:52:35 +04:00
|
|
|
|
2006-03-14 22:03:16 +03:00
|
|
|
std::string removeFlags = "CMAKE_";
|
|
|
|
removeFlags += linkLang;
|
|
|
|
removeFlags += flagVar;
|
2006-07-10 15:52:35 +04:00
|
|
|
std::string removeflags =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetSafeDefinition(removeFlags);
|
2006-03-14 22:03:16 +03:00
|
|
|
std::vector<std::string> removeList;
|
|
|
|
cmSystemTools::ExpandListArgument(removeflags, removeList);
|
2013-11-16 00:41:11 +04:00
|
|
|
|
2006-03-14 22:03:16 +03:00
|
|
|
for(std::vector<std::string>::iterator i = removeList.begin();
|
|
|
|
i != removeList.end(); ++i)
|
|
|
|
{
|
2013-11-16 00:41:11 +04:00
|
|
|
std::string tmp;
|
|
|
|
std::string::size_type lastPosition = 0;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
std::string::size_type position = linkFlags.find(*i, lastPosition);
|
|
|
|
|
|
|
|
if(position == std::string::npos)
|
|
|
|
{
|
|
|
|
tmp += linkFlags.substr(lastPosition);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string::size_type prefixLength = position - lastPosition;
|
|
|
|
tmp += linkFlags.substr(lastPosition, prefixLength);
|
|
|
|
lastPosition = position + i->length();
|
|
|
|
|
|
|
|
bool validFlagStart = position == 0 ||
|
|
|
|
isspace(linkFlags[position - 1]);
|
|
|
|
|
|
|
|
bool validFlagEnd = lastPosition == linkFlags.size() ||
|
|
|
|
isspace(linkFlags[lastPosition]);
|
|
|
|
|
|
|
|
if(!validFlagStart || !validFlagEnd)
|
|
|
|
{
|
|
|
|
tmp += *i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
linkFlags = tmp;
|
2006-03-14 22:03:16 +03:00
|
|
|
}
|
|
|
|
}
|
2006-07-11 17:55:27 +04:00
|
|
|
|
2007-12-21 20:22:12 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::AddMultipleOutputPair(const char* depender, const char* dependee)
|
|
|
|
{
|
|
|
|
MultipleOutputPairsType::value_type p(depender, dependee);
|
|
|
|
this->MultipleOutputPairs.insert(p);
|
|
|
|
}
|
2007-12-28 22:59:06 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::CreateLinkScript(const char* name,
|
|
|
|
std::vector<std::string> const& link_commands,
|
2008-02-20 22:56:29 +03:00
|
|
|
std::vector<std::string>& makefile_commands,
|
|
|
|
std::vector<std::string>& makefile_depends)
|
2007-12-28 22:59:06 +03:00
|
|
|
{
|
|
|
|
// Create the link script file.
|
|
|
|
std::string linkScriptName = this->TargetBuildDirectoryFull;
|
|
|
|
linkScriptName += "/";
|
|
|
|
linkScriptName += name;
|
|
|
|
cmGeneratedFileStream linkScriptStream(linkScriptName.c_str());
|
2008-02-20 22:56:29 +03:00
|
|
|
linkScriptStream.SetCopyIfDifferent(true);
|
2007-12-28 22:59:06 +03:00
|
|
|
for(std::vector<std::string>::const_iterator cmd = link_commands.begin();
|
|
|
|
cmd != link_commands.end(); ++cmd)
|
|
|
|
{
|
|
|
|
// Do not write out empty commands or commands beginning in the
|
|
|
|
// shell no-op ":".
|
|
|
|
if(!cmd->empty() && (*cmd)[0] != ':')
|
|
|
|
{
|
|
|
|
linkScriptStream << *cmd << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the makefile command to invoke the link script.
|
|
|
|
std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
|
2014-03-11 03:04:11 +04:00
|
|
|
link_command += this->Convert(linkScriptName,
|
2007-12-28 22:59:06 +03:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
link_command += " --verbose=$(VERBOSE)";
|
|
|
|
makefile_commands.push_back(link_command);
|
2008-02-20 22:56:29 +03:00
|
|
|
makefile_depends.push_back(linkScriptName);
|
2007-12-28 22:59:06 +03:00
|
|
|
}
|
2007-12-31 00:11:38 +03:00
|
|
|
|
2008-02-28 01:10:45 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmMakefileTargetGenerator
|
|
|
|
::CreateResponseFile(const char* name, std::string const& options,
|
|
|
|
std::vector<std::string>& makefile_depends)
|
|
|
|
{
|
|
|
|
// Create the response file.
|
|
|
|
std::string responseFileNameFull = this->TargetBuildDirectoryFull;
|
|
|
|
responseFileNameFull += "/";
|
|
|
|
responseFileNameFull += name;
|
|
|
|
cmGeneratedFileStream responseStream(responseFileNameFull.c_str());
|
2008-04-03 19:11:54 +04:00
|
|
|
responseStream.SetCopyIfDifferent(true);
|
2008-02-28 01:10:45 +03:00
|
|
|
responseStream << options << "\n";
|
|
|
|
|
|
|
|
// Add a dependency so the target will rebuild when the set of
|
|
|
|
// objects changes.
|
|
|
|
makefile_depends.push_back(responseFileNameFull);
|
|
|
|
|
|
|
|
// Construct the name to be used on the command line.
|
|
|
|
std::string responseFileName = this->TargetBuildDirectory;
|
|
|
|
responseFileName += "/";
|
|
|
|
responseFileName += name;
|
|
|
|
return responseFileName;
|
|
|
|
}
|
|
|
|
|
2008-10-15 18:21:14 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
2014-03-04 20:20:27 +04:00
|
|
|
::CreateLinkLibs(std::string& linkLibs, bool relink,
|
2014-03-04 22:25:42 +04:00
|
|
|
bool useResponseFile,
|
2014-03-04 20:20:27 +04:00
|
|
|
std::vector<std::string>& makefile_depends)
|
|
|
|
{
|
|
|
|
std::string frameworkPath;
|
|
|
|
std::string linkPath;
|
|
|
|
this->LocalGenerator
|
|
|
|
->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
2014-03-04 22:25:42 +04:00
|
|
|
*this->GeneratorTarget, relink,
|
|
|
|
useResponseFile);
|
2014-03-04 20:20:27 +04:00
|
|
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
2014-03-04 22:25:42 +04:00
|
|
|
|
|
|
|
if(useResponseFile)
|
|
|
|
{
|
|
|
|
// Lookup the response file reference flag.
|
|
|
|
std::string responseFlagVar = "CMAKE_";
|
|
|
|
responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
|
|
|
|
responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
|
|
|
|
const char* responseFlag =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(responseFlagVar);
|
2014-03-04 22:25:42 +04:00
|
|
|
if(!responseFlag)
|
|
|
|
{
|
|
|
|
responseFlag = "@";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create this response file.
|
|
|
|
std::string link_rsp =
|
|
|
|
this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends);
|
|
|
|
|
|
|
|
// Reference the response file.
|
|
|
|
linkLibs = responseFlag;
|
2014-03-11 03:04:11 +04:00
|
|
|
linkLibs += this->Convert(link_rsp,
|
2014-03-04 22:25:42 +04:00
|
|
|
cmLocalGenerator::NONE,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
}
|
2014-03-04 20:20:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmMakefileTargetGenerator
|
2008-10-15 18:21:14 +04:00
|
|
|
::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
|
|
|
|
bool useResponseFile, std::string& buildObjs,
|
|
|
|
std::vector<std::string>& makefile_depends)
|
|
|
|
{
|
|
|
|
std::string variableName;
|
|
|
|
std::string variableNameExternal;
|
|
|
|
this->WriteObjectsVariable(variableName, variableNameExternal);
|
|
|
|
if(useResponseFile)
|
|
|
|
{
|
2008-10-15 18:21:21 +04:00
|
|
|
// MSVC response files cannot exceed 128K.
|
|
|
|
std::string::size_type const responseFileLimit = 131000;
|
|
|
|
|
|
|
|
// Construct the individual object list strings.
|
|
|
|
std::vector<std::string> object_strings;
|
|
|
|
this->WriteObjectsStrings(object_strings, responseFileLimit);
|
|
|
|
|
2010-03-11 17:03:26 +03:00
|
|
|
// Lookup the response file reference flag.
|
|
|
|
std::string responseFlagVar = "CMAKE_";
|
|
|
|
responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
|
|
|
|
responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
|
|
|
|
const char* responseFlag =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(responseFlagVar);
|
2010-03-11 17:03:26 +03:00
|
|
|
if(!responseFlag)
|
|
|
|
{
|
|
|
|
responseFlag = "@";
|
|
|
|
}
|
|
|
|
|
2008-10-15 18:21:21 +04:00
|
|
|
// Write a response file for each string.
|
|
|
|
const char* sep = "";
|
|
|
|
for(unsigned int i = 0; i < object_strings.size(); ++i)
|
|
|
|
{
|
|
|
|
// Number the response files.
|
|
|
|
char rsp[32];
|
|
|
|
sprintf(rsp, "objects%u.rsp", i+1);
|
|
|
|
|
|
|
|
// Create this response file.
|
|
|
|
std::string objects_rsp =
|
|
|
|
this->CreateResponseFile(rsp, object_strings[i], makefile_depends);
|
|
|
|
|
|
|
|
// Separate from previous response file references.
|
|
|
|
buildObjs += sep;
|
|
|
|
sep = " ";
|
|
|
|
|
|
|
|
// Reference the response file.
|
2010-03-11 17:03:26 +03:00
|
|
|
buildObjs += responseFlag;
|
2014-03-11 03:04:11 +04:00
|
|
|
buildObjs += this->Convert(objects_rsp,
|
2008-10-15 18:21:21 +04:00
|
|
|
cmLocalGenerator::NONE,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
}
|
2008-10-15 18:21:14 +04:00
|
|
|
}
|
|
|
|
else if(useLinkScript)
|
|
|
|
{
|
|
|
|
if(!useArchiveRules)
|
|
|
|
{
|
|
|
|
this->WriteObjectsString(buildObjs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buildObjs = "$(";
|
|
|
|
buildObjs += variableName;
|
|
|
|
buildObjs += ") $(";
|
|
|
|
buildObjs += variableNameExternal;
|
|
|
|
buildObjs += ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-15 21:07:36 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang)
|
2011-03-15 21:07:36 +03:00
|
|
|
{
|
|
|
|
std::string responseVar = "CMAKE_";
|
|
|
|
responseVar += lang;
|
|
|
|
responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
|
2014-03-11 03:04:11 +04:00
|
|
|
bool useResponseFile = this->Makefile->IsOn(responseVar);
|
2011-03-15 21:07:36 +03:00
|
|
|
|
2011-12-04 19:36:48 +04:00
|
|
|
|
|
|
|
std::vector<std::string> includes;
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config =
|
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2012-09-16 12:03:42 +04:00
|
|
|
this->LocalGenerator->GetIncludeDirectories(includes,
|
2012-10-15 12:42:42 +04:00
|
|
|
this->GeneratorTarget,
|
|
|
|
lang, config);
|
2011-12-04 19:36:48 +04:00
|
|
|
|
2011-03-15 21:07:36 +03:00
|
|
|
std::string includeFlags =
|
2013-07-02 00:28:26 +04:00
|
|
|
this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
|
|
|
|
lang, useResponseFile);
|
2011-03-15 21:07:36 +03:00
|
|
|
if(includeFlags.empty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(useResponseFile)
|
|
|
|
{
|
|
|
|
std::string name = "includes_";
|
|
|
|
name += lang;
|
|
|
|
name += ".rsp";
|
|
|
|
std::string arg = "@" +
|
|
|
|
this->CreateResponseFile(name.c_str(), includeFlags,
|
|
|
|
this->FlagFileDepends[lang]);
|
|
|
|
this->LocalGenerator->AppendFlags(flags, arg.c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->LocalGenerator->AppendFlags(flags, includeFlags.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-31 00:11:38 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char* cmMakefileTargetGenerator::GetFortranModuleDirectory()
|
|
|
|
{
|
|
|
|
// Compute the module directory.
|
|
|
|
if(!this->FortranModuleDirectoryComputed)
|
|
|
|
{
|
|
|
|
const char* target_mod_dir =
|
|
|
|
this->Target->GetProperty("Fortran_MODULE_DIRECTORY");
|
|
|
|
const char* moddir_flag =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
|
|
|
|
if(target_mod_dir && moddir_flag)
|
|
|
|
{
|
|
|
|
// Compute the full path to the module directory.
|
|
|
|
if(cmSystemTools::FileIsFullPath(target_mod_dir))
|
|
|
|
{
|
|
|
|
// Already a full path.
|
|
|
|
this->FortranModuleDirectory = target_mod_dir;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Interpret relative to the current output directory.
|
|
|
|
this->FortranModuleDirectory =
|
|
|
|
this->Makefile->GetCurrentOutputDirectory();
|
|
|
|
this->FortranModuleDirectory += "/";
|
|
|
|
this->FortranModuleDirectory += target_mod_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the module output directory exists.
|
|
|
|
cmSystemTools::MakeDirectory(this->FortranModuleDirectory.c_str());
|
|
|
|
}
|
|
|
|
this->FortranModuleDirectoryComputed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the computed directory.
|
|
|
|
if(this->FortranModuleDirectory.empty())
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this->FortranModuleDirectory.c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
|
|
|
|
{
|
2010-11-12 17:03:49 +03:00
|
|
|
// Enable module output if necessary.
|
|
|
|
if(const char* modout_flag =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG"))
|
|
|
|
{
|
|
|
|
this->LocalGenerator->AppendFlags(flags, modout_flag);
|
|
|
|
}
|
|
|
|
|
2007-12-31 00:11:38 +03:00
|
|
|
// Add a module output directory flag if necessary.
|
2010-12-06 18:35:25 +03:00
|
|
|
const char* mod_dir = this->GetFortranModuleDirectory();
|
|
|
|
if(!mod_dir)
|
|
|
|
{
|
|
|
|
mod_dir = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
|
|
|
|
}
|
|
|
|
if(mod_dir)
|
2007-12-31 00:11:38 +03:00
|
|
|
{
|
|
|
|
const char* moddir_flag =
|
|
|
|
this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
|
|
|
|
std::string modflag = moddir_flag;
|
|
|
|
modflag += this->Convert(mod_dir,
|
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
this->LocalGenerator->AppendFlags(flags, modflag.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there is a separate module path flag then duplicate the
|
|
|
|
// include path with it. This compiler does not search the include
|
|
|
|
// path for modules.
|
|
|
|
if(const char* modpath_flag =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
|
|
|
|
{
|
|
|
|
std::vector<std::string> includes;
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
|
2012-09-16 12:03:42 +04:00
|
|
|
this->LocalGenerator->GetIncludeDirectories(includes,
|
2012-10-15 12:42:42 +04:00
|
|
|
this->GeneratorTarget,
|
|
|
|
"C", config);
|
2007-12-31 00:11:38 +03:00
|
|
|
for(std::vector<std::string>::const_iterator idi = includes.begin();
|
|
|
|
idi != includes.end(); ++idi)
|
|
|
|
{
|
|
|
|
std::string flg = modpath_flag;
|
2014-03-11 03:04:11 +04:00
|
|
|
flg += this->Convert(*idi,
|
2007-12-31 00:11:38 +03:00
|
|
|
cmLocalGenerator::NONE,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
this->LocalGenerator->AppendFlags(flags, flg.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-30 00:39:07 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
|
|
|
|
{
|
2014-02-14 13:23:23 +04:00
|
|
|
std::string def = this->GeneratorTarget->GetModuleDefinitionFile();
|
|
|
|
if(def.empty())
|
2009-09-30 00:39:07 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Create a per-language flag variable.
|
|
|
|
const char* defFileFlag =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
|
|
|
if(!defFileFlag)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-30 18:12:54 +04:00
|
|
|
// Append the flag and value. Use ConvertToLinkReference to help
|
|
|
|
// vs6's "cl -link" pass it to the linker.
|
2009-09-30 00:39:07 +04:00
|
|
|
std::string flag = defFileFlag;
|
2014-03-11 03:04:11 +04:00
|
|
|
flag += (this->LocalGenerator->ConvertToLinkReference(def));
|
2009-09-30 00:39:07 +04:00
|
|
|
this->LocalGenerator->AppendFlags(flags, flag.c_str());
|
|
|
|
}
|
2009-10-02 21:51:49 +04:00
|
|
|
|
2009-10-02 21:52:01 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2014-02-10 08:09:05 +04:00
|
|
|
const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature)
|
2009-10-02 21:52:01 +04:00
|
|
|
{
|
|
|
|
return this->Target->GetFeature(feature, this->ConfigName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2014-02-10 08:09:05 +04:00
|
|
|
bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature)
|
2009-10-02 21:52:01 +04:00
|
|
|
{
|
|
|
|
return cmSystemTools::IsOn(this->GetFeature(feature));
|
|
|
|
}
|
|
|
|
|
2009-10-02 21:51:49 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmMakefileTargetGenerator::AddFeatureFlags(
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string& flags, const std::string& lang
|
2009-10-02 21:51:49 +04:00
|
|
|
)
|
|
|
|
{
|
|
|
|
// Add language-specific flags.
|
|
|
|
this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName);
|
2009-10-02 21:52:13 +04:00
|
|
|
|
|
|
|
if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION"))
|
|
|
|
{
|
|
|
|
this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
|
|
|
|
}
|
2009-10-02 21:51:49 +04:00
|
|
|
}
|