2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-08-31 00:00:35 +04: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.
|
2002-08-31 00:00:35 +04: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.
|
|
|
|
============================================================================*/
|
2002-08-31 00:00:35 +04:00
|
|
|
#include "cmLocalGenerator.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
|
2008-01-22 17:13:04 +03:00
|
|
|
#include "cmComputeLinkInformation.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2002-09-04 23:24:49 +04:00
|
|
|
#include "cmGlobalGenerator.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmInstallGenerator.h"
|
2006-02-20 02:47:13 +03:00
|
|
|
#include "cmInstallFilesGenerator.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmInstallScriptGenerator.h"
|
|
|
|
#include "cmInstallTargetGenerator.h"
|
2002-08-31 00:00:35 +04:00
|
|
|
#include "cmMakefile.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmSourceFile.h"
|
2005-04-24 23:59:51 +04:00
|
|
|
#include "cmTest.h"
|
2009-03-16 17:40:46 +03:00
|
|
|
#include "cmTestGenerator.h"
|
2009-03-05 23:17:07 +03:00
|
|
|
#include "cmVersion.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
|
2007-03-16 17:34:25 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
# define CM_LG_ENCODE_OBJECT_NAMES
|
|
|
|
# include <cmsys/MD5.h>
|
|
|
|
#endif
|
|
|
|
|
2006-09-21 23:14:06 +04:00
|
|
|
#include <cmsys/System.h>
|
|
|
|
|
2005-04-12 23:11:54 +04:00
|
|
|
#include <ctype.h> // for isalpha
|
2002-08-31 00:00:35 +04:00
|
|
|
|
2007-03-07 23:30:30 +03:00
|
|
|
#include <assert.h>
|
|
|
|
|
2009-09-30 16:31:53 +04:00
|
|
|
#if defined(__HAIKU__)
|
2013-10-05 18:31:36 +04:00
|
|
|
#include <FindDirectory.h>
|
|
|
|
#include <StorageDefs.h>
|
2009-09-30 16:31:53 +04:00
|
|
|
#endif
|
|
|
|
|
2002-08-31 00:00:35 +04:00
|
|
|
cmLocalGenerator::cmLocalGenerator()
|
|
|
|
{
|
2009-07-17 18:05:54 +04:00
|
|
|
this->Makefile = 0; // moved to after set on global
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Parent = 0;
|
|
|
|
this->WindowsShell = false;
|
2006-09-27 21:43:46 +04:00
|
|
|
this->WindowsVSIDE = false;
|
2006-10-25 19:23:04 +04:00
|
|
|
this->WatcomWMake = false;
|
2007-05-17 18:53:18 +04:00
|
|
|
this->MinGWMake = false;
|
2008-01-14 00:36:20 +03:00
|
|
|
this->NMake = false;
|
2006-09-28 18:37:19 +04:00
|
|
|
this->MSYSShell = false;
|
2008-01-30 05:16:49 +03:00
|
|
|
this->LinkScriptShell = false;
|
2006-03-15 19:02:08 +03:00
|
|
|
this->IgnoreLibPrefix = false;
|
|
|
|
this->UseRelativePaths = false;
|
2005-03-18 18:41:41 +03:00
|
|
|
this->Configured = false;
|
2006-03-24 17:15:05 +03:00
|
|
|
this->EmitUniversalBinaryFlags = true;
|
2007-03-07 23:15:46 +03:00
|
|
|
this->RelativePathsConfigured = false;
|
2007-03-08 16:38:40 +03:00
|
|
|
this->PathConversionsSetup = false;
|
2007-12-29 07:07:14 +03:00
|
|
|
this->BackwardsCompatibility = 0;
|
|
|
|
this->BackwardsCompatibilityFinal = false;
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmLocalGenerator::~cmLocalGenerator()
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
delete this->Makefile;
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
2009-09-03 16:26:31 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class cmLocalGeneratorCurrent
|
|
|
|
{
|
|
|
|
cmGlobalGenerator* GG;
|
|
|
|
cmLocalGenerator* LG;
|
|
|
|
public:
|
|
|
|
cmLocalGeneratorCurrent(cmLocalGenerator* lg)
|
|
|
|
{
|
|
|
|
this->GG = lg->GetGlobalGenerator();
|
|
|
|
this->LG = this->GG->GetCurrentLocalGenerator();
|
|
|
|
this->GG->SetCurrentLocalGenerator(lg);
|
|
|
|
}
|
|
|
|
~cmLocalGeneratorCurrent()
|
|
|
|
{
|
|
|
|
this->GG->SetCurrentLocalGenerator(this->LG);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2002-08-31 00:00:35 +04:00
|
|
|
void cmLocalGenerator::Configure()
|
|
|
|
{
|
2009-09-03 16:26:31 +04:00
|
|
|
// Manage the global generator's current local generator.
|
|
|
|
cmLocalGeneratorCurrent clg(this);
|
|
|
|
static_cast<void>(clg);
|
2007-07-17 17:25:08 +04:00
|
|
|
|
2005-07-29 17:19:25 +04:00
|
|
|
// make sure the CMakeFiles dir is there
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string filesDir = this->Makefile->GetStartOutputDirectory();
|
2006-06-14 20:28:32 +04:00
|
|
|
filesDir += cmake::GetCMakeFilesDirectory();
|
2005-07-29 17:19:25 +04:00
|
|
|
cmSystemTools::MakeDirectory(filesDir.c_str());
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2002-08-31 00:00:35 +04:00
|
|
|
// find & read the list file
|
2009-09-03 16:27:00 +04:00
|
|
|
this->ReadInputFile();
|
2005-02-25 00:04:54 +03:00
|
|
|
|
2005-03-18 18:41:41 +03:00
|
|
|
// at the end of the ReadListFile handle any old style subdirs
|
|
|
|
// first get all the subdirectories
|
|
|
|
std::vector<cmLocalGenerator *> subdirs = this->GetChildren();
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2005-03-18 18:41:41 +03:00
|
|
|
// for each subdir recurse
|
|
|
|
std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
|
|
|
|
for (; sdi != subdirs.end(); ++sdi)
|
|
|
|
{
|
|
|
|
if (!(*sdi)->Configured)
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->ConfigureSubDirectory(*sdi);
|
2005-03-18 18:41:41 +03:00
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2007-03-08 16:38:40 +03:00
|
|
|
|
2005-07-27 17:49:37 +04:00
|
|
|
// Check whether relative paths should be used for optionally
|
|
|
|
// relative paths.
|
2006-03-15 19:02:08 +03:00
|
|
|
this->UseRelativePaths = this->Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS");
|
2005-07-27 17:49:37 +04:00
|
|
|
|
2009-09-03 16:26:46 +04:00
|
|
|
this->ComputeObjectMaxPath();
|
|
|
|
|
|
|
|
this->Configured = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::ComputeObjectMaxPath()
|
|
|
|
{
|
2008-08-21 17:54:36 +04:00
|
|
|
// Choose a maximum object file name length.
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
this->ObjectPathMax = 250;
|
|
|
|
#else
|
|
|
|
this->ObjectPathMax = 1000;
|
|
|
|
#endif
|
|
|
|
const char* plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX");
|
|
|
|
if(plen && *plen)
|
|
|
|
{
|
|
|
|
unsigned int pmax;
|
|
|
|
if(sscanf(plen, "%u", &pmax) == 1)
|
|
|
|
{
|
|
|
|
if(pmax >= 128)
|
|
|
|
{
|
|
|
|
this->ObjectPathMax = pmax;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream w;
|
|
|
|
w << "CMAKE_OBJECT_PATH_MAX is set to " << pmax
|
|
|
|
<< ", which is less than the minimum of 128. "
|
|
|
|
<< "The value will be ignored.";
|
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream w;
|
|
|
|
w << "CMAKE_OBJECT_PATH_MAX is set to \"" << plen
|
|
|
|
<< "\", which fails to parse as a positive integer. "
|
|
|
|
<< "The value will be ignored.";
|
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
|
|
|
}
|
|
|
|
}
|
2008-12-16 17:15:18 +03:00
|
|
|
this->ObjectMaxPathViolations.clear();
|
2005-07-27 17:49:37 +04:00
|
|
|
}
|
|
|
|
|
2009-09-03 16:27:00 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::ReadInputFile()
|
|
|
|
{
|
2009-09-03 16:27:12 +04:00
|
|
|
// Look for the CMakeLists.txt file.
|
2009-09-03 16:27:00 +04:00
|
|
|
std::string currentStart = this->Makefile->GetStartDirectory();
|
|
|
|
currentStart += "/CMakeLists.txt";
|
2009-09-03 16:27:12 +04:00
|
|
|
if(cmSystemTools::FileExists(currentStart.c_str(), true))
|
|
|
|
{
|
|
|
|
this->Makefile->ReadListFile(currentStart.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!this->Parent)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The file is missing. Check policy CMP0014.
|
|
|
|
cmMakefile* mf = this->Parent->GetMakefile();
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "The source directory\n"
|
|
|
|
<< " " << this->Makefile->GetStartDirectory() << "\n"
|
|
|
|
<< "does not contain a CMakeLists.txt file.";
|
|
|
|
switch (mf->GetPolicyStatus(cmPolicies::CMP0014))
|
|
|
|
{
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
// Print the warning.
|
|
|
|
e << "\n"
|
|
|
|
<< "CMake does not support this case but it used "
|
|
|
|
<< "to work accidentally and is being allowed for "
|
|
|
|
<< "compatibility."
|
|
|
|
<< "\n"
|
|
|
|
<< mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0014);
|
|
|
|
mf->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior does not warn.
|
|
|
|
return;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
e << "\n"
|
|
|
|
<< mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0014);
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior prints the error.
|
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
break;
|
|
|
|
}
|
2009-09-03 16:27:00 +04:00
|
|
|
}
|
|
|
|
|
2005-07-27 17:49:37 +04:00
|
|
|
void cmLocalGenerator::SetupPathConversions()
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2005-02-25 00:04:54 +03:00
|
|
|
// Setup the current output directory components for use by
|
2005-05-13 17:54:30 +04:00
|
|
|
// Convert
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string outdir;
|
2005-05-13 17:54:30 +04:00
|
|
|
outdir =
|
2006-03-15 19:02:08 +03:00
|
|
|
cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory());
|
|
|
|
cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents);
|
2005-05-13 17:54:30 +04:00
|
|
|
outdir =
|
2006-03-15 19:02:08 +03:00
|
|
|
cmSystemTools::CollapseFullPath(this->Makefile->GetStartDirectory());
|
|
|
|
cmSystemTools::SplitPath(outdir.c_str(), this->StartDirectoryComponents);
|
2006-05-12 19:56:09 +04:00
|
|
|
|
|
|
|
outdir = cmSystemTools::CollapseFullPath
|
|
|
|
(this->Makefile->GetHomeOutputDirectory());
|
2011-11-29 17:58:45 +04:00
|
|
|
cmSystemTools::SplitPath(outdir.c_str(),
|
2006-05-12 19:56:09 +04:00
|
|
|
this->HomeOutputDirectoryComponents);
|
|
|
|
|
|
|
|
outdir = cmSystemTools::CollapseFullPath
|
|
|
|
(this->Makefile->GetStartOutputDirectory());
|
2011-11-29 17:58:45 +04:00
|
|
|
cmSystemTools::SplitPath(outdir.c_str(),
|
2006-05-12 19:56:09 +04:00
|
|
|
this->StartOutputDirectoryComponents);
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
2002-09-04 23:24:49 +04:00
|
|
|
|
2005-07-27 17:49:37 +04:00
|
|
|
|
2002-09-04 23:24:49 +04:00
|
|
|
void cmLocalGenerator::SetGlobalGenerator(cmGlobalGenerator *gg)
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
this->GlobalGenerator = gg;
|
2009-07-17 18:05:54 +04:00
|
|
|
this->Makefile = new cmMakefile;
|
|
|
|
this->Makefile->SetLocalGenerator(this);
|
2002-09-04 23:24:49 +04:00
|
|
|
|
|
|
|
// setup the home directories
|
2006-12-07 17:45:32 +03:00
|
|
|
this->Makefile->GetProperties().SetCMakeInstance(gg->GetCMakeInstance());
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->SetHomeDirectory(
|
2002-09-04 23:24:49 +04:00
|
|
|
gg->GetCMakeInstance()->GetHomeDirectory());
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->SetHomeOutputDirectory(
|
2002-09-04 23:24:49 +04:00
|
|
|
gg->GetCMakeInstance()->GetHomeOutputDirectory());
|
2002-09-10 23:37:52 +04:00
|
|
|
}
|
2002-09-15 16:54:16 +04:00
|
|
|
|
|
|
|
void cmLocalGenerator::ConfigureFinalPass()
|
2004-01-23 16:53:51 +03:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->ConfigureFinalPass();
|
2002-09-15 16:54:16 +04:00
|
|
|
}
|
2003-12-22 23:16:46 +03:00
|
|
|
|
2007-05-09 16:25:45 +04:00
|
|
|
void cmLocalGenerator::TraceDependencies()
|
|
|
|
{
|
|
|
|
// Generate the rule files for each target.
|
2012-10-11 02:57:11 +04:00
|
|
|
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
|
|
|
|
for(cmGeneratorTargetsType::iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t)
|
2007-05-09 16:25:45 +04:00
|
|
|
{
|
2013-11-29 16:18:24 +04:00
|
|
|
if (t->second->Target->IsImported())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
t->second->TraceDependencies();
|
2007-05-09 16:25:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-24 23:59:51 +04:00
|
|
|
void cmLocalGenerator::GenerateTestFiles()
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
if ( !this->Makefile->IsOn("CMAKE_TESTING_ENABLED") )
|
2005-04-24 23:59:51 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-03-16 17:40:46 +03:00
|
|
|
|
|
|
|
// Compute the set of configurations.
|
|
|
|
std::vector<std::string> configurationTypes;
|
2010-09-08 22:54:49 +04:00
|
|
|
const char* config =
|
|
|
|
this->Makefile->GetConfigurations(configurationTypes, false);
|
2009-03-16 17:40:46 +03:00
|
|
|
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string file = this->Makefile->GetStartOutputDirectory();
|
2005-04-24 23:59:51 +04:00
|
|
|
file += "/";
|
2008-01-17 20:44:59 +03:00
|
|
|
file += "CTestTestfile.cmake";
|
|
|
|
|
2005-04-24 23:59:51 +04:00
|
|
|
cmGeneratedFileStream fout(file.c_str());
|
|
|
|
fout.SetCopyIfDifferent(true);
|
|
|
|
|
|
|
|
fout << "# CMake generated Testfile for " << std::endl
|
2011-11-29 17:58:45 +04:00
|
|
|
<< "# Source directory: "
|
2006-05-12 19:56:09 +04:00
|
|
|
<< this->Makefile->GetStartDirectory() << std::endl
|
2011-11-29 17:58:45 +04:00
|
|
|
<< "# Build directory: "
|
2006-05-12 19:56:09 +04:00
|
|
|
<< this->Makefile->GetStartOutputDirectory() << std::endl
|
|
|
|
<< "# " << std::endl
|
2013-05-01 13:36:14 +04:00
|
|
|
<< "# This file includes the relevant testing commands "
|
2009-08-04 23:41:57 +04:00
|
|
|
<< "required for " << std::endl
|
|
|
|
<< "# testing this directory and lists subdirectories to "
|
|
|
|
<< "be tested as well." << std::endl;
|
2011-11-29 17:58:45 +04:00
|
|
|
|
|
|
|
const char* testIncludeFile =
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Makefile->GetProperty("TEST_INCLUDE_FILE");
|
2005-06-07 17:57:05 +04:00
|
|
|
if ( testIncludeFile )
|
|
|
|
{
|
2013-08-22 13:30:19 +04:00
|
|
|
fout << "include(\"" << testIncludeFile << "\")" << std::endl;
|
2005-06-07 17:57:05 +04:00
|
|
|
}
|
2009-03-16 17:40:46 +03:00
|
|
|
|
|
|
|
// Ask each test generator to write its code.
|
|
|
|
std::vector<cmTestGenerator*> const&
|
|
|
|
testers = this->Makefile->GetTestGenerators();
|
|
|
|
for(std::vector<cmTestGenerator*>::const_iterator gi = testers.begin();
|
|
|
|
gi != testers.end(); ++gi)
|
2005-04-24 23:59:51 +04:00
|
|
|
{
|
2009-03-16 17:40:46 +03:00
|
|
|
(*gi)->Generate(fout, config, configurationTypes);
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
if ( this->Children.size())
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for(i = 0; i < this->Children.size(); ++i)
|
|
|
|
{
|
2013-08-22 13:30:19 +04:00
|
|
|
// TODO: Use add_subdirectory instead?
|
|
|
|
fout << "subdirs(";
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string outP =
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Children[i]->GetMakefile()->GetStartOutputDirectory();
|
2008-01-18 18:25:25 +03:00
|
|
|
fout << this->Convert(outP.c_str(),START_OUTPUT);
|
|
|
|
fout << ")" << std::endl;
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2004-01-26 03:25:26 +03:00
|
|
|
void cmLocalGenerator::GenerateInstallRules()
|
|
|
|
{
|
2006-02-19 23:25:27 +03:00
|
|
|
// Compute the install prefix.
|
2006-03-15 19:02:08 +03:00
|
|
|
const char* prefix = this->Makefile->GetDefinition("CMAKE_INSTALL_PREFIX");
|
2005-02-22 23:22:40 +03:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
std::string prefix_win32;
|
|
|
|
if(!prefix)
|
|
|
|
{
|
|
|
|
if(!cmSystemTools::GetEnv("SystemDrive", prefix_win32))
|
|
|
|
{
|
|
|
|
prefix_win32 = "C:";
|
|
|
|
}
|
2006-03-15 19:02:08 +03:00
|
|
|
const char* project_name = this->Makefile->GetDefinition("PROJECT_NAME");
|
2005-02-22 23:22:40 +03:00
|
|
|
if(project_name && project_name[0])
|
|
|
|
{
|
|
|
|
prefix_win32 += "/Program Files/";
|
|
|
|
prefix_win32 += project_name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prefix_win32 += "/InstalledCMakeProject";
|
|
|
|
}
|
|
|
|
prefix = prefix_win32.c_str();
|
|
|
|
}
|
2009-09-30 16:31:53 +04:00
|
|
|
#elif defined(__HAIKU__)
|
2013-10-05 18:31:36 +04:00
|
|
|
char dir[B_PATH_NAME_LENGTH];
|
2009-09-30 16:31:53 +04:00
|
|
|
if (!prefix)
|
|
|
|
{
|
2013-10-05 18:31:36 +04:00
|
|
|
if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir))
|
|
|
|
== B_OK)
|
2009-09-30 16:31:53 +04:00
|
|
|
{
|
2013-10-05 18:31:36 +04:00
|
|
|
prefix = dir;
|
2009-09-30 16:31:53 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-05 18:31:36 +04:00
|
|
|
prefix = "/boot/system";
|
2009-09-30 16:31:53 +04:00
|
|
|
}
|
|
|
|
}
|
2005-02-22 23:22:40 +03:00
|
|
|
#else
|
2004-01-26 03:25:26 +03:00
|
|
|
if (!prefix)
|
|
|
|
{
|
|
|
|
prefix = "/usr/local";
|
|
|
|
}
|
2005-02-22 23:22:40 +03:00
|
|
|
#endif
|
2013-11-14 15:04:40 +04:00
|
|
|
if (const char *stagingPrefix
|
|
|
|
= this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"))
|
|
|
|
{
|
|
|
|
prefix = stagingPrefix;
|
|
|
|
}
|
2004-01-26 03:25:26 +03:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Compute the set of configurations.
|
|
|
|
std::vector<std::string> configurationTypes;
|
2010-09-08 22:54:49 +04:00
|
|
|
const char* config =
|
|
|
|
this->Makefile->GetConfigurations(configurationTypes, false);
|
2006-02-19 23:25:27 +03:00
|
|
|
|
2006-05-05 22:57:19 +04:00
|
|
|
// Choose a default install configuration.
|
|
|
|
const char* default_config = config;
|
|
|
|
const char* default_order[] = {"RELEASE", "MINSIZEREL",
|
|
|
|
"RELWITHDEBINFO", "DEBUG", 0};
|
|
|
|
for(const char** c = default_order; *c && !default_config; ++c)
|
|
|
|
{
|
|
|
|
for(std::vector<std::string>::iterator i = configurationTypes.begin();
|
|
|
|
i != configurationTypes.end(); ++i)
|
|
|
|
{
|
|
|
|
if(cmSystemTools::UpperCase(*i) == *c)
|
|
|
|
{
|
|
|
|
default_config = i->c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!default_config && !configurationTypes.empty())
|
|
|
|
{
|
|
|
|
default_config = configurationTypes[0].c_str();
|
|
|
|
}
|
|
|
|
if(!default_config)
|
|
|
|
{
|
|
|
|
default_config = "Release";
|
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Create the install script file.
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string file = this->Makefile->GetStartOutputDirectory();
|
|
|
|
std::string homedir = this->Makefile->GetHomeOutputDirectory();
|
|
|
|
std::string currdir = this->Makefile->GetCurrentOutputDirectory();
|
2004-01-27 00:24:35 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(file);
|
2004-03-29 02:59:46 +04:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(homedir);
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(currdir);
|
|
|
|
int toplevel_install = 0;
|
|
|
|
if ( currdir == homedir )
|
|
|
|
{
|
|
|
|
toplevel_install = 1;
|
|
|
|
}
|
2004-01-26 03:25:26 +03:00
|
|
|
file += "/cmake_install.cmake";
|
2004-11-03 15:51:51 +03:00
|
|
|
cmGeneratedFileStream fout(file.c_str());
|
|
|
|
fout.SetCopyIfDifferent(true);
|
2004-01-26 03:25:26 +03:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Write the header.
|
|
|
|
fout << "# Install script for directory: "
|
2006-03-15 19:02:08 +03:00
|
|
|
<< this->Makefile->GetCurrentDirectory() << std::endl << std::endl;
|
|
|
|
fout << "# Set the install prefix" << std::endl
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
|
|
|
|
<< " set(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl
|
|
|
|
<< "endif()" << std::endl
|
|
|
|
<< "string(REGEX REPLACE \"/$\" \"\" CMAKE_INSTALL_PREFIX "
|
2006-05-12 19:56:09 +04:00
|
|
|
<< "\"${CMAKE_INSTALL_PREFIX}\")" << std::endl
|
|
|
|
<< std::endl;
|
2004-01-26 03:25:26 +03:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Write support code for generating per-configuration install rules.
|
2006-01-14 02:18:32 +03:00
|
|
|
fout <<
|
|
|
|
"# Set the install configuration name.\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
"if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)\n"
|
|
|
|
" if(BUILD_TYPE)\n"
|
|
|
|
" string(REGEX REPLACE \"^[^A-Za-z0-9_]+\" \"\"\n"
|
2006-01-14 02:18:32 +03:00
|
|
|
" CMAKE_INSTALL_CONFIG_NAME \"${BUILD_TYPE}\")\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
" else()\n"
|
|
|
|
" set(CMAKE_INSTALL_CONFIG_NAME \"" << default_config << "\")\n"
|
|
|
|
" endif()\n"
|
|
|
|
" message(STATUS \"Install configuration: "
|
2006-05-12 19:56:09 +04:00
|
|
|
"\\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
"endif()\n"
|
2006-01-14 02:18:32 +03:00
|
|
|
"\n";
|
2004-02-03 18:53:41 +03:00
|
|
|
|
2006-03-30 22:33:48 +04:00
|
|
|
// Write support code for dealing with component-specific installs.
|
|
|
|
fout <<
|
|
|
|
"# Set the component getting installed.\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
"if(NOT CMAKE_INSTALL_COMPONENT)\n"
|
|
|
|
" if(COMPONENT)\n"
|
|
|
|
" message(STATUS \"Install component: \\\"${COMPONENT}\\\"\")\n"
|
|
|
|
" set(CMAKE_INSTALL_COMPONENT \"${COMPONENT}\")\n"
|
|
|
|
" else()\n"
|
|
|
|
" set(CMAKE_INSTALL_COMPONENT)\n"
|
|
|
|
" endif()\n"
|
|
|
|
"endif()\n"
|
2006-03-30 22:33:48 +04:00
|
|
|
"\n";
|
|
|
|
|
2007-04-10 19:22:15 +04:00
|
|
|
// Copy user-specified install options to the install code.
|
|
|
|
if(const char* so_no_exe =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_INSTALL_SO_NO_EXE"))
|
|
|
|
{
|
|
|
|
fout <<
|
|
|
|
"# Install shared libraries without execute permission?\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
"if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)\n"
|
|
|
|
" set(CMAKE_INSTALL_SO_NO_EXE \"" << so_no_exe << "\")\n"
|
|
|
|
"endif()\n"
|
2007-04-10 19:22:15 +04:00
|
|
|
"\n";
|
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Ask each install generator to write its code.
|
|
|
|
std::vector<cmInstallGenerator*> const& installers =
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->GetInstallGenerators();
|
2011-11-29 17:58:45 +04:00
|
|
|
for(std::vector<cmInstallGenerator*>::const_iterator
|
2006-05-12 19:56:09 +04:00
|
|
|
gi = installers.begin();
|
2006-02-19 23:25:27 +03:00
|
|
|
gi != installers.end(); ++gi)
|
2004-01-26 03:25:26 +03:00
|
|
|
{
|
2006-02-19 23:25:27 +03:00
|
|
|
(*gi)->Generate(fout, config, configurationTypes);
|
2006-02-10 21:54:36 +03:00
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Write rules from old-style specification stored in targets.
|
|
|
|
this->GenerateTargetInstallRules(fout, config, configurationTypes);
|
2005-03-18 18:41:41 +03:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Include install scripts from subdirectories.
|
2006-04-11 21:32:48 +04:00
|
|
|
if(!this->Children.empty())
|
2004-01-26 03:25:26 +03:00
|
|
|
{
|
2013-08-22 13:30:19 +04:00
|
|
|
fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n";
|
2006-08-29 18:03:47 +04:00
|
|
|
fout << " # Include the install script for each subdirectory.\n";
|
2006-04-11 21:32:48 +04:00
|
|
|
for(std::vector<cmLocalGenerator*>::const_iterator
|
|
|
|
ci = this->Children.begin(); ci != this->Children.end(); ++ci)
|
2004-01-26 03:25:26 +03:00
|
|
|
{
|
2007-03-13 18:58:12 +03:00
|
|
|
if(!(*ci)->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
|
2006-04-11 21:32:48 +04:00
|
|
|
{
|
|
|
|
std::string odir = (*ci)->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(odir);
|
2013-08-22 13:30:19 +04:00
|
|
|
fout << " include(\"" << odir.c_str()
|
2006-04-11 21:32:48 +04:00
|
|
|
<< "/cmake_install.cmake\")" << std::endl;
|
|
|
|
}
|
2004-01-26 03:25:26 +03:00
|
|
|
}
|
2006-04-11 21:32:48 +04:00
|
|
|
fout << "\n";
|
2013-08-22 13:30:19 +04:00
|
|
|
fout << "endif()\n\n";
|
2004-01-26 03:25:26 +03:00
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
// Record the install manifest.
|
2004-03-29 02:59:46 +04:00
|
|
|
if ( toplevel_install )
|
|
|
|
{
|
2006-03-30 22:33:48 +04:00
|
|
|
fout <<
|
2013-08-22 13:30:19 +04:00
|
|
|
"if(CMAKE_INSTALL_COMPONENT)\n"
|
|
|
|
" set(CMAKE_INSTALL_MANIFEST \"install_manifest_"
|
2006-03-30 22:33:48 +04:00
|
|
|
"${CMAKE_INSTALL_COMPONENT}.txt\")\n"
|
2013-08-22 13:30:19 +04:00
|
|
|
"else()\n"
|
|
|
|
" set(CMAKE_INSTALL_MANIFEST \"install_manifest.txt\")\n"
|
|
|
|
"endif()\n\n";
|
2006-03-30 22:33:48 +04:00
|
|
|
fout
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "file(WRITE \""
|
2006-03-30 22:33:48 +04:00
|
|
|
<< homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" "
|
|
|
|
<< "\"\")" << std::endl;
|
|
|
|
fout
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "foreach(file ${CMAKE_INSTALL_MANIFEST_FILES})" << std::endl
|
|
|
|
<< " file(APPEND \""
|
2006-03-30 22:33:48 +04:00
|
|
|
<< homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" "
|
2004-03-29 02:59:46 +04:00
|
|
|
<< "\"${file}\\n\")" << std::endl
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "endforeach()" << std::endl;
|
2004-03-29 02:59:46 +04:00
|
|
|
}
|
2004-01-26 03:25:26 +03:00
|
|
|
}
|
|
|
|
|
2006-04-04 19:48:19 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2008-01-22 17:13:04 +03:00
|
|
|
void cmLocalGenerator::GenerateTargetManifest()
|
2006-04-04 19:48:19 +04:00
|
|
|
{
|
|
|
|
// Collect the set of configuration types.
|
|
|
|
std::vector<std::string> configNames;
|
2010-09-08 22:54:49 +04:00
|
|
|
this->Makefile->GetConfigurations(configNames);
|
2006-04-04 19:48:19 +04:00
|
|
|
|
|
|
|
// Add our targets to the manifest for each configuration.
|
2012-09-14 21:04:25 +04:00
|
|
|
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
|
|
|
|
for(cmGeneratorTargetsType::iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t)
|
2006-04-04 19:48:19 +04:00
|
|
|
{
|
2012-09-14 21:04:25 +04:00
|
|
|
cmGeneratorTarget& target = *t->second;
|
2013-11-20 15:44:04 +04:00
|
|
|
if (target.Target->GetType() == cmTarget::INTERFACE_LIBRARY)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2013-11-29 16:18:24 +04:00
|
|
|
if (target.Target->IsImported())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2008-01-22 17:13:04 +03:00
|
|
|
if(configNames.empty())
|
2006-04-04 19:48:19 +04:00
|
|
|
{
|
2008-01-22 17:13:04 +03:00
|
|
|
target.GenerateTargetManifest(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(std::vector<std::string>::iterator ci = configNames.begin();
|
|
|
|
ci != configNames.end(); ++ci)
|
2006-04-04 19:48:19 +04:00
|
|
|
{
|
2008-01-22 17:13:04 +03:00
|
|
|
const char* config = ci->c_str();
|
|
|
|
target.GenerateTargetManifest(config);
|
2006-04-04 19:48:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-29 17:58:45 +04:00
|
|
|
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
2012-09-16 03:16:43 +04:00
|
|
|
const char* lang,
|
|
|
|
cmSourceFile& source,
|
|
|
|
cmGeneratorTarget& target)
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2006-04-17 22:01:22 +04:00
|
|
|
std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
|
2006-04-17 23:35:51 +04:00
|
|
|
objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
|
2005-05-13 17:54:30 +04:00
|
|
|
std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string sourceFile =
|
2005-05-13 17:54:30 +04:00
|
|
|
this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
|
2004-10-21 22:34:02 +04:00
|
|
|
std::string varString = "CMAKE_";
|
|
|
|
varString += lang;
|
|
|
|
varString += "_COMPILE_OBJECT";
|
|
|
|
std::vector<std::string> rules;
|
2006-03-15 19:02:08 +03:00
|
|
|
rules.push_back(this->Makefile->GetRequiredDefinition(varString.c_str()));
|
2004-10-21 22:34:02 +04:00
|
|
|
varString = "CMAKE_";
|
|
|
|
varString += lang;
|
|
|
|
varString += "_FLAGS";
|
|
|
|
std::string flags;
|
2006-03-15 19:02:08 +03:00
|
|
|
flags += this->Makefile->GetSafeDefinition(varString.c_str());
|
2004-10-21 22:34:02 +04:00
|
|
|
flags += " ";
|
2011-12-04 19:36:48 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> includes;
|
2011-11-05 19:17:49 +04:00
|
|
|
this->GetIncludeDirectories(includes, &target, lang);
|
2013-07-02 00:28:26 +04:00
|
|
|
flags += this->GetIncludeFlags(includes, &target, lang);
|
2011-12-04 19:36:48 +04:00
|
|
|
}
|
2011-03-15 20:09:06 +03:00
|
|
|
flags += this->Makefile->GetDefineFlags();
|
2006-04-11 22:53:57 +04:00
|
|
|
|
|
|
|
// Construct the command lines.
|
|
|
|
cmCustomCommandLines commandLines;
|
2004-10-21 22:34:02 +04:00
|
|
|
std::vector<std::string> commands;
|
|
|
|
cmSystemTools::ExpandList(rules, commands);
|
2006-02-20 21:42:18 +03:00
|
|
|
cmLocalGenerator::RuleVariables vars;
|
|
|
|
vars.Language = lang;
|
|
|
|
vars.Source = sourceFile.c_str();
|
|
|
|
vars.Object = objectFile.c_str();
|
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();
|
2004-10-21 22:34:02 +04:00
|
|
|
for(std::vector<std::string>::iterator i = commands.begin();
|
|
|
|
i != commands.end(); ++i)
|
|
|
|
{
|
2006-04-11 22:53:57 +04:00
|
|
|
// Expand the full command line string.
|
2006-02-20 21:42:18 +03:00
|
|
|
this->ExpandRuleVariables(*i, vars);
|
2006-04-11 22:53:57 +04:00
|
|
|
|
|
|
|
// Parse the string to get the custom command line.
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
|
|
|
|
for(std::vector<cmStdString>::iterator a = cmd.begin();
|
|
|
|
a != cmd.end(); ++a)
|
|
|
|
{
|
|
|
|
commandLine.push_back(*a);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store this command line.
|
|
|
|
commandLines.push_back(commandLine);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2006-04-11 22:53:57 +04:00
|
|
|
|
|
|
|
// Check for extra object-file dependencies.
|
2004-10-21 22:34:02 +04:00
|
|
|
std::vector<std::string> depends;
|
|
|
|
const char* additionalDeps = source.GetProperty("OBJECT_DEPENDS");
|
|
|
|
if(additionalDeps)
|
|
|
|
{
|
|
|
|
cmSystemTools::ExpandListArgument(additionalDeps, depends);
|
2006-04-11 22:53:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Generate a meaningful comment for the command.
|
|
|
|
std::string comment = "Building ";
|
|
|
|
comment += lang;
|
|
|
|
comment += " object ";
|
|
|
|
comment += this->Convert(ofname, START_OUTPUT);
|
|
|
|
|
|
|
|
// Add the custom command to build the object file.
|
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
ofname,
|
|
|
|
depends,
|
|
|
|
source.GetFullPath().c_str(),
|
|
|
|
commandLines,
|
|
|
|
comment.c_str(),
|
|
|
|
this->Makefile->GetStartOutputDirectory()
|
|
|
|
);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2012-09-16 03:16:43 +04:00
|
|
|
void cmLocalGenerator::AddBuildTargetRule(const char* llang,
|
|
|
|
cmGeneratorTarget& target)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
|
|
|
cmStdString objs;
|
|
|
|
std::vector<std::string> objVector;
|
|
|
|
// Add all the sources outputs to the depends of the target
|
2013-07-14 20:22:57 +04:00
|
|
|
std::vector<cmSourceFile*> classes;
|
|
|
|
target.GetSourceFiles(classes);
|
2007-05-28 18:25:03 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
|
2004-10-21 22:34:02 +04:00
|
|
|
i != classes.end(); ++i)
|
2007-06-18 19:59:23 +04:00
|
|
|
{
|
|
|
|
cmSourceFile* sf = *i;
|
|
|
|
if(!sf->GetCustomCommand() &&
|
|
|
|
!sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
|
|
|
|
!sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2008-12-16 17:14:40 +03:00
|
|
|
std::string dir_max;
|
|
|
|
dir_max += this->Makefile->GetCurrentOutputDirectory();
|
|
|
|
dir_max += "/";
|
|
|
|
std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
|
2007-06-18 19:59:23 +04:00
|
|
|
if(!obj.empty())
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string ofname = this->Makefile->GetCurrentOutputDirectory();
|
2004-10-21 22:34:02 +04:00
|
|
|
ofname += "/";
|
2007-06-18 19:59:23 +04:00
|
|
|
ofname += obj;
|
2004-10-21 22:34:02 +04:00
|
|
|
objVector.push_back(ofname);
|
2011-11-29 17:58:45 +04:00
|
|
|
this->AddCustomCommandToCreateObject(ofname.c_str(),
|
2006-05-12 19:56:09 +04:00
|
|
|
llang, *(*i), target);
|
2005-05-13 17:54:30 +04:00
|
|
|
objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE);
|
2004-10-21 22:34:02 +04:00
|
|
|
objs += " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::string createRule = "CMAKE_";
|
|
|
|
createRule += llang;
|
|
|
|
createRule += target.GetCreateRuleVariable();
|
2012-09-16 03:16:43 +04:00
|
|
|
std::string targetName = target.Target->GetFullName();
|
2004-10-21 22:34:02 +04:00
|
|
|
// Executable :
|
|
|
|
// Shared Library:
|
|
|
|
// Static Library:
|
|
|
|
// Shared Module:
|
|
|
|
std::string linkLibs; // should be set
|
2012-09-26 16:38:15 +04:00
|
|
|
std::string frameworkPath;
|
|
|
|
std::string linkPath;
|
2004-10-21 22:34:02 +04:00
|
|
|
std::string flags; // should be set
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string linkFlags; // should be set
|
2012-09-26 16:38:15 +04:00
|
|
|
this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
|
|
|
|
&target);
|
|
|
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
2006-02-20 21:42:18 +03:00
|
|
|
cmLocalGenerator::RuleVariables vars;
|
|
|
|
vars.Language = llang;
|
|
|
|
vars.Objects = objs.c_str();
|
2006-04-17 23:35:51 +04:00
|
|
|
vars.ObjectDir = ".";
|
2006-02-20 21:42:18 +03:00
|
|
|
vars.Target = targetName.c_str();
|
|
|
|
vars.LinkLibraries = linkLibs.c_str();
|
|
|
|
vars.Flags = flags.c_str();
|
|
|
|
vars.LinkFlags = linkFlags.c_str();
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2006-08-08 21:44:25 +04:00
|
|
|
std::string langFlags;
|
|
|
|
this->AddLanguageFlags(langFlags, llang, 0);
|
2009-10-21 21:00:49 +04:00
|
|
|
this->AddArchitectureFlags(langFlags, &target, llang, 0);
|
2006-08-08 21:44:25 +04:00
|
|
|
vars.LanguageCompileFlags = langFlags.c_str();
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2006-04-12 01:11:34 +04:00
|
|
|
cmCustomCommandLines commandLines;
|
|
|
|
std::vector<std::string> rules;
|
|
|
|
rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str()));
|
|
|
|
std::vector<std::string> commands;
|
2011-11-29 17:58:45 +04:00
|
|
|
cmSystemTools::ExpandList(rules, commands);
|
2006-04-12 01:11:34 +04:00
|
|
|
for(std::vector<std::string>::iterator i = commands.begin();
|
|
|
|
i != commands.end(); ++i)
|
|
|
|
{
|
|
|
|
// Expand the full command line string.
|
|
|
|
this->ExpandRuleVariables(*i, vars);
|
|
|
|
// Parse the string to get the custom command line.
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
|
|
|
|
for(std::vector<cmStdString>::iterator a = cmd.begin();
|
|
|
|
a != cmd.end(); ++a)
|
|
|
|
{
|
|
|
|
commandLine.push_back(*a);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store this command line.
|
|
|
|
commandLines.push_back(commandLine);
|
|
|
|
}
|
2012-09-16 03:16:43 +04:00
|
|
|
std::string targetFullPath = target.Target->GetFullPath();
|
2006-04-12 01:11:34 +04:00
|
|
|
// Generate a meaningful comment for the command.
|
|
|
|
std::string comment = "Linking ";
|
|
|
|
comment += llang;
|
|
|
|
comment += " target ";
|
|
|
|
comment += this->Convert(targetFullPath.c_str(), START_OUTPUT);
|
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
targetFullPath.c_str(),
|
|
|
|
objVector,
|
|
|
|
0,
|
|
|
|
commandLines,
|
|
|
|
comment.c_str(),
|
|
|
|
this->Makefile->GetStartOutputDirectory()
|
|
|
|
);
|
2012-09-16 03:16:43 +04:00
|
|
|
target.Target->AddSourceFile
|
2006-05-12 19:56:09 +04:00
|
|
|
(this->Makefile->GetSource(targetFullPath.c_str()));
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2004-09-03 20:03:41 +04:00
|
|
|
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2006-05-12 19:56:09 +04:00
|
|
|
void cmLocalGenerator
|
|
|
|
::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang)
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2012-09-16 03:16:43 +04:00
|
|
|
cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets();
|
|
|
|
for(cmGeneratorTargetsType::iterator l = tgts.begin();
|
2004-10-21 22:34:02 +04:00
|
|
|
l != tgts.end(); l++)
|
|
|
|
{
|
2012-10-10 02:07:34 +04:00
|
|
|
if (l->first->IsImported())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2012-09-16 03:16:43 +04:00
|
|
|
cmGeneratorTarget& target = *l->second;
|
2004-10-21 22:34:02 +04:00
|
|
|
switch(target.GetType())
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2004-10-21 22:34:02 +04:00
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
2011-11-29 17:58:45 +04:00
|
|
|
case cmTarget::EXECUTABLE:
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2012-09-16 03:16:43 +04:00
|
|
|
const char* llang = target.Target->GetLinkerLanguage();
|
2004-10-27 18:53:01 +04:00
|
|
|
if(!llang)
|
|
|
|
{
|
2006-05-12 19:56:09 +04:00
|
|
|
cmSystemTools::Error
|
2013-06-21 15:51:58 +04:00
|
|
|
("CMake can not determine linker language for target: ",
|
2012-09-16 03:16:43 +04:00
|
|
|
target.Target->GetName());
|
2004-10-27 18:53:01 +04:00
|
|
|
return;
|
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
// if the language is not in the set lang then create custom
|
|
|
|
// commands to build the target
|
|
|
|
if(lang.count(llang) == 0)
|
|
|
|
{
|
|
|
|
this->AddBuildTargetRule(llang, target);
|
|
|
|
}
|
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
break;
|
2008-08-18 19:26:51 +04:00
|
|
|
default:
|
2004-10-21 22:34:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// List of variables that are replaced when
|
|
|
|
// rules are expanced. These variables are
|
|
|
|
// replaced in the form <var> with GetSafeDefinition(var).
|
2011-11-29 17:58:45 +04:00
|
|
|
// ${LANG} is replaced in the variable first with all enabled
|
2004-10-21 22:34:02 +04:00
|
|
|
// languages.
|
|
|
|
static const char* ruleReplaceVars[] =
|
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
"CMAKE_${LANG}_COMPILER",
|
2004-10-21 22:34:02 +04:00
|
|
|
"CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
|
|
|
|
"CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
|
2011-11-29 17:58:45 +04:00
|
|
|
"CMAKE_SHARED_MODULE_${LANG}_FLAGS",
|
2004-10-21 22:34:02 +04:00
|
|
|
"CMAKE_SHARED_LIBRARY_${LANG}_FLAGS",
|
|
|
|
"CMAKE_${LANG}_LINK_FLAGS",
|
|
|
|
"CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG",
|
|
|
|
"CMAKE_${LANG}_ARCHIVE",
|
|
|
|
"CMAKE_AR",
|
|
|
|
"CMAKE_CURRENT_SOURCE_DIR",
|
|
|
|
"CMAKE_CURRENT_BINARY_DIR",
|
|
|
|
"CMAKE_RANLIB",
|
2007-05-18 18:32:22 +04:00
|
|
|
"CMAKE_LINKER",
|
2013-12-02 02:16:06 +04:00
|
|
|
"CMAKE_CL_SHOWINCLUDES_PREFIX",
|
2004-10-21 22:34:02 +04:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2005-04-12 21:27:07 +04:00
|
|
|
std::string
|
|
|
|
cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
|
2006-02-20 21:42:18 +03:00
|
|
|
const RuleVariables& replaceValues)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.LinkFlags)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "LINK_FLAGS")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.LinkFlags;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.Flags)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "FLAGS")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Flags;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.Source)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "SOURCE")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Source;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2006-08-08 07:25:21 +04:00
|
|
|
if(replaceValues.PreprocessedSource)
|
|
|
|
{
|
|
|
|
if(variable == "PREPROCESSED_SOURCE")
|
|
|
|
{
|
|
|
|
return replaceValues.PreprocessedSource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(replaceValues.AssemblySource)
|
|
|
|
{
|
|
|
|
if(variable == "ASSEMBLY_SOURCE")
|
|
|
|
{
|
|
|
|
return replaceValues.AssemblySource;
|
|
|
|
}
|
|
|
|
}
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.Object)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "OBJECT")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Object;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2006-04-17 22:01:22 +04:00
|
|
|
if(replaceValues.ObjectDir)
|
|
|
|
{
|
|
|
|
if(variable == "OBJECT_DIR")
|
|
|
|
{
|
|
|
|
return replaceValues.ObjectDir;
|
|
|
|
}
|
|
|
|
}
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.Objects)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "OBJECTS")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Objects;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.ObjectsQuoted)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "OBJECTS_QUOTED")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.ObjectsQuoted;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
if(replaceValues.Defines && variable == "DEFINES")
|
|
|
|
{
|
|
|
|
return replaceValues.Defines;
|
|
|
|
}
|
2006-04-20 00:36:14 +04:00
|
|
|
if(replaceValues.TargetPDB )
|
|
|
|
{
|
|
|
|
if(variable == "TARGET_PDB")
|
|
|
|
{
|
|
|
|
return replaceValues.TargetPDB;
|
|
|
|
}
|
|
|
|
}
|
2012-06-13 02:52:46 +04:00
|
|
|
if(replaceValues.DependencyFile )
|
|
|
|
{
|
|
|
|
if(variable == "DEP_FILE")
|
|
|
|
{
|
|
|
|
return replaceValues.DependencyFile;
|
|
|
|
}
|
|
|
|
}
|
2006-04-20 00:36:14 +04:00
|
|
|
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.Target)
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "TARGET_QUOTED")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
std::string targetQuoted = replaceValues.Target;
|
2005-04-12 21:27:07 +04:00
|
|
|
if(targetQuoted.size() && targetQuoted[0] != '\"')
|
|
|
|
{
|
|
|
|
targetQuoted = '\"';
|
2006-02-20 21:42:18 +03:00
|
|
|
targetQuoted += replaceValues.Target;
|
2005-04-12 21:27:07 +04:00
|
|
|
targetQuoted += '\"';
|
|
|
|
}
|
2006-10-10 22:13:35 +04:00
|
|
|
return targetQuoted;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2009-11-30 19:16:24 +03:00
|
|
|
if(variable == "TARGET_UNQUOTED")
|
|
|
|
{
|
|
|
|
std::string unquoted = replaceValues.Target;
|
|
|
|
std::string::size_type sz = unquoted.size();
|
|
|
|
if(sz > 2 && unquoted[0] == '\"' && unquoted[sz-1] == '\"')
|
|
|
|
{
|
|
|
|
unquoted = unquoted.substr(1, sz-2);
|
|
|
|
}
|
|
|
|
return unquoted;
|
|
|
|
}
|
2006-08-08 21:44:25 +04:00
|
|
|
if(replaceValues.LanguageCompileFlags)
|
2006-03-06 23:14:23 +03:00
|
|
|
{
|
2006-08-08 21:44:25 +04:00
|
|
|
if(variable == "LANGUAGE_COMPILE_FLAGS")
|
|
|
|
{
|
|
|
|
return replaceValues.LanguageCompileFlags;
|
|
|
|
}
|
2006-03-06 23:14:23 +03:00
|
|
|
}
|
2006-08-08 21:44:25 +04:00
|
|
|
if(replaceValues.Target)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2006-08-08 21:44:25 +04:00
|
|
|
if(variable == "TARGET")
|
|
|
|
{
|
|
|
|
return replaceValues.Target;
|
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2006-02-18 23:37:23 +03:00
|
|
|
if(variable == "TARGET_IMPLIB")
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
return this->TargetImplib;
|
2006-02-18 23:37:23 +03:00
|
|
|
}
|
2006-10-17 02:17:14 +04:00
|
|
|
if(variable == "TARGET_VERSION_MAJOR")
|
|
|
|
{
|
|
|
|
if(replaceValues.TargetVersionMajor)
|
|
|
|
{
|
|
|
|
return replaceValues.TargetVersionMajor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(variable == "TARGET_VERSION_MINOR")
|
|
|
|
{
|
|
|
|
if(replaceValues.TargetVersionMinor)
|
|
|
|
{
|
|
|
|
return replaceValues.TargetVersionMinor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
}
|
2006-08-08 21:44:25 +04:00
|
|
|
if(replaceValues.Target)
|
2005-04-12 21:27:07 +04:00
|
|
|
{
|
2006-08-08 21:44:25 +04:00
|
|
|
if(variable == "TARGET_BASE")
|
2005-04-12 21:27:07 +04:00
|
|
|
{
|
2006-08-08 21:44:25 +04:00
|
|
|
// Strip the last extension off the target name.
|
|
|
|
std::string targetBase = replaceValues.Target;
|
|
|
|
std::string::size_type pos = targetBase.rfind(".");
|
|
|
|
if(pos != targetBase.npos)
|
|
|
|
{
|
2006-01-14 02:18:32 +03:00
|
|
|
return targetBase.substr(0, pos);
|
2006-08-08 21:44:25 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return targetBase;
|
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
2012-04-22 17:42:55 +04:00
|
|
|
if(variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
|
|
|
|
variable == "TARGET_INSTALLNAME_DIR")
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2012-04-22 17:42:55 +04:00
|
|
|
// All these variables depend on TargetSOName
|
|
|
|
if(replaceValues.TargetSOName)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2012-04-22 17:42:55 +04:00
|
|
|
if(variable == "TARGET_SONAME")
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2012-04-22 17:42:55 +04:00
|
|
|
return replaceValues.TargetSOName;
|
|
|
|
}
|
|
|
|
if(variable == "SONAME_FLAG" && replaceValues.SONameFlag)
|
|
|
|
{
|
|
|
|
return replaceValues.SONameFlag;
|
|
|
|
}
|
|
|
|
if(replaceValues.TargetInstallNameDir &&
|
|
|
|
variable == "TARGET_INSTALLNAME_DIR")
|
|
|
|
{
|
|
|
|
return replaceValues.TargetInstallNameDir;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
2012-04-22 17:42:55 +04:00
|
|
|
return "";
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
2006-02-20 21:42:18 +03:00
|
|
|
if(replaceValues.LinkLibraries)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
if(variable == "LINK_LIBRARIES")
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.LinkLibraries;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2009-02-10 16:52:07 +03:00
|
|
|
if(replaceValues.Language)
|
|
|
|
{
|
|
|
|
if(variable == "LANGUAGE")
|
|
|
|
{
|
|
|
|
return replaceValues.Language;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(replaceValues.CMTarget)
|
|
|
|
{
|
|
|
|
if(variable == "TARGET_NAME")
|
|
|
|
{
|
|
|
|
return replaceValues.CMTarget->GetName();
|
|
|
|
}
|
|
|
|
if(variable == "TARGET_TYPE")
|
|
|
|
{
|
2011-03-20 19:57:42 +03:00
|
|
|
return cmTarget::GetTargetTypeName(replaceValues.CMTarget->GetType());
|
2009-02-10 16:52:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(replaceValues.Output)
|
|
|
|
{
|
|
|
|
if(variable == "OUTPUT")
|
|
|
|
{
|
|
|
|
return replaceValues.Output;
|
|
|
|
}
|
|
|
|
}
|
2008-03-01 17:08:34 +03:00
|
|
|
if(variable == "CMAKE_COMMAND")
|
|
|
|
{
|
|
|
|
const char* cmcommand =
|
2008-03-28 22:54:20 +03:00
|
|
|
this->GetMakefile()->GetDefinition("CMAKE_COMMAND");
|
2008-03-01 17:08:34 +03:00
|
|
|
return this->Convert(cmcommand, FULL, SHELL);
|
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
std::vector<std::string> enabledLanguages;
|
2006-03-15 19:02:08 +03:00
|
|
|
this->GlobalGenerator->GetEnabledLanguages(enabledLanguages);
|
2004-10-21 22:34:02 +04:00
|
|
|
// loop over language specific replace variables
|
|
|
|
int pos = 0;
|
|
|
|
while(ruleReplaceVars[pos])
|
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
for(std::vector<std::string>::iterator i = enabledLanguages.begin();
|
|
|
|
i != enabledLanguages.end(); ++i)
|
|
|
|
{
|
2006-02-20 21:42:18 +03:00
|
|
|
const char* lang = i->c_str();
|
2005-04-12 21:27:07 +04:00
|
|
|
std::string actualReplace = ruleReplaceVars[pos];
|
2005-07-20 23:44:55 +04:00
|
|
|
// If this is the compiler then look for the extra variable
|
2011-11-29 17:58:45 +04:00
|
|
|
// _COMPILER_ARG1 which must be the first argument to the compiler
|
2005-07-20 23:44:55 +04:00
|
|
|
const char* compilerArg1 = 0;
|
2013-05-19 21:18:01 +04:00
|
|
|
const char* compilerTarget = 0;
|
|
|
|
const char* compilerOptionTarget = 0;
|
2013-08-08 19:36:36 +04:00
|
|
|
const char* compilerExternalToolchain = 0;
|
|
|
|
const char* compilerOptionExternalToolchain = 0;
|
2013-04-13 16:46:57 +04:00
|
|
|
const char* compilerSysroot = 0;
|
|
|
|
const char* compilerOptionSysroot = 0;
|
2005-07-20 23:44:55 +04:00
|
|
|
if(actualReplace == "CMAKE_${LANG}_COMPILER")
|
|
|
|
{
|
|
|
|
std::string arg1 = actualReplace + "_ARG1";
|
|
|
|
cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
|
2006-03-15 19:02:08 +03:00
|
|
|
compilerArg1 = this->Makefile->GetDefinition(arg1.c_str());
|
2013-05-19 21:18:01 +04:00
|
|
|
compilerTarget
|
|
|
|
= this->Makefile->GetDefinition(
|
|
|
|
(std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str());
|
|
|
|
compilerOptionTarget
|
|
|
|
= this->Makefile->GetDefinition(
|
|
|
|
(std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILE_OPTIONS_TARGET").c_str());
|
2013-08-08 19:36:36 +04:00
|
|
|
compilerExternalToolchain
|
|
|
|
= this->Makefile->GetDefinition(
|
|
|
|
(std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILER_EXTERNAL_TOOLCHAIN").c_str());
|
|
|
|
compilerOptionExternalToolchain
|
|
|
|
= this->Makefile->GetDefinition(
|
|
|
|
(std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str());
|
2013-04-13 16:46:57 +04:00
|
|
|
compilerSysroot
|
|
|
|
= this->Makefile->GetDefinition("CMAKE_SYSROOT");
|
|
|
|
compilerOptionSysroot
|
|
|
|
= this->Makefile->GetDefinition(
|
|
|
|
(std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILE_OPTIONS_SYSROOT").c_str());
|
2005-07-20 23:44:55 +04:00
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
if(actualReplace.find("${LANG}") != actualReplace.npos)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2005-04-12 21:27:07 +04:00
|
|
|
cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
if(actualReplace == variable)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string replace =
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Makefile->GetSafeDefinition(variable.c_str());
|
2005-04-12 21:27:07 +04:00
|
|
|
// if the variable is not a FLAG then treat it like a path
|
|
|
|
if(variable.find("_FLAG") == variable.npos)
|
|
|
|
{
|
2005-07-20 23:44:55 +04:00
|
|
|
std::string ret = this->ConvertToOutputForExisting(replace.c_str());
|
2006-05-12 19:56:09 +04:00
|
|
|
// if there is a required first argument to the compiler add it
|
|
|
|
// to the compiler string
|
2005-07-20 23:44:55 +04:00
|
|
|
if(compilerArg1)
|
|
|
|
{
|
|
|
|
ret += " ";
|
|
|
|
ret += compilerArg1;
|
|
|
|
}
|
2013-05-19 21:18:01 +04:00
|
|
|
if (compilerTarget && compilerOptionTarget)
|
|
|
|
{
|
|
|
|
ret += " ";
|
|
|
|
ret += compilerOptionTarget;
|
|
|
|
ret += compilerTarget;
|
|
|
|
}
|
2013-08-08 19:36:36 +04:00
|
|
|
if (compilerExternalToolchain && compilerOptionExternalToolchain)
|
|
|
|
{
|
|
|
|
ret += " ";
|
|
|
|
ret += compilerOptionExternalToolchain;
|
|
|
|
ret += this->EscapeForShell(compilerExternalToolchain, true);
|
|
|
|
}
|
2013-04-13 16:46:57 +04:00
|
|
|
if (compilerSysroot && compilerOptionSysroot)
|
|
|
|
{
|
|
|
|
ret += " ";
|
|
|
|
ret += compilerOptionSysroot;
|
|
|
|
ret += this->EscapeForShell(compilerSysroot, true);
|
|
|
|
}
|
2005-07-20 23:44:55 +04:00
|
|
|
return ret;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
|
|
|
return replace;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pos++;
|
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
return variable;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-29 17:58:45 +04:00
|
|
|
void
|
2005-04-12 21:27:07 +04:00
|
|
|
cmLocalGenerator::ExpandRuleVariables(std::string& s,
|
2006-02-20 21:42:18 +03:00
|
|
|
const RuleVariables& replaceValues)
|
2005-04-12 21:27:07 +04:00
|
|
|
{
|
2009-02-10 16:51:15 +03:00
|
|
|
this->InsertRuleLauncher(s, replaceValues.CMTarget,
|
|
|
|
replaceValues.RuleLauncher);
|
2005-04-12 21:27:07 +04:00
|
|
|
std::string::size_type start = s.find('<');
|
|
|
|
// no variables to expand
|
|
|
|
if(start == s.npos)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string::size_type pos = 0;
|
|
|
|
std::string expandedInput;
|
|
|
|
while(start != s.npos && start < s.size()-2)
|
|
|
|
{
|
|
|
|
std::string::size_type end = s.find('>', start);
|
|
|
|
// if we find a < with no > we are done
|
|
|
|
if(end == s.npos)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
char c = s[start+1];
|
|
|
|
// if the next char after the < is not A-Za-z then
|
|
|
|
// skip it and try to find the next < in the string
|
|
|
|
if(!isalpha(c))
|
|
|
|
{
|
|
|
|
start = s.find('<', start+1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// extract the var
|
|
|
|
std::string var = s.substr(start+1, end - start-1);
|
2006-02-20 21:42:18 +03:00
|
|
|
std::string replace = this->ExpandRuleVariable(var,
|
|
|
|
replaceValues);
|
2005-04-12 21:27:07 +04:00
|
|
|
expandedInput += s.substr(pos, start-pos);
|
|
|
|
expandedInput += replace;
|
|
|
|
// move to next one
|
|
|
|
start = s.find('<', start+var.size()+2);
|
|
|
|
pos = end+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// add the rest of the input
|
|
|
|
expandedInput += s.substr(pos, s.size()-pos);
|
|
|
|
s = expandedInput;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2009-02-10 16:51:15 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
|
|
|
|
const char* prop)
|
|
|
|
{
|
|
|
|
if(target)
|
|
|
|
{
|
|
|
|
return target->GetProperty(prop);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this->Makefile->GetProperty(prop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
|
|
|
|
const char* prop)
|
|
|
|
{
|
|
|
|
if(const char* val = this->GetRuleLauncher(target, prop))
|
|
|
|
{
|
|
|
|
cmOStringStream wrapped;
|
|
|
|
wrapped << val << " " << s;
|
|
|
|
s = wrapped.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-09 23:30:07 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
|
|
|
|
std::string const& result)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2008-10-09 23:30:07 +04:00
|
|
|
// If this is a windows shell, the result has a space, and the path
|
|
|
|
// already exists, we can use a short-path to reference it without a
|
|
|
|
// space.
|
|
|
|
if(this->WindowsShell && result.find(' ') != result.npos &&
|
|
|
|
cmSystemTools::FileExists(remote))
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2008-10-09 23:30:07 +04:00
|
|
|
std::string tmp;
|
|
|
|
if(cmSystemTools::GetShortPath(remote, tmp))
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2008-10-09 23:30:07 +04:00
|
|
|
return this->Convert(tmp.c_str(), NONE, SHELL, true);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
2008-10-09 23:30:07 +04:00
|
|
|
|
|
|
|
// Otherwise, leave it unchanged.
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmLocalGenerator::ConvertToOutputForExisting(const char* remote,
|
|
|
|
RelativeRoot local)
|
|
|
|
{
|
|
|
|
// Perform standard conversion.
|
|
|
|
std::string result = this->Convert(remote, local, SHELL, true);
|
|
|
|
|
|
|
|
// Consider short-path.
|
|
|
|
return this->ConvertToOutputForExistingCommon(remote, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote,
|
|
|
|
const char* local)
|
|
|
|
{
|
|
|
|
// Perform standard conversion.
|
|
|
|
std::string result = this->Convert(remote, local, SHELL, true);
|
|
|
|
|
|
|
|
// Consider short-path.
|
|
|
|
const char* remotePath = this->GetRelativeRootPath(remote);
|
|
|
|
return this->ConvertToOutputForExistingCommon(remotePath, result);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2011-09-07 05:41:41 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
|
|
|
|
{
|
|
|
|
return this->ConvertToOutputForExisting(path.c_str());
|
|
|
|
}
|
|
|
|
|
2008-10-09 23:30:07 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2011-11-07 14:49:33 +04:00
|
|
|
std::string cmLocalGenerator::GetIncludeFlags(
|
2011-12-04 19:36:48 +04:00
|
|
|
const std::vector<std::string> &includes,
|
2013-07-02 00:28:26 +04:00
|
|
|
cmGeneratorTarget* target,
|
2013-01-25 12:26:35 +04:00
|
|
|
const char* lang, bool forResponseFile,
|
|
|
|
const char *config)
|
2004-10-26 18:15:49 +04:00
|
|
|
{
|
2004-10-21 22:34:02 +04:00
|
|
|
if(!lang)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2009-02-25 19:44:46 +03:00
|
|
|
|
2004-10-21 22:34:02 +04:00
|
|
|
cmOStringStream includeFlags;
|
2004-10-26 18:15:49 +04:00
|
|
|
|
|
|
|
std::string flagVar = "CMAKE_INCLUDE_FLAG_";
|
|
|
|
flagVar += lang;
|
2011-11-29 17:58:45 +04:00
|
|
|
const char* includeFlag =
|
2007-01-23 21:08:40 +03:00
|
|
|
this->Makefile->GetSafeDefinition(flagVar.c_str());
|
2004-10-26 18:15:49 +04:00
|
|
|
flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
|
|
|
|
flagVar += lang;
|
2006-03-15 19:02:08 +03:00
|
|
|
const char* sep = this->Makefile->GetDefinition(flagVar.c_str());
|
2006-01-23 21:50:23 +03:00
|
|
|
bool quotePaths = false;
|
2006-03-15 19:02:08 +03:00
|
|
|
if(this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS"))
|
2006-01-23 21:50:23 +03:00
|
|
|
{
|
|
|
|
quotePaths = true;
|
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
bool repeatFlag = true;
|
2006-05-12 19:56:09 +04:00
|
|
|
// should the include flag be repeated like ie. -IA -IB
|
2004-10-26 18:15:49 +04:00
|
|
|
if(!sep)
|
|
|
|
{
|
|
|
|
sep = " ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-12 19:56:09 +04:00
|
|
|
// if there is a separator then the flag is not repeated but is only
|
|
|
|
// given once i.e. -classpath a:b:c
|
2004-10-26 18:15:49 +04:00
|
|
|
repeatFlag = false;
|
|
|
|
}
|
2006-10-05 16:55:59 +04:00
|
|
|
|
|
|
|
// Support special system include flag if it is available and the
|
|
|
|
// normal flag is repeated for each directory.
|
|
|
|
std::string sysFlagVar = "CMAKE_INCLUDE_SYSTEM_FLAG_";
|
|
|
|
sysFlagVar += lang;
|
|
|
|
const char* sysIncludeFlag = 0;
|
|
|
|
if(repeatFlag)
|
|
|
|
{
|
2007-01-23 22:28:40 +03:00
|
|
|
sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar.c_str());
|
2006-10-05 16:55:59 +04:00
|
|
|
}
|
|
|
|
|
2013-10-10 16:29:04 +04:00
|
|
|
std::string fwSearchFlagVar = "CMAKE_";
|
|
|
|
fwSearchFlagVar += lang;
|
|
|
|
fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
|
|
|
|
const char* fwSearchFlag =
|
|
|
|
this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
|
|
|
|
|
2004-10-26 18:15:49 +04:00
|
|
|
bool flagUsed = false;
|
2005-12-27 22:56:56 +03:00
|
|
|
std::set<cmStdString> emitted;
|
2007-03-30 18:53:02 +04:00
|
|
|
#ifdef __APPLE__
|
|
|
|
emitted.insert("/System/Library/Frameworks");
|
|
|
|
#endif
|
2011-12-04 19:36:48 +04:00
|
|
|
std::vector<std::string>::const_iterator i;
|
2004-10-26 18:15:49 +04:00
|
|
|
for(i = includes.begin(); i != includes.end(); ++i)
|
|
|
|
{
|
2013-10-10 16:29:04 +04:00
|
|
|
if(fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE")
|
2010-05-01 16:29:13 +04:00
|
|
|
&& cmSystemTools::IsPathToFramework(i->c_str()))
|
2005-12-27 22:56:56 +03:00
|
|
|
{
|
|
|
|
std::string frameworkDir = *i;
|
|
|
|
frameworkDir += "/../";
|
|
|
|
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
|
|
|
|
if(emitted.insert(frameworkDir).second)
|
|
|
|
{
|
2011-03-15 21:07:36 +03:00
|
|
|
OutputFormat format = forResponseFile? RESPONSE : SHELL;
|
2008-10-09 23:07:35 +04:00
|
|
|
includeFlags
|
2013-10-10 16:29:04 +04:00
|
|
|
<< fwSearchFlag << this->Convert(frameworkDir.c_str(),
|
|
|
|
START_OUTPUT, format, true)
|
2008-10-09 23:07:35 +04:00
|
|
|
<< " ";
|
2005-12-27 22:56:56 +03:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2010-05-01 16:29:13 +04:00
|
|
|
|
2004-10-26 18:15:49 +04:00
|
|
|
if(!flagUsed || repeatFlag)
|
|
|
|
{
|
2013-07-02 00:28:26 +04:00
|
|
|
if(sysIncludeFlag && target &&
|
|
|
|
target->IsSystemIncludeDirectory(i->c_str(), config))
|
2006-10-05 16:55:59 +04:00
|
|
|
{
|
|
|
|
includeFlags << sysIncludeFlag;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
includeFlags << includeFlag;
|
|
|
|
}
|
2004-10-26 18:15:49 +04:00
|
|
|
flagUsed = true;
|
|
|
|
}
|
2011-03-15 21:07:36 +03:00
|
|
|
std::string includePath;
|
|
|
|
if(forResponseFile)
|
|
|
|
{
|
|
|
|
includePath = this->Convert(i->c_str(), START_OUTPUT,
|
|
|
|
RESPONSE, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-07 05:41:41 +04:00
|
|
|
includePath = this->ConvertToIncludeReference(*i);
|
2011-03-15 21:07:36 +03:00
|
|
|
}
|
2006-01-23 21:50:23 +03:00
|
|
|
if(quotePaths && includePath.size() && includePath[0] != '\"')
|
|
|
|
{
|
|
|
|
includeFlags << "\"";
|
|
|
|
}
|
|
|
|
includeFlags << includePath;
|
|
|
|
if(quotePaths && includePath.size() && includePath[0] != '\"')
|
|
|
|
{
|
|
|
|
includeFlags << "\"";
|
|
|
|
}
|
|
|
|
includeFlags << sep;
|
2004-10-26 18:15:49 +04:00
|
|
|
}
|
|
|
|
std::string flags = includeFlags.str();
|
|
|
|
// remove trailing separators
|
2009-04-07 23:13:07 +04:00
|
|
|
if((sep[0] != ' ') && flags.size()>0 && flags[flags.size()-1] == sep[0])
|
2004-10-26 18:15:49 +04:00
|
|
|
{
|
|
|
|
flags[flags.size()-1] = ' ';
|
|
|
|
}
|
2011-11-07 14:49:33 +04:00
|
|
|
return flags;
|
2004-10-26 18:15:49 +04:00
|
|
|
}
|
|
|
|
|
2013-06-06 20:13:35 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
|
2013-12-10 18:44:56 +04:00
|
|
|
cmTarget const* target,
|
2013-06-06 20:13:35 +04:00
|
|
|
const char* config)
|
|
|
|
{
|
|
|
|
std::vector<std::string> targetDefines;
|
|
|
|
target->GetCompileDefinitions(targetDefines,
|
|
|
|
config);
|
|
|
|
this->AppendDefines(defines, targetDefines);
|
|
|
|
}
|
|
|
|
|
2013-05-16 16:59:04 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2013-06-27 20:04:02 +04:00
|
|
|
void cmLocalGenerator::AddCompileOptions(
|
|
|
|
std::string& flags, cmTarget* target,
|
|
|
|
const char* lang, const char* config
|
|
|
|
)
|
2013-05-16 16:59:04 +04:00
|
|
|
{
|
2013-06-27 20:04:02 +04:00
|
|
|
std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX";
|
|
|
|
if(const char* langFlagRegexStr =
|
|
|
|
this->Makefile->GetDefinition(langFlagRegexVar.c_str()))
|
|
|
|
{
|
|
|
|
// Filter flags acceptable to this language.
|
|
|
|
cmsys::RegularExpression r(langFlagRegexStr);
|
|
|
|
std::vector<std::string> opts;
|
|
|
|
if(const char* targetFlags = target->GetProperty("COMPILE_FLAGS"))
|
|
|
|
{
|
|
|
|
cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
|
|
|
|
}
|
|
|
|
target->GetCompileOptions(opts, config);
|
|
|
|
for(std::vector<std::string>::const_iterator i = opts.begin();
|
|
|
|
i != opts.end(); ++i)
|
|
|
|
{
|
|
|
|
if(r.find(i->c_str()))
|
|
|
|
{
|
|
|
|
// (Re-)Escape this flag. COMPILE_FLAGS were already parsed
|
|
|
|
// as a command line above, and COMPILE_OPTIONS are escaped.
|
|
|
|
this->AppendFlagEscape(flags, i->c_str());
|
|
|
|
}
|
|
|
|
}
|
2013-05-16 16:59:04 +04:00
|
|
|
}
|
2013-06-27 20:04:02 +04:00
|
|
|
else
|
2013-05-16 17:15:28 +04:00
|
|
|
{
|
2013-06-27 20:04:02 +04:00
|
|
|
// Use all flags.
|
|
|
|
if(const char* targetFlags = target->GetProperty("COMPILE_FLAGS"))
|
|
|
|
{
|
|
|
|
// COMPILE_FLAGS are not escaped for historical reasons.
|
|
|
|
this->AppendFlags(flags, targetFlags);
|
|
|
|
}
|
2013-07-18 13:49:11 +04:00
|
|
|
std::vector<std::string> opts;
|
2013-06-27 20:04:02 +04:00
|
|
|
target->GetCompileOptions(opts, config);
|
|
|
|
for(std::vector<std::string>::const_iterator i = opts.begin();
|
|
|
|
i != opts.end(); ++i)
|
|
|
|
{
|
|
|
|
// COMPILE_OPTIONS are escaped.
|
|
|
|
this->AppendFlagEscape(flags, i->c_str());
|
|
|
|
}
|
2013-05-16 17:15:28 +04:00
|
|
|
}
|
2013-05-16 16:59:04 +04:00
|
|
|
}
|
|
|
|
|
2004-10-26 18:15:49 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2009-02-26 17:16:16 +03:00
|
|
|
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
|
2012-09-16 12:03:42 +04:00
|
|
|
cmGeneratorTarget* target,
|
2012-10-15 12:42:42 +04:00
|
|
|
const char* lang,
|
2012-12-08 00:24:28 +04:00
|
|
|
const char *config,
|
|
|
|
bool stripImplicitInclDirs
|
|
|
|
)
|
2004-10-26 18:15:49 +04:00
|
|
|
{
|
2006-02-19 21:10:25 +03:00
|
|
|
// Need to decide whether to automatically include the source and
|
|
|
|
// binary directories at the beginning of the include path.
|
|
|
|
bool includeSourceDir = false;
|
|
|
|
bool includeBinaryDir = false;
|
|
|
|
|
2006-03-21 16:45:57 +03:00
|
|
|
// When automatic include directories are requested for a build then
|
|
|
|
// include the source and binary directories at the beginning of the
|
|
|
|
// include path to approximate include file behavior for an
|
|
|
|
// in-source build. This does not account for the case of a source
|
|
|
|
// file in a subdirectory of the current source directory but we
|
|
|
|
// cannot fix this because not all native build tools support
|
|
|
|
// per-source-file include paths.
|
|
|
|
if(this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR"))
|
2006-02-19 21:10:25 +03:00
|
|
|
{
|
|
|
|
includeSourceDir = true;
|
|
|
|
includeBinaryDir = true;
|
|
|
|
}
|
|
|
|
|
2006-02-18 19:51:23 +03:00
|
|
|
// Do not repeat an include path.
|
|
|
|
std::set<cmStdString> emitted;
|
|
|
|
|
|
|
|
// Store the automatic include paths.
|
|
|
|
if(includeBinaryDir)
|
|
|
|
{
|
2011-12-04 19:45:39 +04:00
|
|
|
if(emitted.find(
|
|
|
|
this->Makefile->GetStartOutputDirectory()) == emitted.end())
|
|
|
|
{
|
|
|
|
dirs.push_back(this->Makefile->GetStartOutputDirectory());
|
|
|
|
emitted.insert(this->Makefile->GetStartOutputDirectory());
|
|
|
|
}
|
2006-02-18 19:51:23 +03:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
if(includeSourceDir)
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
if(emitted.find(this->Makefile->GetStartDirectory()) == emitted.end())
|
2006-02-18 19:51:23 +03:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
dirs.push_back(this->Makefile->GetStartDirectory());
|
|
|
|
emitted.insert(this->Makefile->GetStartDirectory());
|
2006-02-18 19:51:23 +03:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2012-08-20 01:14:15 +04:00
|
|
|
if(!target)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-13 16:46:57 +04:00
|
|
|
std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
|
|
|
|
|
Automoc: append implicit includes after user-specified dirs
The commit d2536579 (Automoc: fix regression #13667, broken build in
phonon, 2012-11-19) changed Automoc to try to re-add the Qt header dir
if it was stripped out as an implicit include from the moc command
line. When invoking a compiler, those directories are stripped out
because they are built-in, but for moc, there are no built-in directories.
The follow-up commit acc22400 (Automoc: get include dirs without
stripping implicit include dirs off, 2012-12-07) went further by not
removing the implicit include dirs, if they were specified specifically
by the user.
This had the remaining problem that the implicit include dirs appeared
in a different order of precedence for moc compared to the compiler.
Resolve that by stripping out the include dirs, where specified for
the moc command line to, and then appending them at the end. Note that
the order of the appended implicit include directories is the order
they are specified in the CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES, not
the order specified by the user.
2013-03-17 22:40:37 +04:00
|
|
|
std::vector<std::string> implicitDirs;
|
|
|
|
// Load implicit include directories for this language.
|
|
|
|
std::string impDirVar = "CMAKE_";
|
|
|
|
impDirVar += lang;
|
|
|
|
impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES";
|
|
|
|
if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str()))
|
|
|
|
{
|
|
|
|
std::vector<std::string> impDirVec;
|
|
|
|
cmSystemTools::ExpandListArgument(value, impDirVec);
|
|
|
|
for(std::vector<std::string>::const_iterator i = impDirVec.begin();
|
|
|
|
i != impDirVec.end(); ++i)
|
2009-02-26 17:16:16 +03:00
|
|
|
{
|
2013-04-13 16:46:57 +04:00
|
|
|
std::string d = rootPath + *i;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(d);
|
|
|
|
emitted.insert(d);
|
Automoc: append implicit includes after user-specified dirs
The commit d2536579 (Automoc: fix regression #13667, broken build in
phonon, 2012-11-19) changed Automoc to try to re-add the Qt header dir
if it was stripped out as an implicit include from the moc command
line. When invoking a compiler, those directories are stripped out
because they are built-in, but for moc, there are no built-in directories.
The follow-up commit acc22400 (Automoc: get include dirs without
stripping implicit include dirs off, 2012-12-07) went further by not
removing the implicit include dirs, if they were specified specifically
by the user.
This had the remaining problem that the implicit include dirs appeared
in a different order of precedence for moc compared to the compiler.
Resolve that by stripping out the include dirs, where specified for
the moc command line to, and then appending them at the end. Note that
the order of the appended implicit include directories is the order
they are specified in the CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES, not
the order specified by the user.
2013-03-17 22:40:37 +04:00
|
|
|
if (!stripImplicitInclDirs)
|
2012-12-08 00:24:28 +04:00
|
|
|
{
|
Automoc: append implicit includes after user-specified dirs
The commit d2536579 (Automoc: fix regression #13667, broken build in
phonon, 2012-11-19) changed Automoc to try to re-add the Qt header dir
if it was stripped out as an implicit include from the moc command
line. When invoking a compiler, those directories are stripped out
because they are built-in, but for moc, there are no built-in directories.
The follow-up commit acc22400 (Automoc: get include dirs without
stripping implicit include dirs off, 2012-12-07) went further by not
removing the implicit include dirs, if they were specified specifically
by the user.
This had the remaining problem that the implicit include dirs appeared
in a different order of precedence for moc compared to the compiler.
Resolve that by stripping out the include dirs, where specified for
the moc command line to, and then appending them at the end. Note that
the order of the appended implicit include directories is the order
they are specified in the CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES, not
the order specified by the user.
2013-03-17 22:40:37 +04:00
|
|
|
implicitDirs.push_back(*i);
|
2012-12-08 00:24:28 +04:00
|
|
|
}
|
2009-02-26 17:16:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-05 19:17:49 +04:00
|
|
|
// Get the target-specific include directories.
|
|
|
|
std::vector<std::string> includes;
|
2012-08-20 01:14:15 +04:00
|
|
|
|
2012-10-15 12:42:42 +04:00
|
|
|
includes = target->GetIncludeDirectories(config);
|
2006-04-25 17:54:12 +04:00
|
|
|
|
|
|
|
// Support putting all the in-project include directories first if
|
|
|
|
// it is requested by the project.
|
|
|
|
if(this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"))
|
|
|
|
{
|
|
|
|
const char* topSourceDir = this->Makefile->GetHomeDirectory();
|
|
|
|
const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory();
|
2012-01-24 20:54:46 +04:00
|
|
|
for(std::vector<std::string>::const_iterator i = includes.begin();
|
2006-04-25 17:54:12 +04:00
|
|
|
i != includes.end(); ++i)
|
|
|
|
{
|
|
|
|
// Emit this directory only if it is a subdirectory of the
|
|
|
|
// top-level source or binary tree.
|
|
|
|
if(cmSystemTools::ComparePath(i->c_str(), topSourceDir) ||
|
|
|
|
cmSystemTools::ComparePath(i->c_str(), topBinaryDir) ||
|
|
|
|
cmSystemTools::IsSubDirectory(i->c_str(), topSourceDir) ||
|
|
|
|
cmSystemTools::IsSubDirectory(i->c_str(), topBinaryDir))
|
|
|
|
{
|
|
|
|
if(emitted.insert(*i).second)
|
|
|
|
{
|
|
|
|
dirs.push_back(*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct the final ordered include directory list.
|
2012-01-24 20:54:46 +04:00
|
|
|
for(std::vector<std::string>::const_iterator i = includes.begin();
|
2004-10-26 18:15:49 +04:00
|
|
|
i != includes.end(); ++i)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2006-04-25 17:54:12 +04:00
|
|
|
if(emitted.insert(*i).second)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2004-10-26 18:15:49 +04:00
|
|
|
dirs.push_back(*i);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
Automoc: append implicit includes after user-specified dirs
The commit d2536579 (Automoc: fix regression #13667, broken build in
phonon, 2012-11-19) changed Automoc to try to re-add the Qt header dir
if it was stripped out as an implicit include from the moc command
line. When invoking a compiler, those directories are stripped out
because they are built-in, but for moc, there are no built-in directories.
The follow-up commit acc22400 (Automoc: get include dirs without
stripping implicit include dirs off, 2012-12-07) went further by not
removing the implicit include dirs, if they were specified specifically
by the user.
This had the remaining problem that the implicit include dirs appeared
in a different order of precedence for moc compared to the compiler.
Resolve that by stripping out the include dirs, where specified for
the moc command line to, and then appending them at the end. Note that
the order of the appended implicit include directories is the order
they are specified in the CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES, not
the order specified by the user.
2013-03-17 22:40:37 +04:00
|
|
|
|
|
|
|
for(std::vector<std::string>::const_iterator i = implicitDirs.begin();
|
|
|
|
i != implicitDirs.end(); ++i)
|
|
|
|
{
|
|
|
|
if(std::find(includes.begin(), includes.end(), *i) != includes.end())
|
|
|
|
{
|
|
|
|
dirs.push_back(*i);
|
|
|
|
}
|
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2013-07-10 21:11:04 +04:00
|
|
|
void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
|
|
|
|
std::string const& config,
|
|
|
|
cmTarget* target)
|
|
|
|
{
|
2013-04-07 19:39:05 +04:00
|
|
|
this->AppendFlags(flags,
|
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
|
|
|
|
if(!config.empty())
|
|
|
|
{
|
|
|
|
std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
|
|
|
|
this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name.c_str()));
|
|
|
|
}
|
2013-07-10 21:11:04 +04:00
|
|
|
this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS"));
|
|
|
|
if(!config.empty())
|
|
|
|
{
|
|
|
|
std::string name = "STATIC_LIBRARY_FLAGS_" + config;
|
|
|
|
this->AppendFlags(flags, target->GetProperty(name.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-21 22:34:02 +04:00
|
|
|
void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
|
|
|
|
std::string& flags,
|
|
|
|
std::string& linkFlags,
|
2012-09-26 16:38:15 +04:00
|
|
|
std::string& frameworkPath,
|
|
|
|
std::string& linkPath,
|
2012-09-16 03:35:08 +04:00
|
|
|
cmGeneratorTarget* target)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string buildType =
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2011-11-29 17:58:45 +04:00
|
|
|
buildType = cmSystemTools::UpperCase(buildType);
|
|
|
|
const char* libraryLinkVariable =
|
2006-05-12 19:56:09 +04:00
|
|
|
"CMAKE_SHARED_LINKER_FLAGS"; // default to shared library
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2012-09-16 03:35:08 +04:00
|
|
|
switch(target->GetType())
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
case cmTarget::STATIC_LIBRARY:
|
2013-07-10 21:11:04 +04:00
|
|
|
this->GetStaticLibraryFlags(linkFlags, buildType, target->Target);
|
2011-11-29 17:58:45 +04:00
|
|
|
break;
|
2004-10-21 22:34:02 +04:00
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable);
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
2011-09-22 06:59:55 +04:00
|
|
|
if(!buildType.empty())
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
|
|
|
std::string build = libraryLinkVariable;
|
|
|
|
build += "_";
|
|
|
|
build += buildType;
|
2006-03-15 19:02:08 +03:00
|
|
|
linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
|
|
|
if(this->Makefile->IsOn("WIN32") &&
|
2006-05-12 19:56:09 +04:00
|
|
|
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2013-07-14 20:22:57 +04:00
|
|
|
std::vector<cmSourceFile*> sources;
|
|
|
|
target->GetSourceFiles(sources);
|
2004-10-21 22:34:02 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
|
|
|
|
i != sources.end(); ++i)
|
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
cmSourceFile* sf = *i;
|
|
|
|
if(sf->GetExtension() == "def")
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
linkFlags +=
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
|
2007-06-18 19:59:23 +04:00
|
|
|
linkFlags += this->Convert(sf->GetFullPath().c_str(),
|
2012-03-07 02:41:40 +04:00
|
|
|
FULL, SHELL);
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
|
|
|
}
|
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2012-09-16 03:35:08 +04:00
|
|
|
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
2004-10-21 22:34:02 +04:00
|
|
|
if(targetLinkFlags)
|
|
|
|
{
|
|
|
|
linkFlags += targetLinkFlags;
|
|
|
|
linkFlags += " ";
|
2011-09-22 06:59:55 +04:00
|
|
|
}
|
|
|
|
if(!buildType.empty())
|
|
|
|
{
|
|
|
|
std::string configLinkFlags = "LINK_FLAGS_";
|
2006-04-03 20:57:51 +04:00
|
|
|
configLinkFlags += buildType;
|
2012-09-16 03:35:08 +04:00
|
|
|
targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
|
2006-04-03 20:57:51 +04:00
|
|
|
if(targetLinkFlags)
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2006-04-03 20:57:51 +04:00
|
|
|
linkFlags += targetLinkFlags;
|
|
|
|
linkFlags += " ";
|
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2012-09-26 16:38:15 +04:00
|
|
|
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
|
|
|
*target, false);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
linkFlags +=
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
2011-09-22 06:59:55 +04:00
|
|
|
if(!buildType.empty())
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
|
|
|
std::string build = "CMAKE_EXE_LINKER_FLAGS_";
|
|
|
|
build += buildType;
|
2006-03-15 19:02:08 +03:00
|
|
|
linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2012-09-16 03:35:08 +04:00
|
|
|
const char* linkLanguage = target->Target->GetLinkerLanguage();
|
2004-10-27 18:53:01 +04:00
|
|
|
if(!linkLanguage)
|
|
|
|
{
|
2006-05-12 19:56:09 +04:00
|
|
|
cmSystemTools::Error
|
2013-06-21 15:51:58 +04:00
|
|
|
("CMake can not determine linker language for target: ",
|
2012-09-16 03:35:08 +04:00
|
|
|
target->Target->GetName());
|
2004-10-27 18:53:01 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-04-30 07:25:37 +04:00
|
|
|
this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
|
2012-09-26 16:38:15 +04:00
|
|
|
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
|
|
|
*target, false);
|
2006-05-12 19:56:09 +04:00
|
|
|
if(cmSystemTools::IsOn
|
|
|
|
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_")
|
2006-05-12 19:56:09 +04:00
|
|
|
+ linkLanguage + std::string("_FLAGS");
|
2006-03-15 19:02:08 +03:00
|
|
|
linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str());
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
|
|
|
}
|
2012-09-16 03:35:08 +04:00
|
|
|
if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") )
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2006-05-12 19:56:09 +04:00
|
|
|
linkFlags +=
|
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-29 17:58:45 +04:00
|
|
|
linkFlags +=
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
|
|
|
}
|
2012-09-16 03:35:08 +04:00
|
|
|
if (target->Target->IsExecutableWithExports())
|
2011-11-11 23:11:38 +04:00
|
|
|
{
|
|
|
|
std::string exportFlagVar = "CMAKE_EXE_EXPORTS_";
|
|
|
|
exportFlagVar += linkLanguage;
|
|
|
|
exportFlagVar += "_FLAG";
|
|
|
|
|
|
|
|
linkFlags +=
|
|
|
|
this->Makefile->GetSafeDefinition(exportFlagVar.c_str());
|
|
|
|
linkFlags += " ";
|
|
|
|
}
|
2012-09-16 03:35:08 +04:00
|
|
|
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
2004-10-21 22:34:02 +04:00
|
|
|
if(targetLinkFlags)
|
|
|
|
{
|
|
|
|
linkFlags += targetLinkFlags;
|
2011-09-22 06:59:55 +04:00
|
|
|
linkFlags += " ";
|
|
|
|
}
|
|
|
|
if(!buildType.empty())
|
|
|
|
{
|
|
|
|
std::string configLinkFlags = "LINK_FLAGS_";
|
2006-04-03 20:57:51 +04:00
|
|
|
configLinkFlags += buildType;
|
2012-09-16 03:35:08 +04:00
|
|
|
targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
|
2006-04-03 20:57:51 +04:00
|
|
|
if(targetLinkFlags)
|
2011-11-29 17:58:45 +04:00
|
|
|
{
|
2006-04-03 20:57:51 +04:00
|
|
|
linkFlags += targetLinkFlags;
|
|
|
|
linkFlags += " ";
|
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
break;
|
2008-08-18 19:26:51 +04:00
|
|
|
default:
|
2004-10-21 22:34:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-23 21:03:03 +03:00
|
|
|
std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
|
|
|
|
{
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2008-01-23 21:30:55 +03:00
|
|
|
// Work-ardound command line parsing limitations in MSVC 6.0 and
|
|
|
|
// Watcom.
|
|
|
|
if(this->Makefile->IsOn("MSVC60") || this->Makefile->IsOn("WATCOM"))
|
2008-01-23 21:03:03 +03:00
|
|
|
{
|
|
|
|
// Search for the last space.
|
|
|
|
std::string::size_type pos = lib.rfind(' ');
|
|
|
|
if(pos != lib.npos)
|
|
|
|
{
|
|
|
|
// Find the slash after the last space, if any.
|
|
|
|
pos = lib.find('/', pos);
|
|
|
|
|
|
|
|
// Convert the portion of the path with a space to a short path.
|
|
|
|
std::string sp;
|
|
|
|
if(cmSystemTools::GetShortPath(lib.substr(0, pos).c_str(), sp))
|
|
|
|
{
|
|
|
|
// Append the rest of the path with no space.
|
|
|
|
sp += lib.substr(pos);
|
|
|
|
|
|
|
|
// Convert to an output path.
|
|
|
|
return this->Convert(sp.c_str(), NONE, SHELL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Normal behavior.
|
|
|
|
return this->Convert(lib.c_str(), START_OUTPUT, SHELL);
|
|
|
|
}
|
|
|
|
|
2008-01-29 23:07:33 +03:00
|
|
|
/**
|
|
|
|
* Output the linking rules on a command line. For executables,
|
|
|
|
* targetLibrary should be a NULL pointer. For libraries, it should point
|
|
|
|
* to the name of the library. This will not link a library against itself.
|
|
|
|
*/
|
2012-09-26 16:38:15 +04:00
|
|
|
void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
|
|
|
|
std::string& frameworkPath,
|
|
|
|
std::string& linkPath,
|
|
|
|
cmGeneratorTarget &tgt,
|
2008-01-29 23:07:33 +03:00
|
|
|
bool relink)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2012-09-26 16:38:15 +04:00
|
|
|
cmOStringStream fout;
|
2008-01-22 17:13:04 +03:00
|
|
|
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
|
2012-11-05 19:14:02 +04:00
|
|
|
cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config);
|
2008-01-29 23:07:33 +03:00
|
|
|
if(!pcli)
|
2008-01-22 17:13:04 +03:00
|
|
|
{
|
2008-01-29 23:07:33 +03:00
|
|
|
return;
|
2004-10-27 18:53:01 +04:00
|
|
|
}
|
2008-01-29 23:07:33 +03:00
|
|
|
cmComputeLinkInformation& cli = *pcli;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2008-01-29 23:07:33 +03:00
|
|
|
// Collect library linking flags command line options.
|
|
|
|
std::string linkLibs;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2008-01-29 23:07:33 +03:00
|
|
|
const char* linkLanguage = cli.GetLinkLanguage();
|
2004-10-21 22:34:02 +04:00
|
|
|
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string libPathFlag =
|
2006-05-12 19:56:09 +04:00
|
|
|
this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
|
2011-11-29 17:58:45 +04:00
|
|
|
std::string libPathTerminator =
|
2007-08-29 00:19:01 +04:00
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
|
2008-01-29 23:07:33 +03:00
|
|
|
|
2004-10-21 22:34:02 +04:00
|
|
|
// Flags to link an executable to shared libraries.
|
|
|
|
std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
|
|
|
|
linkFlagsVar += linkLanguage;
|
|
|
|
linkFlagsVar += "_FLAGS";
|
|
|
|
if( tgt.GetType() == cmTarget::EXECUTABLE )
|
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str());
|
2004-10-21 22:34:02 +04:00
|
|
|
linkLibs += " ";
|
|
|
|
}
|
2006-01-14 02:18:32 +03:00
|
|
|
|
2008-01-22 17:13:04 +03:00
|
|
|
// Append the framework search path flags.
|
2013-10-10 16:29:04 +04:00
|
|
|
std::string fwSearchFlagVar = "CMAKE_";
|
|
|
|
fwSearchFlagVar += linkLanguage;
|
|
|
|
fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
|
|
|
|
const char* fwSearchFlag =
|
|
|
|
this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
|
|
|
|
if(fwSearchFlag && *fwSearchFlag)
|
2008-01-22 17:13:04 +03:00
|
|
|
{
|
2013-10-10 16:29:04 +04:00
|
|
|
std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
|
|
|
|
for(std::vector<std::string>::const_iterator fdi = fwDirs.begin();
|
|
|
|
fdi != fwDirs.end(); ++fdi)
|
|
|
|
{
|
|
|
|
frameworkPath += fwSearchFlag;
|
|
|
|
frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false);
|
|
|
|
frameworkPath += " ";
|
|
|
|
}
|
2008-01-22 17:13:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Append the library search path flags.
|
|
|
|
std::vector<std::string> const& libDirs = cli.GetDirectories();
|
|
|
|
for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
|
|
|
|
libDir != libDirs.end(); ++libDir)
|
|
|
|
{
|
|
|
|
std::string libpath = this->ConvertToOutputForExisting(libDir->c_str());
|
2012-09-26 16:38:15 +04:00
|
|
|
linkPath += " " + libPathFlag;
|
|
|
|
linkPath += libpath;
|
|
|
|
linkPath += libPathTerminator;
|
|
|
|
linkPath += " ";
|
2008-01-22 17:13:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Append the link items.
|
|
|
|
typedef cmComputeLinkInformation::ItemVector ItemVector;
|
|
|
|
ItemVector const& items = cli.GetItems();
|
|
|
|
for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li)
|
|
|
|
{
|
2012-11-02 18:47:40 +04:00
|
|
|
if(li->Target && li->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2008-01-22 17:13:04 +03:00
|
|
|
if(li->IsPath)
|
|
|
|
{
|
2008-01-23 21:03:03 +03:00
|
|
|
linkLibs += this->ConvertToLinkReference(li->Value);
|
2008-01-22 17:13:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
linkLibs += li->Value;
|
|
|
|
}
|
|
|
|
linkLibs += " ";
|
|
|
|
}
|
2006-01-14 02:18:32 +03:00
|
|
|
|
2008-01-29 23:07:33 +03:00
|
|
|
// Write the library flags to the build rule.
|
|
|
|
fout << linkLibs;
|
2006-02-16 23:19:00 +03:00
|
|
|
|
2008-01-29 23:07:33 +03:00
|
|
|
// Get the RPATH entries.
|
2006-02-16 23:19:00 +03:00
|
|
|
std::vector<std::string> runtimeDirs;
|
2008-01-29 23:07:33 +03:00
|
|
|
cli.GetRPath(runtimeDirs, relink);
|
|
|
|
|
|
|
|
// Check what kind of rpath flags to use.
|
|
|
|
if(cli.GetRuntimeSep().empty())
|
2005-02-24 21:16:41 +03:00
|
|
|
{
|
2008-01-29 23:07:33 +03:00
|
|
|
// Each rpath entry gets its own option ("-R a -R b -R c")
|
|
|
|
std::string rpath;
|
|
|
|
for(std::vector<std::string>::iterator ri = runtimeDirs.begin();
|
|
|
|
ri != runtimeDirs.end(); ++ri)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2008-01-29 23:07:33 +03:00
|
|
|
rpath += cli.GetRuntimeFlag();
|
2008-08-05 17:55:08 +04:00
|
|
|
rpath += this->Convert(ri->c_str(), NONE, SHELL, false);
|
2008-01-29 23:07:33 +03:00
|
|
|
rpath += " ";
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2008-01-29 23:07:33 +03:00
|
|
|
fout << rpath;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2008-01-29 23:07:33 +03:00
|
|
|
else
|
2006-01-14 02:18:32 +03:00
|
|
|
{
|
2008-01-29 23:07:33 +03:00
|
|
|
// All rpath entries are combined ("-Wl,-rpath,a:b:c").
|
|
|
|
std::string rpath = cli.GetRPathString(relink);
|
2004-10-21 22:34:02 +04:00
|
|
|
|
2008-01-29 23:07:33 +03:00
|
|
|
// Store the rpath option in the stream.
|
|
|
|
if(!rpath.empty())
|
2007-12-19 01:50:27 +03:00
|
|
|
{
|
2008-01-29 23:07:33 +03:00
|
|
|
fout << cli.GetRuntimeFlag();
|
|
|
|
fout << this->EscapeForShell(rpath.c_str(), true);
|
|
|
|
fout << " ";
|
2007-12-19 01:50:27 +03:00
|
|
|
}
|
|
|
|
}
|
2006-04-12 00:55:49 +04:00
|
|
|
|
2008-02-01 16:56:00 +03:00
|
|
|
// Add the linker runtime search path if any.
|
|
|
|
std::string rpath_link = cli.GetRPathLinkString();
|
|
|
|
if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty())
|
|
|
|
{
|
|
|
|
fout << cli.GetRPathLinkFlag();
|
|
|
|
fout << this->EscapeForShell(rpath_link.c_str(), true);
|
|
|
|
fout << " ";
|
|
|
|
}
|
|
|
|
|
2006-04-12 00:55:49 +04:00
|
|
|
// Add standard libraries for this language.
|
|
|
|
std::string standardLibsVar = "CMAKE_";
|
2008-01-29 23:07:33 +03:00
|
|
|
standardLibsVar += cli.GetLinkLanguage();
|
2006-04-12 00:55:49 +04:00
|
|
|
standardLibsVar += "_STANDARD_LIBRARIES";
|
|
|
|
if(const char* stdLibs =
|
|
|
|
this->Makefile->GetDefinition(standardLibsVar.c_str()))
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2006-04-12 00:55:49 +04:00
|
|
|
fout << stdLibs << " ";
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2012-09-26 16:38:15 +04:00
|
|
|
|
|
|
|
linkLibraries = fout.str();
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2005-02-02 21:19:57 +03:00
|
|
|
|
2009-10-21 21:00:49 +04:00
|
|
|
|
2005-02-02 21:19:57 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2009-10-21 21:00:49 +04:00
|
|
|
void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
|
2012-09-16 03:16:43 +04:00
|
|
|
cmGeneratorTarget* target,
|
2009-10-21 21:00:49 +04:00
|
|
|
const char *lang,
|
|
|
|
const char* config)
|
|
|
|
{
|
2010-05-01 16:29:13 +04:00
|
|
|
// Only add Mac OS X specific flags on Darwin platforms (OSX and iphone):
|
|
|
|
if(!this->Makefile->IsOn("APPLE"))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-24 17:15:05 +03:00
|
|
|
if(this->EmitUniversalBinaryFlags)
|
|
|
|
{
|
2009-10-21 21:00:49 +04:00
|
|
|
std::vector<std::string> archs;
|
|
|
|
target->GetAppleArchs(config, archs);
|
2012-09-21 16:53:42 +04:00
|
|
|
const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
|
|
|
if(sysroot && sysroot[0] == '/' && !sysroot[1])
|
|
|
|
{ sysroot = 0; }
|
|
|
|
std::string sysrootFlagVar =
|
|
|
|
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
|
|
|
|
const char* sysrootFlag =
|
|
|
|
this->Makefile->GetDefinition(sysrootFlagVar.c_str());
|
2011-11-29 17:58:45 +04:00
|
|
|
const char* deploymentTarget =
|
2009-01-27 18:30:55 +03:00
|
|
|
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
2010-02-02 05:43:51 +03:00
|
|
|
std::string deploymentTargetFlagVar =
|
|
|
|
std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
|
2010-01-29 19:56:35 +03:00
|
|
|
const char* deploymentTargetFlag =
|
|
|
|
this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str());
|
2012-09-21 16:53:42 +04:00
|
|
|
if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F'))
|
|
|
|
{
|
|
|
|
for(std::vector<std::string>::iterator i = archs.begin();
|
|
|
|
i != archs.end(); ++i)
|
2007-10-20 06:24:00 +04:00
|
|
|
{
|
2012-09-21 16:53:42 +04:00
|
|
|
flags += " -arch ";
|
|
|
|
flags += *i;
|
2006-03-24 17:15:05 +03:00
|
|
|
}
|
|
|
|
}
|
2009-01-27 18:30:55 +03:00
|
|
|
|
2012-09-21 16:53:42 +04:00
|
|
|
if(sysrootFlag && *sysrootFlag && sysroot && *sysroot)
|
2008-04-28 21:53:14 +04:00
|
|
|
{
|
2012-09-21 16:53:42 +04:00
|
|
|
flags += " ";
|
|
|
|
flags += sysrootFlag;
|
|
|
|
flags += " ";
|
2008-04-28 21:53:14 +04:00
|
|
|
flags += sysroot;
|
|
|
|
}
|
2009-01-27 18:30:55 +03:00
|
|
|
|
2010-01-29 19:56:35 +03:00
|
|
|
if (deploymentTargetFlag && *deploymentTargetFlag &&
|
|
|
|
deploymentTarget && *deploymentTarget)
|
2009-01-27 18:30:55 +03:00
|
|
|
{
|
2010-01-29 19:56:35 +03:00
|
|
|
flags += " ";
|
|
|
|
flags += deploymentTargetFlag;
|
2009-01-27 18:30:55 +03:00
|
|
|
flags += deploymentTarget;
|
|
|
|
}
|
2006-03-24 17:15:05 +03:00
|
|
|
}
|
2009-10-21 21:00:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
|
|
|
const char* lang,
|
|
|
|
const char* config)
|
|
|
|
{
|
|
|
|
// Add language-specific flags.
|
|
|
|
std::string flagsVar = "CMAKE_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_FLAGS";
|
2008-04-29 20:10:47 +04:00
|
|
|
this->AddConfigVariableFlags(flags, flagsVar.c_str(), config);
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2010-12-09 00:51:16 +03:00
|
|
|
bool cmLocalGenerator::GetRealDependency(const char* inName,
|
|
|
|
const char* config,
|
|
|
|
std::string& dep)
|
2006-01-14 02:18:32 +03:00
|
|
|
{
|
|
|
|
// Older CMake code may specify the dependency using the target
|
|
|
|
// output file rather than the target name. Such code would have
|
|
|
|
// been written before there was support for target properties that
|
|
|
|
// modify the name so stripping down to just the file name should
|
|
|
|
// produce the target name in this case.
|
|
|
|
std::string name = cmSystemTools::GetFilenameName(inName);
|
2012-11-21 20:23:14 +04:00
|
|
|
|
|
|
|
// If the input name is the empty string, there is no real
|
|
|
|
// dependency. Short-circuit the other checks:
|
|
|
|
if(name == "")
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-01-14 02:18:32 +03:00
|
|
|
if(cmSystemTools::GetFilenameLastExtension(name) == ".exe")
|
|
|
|
{
|
|
|
|
name = cmSystemTools::GetFilenameWithoutLastExtension(name);
|
|
|
|
}
|
|
|
|
|
2006-01-14 04:51:45 +03:00
|
|
|
// Look for a CMake target with the given name.
|
2008-01-28 16:38:36 +03:00
|
|
|
if(cmTarget* target = this->Makefile->FindTargetToUse(name.c_str()))
|
2006-01-14 02:18:32 +03:00
|
|
|
{
|
2006-11-25 18:59:26 +03:00
|
|
|
// make sure it is not just a coincidence that the target name
|
|
|
|
// found is part of the inName
|
|
|
|
if(cmSystemTools::FileIsFullPath(inName))
|
|
|
|
{
|
2009-09-25 21:23:19 +04:00
|
|
|
std::string tLocation;
|
2011-11-29 17:58:45 +04:00
|
|
|
if(target->GetType() >= cmTarget::EXECUTABLE &&
|
2009-09-25 21:23:19 +04:00
|
|
|
target->GetType() <= cmTarget::MODULE_LIBRARY)
|
|
|
|
{
|
|
|
|
tLocation = target->GetLocation(config);
|
|
|
|
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
|
|
|
tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
|
|
|
|
}
|
2006-11-25 18:59:26 +03:00
|
|
|
std::string depLocation = cmSystemTools::GetFilenamePath(
|
|
|
|
std::string(inName));
|
2006-12-07 07:05:10 +03:00
|
|
|
depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
|
2006-11-25 18:59:26 +03:00
|
|
|
if(depLocation != tLocation)
|
|
|
|
{
|
|
|
|
// it is a full path to a depend that has the same name
|
|
|
|
// as a target but is in a different location so do not use
|
|
|
|
// the target as the depend
|
2010-12-09 00:51:16 +03:00
|
|
|
dep = inName;
|
|
|
|
return true;
|
2006-11-25 18:59:26 +03:00
|
|
|
}
|
|
|
|
}
|
2006-01-14 02:18:32 +03:00
|
|
|
switch (target->GetType())
|
|
|
|
{
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
2008-08-18 19:39:22 +04:00
|
|
|
case cmTarget::UNKNOWN_LIBRARY:
|
2012-02-25 13:20:57 +04:00
|
|
|
dep = target->GetLocation(config);
|
|
|
|
return true;
|
2012-03-12 18:47:40 +04:00
|
|
|
case cmTarget::OBJECT_LIBRARY:
|
|
|
|
// An object library has no single file on which to depend.
|
|
|
|
// This was listed to get the target-level dependency.
|
|
|
|
return false;
|
2012-11-02 18:47:40 +04:00
|
|
|
case cmTarget::INTERFACE_LIBRARY:
|
|
|
|
// An interface library has no file on which to depend.
|
|
|
|
// This was listed to get the target-level dependency.
|
|
|
|
return false;
|
2006-01-14 02:18:32 +03:00
|
|
|
case cmTarget::UTILITY:
|
2006-02-24 18:56:39 +03:00
|
|
|
case cmTarget::GLOBAL_TARGET:
|
2010-12-09 01:05:23 +03:00
|
|
|
// A utility target has no file on which to depend. This was listed
|
|
|
|
// only to get the target-level dependency.
|
|
|
|
return false;
|
2006-01-14 02:18:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-14 04:51:45 +03:00
|
|
|
// The name was not that of a CMake target. It must name a file.
|
|
|
|
if(cmSystemTools::FileIsFullPath(inName))
|
|
|
|
{
|
|
|
|
// This is a full path. Return it as given.
|
2010-12-09 00:51:16 +03:00
|
|
|
dep = inName;
|
|
|
|
return true;
|
2006-01-14 04:51:45 +03:00
|
|
|
}
|
2008-08-05 21:27:06 +04:00
|
|
|
|
|
|
|
// Check for a source file in this directory that matches the
|
|
|
|
// dependency.
|
|
|
|
if(cmSourceFile* sf = this->Makefile->GetSource(inName))
|
|
|
|
{
|
2010-12-09 00:51:16 +03:00
|
|
|
dep = sf->GetFullPath();
|
|
|
|
return true;
|
2008-08-05 21:27:06 +04:00
|
|
|
}
|
|
|
|
|
2006-01-24 15:58:55 +03:00
|
|
|
// Treat the name as relative to the source directory in which it
|
|
|
|
// was given.
|
2010-12-09 00:51:16 +03:00
|
|
|
dep = this->Makefile->GetCurrentDirectory();
|
|
|
|
dep += "/";
|
|
|
|
dep += inName;
|
|
|
|
return true;
|
2006-01-14 02:18:32 +03:00
|
|
|
}
|
|
|
|
|
2007-05-09 16:25:45 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2005-02-02 21:19:57 +03:00
|
|
|
void cmLocalGenerator::AddSharedFlags(std::string& flags,
|
2006-02-24 19:13:31 +03:00
|
|
|
const char* lang,
|
|
|
|
bool shared)
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
|
|
|
std::string flagsVar;
|
|
|
|
|
|
|
|
// Add flags for dealing with shared libraries for this language.
|
|
|
|
if(shared)
|
|
|
|
{
|
|
|
|
flagsVar = "CMAKE_SHARED_LIBRARY_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_FLAGS";
|
2006-03-15 19:02:08 +03:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-23 17:32:17 +04:00
|
|
|
static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
|
|
|
|
cmLocalGenerator *lg, const char *lang)
|
2013-05-18 14:12:18 +04:00
|
|
|
{
|
|
|
|
std::string l(lang);
|
|
|
|
std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
|
2013-05-23 17:32:17 +04:00
|
|
|
const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
|
2013-05-18 14:12:18 +04:00
|
|
|
if (!opt)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string flagDefine = l + "_VISIBILITY_PRESET";
|
|
|
|
|
|
|
|
const char *prop = target->GetProperty(flagDefine.c_str());
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (strcmp(prop, "hidden") != 0
|
|
|
|
&& strcmp(prop, "default") != 0
|
|
|
|
&& strcmp(prop, "protected") != 0
|
|
|
|
&& strcmp(prop, "internal") != 0 )
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Target " << target->GetName() << " uses unsupported value \""
|
|
|
|
<< prop << "\" for " << flagDefine << ".";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string option = std::string(opt) + prop;
|
2013-05-23 17:32:17 +04:00
|
|
|
lg->AppendFlags(flags, option.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void AddInlineVisibilityCompileOption(std::string &flags,
|
|
|
|
cmTarget* target,
|
|
|
|
cmLocalGenerator *lg)
|
|
|
|
{
|
|
|
|
std::string compileOption
|
|
|
|
= "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
|
|
|
|
const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
|
|
|
|
if (!opt)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool prop = target->GetPropertyAsBool("VISIBILITY_INLINES_HIDDEN");
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lg->AppendFlags(flags, opt);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator
|
|
|
|
::AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
|
|
|
|
const char *lang)
|
|
|
|
{
|
|
|
|
int targetType = target->GetType();
|
|
|
|
bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY)
|
|
|
|
|| (targetType == cmTarget::MODULE_LIBRARY)
|
|
|
|
|| (target->IsExecutableWithExports()));
|
|
|
|
|
|
|
|
if (!suitableTarget)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lang)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AddVisibilityCompileOption(flags, target, this, lang);
|
|
|
|
AddInlineVisibilityCompileOption(flags, target, this);
|
2013-05-18 14:12:18 +04:00
|
|
|
}
|
|
|
|
|
2012-05-30 22:13:09 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target,
|
2012-11-05 15:46:26 +04:00
|
|
|
std::string const& lang,
|
|
|
|
const char *config)
|
2012-05-30 22:13:09 +04:00
|
|
|
{
|
|
|
|
int targetType = target->GetType();
|
|
|
|
|
|
|
|
bool shared = ((targetType == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(targetType == cmTarget::MODULE_LIBRARY));
|
|
|
|
|
|
|
|
if (this->GetShouldUseOldFlags(shared, lang))
|
|
|
|
{
|
|
|
|
this->AddSharedFlags(flags, lang.c_str(), shared);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-05 15:46:26 +04:00
|
|
|
if (target->GetType() == cmTarget::OBJECT_LIBRARY)
|
2013-05-18 11:54:50 +04:00
|
|
|
{
|
2012-11-05 15:46:26 +04:00
|
|
|
if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE"))
|
|
|
|
{
|
|
|
|
this->AddPositionIndependentFlags(flags, lang, targetType);
|
|
|
|
}
|
|
|
|
return;
|
2013-05-18 11:54:50 +04:00
|
|
|
}
|
2012-11-05 15:46:26 +04:00
|
|
|
|
|
|
|
if (target->GetLinkInterfaceDependentBoolProperty(
|
|
|
|
"POSITION_INDEPENDENT_CODE",
|
|
|
|
config))
|
2012-05-30 22:13:09 +04:00
|
|
|
{
|
|
|
|
this->AddPositionIndependentFlags(flags, lang, targetType);
|
|
|
|
}
|
|
|
|
if (shared)
|
|
|
|
{
|
|
|
|
this->AppendFeatureOptions(flags, lang.c_str(), "DLL");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
|
|
|
|
const std::string &lang) const
|
|
|
|
{
|
|
|
|
std::string originalFlags =
|
|
|
|
this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang);
|
|
|
|
if (shared)
|
|
|
|
{
|
|
|
|
std::string flagsVar = "CMAKE_SHARED_LIBRARY_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_FLAGS";
|
|
|
|
const char* flags =
|
|
|
|
this->Makefile->GetSafeDefinition(flagsVar.c_str());
|
|
|
|
|
|
|
|
if (flags && flags != originalFlags)
|
|
|
|
{
|
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0018))
|
|
|
|
{
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Variable " << flagsVar << " has been modified. CMake "
|
|
|
|
"will ignore the POSITION_INDEPENDENT_CODE target property for "
|
|
|
|
"shared libraries and will use the " << flagsVar << " variable "
|
|
|
|
"instead. This may cause errors if the original content of "
|
|
|
|
<< flagsVar << " was removed.\n"
|
|
|
|
<< this->Makefile->GetPolicies()->GetPolicyWarning(
|
|
|
|
cmPolicies::CMP0018);
|
|
|
|
|
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
|
|
|
// fall through to OLD behaviour
|
|
|
|
}
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
return true;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
|
|
|
|
std::string const& lang,
|
|
|
|
int targetType)
|
|
|
|
{
|
|
|
|
const char* picFlags = 0;
|
|
|
|
|
|
|
|
if(targetType == cmTarget::EXECUTABLE)
|
|
|
|
{
|
|
|
|
std::string flagsVar = "CMAKE_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_COMPILE_OPTIONS_PIE";
|
|
|
|
picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str());
|
|
|
|
}
|
|
|
|
if (!picFlags)
|
|
|
|
{
|
|
|
|
std::string flagsVar = "CMAKE_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_COMPILE_OPTIONS_PIC";
|
|
|
|
picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str());
|
|
|
|
}
|
|
|
|
if (picFlags)
|
|
|
|
{
|
|
|
|
std::vector<std::string> options;
|
|
|
|
cmSystemTools::ExpandListArgument(picFlags, options);
|
|
|
|
for(std::vector<std::string>::const_iterator oi = options.begin();
|
|
|
|
oi != options.end(); ++oi)
|
|
|
|
{
|
2013-06-27 19:49:06 +04:00
|
|
|
this->AppendFlagEscape(flags, oi->c_str());
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-02 21:19:57 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
|
2006-02-24 19:13:31 +03:00
|
|
|
const char* var,
|
|
|
|
const char* config)
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
|
|
|
// Add the flags from the variable itself.
|
|
|
|
std::string flagsVar = var;
|
2006-03-15 19:02:08 +03:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
|
2005-02-02 21:19:57 +03:00
|
|
|
// Add the flags from the build-type specific variable.
|
2006-02-24 19:13:31 +03:00
|
|
|
if(config && *config)
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
|
|
|
flagsVar += "_";
|
2006-02-24 19:13:31 +03:00
|
|
|
flagsVar += cmSystemTools::UpperCase(config);
|
2006-03-15 19:02:08 +03:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AppendFlags(std::string& flags,
|
|
|
|
const char* newFlags)
|
|
|
|
{
|
|
|
|
if(newFlags && *newFlags)
|
|
|
|
{
|
2007-05-10 22:43:55 +04:00
|
|
|
std::string newf = newFlags;
|
2005-02-02 21:19:57 +03:00
|
|
|
if(flags.size())
|
|
|
|
{
|
|
|
|
flags += " ";
|
|
|
|
}
|
|
|
|
flags += newFlags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-27 19:49:06 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AppendFlagEscape(std::string& flags,
|
|
|
|
const char* rawFlag)
|
|
|
|
{
|
|
|
|
this->AppendFlags(flags, this->EscapeForShell(rawFlag).c_str());
|
|
|
|
}
|
|
|
|
|
2008-01-14 17:20:58 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2012-08-09 11:44:15 +04:00
|
|
|
void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
|
|
|
|
const char* defines_list)
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
|
|
|
// Short-circuit if there are no definitions.
|
|
|
|
if(!defines_list)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Expand the list of definitions.
|
|
|
|
std::vector<std::string> defines_vec;
|
|
|
|
cmSystemTools::ExpandListArgument(defines_list, defines_vec);
|
2013-06-06 20:17:10 +04:00
|
|
|
this->AppendDefines(defines, defines_vec);
|
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
|
2013-06-06 20:17:10 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
|
|
|
|
const std::vector<std::string> &defines_vec)
|
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
for(std::vector<std::string>::const_iterator di = defines_vec.begin();
|
|
|
|
di != defines_vec.end(); ++di)
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
// Skip unsupported definitions.
|
|
|
|
if(!this->CheckDefinition(*di))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
defines.insert(*di);
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2012-08-09 11:44:15 +04:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
|
2012-08-09 11:44:15 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
|
|
|
|
std::string &definesString,
|
|
|
|
const char* lang)
|
|
|
|
{
|
2008-01-17 18:00:19 +03:00
|
|
|
// Lookup the define flag for the current language.
|
|
|
|
std::string dflag = "-D";
|
|
|
|
if(lang)
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
2008-01-17 18:00:19 +03:00
|
|
|
std::string defineFlagVar = "CMAKE_";
|
|
|
|
defineFlagVar += lang;
|
|
|
|
defineFlagVar += "_DEFINE_FLAG";
|
|
|
|
const char* df = this->Makefile->GetDefinition(defineFlagVar.c_str());
|
|
|
|
if(df && *df)
|
|
|
|
{
|
|
|
|
dflag = df;
|
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
|
|
|
|
2012-08-09 11:44:15 +04:00
|
|
|
std::set<std::string>::const_iterator defineIt = defines.begin();
|
|
|
|
const std::set<std::string>::const_iterator defineEnd = defines.end();
|
|
|
|
const char* itemSeparator = definesString.empty() ? "" : " ";
|
|
|
|
for( ; defineIt != defineEnd; ++defineIt)
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
|
|
|
// Append the definition with proper escaping.
|
2012-08-09 11:44:15 +04:00
|
|
|
std::string def = dflag;
|
2008-01-14 17:20:58 +03:00
|
|
|
if(this->WatcomWMake)
|
|
|
|
{
|
|
|
|
// The Watcom compiler does its own command line parsing instead
|
|
|
|
// of using the windows shell rules. Definitions are one of
|
|
|
|
// -DNAME
|
|
|
|
// -DNAME=<cpp-token>
|
|
|
|
// -DNAME="c-string with spaces and other characters(?@#$)"
|
|
|
|
//
|
|
|
|
// Watcom will properly parse each of these cases from the
|
|
|
|
// command line without any escapes. However we still have to
|
|
|
|
// get the '$' and '#' characters through WMake as '$$' and
|
|
|
|
// '$#'.
|
2012-08-09 11:44:15 +04:00
|
|
|
for(const char* c = defineIt->c_str(); *c; ++c)
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
|
|
|
if(*c == '$' || *c == '#')
|
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
def += '$';
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2012-08-09 11:44:15 +04:00
|
|
|
def += *c;
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-24 19:18:06 +04:00
|
|
|
// Make the definition appear properly on the command line. Use
|
|
|
|
// -DNAME="value" instead of -D"NAME=value" to help VS6 parser.
|
2012-08-09 11:44:15 +04:00
|
|
|
std::string::size_type eq = defineIt->find("=");
|
|
|
|
def += defineIt->substr(0, eq);
|
|
|
|
if(eq != defineIt->npos)
|
2009-04-24 19:18:06 +04:00
|
|
|
{
|
2012-08-09 11:44:15 +04:00
|
|
|
def += "=";
|
|
|
|
def += this->EscapeForShell(defineIt->c_str() + eq + 1, true);
|
2009-04-24 19:18:06 +04:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2012-08-09 11:44:15 +04:00
|
|
|
definesString += itemSeparator;
|
|
|
|
itemSeparator = " ";
|
|
|
|
definesString += def;
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-02 21:52:01 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AppendFeatureOptions(
|
|
|
|
std::string& flags, const char* lang, const char* feature)
|
|
|
|
{
|
|
|
|
std::string optVar = "CMAKE_";
|
|
|
|
optVar += lang;
|
|
|
|
optVar += "_COMPILE_OPTIONS_";
|
|
|
|
optVar += feature;
|
|
|
|
if(const char* optionList = this->Makefile->GetDefinition(optVar.c_str()))
|
|
|
|
{
|
|
|
|
std::vector<std::string> options;
|
|
|
|
cmSystemTools::ExpandListArgument(optionList, options);
|
|
|
|
for(std::vector<std::string>::const_iterator oi = options.begin();
|
|
|
|
oi != options.end(); ++oi)
|
|
|
|
{
|
2013-06-27 19:49:06 +04:00
|
|
|
this->AppendFlagEscape(flags, oi->c_str());
|
2009-10-02 21:52:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-11 19:06:19 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmLocalGenerator::ConstructComment(const cmCustomCommand& cc,
|
|
|
|
const char* default_comment)
|
|
|
|
{
|
|
|
|
// Check for a comment provided with the command.
|
2006-09-29 00:40:35 +04:00
|
|
|
if(cc.GetComment())
|
2006-04-11 19:06:19 +04:00
|
|
|
{
|
|
|
|
return cc.GetComment();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct a reasonable default comment if possible.
|
|
|
|
if(!cc.GetOutputs().empty())
|
|
|
|
{
|
|
|
|
std::string comment;
|
|
|
|
comment = "Generating ";
|
|
|
|
const char* sep = "";
|
|
|
|
for(std::vector<std::string>::const_iterator o = cc.GetOutputs().begin();
|
|
|
|
o != cc.GetOutputs().end(); ++o)
|
|
|
|
{
|
|
|
|
comment += sep;
|
|
|
|
comment += this->Convert(o->c_str(), cmLocalGenerator::START_OUTPUT);
|
|
|
|
sep = ", ";
|
|
|
|
}
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise use the provided default.
|
|
|
|
return default_comment;
|
|
|
|
}
|
|
|
|
|
2005-02-25 00:04:54 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote)
|
2005-05-13 17:54:30 +04:00
|
|
|
{
|
|
|
|
return this->Convert(remote, START_OUTPUT, SHELL, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-10-09 23:30:07 +04:00
|
|
|
const char* cmLocalGenerator::GetRelativeRootPath(RelativeRoot relroot)
|
|
|
|
{
|
|
|
|
switch (relroot)
|
|
|
|
{
|
|
|
|
case HOME: return this->Makefile->GetHomeDirectory();
|
|
|
|
case START: return this->Makefile->GetStartDirectory();
|
|
|
|
case HOME_OUTPUT: return this->Makefile->GetHomeOutputDirectory();
|
|
|
|
case START_OUTPUT: return this->Makefile->GetStartOutputDirectory();
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmLocalGenerator::Convert(const char* source,
|
2005-05-13 17:54:30 +04:00
|
|
|
RelativeRoot relative,
|
|
|
|
OutputFormat output,
|
|
|
|
bool optional)
|
2005-02-25 00:04:54 +03:00
|
|
|
{
|
2007-03-08 16:38:40 +03:00
|
|
|
// Make sure the relative path conversion components are set.
|
|
|
|
if(!this->PathConversionsSetup)
|
|
|
|
{
|
|
|
|
this->SetupPathConversions();
|
|
|
|
this->PathConversionsSetup = true;
|
|
|
|
}
|
|
|
|
|
2005-02-25 00:04:54 +03:00
|
|
|
// Convert the path to a relative path.
|
2005-05-13 17:54:30 +04:00
|
|
|
std::string result = source;
|
2005-02-25 00:04:54 +03:00
|
|
|
|
2006-03-15 19:02:08 +03:00
|
|
|
if (!optional || this->UseRelativePaths)
|
2005-05-13 17:54:30 +04:00
|
|
|
{
|
|
|
|
switch (relative)
|
|
|
|
{
|
|
|
|
case HOME:
|
|
|
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
2007-03-07 23:15:46 +03:00
|
|
|
result = this->ConvertToRelativePath(this->HomeDirectoryComponents,
|
|
|
|
result.c_str());
|
2005-05-13 17:54:30 +04:00
|
|
|
break;
|
|
|
|
case START:
|
|
|
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
2007-03-07 23:15:46 +03:00
|
|
|
result = this->ConvertToRelativePath(this->StartDirectoryComponents,
|
|
|
|
result.c_str());
|
2005-05-13 17:54:30 +04:00
|
|
|
break;
|
|
|
|
case HOME_OUTPUT:
|
|
|
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
2007-03-07 23:15:46 +03:00
|
|
|
result =
|
|
|
|
this->ConvertToRelativePath(this->HomeOutputDirectoryComponents,
|
|
|
|
result.c_str());
|
2005-05-13 17:54:30 +04:00
|
|
|
break;
|
|
|
|
case START_OUTPUT:
|
|
|
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
2007-03-07 23:15:46 +03:00
|
|
|
result =
|
|
|
|
this->ConvertToRelativePath(this->StartOutputDirectoryComponents,
|
|
|
|
result.c_str());
|
2005-05-13 17:54:30 +04:00
|
|
|
break;
|
|
|
|
case FULL:
|
|
|
|
result = cmSystemTools::CollapseFullPath(result.c_str());
|
|
|
|
break;
|
2005-05-13 23:50:42 +04:00
|
|
|
case NONE:
|
|
|
|
break;
|
2005-05-13 17:54:30 +04:00
|
|
|
}
|
|
|
|
}
|
2008-10-09 23:30:07 +04:00
|
|
|
return this->ConvertToOutputFormat(result.c_str(), output);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmLocalGenerator::ConvertToOutputFormat(const char* source,
|
|
|
|
OutputFormat output)
|
|
|
|
{
|
|
|
|
std::string result = source;
|
|
|
|
// Convert it to an output path.
|
2005-12-23 00:42:36 +03:00
|
|
|
if (output == MAKEFILE)
|
2005-05-13 17:54:30 +04:00
|
|
|
{
|
|
|
|
result = cmSystemTools::ConvertToOutputPath(result.c_str());
|
|
|
|
}
|
2007-07-23 17:06:48 +04:00
|
|
|
else if( output == SHELL)
|
2005-12-23 00:42:36 +03:00
|
|
|
{
|
2007-02-28 22:29:26 +03:00
|
|
|
// For the MSYS shell convert drive letters to posix paths, so
|
2006-09-28 18:37:19 +04:00
|
|
|
// that c:/some/path becomes /c/some/path. This is needed to
|
|
|
|
// avoid problems with the shell path translation.
|
2008-01-30 05:16:49 +03:00
|
|
|
if(this->MSYSShell && !this->LinkScriptShell)
|
2006-09-28 18:37:19 +04:00
|
|
|
{
|
|
|
|
if(result.size() > 2 && result[1] == ':')
|
|
|
|
{
|
|
|
|
result[1] = result[0];
|
|
|
|
result[0] = '/';
|
|
|
|
}
|
|
|
|
}
|
2007-02-28 22:29:26 +03:00
|
|
|
if(this->WindowsShell)
|
2007-02-22 05:24:17 +03:00
|
|
|
{
|
2007-02-28 22:29:26 +03:00
|
|
|
std::string::size_type pos = 0;
|
|
|
|
while((pos = result.find('/', pos)) != std::string::npos)
|
|
|
|
{
|
|
|
|
result[pos] = '\\';
|
|
|
|
pos++;
|
|
|
|
}
|
2007-02-22 05:24:17 +03:00
|
|
|
}
|
2007-02-28 22:29:26 +03:00
|
|
|
result = this->EscapeForShell(result.c_str(), true, false);
|
2005-12-23 00:42:36 +03:00
|
|
|
}
|
2010-03-11 16:49:05 +03:00
|
|
|
else if(output == RESPONSE)
|
|
|
|
{
|
|
|
|
result = this->EscapeForShell(result.c_str(), false, false);
|
|
|
|
}
|
2005-05-13 17:54:30 +04:00
|
|
|
return result;
|
2005-02-25 00:04:54 +03:00
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
|
2008-10-09 23:30:07 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmLocalGenerator::Convert(RelativeRoot remote,
|
|
|
|
const char* local,
|
|
|
|
OutputFormat output,
|
|
|
|
bool optional)
|
|
|
|
{
|
|
|
|
const char* remotePath = this->GetRelativeRootPath(remote);
|
2009-02-26 16:49:10 +03:00
|
|
|
|
|
|
|
// The relative root must have a path (i.e. not FULL or NONE)
|
|
|
|
assert(remotePath != 0);
|
|
|
|
|
2008-10-09 23:30:07 +04:00
|
|
|
if(local && (!optional || this->UseRelativePaths))
|
|
|
|
{
|
|
|
|
std::vector<std::string> components;
|
2009-02-26 16:49:10 +03:00
|
|
|
cmSystemTools::SplitPath(local, components);
|
|
|
|
std::string result = this->ConvertToRelativePath(components, remotePath);
|
2008-10-09 23:30:07 +04:00
|
|
|
return this->ConvertToOutputFormat(result.c_str(), output);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this->ConvertToOutputFormat(remotePath, output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-07 23:15:46 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-03-08 01:32:35 +03:00
|
|
|
std::string cmLocalGenerator::FindRelativePathTopSource()
|
2007-03-07 23:15:46 +03:00
|
|
|
{
|
2007-03-08 01:32:35 +03:00
|
|
|
// Relative path conversion within a single tree managed by CMake is
|
|
|
|
// safe. We can use our parent relative path top if and only if
|
|
|
|
// this is a subdirectory of that top.
|
|
|
|
if(cmLocalGenerator* parent = this->GetParent())
|
2007-03-08 00:35:53 +03:00
|
|
|
{
|
2007-03-08 01:32:35 +03:00
|
|
|
std::string parentTop = parent->FindRelativePathTopSource();
|
2007-03-08 00:35:53 +03:00
|
|
|
if(cmSystemTools::IsSubDirectory(
|
2007-03-08 01:32:35 +03:00
|
|
|
this->Makefile->GetStartDirectory(), parentTop.c_str()))
|
2007-03-08 00:35:53 +03:00
|
|
|
{
|
2007-03-08 01:32:35 +03:00
|
|
|
return parentTop;
|
2007-03-08 00:35:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-08 01:32:35 +03:00
|
|
|
// Otherwise this directory itself is the new top.
|
|
|
|
return this->Makefile->GetStartDirectory();
|
|
|
|
}
|
2007-03-08 00:35:53 +03:00
|
|
|
|
2007-03-08 01:32:35 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmLocalGenerator::FindRelativePathTopBinary()
|
|
|
|
{
|
|
|
|
// Relative path conversion within a single tree managed by CMake is
|
|
|
|
// safe. We can use our parent relative path top if and only if
|
|
|
|
// this is a subdirectory of that top.
|
|
|
|
if(cmLocalGenerator* parent = this->GetParent())
|
2007-03-08 00:35:53 +03:00
|
|
|
{
|
2007-03-08 01:32:35 +03:00
|
|
|
std::string parentTop = parent->FindRelativePathTopBinary();
|
2007-03-08 00:35:53 +03:00
|
|
|
if(cmSystemTools::IsSubDirectory(
|
2007-03-08 01:32:35 +03:00
|
|
|
this->Makefile->GetStartOutputDirectory(), parentTop.c_str()))
|
2007-03-08 00:35:53 +03:00
|
|
|
{
|
2007-03-08 01:32:35 +03:00
|
|
|
return parentTop;
|
2007-03-08 00:35:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-08 01:32:35 +03:00
|
|
|
// Otherwise this directory itself is the new top.
|
|
|
|
return this->Makefile->GetStartOutputDirectory();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::ConfigureRelativePaths()
|
|
|
|
{
|
|
|
|
// Relative path conversion inside the source tree is not used to
|
|
|
|
// construct relative paths passed to build tools so it is safe to
|
|
|
|
// even when the source is a network path.
|
|
|
|
std::string source = this->FindRelativePathTopSource();
|
|
|
|
this->RelativePathTopSource = source;
|
|
|
|
|
2007-03-07 23:15:46 +03:00
|
|
|
// The current working directory on Windows cannot be a network
|
2007-03-08 00:35:53 +03:00
|
|
|
// path. Therefore relative paths cannot work when the binary tree
|
2007-03-07 23:15:46 +03:00
|
|
|
// is a network path.
|
2007-03-08 01:32:35 +03:00
|
|
|
std::string binary = this->FindRelativePathTopBinary();
|
2007-03-07 23:15:46 +03:00
|
|
|
if(binary.size() < 2 || binary.substr(0, 2) != "//")
|
|
|
|
{
|
|
|
|
this->RelativePathTopBinary = binary;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->RelativePathTopBinary = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-10 01:15:13 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static bool cmLocalGeneratorNotAbove(const char* a, const char* b)
|
|
|
|
{
|
|
|
|
return (cmSystemTools::ComparePath(a, b) ||
|
|
|
|
cmSystemTools::IsSubDirectory(a, b));
|
|
|
|
}
|
|
|
|
|
2007-03-07 23:15:46 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
2007-07-23 17:06:48 +04:00
|
|
|
cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
|
2009-09-23 00:16:56 +04:00
|
|
|
const char* in_remote, bool force)
|
2007-03-07 23:15:46 +03:00
|
|
|
{
|
|
|
|
// The path should never be quoted.
|
|
|
|
assert(in_remote[0] != '\"');
|
|
|
|
|
|
|
|
// The local path should never have a trailing slash.
|
|
|
|
assert(local.size() > 0 && !(local[local.size()-1] == ""));
|
|
|
|
|
|
|
|
// If the path is already relative then just return the path.
|
|
|
|
if(!cmSystemTools::FileIsFullPath(in_remote))
|
|
|
|
{
|
|
|
|
return in_remote;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure relative path conversion is configured.
|
|
|
|
if(!this->RelativePathsConfigured)
|
|
|
|
{
|
|
|
|
this->ConfigureRelativePaths();
|
|
|
|
this->RelativePathsConfigured = true;
|
|
|
|
}
|
|
|
|
|
2009-09-23 00:16:56 +04:00
|
|
|
if(!force)
|
2007-03-07 23:15:46 +03:00
|
|
|
{
|
2009-09-23 00:16:56 +04:00
|
|
|
// Skip conversion if the path and local are not both in the source
|
|
|
|
// or both in the binary tree.
|
|
|
|
std::string local_path = cmSystemTools::JoinPath(local);
|
|
|
|
if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
|
|
|
|
this->RelativePathTopBinary.c_str()) &&
|
|
|
|
cmLocalGeneratorNotAbove(in_remote,
|
|
|
|
this->RelativePathTopBinary.c_str())) ||
|
|
|
|
(cmLocalGeneratorNotAbove(local_path.c_str(),
|
|
|
|
this->RelativePathTopSource.c_str()) &&
|
|
|
|
cmLocalGeneratorNotAbove(in_remote,
|
|
|
|
this->RelativePathTopSource.c_str()))))
|
|
|
|
{
|
|
|
|
return in_remote;
|
|
|
|
}
|
2007-03-07 23:15:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Identify the longest shared path component between the remote
|
|
|
|
// path and the local path.
|
|
|
|
std::vector<std::string> remote;
|
|
|
|
cmSystemTools::SplitPath(in_remote, remote);
|
|
|
|
unsigned int common=0;
|
|
|
|
while(common < remote.size() &&
|
|
|
|
common < local.size() &&
|
|
|
|
cmSystemTools::ComparePath(remote[common].c_str(),
|
|
|
|
local[common].c_str()))
|
|
|
|
{
|
|
|
|
++common;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If no part of the path is in common then return the full path.
|
|
|
|
if(common == 0)
|
|
|
|
{
|
|
|
|
return in_remote;
|
|
|
|
}
|
|
|
|
|
2007-03-14 23:29:10 +03:00
|
|
|
// If the entire path is in common then just return a ".".
|
2007-03-07 23:15:46 +03:00
|
|
|
if(common == remote.size() &&
|
|
|
|
common == local.size())
|
|
|
|
{
|
2007-03-14 23:29:10 +03:00
|
|
|
return ".";
|
2007-03-07 23:15:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the entire path is in common except for a trailing slash then
|
|
|
|
// just return a "./".
|
|
|
|
if(common+1 == remote.size() &&
|
|
|
|
remote[common].size() == 0 &&
|
|
|
|
common == local.size())
|
|
|
|
{
|
|
|
|
return "./";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct the relative path.
|
|
|
|
std::string relative;
|
|
|
|
|
|
|
|
// First add enough ../ to get up to the level of the shared portion
|
|
|
|
// of the path. Leave off the trailing slash. Note that the last
|
|
|
|
// component of local will never be empty because local should never
|
|
|
|
// have a trailing slash.
|
|
|
|
for(unsigned int i=common; i < local.size(); ++i)
|
|
|
|
{
|
|
|
|
relative += "..";
|
|
|
|
if(i < local.size()-1)
|
|
|
|
{
|
|
|
|
relative += "/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now add the portion of the destination path that is not included
|
|
|
|
// in the shared portion of the path. Add a slash the first time
|
|
|
|
// only if there was already something in the path. If there was a
|
|
|
|
// trailing slash in the input then the last iteration of the loop
|
|
|
|
// will add a slash followed by an empty string which will preserve
|
|
|
|
// the trailing slash in the output.
|
|
|
|
for(unsigned int i=common; i < remote.size(); ++i)
|
|
|
|
{
|
|
|
|
if(relative.size() > 0)
|
|
|
|
{
|
|
|
|
relative += "/";
|
|
|
|
}
|
|
|
|
relative += remote[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally return the path.
|
|
|
|
return relative;
|
|
|
|
}
|
2007-02-26 19:56:13 +03:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmLocalGenerator
|
|
|
|
::GenerateTargetInstallRules(
|
|
|
|
std::ostream& os, const char* config,
|
|
|
|
std::vector<std::string> const& configurationTypes)
|
|
|
|
{
|
|
|
|
// Convert the old-style install specification from each target to
|
|
|
|
// an install generator and run it.
|
2006-03-15 19:02:08 +03:00
|
|
|
cmTargets& tgts = this->Makefile->GetTargets();
|
2006-02-19 23:25:27 +03:00
|
|
|
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
|
|
|
|
{
|
2013-11-20 15:44:04 +04:00
|
|
|
if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Include the user-specified pre-install script for this target.
|
|
|
|
if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT"))
|
|
|
|
{
|
2007-10-15 15:08:15 +04:00
|
|
|
cmInstallScriptGenerator g(preinstall, false, 0);
|
2006-02-19 23:25:27 +03:00
|
|
|
g.Generate(os, config, configurationTypes);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Install this target if a destination is given.
|
|
|
|
if(l->second.GetInstallPath() != "")
|
|
|
|
{
|
|
|
|
// Compute the full install destination. Note that converting
|
|
|
|
// to unix slashes also removes any trailing slash.
|
2008-01-28 16:38:36 +03:00
|
|
|
// We also skip over the leading slash given by the user.
|
|
|
|
std::string destination = l->second.GetInstallPath().substr(1);
|
2006-02-19 23:25:27 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(destination);
|
2009-02-04 18:34:10 +03:00
|
|
|
if(destination.empty())
|
|
|
|
{
|
|
|
|
destination = ".";
|
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
// Generate the proper install generator for this target type.
|
|
|
|
switch(l->second.GetType())
|
|
|
|
{
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
{
|
|
|
|
// Use a target install generator.
|
|
|
|
cmInstallTargetGenerator g(l->second, destination.c_str(), false);
|
|
|
|
g.Generate(os, config, configurationTypes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
{
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
// Special code to handle DLL. Install the import library
|
|
|
|
// to the normal destination and the DLL to the runtime
|
|
|
|
// destination.
|
|
|
|
cmInstallTargetGenerator g1(l->second, destination.c_str(), true);
|
|
|
|
g1.Generate(os, config, configurationTypes);
|
2008-01-28 16:38:36 +03:00
|
|
|
// We also skip over the leading slash given by the user.
|
|
|
|
destination = l->second.GetRuntimeInstallPath().substr(1);
|
2006-02-19 23:25:27 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(destination);
|
|
|
|
cmInstallTargetGenerator g2(l->second, destination.c_str(), false);
|
|
|
|
g2.Generate(os, config, configurationTypes);
|
|
|
|
#else
|
|
|
|
// Use a target install generator.
|
|
|
|
cmInstallTargetGenerator g(l->second, destination.c_str(), false);
|
|
|
|
g.Generate(os, config, configurationTypes);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Include the user-specified post-install script for this target.
|
|
|
|
if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT"))
|
|
|
|
{
|
2007-10-15 15:08:15 +04:00
|
|
|
cmInstallScriptGenerator g(postinstall, false, 0);
|
2006-02-19 23:25:27 +03:00
|
|
|
g.Generate(os, config, configurationTypes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
|
2007-03-16 17:34:25 +03:00
|
|
|
#if defined(CM_LG_ENCODE_OBJECT_NAMES)
|
|
|
|
static std::string cmLocalGeneratorMD5(const char* input)
|
|
|
|
{
|
|
|
|
char md5out[32];
|
|
|
|
cmsysMD5* md5 = cmsysMD5_New();
|
|
|
|
cmsysMD5_Initialize(md5);
|
|
|
|
cmsysMD5_Append(md5, reinterpret_cast<unsigned char const*>(input), -1);
|
|
|
|
cmsysMD5_FinalizeHex(md5, md5out);
|
|
|
|
cmsysMD5_Delete(md5);
|
|
|
|
return std::string(md5out, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
cmLocalGeneratorShortenObjectName(std::string& objName,
|
|
|
|
std::string::size_type max_len)
|
|
|
|
{
|
|
|
|
// Replace the beginning of the path portion of the object name with
|
|
|
|
// its own md5 sum.
|
|
|
|
std::string::size_type pos = objName.find('/', objName.size()-max_len+32);
|
|
|
|
if(pos != objName.npos)
|
|
|
|
{
|
|
|
|
std::string md5name = cmLocalGeneratorMD5(objName.substr(0, pos).c_str());
|
|
|
|
md5name += objName.substr(pos);
|
|
|
|
objName = md5name;
|
|
|
|
|
|
|
|
// The object name is now short enough.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The object name could not be shortened enough.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 17:54:36 +04:00
|
|
|
static
|
|
|
|
bool cmLocalGeneratorCheckObjectName(std::string& objName,
|
|
|
|
std::string::size_type dir_len,
|
|
|
|
std::string::size_type max_total_len)
|
2007-03-16 17:34:25 +03:00
|
|
|
{
|
|
|
|
// Enforce the maximum file name length if possible.
|
|
|
|
std::string::size_type max_obj_len = max_total_len;
|
|
|
|
if(dir_len < max_total_len)
|
|
|
|
{
|
|
|
|
max_obj_len = max_total_len - dir_len;
|
|
|
|
if(objName.size() > max_obj_len)
|
|
|
|
{
|
|
|
|
// The current object file name is too long. Try to shorten it.
|
|
|
|
return cmLocalGeneratorShortenObjectName(objName, max_obj_len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The object file name is short enough.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The build directory in which the object will be stored is
|
|
|
|
// already too deep.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-07-11 19:41:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-03-16 17:34:25 +03:00
|
|
|
std::string&
|
|
|
|
cmLocalGenerator
|
|
|
|
::CreateSafeUniqueObjectFileName(const char* sin,
|
2008-12-16 17:14:40 +03:00
|
|
|
std::string const& dir_max)
|
2006-07-11 19:41:38 +04:00
|
|
|
{
|
|
|
|
// Look for an existing mapped name for this object file.
|
|
|
|
std::map<cmStdString,cmStdString>::iterator it =
|
|
|
|
this->UniqueObjectNamesMap.find(sin);
|
|
|
|
|
|
|
|
// If no entry exists create one.
|
|
|
|
if(it == this->UniqueObjectNamesMap.end())
|
|
|
|
{
|
|
|
|
// Start with the original name.
|
|
|
|
std::string ssin = sin;
|
|
|
|
|
|
|
|
// Avoid full paths by removing leading slashes.
|
|
|
|
std::string::size_type pos = 0;
|
2008-07-22 21:32:43 +04:00
|
|
|
for(;pos < ssin.size() && ssin[pos] == '/'; ++pos)
|
|
|
|
{
|
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
ssin = ssin.substr(pos);
|
|
|
|
|
|
|
|
// Avoid full paths by removing colons.
|
|
|
|
cmSystemTools::ReplaceString(ssin, ":", "_");
|
|
|
|
|
|
|
|
// Avoid relative paths that go up the tree.
|
|
|
|
cmSystemTools::ReplaceString(ssin, "../", "__/");
|
|
|
|
|
|
|
|
// Avoid spaces.
|
|
|
|
cmSystemTools::ReplaceString(ssin, " ", "_");
|
|
|
|
|
|
|
|
// Mangle the name if necessary.
|
|
|
|
if(this->Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES"))
|
|
|
|
{
|
|
|
|
bool done;
|
|
|
|
int cc = 0;
|
|
|
|
char rpstr[100];
|
|
|
|
sprintf(rpstr, "_p_");
|
|
|
|
cmSystemTools::ReplaceString(ssin, "+", rpstr);
|
|
|
|
std::string sssin = sin;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
done = true;
|
|
|
|
for ( it = this->UniqueObjectNamesMap.begin();
|
|
|
|
it != this->UniqueObjectNamesMap.end();
|
|
|
|
++ it )
|
|
|
|
{
|
|
|
|
if ( it->second == ssin )
|
|
|
|
{
|
|
|
|
done = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( done )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sssin = ssin;
|
|
|
|
cmSystemTools::ReplaceString(ssin, "_p_", rpstr);
|
|
|
|
sprintf(rpstr, "_p%d_", cc++);
|
|
|
|
}
|
|
|
|
while ( !done );
|
|
|
|
}
|
|
|
|
|
2007-03-16 17:34:25 +03:00
|
|
|
#if defined(CM_LG_ENCODE_OBJECT_NAMES)
|
2008-12-16 17:15:18 +03:00
|
|
|
if(!cmLocalGeneratorCheckObjectName(ssin, dir_max.size(),
|
|
|
|
this->ObjectPathMax))
|
|
|
|
{
|
|
|
|
// Warn if this is the first time the path has been seen.
|
|
|
|
if(this->ObjectMaxPathViolations.insert(dir_max).second)
|
|
|
|
{
|
|
|
|
cmOStringStream m;
|
|
|
|
m << "The object file directory\n"
|
|
|
|
<< " " << dir_max << "\n"
|
|
|
|
<< "has " << dir_max.size() << " characters. "
|
|
|
|
<< "The maximum full path to an object file is "
|
|
|
|
<< this->ObjectPathMax << " characters "
|
|
|
|
<< "(see CMAKE_OBJECT_PATH_MAX). "
|
|
|
|
<< "Object file\n"
|
|
|
|
<< " " << ssin << "\n"
|
|
|
|
<< "cannot be safely placed under this directory. "
|
|
|
|
<< "The build may not work correctly.";
|
|
|
|
this->Makefile->IssueMessage(cmake::WARNING, m.str());
|
|
|
|
}
|
|
|
|
}
|
2007-03-16 17:34:25 +03:00
|
|
|
#else
|
2008-12-16 17:14:40 +03:00
|
|
|
(void)dir_max;
|
2007-03-16 17:34:25 +03:00
|
|
|
#endif
|
|
|
|
|
2006-07-11 19:41:38 +04:00
|
|
|
// Insert the newly mapped object file name.
|
|
|
|
std::map<cmStdString, cmStdString>::value_type e(sin, ssin);
|
|
|
|
it = this->UniqueObjectNamesMap.insert(e).first;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the map entry.
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
2007-03-16 17:34:25 +03:00
|
|
|
cmLocalGenerator
|
|
|
|
::GetObjectFileNameWithoutTarget(const cmSourceFile& source,
|
2008-12-16 17:14:40 +03:00
|
|
|
std::string const& dir_max,
|
2008-01-08 00:12:37 +03:00
|
|
|
bool* hasSourceExtension)
|
2006-07-11 19:41:38 +04:00
|
|
|
{
|
2007-03-08 01:39:16 +03:00
|
|
|
// Construct the object file name using the full path to the source
|
2007-03-09 18:30:07 +03:00
|
|
|
// file which is its only unique identification.
|
|
|
|
const char* fullPath = source.GetFullPath().c_str();
|
|
|
|
|
|
|
|
// Try referencing the source relative to the source tree.
|
|
|
|
std::string relFromSource = this->Convert(fullPath, START);
|
|
|
|
assert(!relFromSource.empty());
|
|
|
|
bool relSource = !cmSystemTools::FileIsFullPath(relFromSource.c_str());
|
|
|
|
bool subSource = relSource && relFromSource[0] != '.';
|
|
|
|
|
|
|
|
// Try referencing the source relative to the binary tree.
|
|
|
|
std::string relFromBinary = this->Convert(fullPath, START_OUTPUT);
|
|
|
|
assert(!relFromBinary.empty());
|
|
|
|
bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str());
|
|
|
|
bool subBinary = relBinary && relFromBinary[0] != '.';
|
|
|
|
|
|
|
|
// Select a nice-looking reference to the source file to construct
|
|
|
|
// the object file name.
|
|
|
|
std::string objectName;
|
|
|
|
if((relSource && !relBinary) || (subSource && !subBinary))
|
2006-07-11 19:41:38 +04:00
|
|
|
{
|
2007-03-09 18:30:07 +03:00
|
|
|
objectName = relFromSource;
|
|
|
|
}
|
|
|
|
else if((relBinary && !relSource) || (subBinary && !subSource))
|
|
|
|
{
|
|
|
|
objectName = relFromBinary;
|
2006-07-11 19:41:38 +04:00
|
|
|
}
|
2007-03-09 18:30:07 +03:00
|
|
|
else if(relFromBinary.length() < relFromSource.length())
|
|
|
|
{
|
|
|
|
objectName = relFromBinary;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
objectName = relFromSource;
|
|
|
|
}
|
|
|
|
|
2007-02-01 00:49:25 +03:00
|
|
|
// if it is still a full path check for the try compile case
|
|
|
|
// try compile never have in source sources, and should not
|
|
|
|
// have conflicting source file names in the same target
|
|
|
|
if(cmSystemTools::FileIsFullPath(objectName.c_str()))
|
|
|
|
{
|
|
|
|
if(this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile())
|
|
|
|
{
|
|
|
|
objectName = cmSystemTools::GetFilenameName(source.GetFullPath());
|
|
|
|
}
|
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
|
|
|
|
// Replace the original source file extension with the object file
|
|
|
|
// extension.
|
2008-01-08 00:12:37 +03:00
|
|
|
bool keptSourceExtension = true;
|
2007-06-18 19:59:23 +04:00
|
|
|
if(!source.GetPropertyAsBool("KEEP_EXTENSION"))
|
2006-07-11 19:41:38 +04:00
|
|
|
{
|
2008-01-08 00:12:37 +03:00
|
|
|
// Decide whether this language wants to replace the source
|
|
|
|
// extension with the object extension. For CMake 2.4
|
|
|
|
// compatibility do this by default.
|
2013-10-18 19:25:49 +04:00
|
|
|
bool replaceExt = this->NeedBackwardsCompatibility_2_4();
|
2008-01-08 00:12:37 +03:00
|
|
|
if(!replaceExt)
|
|
|
|
{
|
2012-06-20 16:02:00 +04:00
|
|
|
if(const char* lang = source.GetLanguage())
|
|
|
|
{
|
|
|
|
std::string repVar = "CMAKE_";
|
|
|
|
repVar += lang;
|
|
|
|
repVar += "_OUTPUT_EXTENSION_REPLACE";
|
|
|
|
replaceExt = this->Makefile->IsOn(repVar.c_str());
|
|
|
|
}
|
2008-01-08 00:12:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the source extension if it is to be replaced.
|
|
|
|
if(replaceExt)
|
2006-07-11 19:41:38 +04:00
|
|
|
{
|
2008-01-08 00:12:37 +03:00
|
|
|
keptSourceExtension = false;
|
2007-12-29 07:07:26 +03:00
|
|
|
std::string::size_type dot_pos = objectName.rfind(".");
|
|
|
|
if(dot_pos != std::string::npos)
|
|
|
|
{
|
|
|
|
objectName = objectName.substr(0, dot_pos);
|
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
// Store the new extension.
|
2006-07-11 19:41:38 +04:00
|
|
|
objectName +=
|
2007-06-18 19:59:23 +04:00
|
|
|
this->GlobalGenerator->GetLanguageOutputExtension(source);
|
2006-07-11 19:41:38 +04:00
|
|
|
}
|
2008-01-08 00:12:37 +03:00
|
|
|
if(hasSourceExtension)
|
|
|
|
{
|
|
|
|
*hasSourceExtension = keptSourceExtension;
|
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
|
|
|
|
// Convert to a safe name.
|
2008-12-16 17:14:40 +03:00
|
|
|
return this->CreateSafeUniqueObjectFileName(objectName.c_str(), dir_max);
|
2006-07-11 19:41:38 +04:00
|
|
|
}
|
2006-08-03 17:26:07 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char*
|
|
|
|
cmLocalGenerator
|
|
|
|
::GetSourceFileLanguage(const cmSourceFile& source)
|
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
return source.GetLanguage();
|
2006-08-03 17:26:07 +04:00
|
|
|
}
|
2006-09-21 23:14:06 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-09-27 21:43:46 +04:00
|
|
|
std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str)
|
2006-09-21 23:14:06 +04:00
|
|
|
{
|
|
|
|
std::string result;
|
2010-08-18 18:26:05 +04:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
// if there are spaces
|
|
|
|
std::string temp = str;
|
|
|
|
if (temp.find(" ") != std::string::npos &&
|
|
|
|
temp.find("\"")==std::string::npos)
|
2006-09-25 18:22:48 +04:00
|
|
|
{
|
2010-08-18 18:26:05 +04:00
|
|
|
result = "\"";
|
|
|
|
result += str;
|
|
|
|
result += "\"";
|
|
|
|
return result;
|
2006-09-25 18:22:48 +04:00
|
|
|
}
|
2010-08-18 18:26:05 +04:00
|
|
|
return str;
|
|
|
|
#else
|
|
|
|
for(const char* ch = str; *ch != '\0'; ++ch)
|
2006-09-25 18:22:48 +04:00
|
|
|
{
|
2010-08-18 18:26:05 +04:00
|
|
|
if(*ch == ' ')
|
|
|
|
{
|
|
|
|
result += '\\';
|
|
|
|
}
|
|
|
|
result += *ch;
|
2006-09-25 18:22:48 +04:00
|
|
|
}
|
2006-09-27 21:43:46 +04:00
|
|
|
return result;
|
2010-08-18 18:26:05 +04:00
|
|
|
#endif
|
2006-09-27 21:43:46 +04:00
|
|
|
}
|
|
|
|
|
2008-04-29 23:34:49 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static bool cmLocalGeneratorIsShellOperator(const char* str)
|
|
|
|
{
|
|
|
|
if(strcmp(str, "<") == 0 ||
|
|
|
|
strcmp(str, ">") == 0 ||
|
|
|
|
strcmp(str, "<<") == 0 ||
|
|
|
|
strcmp(str, ">>") == 0 ||
|
|
|
|
strcmp(str, "|") == 0 ||
|
2009-03-17 22:11:33 +03:00
|
|
|
strcmp(str, "||") == 0 ||
|
|
|
|
strcmp(str, "&&") == 0 ||
|
2008-04-29 23:34:49 +04:00
|
|
|
strcmp(str, "&>") == 0 ||
|
2009-03-17 22:11:33 +03:00
|
|
|
strcmp(str, "1>") == 0 ||
|
|
|
|
strcmp(str, "2>") == 0 ||
|
2008-04-29 23:34:49 +04:00
|
|
|
strcmp(str, "2>&1") == 0 ||
|
|
|
|
strcmp(str, "1>&2") == 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-09-27 21:43:46 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2006-10-05 02:52:29 +04:00
|
|
|
std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
|
|
|
|
bool forEcho)
|
2006-09-27 21:43:46 +04:00
|
|
|
{
|
2008-04-29 23:34:49 +04:00
|
|
|
// Do not escape shell operators.
|
|
|
|
if(cmLocalGeneratorIsShellOperator(str))
|
|
|
|
{
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2006-09-27 21:43:46 +04:00
|
|
|
// Compute the flags for the target shell environment.
|
|
|
|
int flags = 0;
|
|
|
|
if(this->WindowsVSIDE)
|
|
|
|
{
|
|
|
|
flags |= cmsysSystem_Shell_Flag_VSIDE;
|
|
|
|
}
|
2008-08-05 17:55:02 +04:00
|
|
|
else if(!this->LinkScriptShell)
|
2006-09-27 21:43:46 +04:00
|
|
|
{
|
|
|
|
flags |= cmsysSystem_Shell_Flag_Make;
|
|
|
|
}
|
|
|
|
if(makeVars)
|
|
|
|
{
|
|
|
|
flags |= cmsysSystem_Shell_Flag_AllowMakeVariables;
|
|
|
|
}
|
2006-10-05 02:52:29 +04:00
|
|
|
if(forEcho)
|
|
|
|
{
|
|
|
|
flags |= cmsysSystem_Shell_Flag_EchoWindows;
|
|
|
|
}
|
2006-10-25 19:23:04 +04:00
|
|
|
if(this->WatcomWMake)
|
|
|
|
{
|
|
|
|
flags |= cmsysSystem_Shell_Flag_WatcomWMake;
|
|
|
|
}
|
2007-05-17 18:53:18 +04:00
|
|
|
if(this->MinGWMake)
|
|
|
|
{
|
|
|
|
flags |= cmsysSystem_Shell_Flag_MinGWMake;
|
|
|
|
}
|
2008-01-14 00:36:20 +03:00
|
|
|
if(this->NMake)
|
|
|
|
{
|
|
|
|
flags |= cmsysSystem_Shell_Flag_NMake;
|
|
|
|
}
|
2006-09-27 21:43:46 +04:00
|
|
|
|
|
|
|
// Compute the buffer size needed.
|
|
|
|
int size = (this->WindowsShell ?
|
|
|
|
cmsysSystem_Shell_GetArgumentSizeForWindows(str, flags) :
|
|
|
|
cmsysSystem_Shell_GetArgumentSizeForUnix(str, flags));
|
|
|
|
|
|
|
|
// Compute the shell argument itself.
|
|
|
|
std::vector<char> arg(size);
|
2006-09-21 23:14:06 +04:00
|
|
|
if(this->WindowsShell)
|
|
|
|
{
|
2006-09-27 21:43:46 +04:00
|
|
|
cmsysSystem_Shell_GetArgumentForWindows(str, &arg[0], flags);
|
2006-09-21 23:14:06 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-27 21:43:46 +04:00
|
|
|
cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags);
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2006-09-27 21:43:46 +04:00
|
|
|
return std::string(&arg[0]);
|
2006-09-21 23:14:06 +04:00
|
|
|
}
|
2007-08-01 23:25:40 +04:00
|
|
|
|
2008-01-18 03:58:01 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmLocalGenerator::EscapeForCMake(const char* str)
|
|
|
|
{
|
|
|
|
// Always double-quote the argument to take care of most escapes.
|
|
|
|
std::string result = "\"";
|
|
|
|
for(const char* c = str; *c; ++c)
|
|
|
|
{
|
|
|
|
if(*c == '"')
|
|
|
|
{
|
|
|
|
// Escape the double quote to avoid ending the argument.
|
|
|
|
result += "\\\"";
|
|
|
|
}
|
|
|
|
else if(*c == '$')
|
|
|
|
{
|
|
|
|
// Escape the dollar to avoid expanding variables.
|
|
|
|
result += "\\$";
|
|
|
|
}
|
|
|
|
else if(*c == '\\')
|
|
|
|
{
|
|
|
|
// Escape the backslash to avoid other escapes.
|
|
|
|
result += "\\\\";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Other characters will be parsed correctly.
|
|
|
|
result += *c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result += "\"";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-08-31 18:24:43 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmLocalGenerator::FortranFormat
|
|
|
|
cmLocalGenerator::GetFortranFormat(const char* value)
|
|
|
|
{
|
|
|
|
FortranFormat format = FortranFormatNone;
|
|
|
|
if(value && *value)
|
|
|
|
{
|
|
|
|
std::vector<std::string> fmt;
|
|
|
|
cmSystemTools::ExpandListArgument(value, fmt);
|
|
|
|
for(std::vector<std::string>::iterator fi = fmt.begin();
|
|
|
|
fi != fmt.end(); ++fi)
|
|
|
|
{
|
|
|
|
if(*fi == "FIXED")
|
|
|
|
{
|
|
|
|
format = FortranFormatFixed;
|
|
|
|
}
|
|
|
|
if(*fi == "FREE")
|
|
|
|
{
|
|
|
|
format = FortranFormatFree;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2007-08-01 23:25:40 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmLocalGenerator::GetTargetDirectory(cmTarget const&) const
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("GetTargetDirectory"
|
|
|
|
" called on cmLocalGenerator");
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2007-12-29 07:07:14 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
unsigned int cmLocalGenerator::GetBackwardsCompatibility()
|
|
|
|
{
|
|
|
|
// The computed version may change until the project is fully
|
|
|
|
// configured.
|
|
|
|
if(!this->BackwardsCompatibilityFinal)
|
|
|
|
{
|
|
|
|
unsigned int major = 0;
|
|
|
|
unsigned int minor = 0;
|
|
|
|
unsigned int patch = 0;
|
|
|
|
if(const char* value
|
|
|
|
= this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"))
|
|
|
|
{
|
|
|
|
switch(sscanf(value, "%u.%u.%u", &major, &minor, &patch))
|
|
|
|
{
|
|
|
|
case 2: patch = 0; break;
|
|
|
|
case 1: minor = 0; patch = 0; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->BackwardsCompatibility = CMake_VERSION_ENCODE(major, minor, patch);
|
|
|
|
this->BackwardsCompatibilityFinal = this->Configured;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->BackwardsCompatibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2013-10-18 19:25:49 +04:00
|
|
|
bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
|
2007-12-29 07:07:14 +03:00
|
|
|
{
|
2008-03-07 23:30:35 +03:00
|
|
|
// Check the policy to decide whether to pay attention to this
|
|
|
|
// variable.
|
2008-03-13 18:38:46 +03:00
|
|
|
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0001))
|
2008-03-07 23:30:35 +03:00
|
|
|
{
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
// WARN is just OLD without warning because user code does not
|
|
|
|
// always affect whether this check is done.
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
// Old behavior is to check the variable.
|
|
|
|
break;
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// New behavior is to ignore the variable.
|
|
|
|
return false;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
// This will never be the case because the only way to require
|
|
|
|
// the setting is to require the user to specify version policy
|
|
|
|
// 2.6 or higher. Once we add that requirement then this whole
|
|
|
|
// method can be removed anyway.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-29 07:07:14 +03:00
|
|
|
// Compatibility is needed if CMAKE_BACKWARDS_COMPATIBILITY is set
|
|
|
|
// equal to or lower than the given version.
|
|
|
|
unsigned int actual_compat = this->GetBackwardsCompatibility();
|
|
|
|
return (actual_compat &&
|
2013-10-18 19:25:49 +04:00
|
|
|
actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
|
2007-12-29 07:07:14 +03:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmLocalGenerator::CheckDefinition(std::string const& define) const
|
|
|
|
{
|
|
|
|
// Many compilers do not support -DNAME(arg)=sdf so we disable it.
|
|
|
|
bool function_style = false;
|
|
|
|
for(const char* c = define.c_str(); *c && *c != '='; ++c)
|
|
|
|
{
|
|
|
|
if(*c == '(')
|
|
|
|
{
|
|
|
|
function_style = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(function_style)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "WARNING: Function-style preprocessor definitions may not be "
|
|
|
|
<< "passed on the compiler command line because many compilers "
|
|
|
|
<< "do not support it.\n"
|
|
|
|
<< "CMake is dropping a preprocessor definition: " << define << "\n"
|
|
|
|
<< "Consider defining the macro in a (configured) header file.\n";
|
|
|
|
cmSystemTools::Message(e.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Many compilers do not support # in the value so we disable it.
|
|
|
|
if(define.find_first_of("#") != define.npos)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
2010-07-02 18:58:00 +04:00
|
|
|
e << "WARNING: Preprocessor definitions containing '#' may not be "
|
2008-01-14 17:20:58 +03:00
|
|
|
<< "passed on the compiler command line because many compilers "
|
|
|
|
<< "do not support it.\n"
|
|
|
|
<< "CMake is dropping a preprocessor definition: " << define << "\n"
|
|
|
|
<< "Consider defining the macro in a (configured) header file.\n";
|
|
|
|
cmSystemTools::Message(e.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assume it is supported.
|
|
|
|
return true;
|
|
|
|
}
|
2008-02-14 23:31:08 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-05-17 20:53:56 +04:00
|
|
|
static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop)
|
2008-02-14 23:31:08 +03:00
|
|
|
{
|
|
|
|
if(const char* val = target->GetProperty(prop))
|
|
|
|
{
|
2008-05-17 20:53:56 +04:00
|
|
|
mf->AddDefinition(prop, val);
|
2008-02-14 23:31:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
|
|
|
|
const char* targetName,
|
|
|
|
const char* fname)
|
|
|
|
{
|
2008-05-17 20:53:56 +04:00
|
|
|
// Find the Info.plist template.
|
|
|
|
const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
|
|
|
|
std::string inFile = (in && *in)? in : "MacOSXBundleInfo.plist.in";
|
|
|
|
if(!cmSystemTools::FileIsFullPath(inFile.c_str()))
|
|
|
|
{
|
|
|
|
std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
|
|
|
|
if(!inMod.empty())
|
|
|
|
{
|
|
|
|
inFile = inMod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!cmSystemTools::FileExists(inFile.c_str(), true))
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Target " << target->GetName() << " Info.plist template \""
|
|
|
|
<< inFile << "\" could not be found.";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert target properties to variables in an isolated makefile
|
|
|
|
// scope to configure the file. If properties are set they will
|
|
|
|
// override user make variables. If not the configuration will fall
|
|
|
|
// back to the directory-level values set by the user.
|
|
|
|
cmMakefile* mf = this->Makefile;
|
|
|
|
mf->PushScope();
|
|
|
|
mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName);
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_LONG_VERSION_STRING");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_NAME");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_SHORT_VERSION_STRING");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_VERSION");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_COPYRIGHT");
|
|
|
|
mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
|
|
|
|
mf->PopScope();
|
2008-02-14 23:31:08 +03:00
|
|
|
}
|
2008-09-02 20:06:32 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
|
|
|
|
const char* targetName,
|
|
|
|
const char* fname)
|
|
|
|
{
|
|
|
|
// Find the Info.plist template.
|
|
|
|
const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
|
|
|
|
std::string inFile = (in && *in)? in : "MacOSXFrameworkInfo.plist.in";
|
|
|
|
if(!cmSystemTools::FileIsFullPath(inFile.c_str()))
|
|
|
|
{
|
|
|
|
std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
|
|
|
|
if(!inMod.empty())
|
|
|
|
{
|
|
|
|
inFile = inMod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!cmSystemTools::FileExists(inFile.c_str(), true))
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Target " << target->GetName() << " Info.plist template \""
|
|
|
|
<< inFile << "\" could not be found.";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert target properties to variables in an isolated makefile
|
|
|
|
// scope to configure the file. If properties are set they will
|
|
|
|
// override user make variables. If not the configuration will fall
|
|
|
|
// back to the directory-level values set by the user.
|
|
|
|
cmMakefile* mf = this->Makefile;
|
|
|
|
mf->PushScope();
|
|
|
|
mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName);
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");
|
|
|
|
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION");
|
|
|
|
mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
|
|
|
|
mf->PopScope();
|
|
|
|
}
|