2006-02-14 18:36:04 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmMakefileExecutableTargetGenerator.h"
|
|
|
|
|
|
|
|
#include "cmGeneratedFileStream.h"
|
2006-12-14 22:30:41 +03: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"
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-09-29 00:40:35 +04:00
|
|
|
cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator()
|
|
|
|
{
|
|
|
|
this->DriveCustomCommandsOnDepends = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-02-14 18:36:04 +03:00
|
|
|
void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
|
|
|
|
{
|
|
|
|
// create the build.make file and directory, put in the common blocks
|
|
|
|
this->CreateRuleFile();
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
// write rules used to help build object files
|
2006-02-14 18:36:04 +03:00
|
|
|
this->WriteCommonCodeRules();
|
2006-02-16 00:35:16 +03:00
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
// write in rules for object files and custom commands
|
|
|
|
this->WriteTargetBuildRules();
|
|
|
|
|
|
|
|
// write the per-target per-language flags
|
|
|
|
this->WriteTargetLanguageFlags();
|
|
|
|
|
2006-02-16 00:35:16 +03:00
|
|
|
// Write the dependency generation rule.
|
|
|
|
this->WriteTargetDependRules();
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// write the link rules
|
2006-02-16 23:19:00 +03:00
|
|
|
this->WriteExecutableRule(false);
|
|
|
|
if(this->Target->NeedRelinkBeforeInstall())
|
|
|
|
{
|
|
|
|
// Write rules to link an installable version of the target.
|
|
|
|
this->WriteExecutableRule(true);
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Write the requires target.
|
|
|
|
this->WriteTargetRequiresRules();
|
|
|
|
|
|
|
|
// Write clean target
|
|
|
|
this->WriteTargetCleanRules();
|
|
|
|
|
|
|
|
// close the streams
|
|
|
|
this->CloseFileStreams();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-02-16 23:19:00 +03:00
|
|
|
void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
|
|
|
|
std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
|
|
|
|
std::string objTarget;
|
|
|
|
|
|
|
|
// Build list of dependencies.
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
for(std::vector<std::string>::const_iterator obj = this->Objects.begin();
|
|
|
|
obj != this->Objects.end(); ++obj)
|
|
|
|
{
|
|
|
|
objTarget = relPath;
|
2006-07-07 00:04:49 +04:00
|
|
|
// Handle extra content on Mac bundles
|
|
|
|
if ( this->ExtraContent.find(*obj) != this->ExtraContent.end() )
|
|
|
|
{
|
|
|
|
objTarget = "";
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
objTarget += *obj;
|
|
|
|
depends.push_back(objTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add dependencies on targets that must be built first.
|
|
|
|
this->AppendTargetDepends(depends);
|
|
|
|
|
|
|
|
// Add a dependency on the rule file itself.
|
|
|
|
this->LocalGenerator->AppendRuleDepend(depends,
|
|
|
|
this->BuildFileNameFull.c_str());
|
2006-03-28 17:54:01 +04:00
|
|
|
|
|
|
|
for(std::vector<std::string>::const_iterator obj =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->ExternalObjects.begin();
|
|
|
|
obj != this->ExternalObjects.end(); ++obj)
|
|
|
|
{
|
|
|
|
depends.push_back(*obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
// from here up is the same for exe or lib
|
|
|
|
|
|
|
|
// Get the name of the executable to generate.
|
|
|
|
std::string targetName;
|
|
|
|
std::string targetNameReal;
|
2007-02-01 17:57:24 +03:00
|
|
|
std::string targetNamePDB;
|
2006-05-12 20:29:09 +04:00
|
|
|
this->Target->GetExecutableNames
|
2007-02-01 17:57:24 +03:00
|
|
|
(targetName, targetNameReal, targetNamePDB,
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->ConfigurationName.c_str());
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Construct the full path version of the names.
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string outpath = this->LocalGenerator->ExecutableOutputPath;
|
2006-02-14 18:36:04 +03:00
|
|
|
if(outpath.length() == 0)
|
|
|
|
{
|
|
|
|
outpath = this->Makefile->GetStartOutputDirectory();
|
|
|
|
outpath += "/";
|
|
|
|
}
|
|
|
|
#ifdef __APPLE__
|
|
|
|
if(this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
|
|
|
|
{
|
|
|
|
// Make bundle directories
|
2006-03-03 20:58:48 +03:00
|
|
|
outpath += targetName;
|
2006-02-14 18:36:04 +03:00
|
|
|
outpath += ".app/Contents/MacOS/";
|
2006-03-28 17:54:01 +04:00
|
|
|
std::string f1 =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->Makefile->GetModulesFile("MacOSXBundleInfo.plist.in");
|
|
|
|
if ( f1.size() == 0 )
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("could not find Mac OSX bundle template file.");
|
|
|
|
}
|
2006-03-28 17:54:01 +04:00
|
|
|
std::string macdir =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
|
|
|
|
if ( macdir.size() == 0 )
|
|
|
|
{
|
|
|
|
macdir = this->Makefile->GetCurrentOutputDirectory();
|
|
|
|
}
|
|
|
|
if(macdir.size() && macdir[macdir.size()-1] != '/')
|
|
|
|
{
|
|
|
|
macdir += "/";
|
|
|
|
}
|
2006-03-03 20:58:48 +03:00
|
|
|
macdir += targetName;
|
2006-02-14 18:36:04 +03:00
|
|
|
macdir += ".app/Contents/";
|
2006-03-03 20:58:48 +03:00
|
|
|
|
2006-03-28 17:54:01 +04:00
|
|
|
std::vector<cmSourceFile*>::iterator sourceIt;
|
|
|
|
for ( sourceIt = this->Target->GetSourceFiles().begin();
|
|
|
|
sourceIt != this->Target->GetSourceFiles().end();
|
|
|
|
++ sourceIt )
|
|
|
|
{
|
2006-05-12 20:29:09 +04:00
|
|
|
const char* subDir =
|
|
|
|
(*sourceIt)->GetProperty("MACOSX_PACKAGE_LOCATION");
|
2006-03-28 17:54:01 +04:00
|
|
|
if ( subDir )
|
|
|
|
{
|
|
|
|
std::string newDir = macdir;
|
|
|
|
newDir += subDir;
|
|
|
|
if ( !cmSystemTools::MakeDirectory(newDir.c_str()) )
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Cannot create a subdirectory for \"",
|
|
|
|
newDir.c_str(), "\".");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-03 20:58:48 +03:00
|
|
|
// Configure the Info.plist file. Note that it needs the executable name
|
|
|
|
// to be set.
|
2006-02-14 18:36:04 +03:00
|
|
|
std::string f2 = macdir + "Info.plist";
|
|
|
|
macdir += "MacOS";
|
|
|
|
cmSystemTools::MakeDirectory(macdir.c_str());
|
2006-03-03 20:58:48 +03:00
|
|
|
this->Makefile->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME",
|
|
|
|
targetName.c_str());
|
2006-05-12 20:29:09 +04:00
|
|
|
this->Makefile->ConfigureFile(f1.c_str(), f2.c_str(),
|
|
|
|
false, false, false);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
#endif
|
2006-02-16 23:19:00 +03:00
|
|
|
if(relink)
|
|
|
|
{
|
|
|
|
outpath = this->Makefile->GetStartOutputDirectory();
|
2006-06-14 20:28:32 +04:00
|
|
|
outpath += cmake::GetCMakeFilesDirectory();
|
|
|
|
outpath += "/CMakeRelink.dir";
|
2006-02-16 23:19:00 +03:00
|
|
|
cmSystemTools::MakeDirectory(outpath.c_str());
|
|
|
|
outpath += "/";
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
std::string targetFullPath = outpath + targetName;
|
|
|
|
std::string targetFullPathReal = outpath + targetNameReal;
|
2007-02-01 17:57:24 +03:00
|
|
|
std::string targetFullPathPDB = outpath + targetNamePDB;
|
2006-04-20 00:36:14 +04:00
|
|
|
std::string targetOutPathPDB =
|
|
|
|
this->Convert(targetFullPathPDB.c_str(),
|
|
|
|
cmLocalGenerator::FULL,
|
2007-03-08 18:31:03 +03:00
|
|
|
cmLocalGenerator::SHELL);
|
2006-02-14 18:36:04 +03:00
|
|
|
// Convert to the output path to use in constructing commands.
|
|
|
|
std::string targetOutPath =
|
|
|
|
this->Convert(targetFullPath.c_str(),
|
2006-04-20 00:36:14 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
2007-03-08 18:31:03 +03:00
|
|
|
cmLocalGenerator::SHELL);
|
2006-02-14 18:36:04 +03:00
|
|
|
std::string targetOutPathReal =
|
|
|
|
this->Convert(targetFullPathReal.c_str(),
|
2006-04-20 00:36:14 +04:00
|
|
|
cmLocalGenerator::START_OUTPUT,
|
2007-03-08 18:31:03 +03:00
|
|
|
cmLocalGenerator::SHELL);
|
2006-04-20 00:36:14 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Get the language to use for linking this executable.
|
|
|
|
const char* linkLanguage =
|
|
|
|
this->Target->GetLinkerLanguage(this->GlobalGenerator);
|
|
|
|
|
|
|
|
// Make sure we have a link language.
|
|
|
|
if(!linkLanguage)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Cannot determine link language for target \"",
|
|
|
|
this->Target->GetName(), "\".");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the link message.
|
|
|
|
std::string buildEcho = "Linking ";
|
|
|
|
buildEcho += linkLanguage;
|
|
|
|
buildEcho += " executable ";
|
|
|
|
buildEcho += targetOutPath;
|
2006-03-31 00:39:03 +04:00
|
|
|
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
|
|
|
|
cmLocalUnixMakefileGenerator3::EchoLink);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Build a list of compiler flags and linker flags.
|
|
|
|
std::string flags;
|
|
|
|
std::string linkFlags;
|
|
|
|
|
|
|
|
// Add flags to deal with shared libraries. Any library being
|
|
|
|
// linked in might be shared, so always use shared flags for an
|
|
|
|
// executable.
|
|
|
|
this->LocalGenerator->AddSharedFlags(linkFlags, linkLanguage, true);
|
|
|
|
|
|
|
|
// Add flags to create an executable.
|
|
|
|
this->LocalGenerator->
|
2006-02-24 19:13:31 +03:00
|
|
|
AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS",
|
2006-03-15 19:02:08 +03:00
|
|
|
this->LocalGenerator->ConfigurationName.c_str());
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
if(this->Target->GetPropertyAsBool("WIN32_EXECUTABLE"))
|
|
|
|
{
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->AppendFlags
|
|
|
|
(linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE"));
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->AppendFlags
|
|
|
|
(linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE"));
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add language-specific flags.
|
2006-02-24 19:13:31 +03:00
|
|
|
this->LocalGenerator
|
|
|
|
->AddLanguageFlags(flags, linkLanguage,
|
2006-03-15 19:02:08 +03:00
|
|
|
this->LocalGenerator->ConfigurationName.c_str());
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Add target-specific linker flags.
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->AppendFlags
|
|
|
|
(linkFlags, this->Target->GetProperty("LINK_FLAGS"));
|
2006-04-03 20:57:51 +04:00
|
|
|
std::string linkFlagsConfig = "LINK_FLAGS_";
|
2006-05-12 20:29:09 +04:00
|
|
|
linkFlagsConfig +=
|
|
|
|
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName.c_str());
|
|
|
|
this->LocalGenerator->AppendFlags
|
|
|
|
(linkFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// Construct a list of files associated with this executable that
|
|
|
|
// may need to be cleaned.
|
|
|
|
std::vector<std::string> exeCleanFiles;
|
|
|
|
{
|
|
|
|
std::string cleanName;
|
|
|
|
std::string cleanRealName;
|
2007-02-01 17:57:24 +03:00
|
|
|
std::string cleanPDBName;
|
2006-05-12 20:29:09 +04:00
|
|
|
this->Target->GetExecutableCleanNames
|
2007-02-01 17:57:24 +03:00
|
|
|
(cleanName, cleanRealName, cleanPDBName,
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->ConfigurationName.c_str());
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
std::string cleanFullName = outpath + cleanName;
|
|
|
|
std::string cleanFullRealName = outpath + cleanRealName;
|
2007-02-01 17:57:24 +03:00
|
|
|
std::string cleanFullPDBName = outpath + cleanPDBName;
|
2006-02-14 18:36:04 +03:00
|
|
|
exeCleanFiles.push_back(this->Convert(cleanFullName.c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT,
|
2006-03-09 22:30:35 +03:00
|
|
|
cmLocalGenerator::UNCHANGED));
|
2006-08-15 23:28:29 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
// There may be a manifest file for this target. Add it to the
|
|
|
|
// clean set just in case.
|
|
|
|
exeCleanFiles.push_back(this->Convert((cleanFullName+".manifest").c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::UNCHANGED));
|
|
|
|
#endif
|
2006-02-14 18:36:04 +03:00
|
|
|
if(cleanRealName != cleanName)
|
|
|
|
{
|
|
|
|
exeCleanFiles.push_back(this->Convert(cleanFullRealName.c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT,
|
2006-03-09 22:30:35 +03:00
|
|
|
cmLocalGenerator::UNCHANGED));
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
2007-02-02 00:52:52 +03:00
|
|
|
|
|
|
|
// List the PDB for cleaning only when the whole target is
|
|
|
|
// cleaned. We do not want to delete the .pdb file just before
|
|
|
|
// linking the target.
|
|
|
|
this->CleanFiles.push_back
|
|
|
|
(this->Convert(cleanFullPDBName.c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT,
|
|
|
|
cmLocalGenerator::UNCHANGED));
|
2006-03-28 17:54:01 +04:00
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Add a command to remove any existing files for this executable.
|
|
|
|
std::vector<std::string> commands1;
|
2006-03-09 22:30:35 +03:00
|
|
|
this->LocalGenerator->AppendCleanCommand(commands1, exeCleanFiles,
|
|
|
|
*this->Target, "target");
|
2006-05-12 20:29:09 +04:00
|
|
|
this->LocalGenerator->CreateCDCommand
|
|
|
|
(commands1,
|
|
|
|
this->Makefile->GetStartOutputDirectory(),
|
|
|
|
this->Makefile->GetHomeOutputDirectory());
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
|
|
|
commands1.clear();
|
2006-02-16 23:39:19 +03:00
|
|
|
|
|
|
|
// Add the pre-build and pre-link rules building but not when relinking.
|
|
|
|
if(!relink)
|
|
|
|
{
|
|
|
|
this->LocalGenerator
|
|
|
|
->AppendCustomCommands(commands, this->Target->GetPreBuildCommands());
|
|
|
|
this->LocalGenerator
|
|
|
|
->AppendCustomCommands(commands, this->Target->GetPreLinkCommands());
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Construct the main link rule.
|
|
|
|
std::string linkRuleVar = "CMAKE_";
|
|
|
|
linkRuleVar += linkLanguage;
|
|
|
|
linkRuleVar += "_LINK_EXECUTABLE";
|
2006-03-28 17:54:01 +04:00
|
|
|
std::string linkRule =
|
2006-02-14 18:36:04 +03:00
|
|
|
this->Makefile->GetRequiredDefinition(linkRuleVar.c_str());
|
|
|
|
cmSystemTools::ExpandListArgument(linkRule, commands1);
|
|
|
|
this->LocalGenerator->CreateCDCommand
|
|
|
|
(commands1,
|
|
|
|
this->Makefile->GetStartOutputDirectory(),
|
|
|
|
this->Makefile->GetHomeOutputDirectory());
|
|
|
|
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
|
|
|
|
|
|
|
// Add a rule to create necessary symlinks for the library.
|
|
|
|
if(targetOutPath != targetOutPathReal)
|
|
|
|
{
|
|
|
|
std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_executable ";
|
|
|
|
symlink += targetOutPathReal;
|
|
|
|
symlink += " ";
|
|
|
|
symlink += targetOutPath;
|
2006-05-16 21:41:27 +04:00
|
|
|
commands1.clear();
|
|
|
|
commands1.push_back(symlink);
|
|
|
|
this->LocalGenerator->CreateCDCommand(commands1,
|
|
|
|
this->Makefile->GetStartOutputDirectory(),
|
|
|
|
this->Makefile->GetHomeOutputDirectory());
|
|
|
|
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
2006-02-16 23:39:19 +03:00
|
|
|
// Add the post-build rules when building but not when relinking.
|
|
|
|
if(!relink)
|
|
|
|
{
|
|
|
|
this->LocalGenerator->
|
|
|
|
AppendCustomCommands(commands, this->Target->GetPostBuildCommands());
|
|
|
|
}
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Collect up flags to link in needed libraries.
|
|
|
|
cmOStringStream linklibs;
|
2006-02-16 23:19:00 +03:00
|
|
|
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Construct object file lists that may be needed to expand the
|
|
|
|
// rule.
|
|
|
|
std::string variableName;
|
|
|
|
std::string variableNameExternal;
|
|
|
|
this->WriteObjectsVariable(variableName, variableNameExternal);
|
|
|
|
std::string buildObjs = "$(";
|
|
|
|
buildObjs += variableName;
|
|
|
|
buildObjs += ") $(";
|
|
|
|
buildObjs += variableNameExternal;
|
|
|
|
buildObjs += ")";
|
|
|
|
std::string cleanObjs = "$(";
|
|
|
|
cleanObjs += variableName;
|
|
|
|
cleanObjs += ")";
|
|
|
|
|
2006-02-20 21:42:18 +03:00
|
|
|
cmLocalGenerator::RuleVariables vars;
|
|
|
|
vars.Language = linkLanguage;
|
|
|
|
vars.Objects = buildObjs.c_str();
|
|
|
|
vars.Target = targetOutPathReal.c_str();
|
2006-04-20 00:36:14 +04:00
|
|
|
vars.TargetPDB = targetOutPathPDB.c_str();
|
2006-10-17 02:17:14 +04:00
|
|
|
|
|
|
|
// Setup the target version.
|
|
|
|
std::string targetVersionMajor;
|
|
|
|
std::string targetVersionMinor;
|
|
|
|
{
|
|
|
|
cmOStringStream majorStream;
|
|
|
|
cmOStringStream minorStream;
|
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
this->Target->GetTargetVersion(major, minor);
|
|
|
|
majorStream << major;
|
|
|
|
minorStream << minor;
|
|
|
|
targetVersionMajor = majorStream.str();
|
|
|
|
targetVersionMinor = minorStream.str();
|
|
|
|
}
|
|
|
|
vars.TargetVersionMajor = targetVersionMajor.c_str();
|
|
|
|
vars.TargetVersionMinor = targetVersionMinor.c_str();
|
|
|
|
|
2006-02-20 21:42:18 +03:00
|
|
|
std::string linkString = linklibs.str();
|
|
|
|
vars.LinkLibraries = linkString.c_str();
|
|
|
|
vars.Flags = flags.c_str();
|
|
|
|
vars.LinkFlags = linkFlags.c_str();
|
2006-02-14 18:36:04 +03:00
|
|
|
// Expand placeholders in the commands.
|
|
|
|
for(std::vector<std::string>::iterator i = commands.begin();
|
|
|
|
i != commands.end(); ++i)
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
this->LocalGenerator->ExpandRuleVariables(*i, vars);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Write the build rule.
|
2006-03-28 17:54:01 +04:00
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream,
|
2006-02-14 18:36:04 +03:00
|
|
|
0,
|
2006-03-28 17:54:01 +04:00
|
|
|
targetFullPathReal.c_str(),
|
2006-02-16 00:35:16 +03:00
|
|
|
depends, commands, false);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// The symlink name for the target should depend on the real target
|
|
|
|
// so if the target version changes it rebuilds and recreates the
|
|
|
|
// symlink.
|
|
|
|
if(targetFullPath != targetFullPathReal)
|
|
|
|
{
|
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
|
|
|
depends.push_back(targetFullPathReal.c_str());
|
|
|
|
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
2006-03-28 17:54:01 +04:00
|
|
|
targetFullPath.c_str(),
|
2006-02-16 00:35:16 +03:00
|
|
|
depends, commands, false);
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
// Write the main driver rule to build everything in this target.
|
|
|
|
this->WriteTargetDriverRule(targetFullPath.c_str(), relink);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// Clean all the possible executable names and symlinks and object files.
|
|
|
|
this->CleanFiles.insert(this->CleanFiles.end(),
|
|
|
|
exeCleanFiles.begin(),
|
|
|
|
exeCleanFiles.end());
|
2006-03-09 22:30:35 +03:00
|
|
|
this->CleanFiles.insert(this->CleanFiles.end(),
|
|
|
|
this->Objects.begin(),
|
|
|
|
this->Objects.end());
|
2006-02-14 18:36:04 +03:00
|
|
|
}
|
|
|
|
|