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"
|
2014-03-10 23:47:19 +04:00
|
|
|
#include "cmCustomCommandGenerator.h"
|
2009-03-05 23:17:07 +03:00
|
|
|
#include "cmVersion.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmake.h"
|
2015-03-08 15:51:20 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
2015-05-03 17:50:34 +03:00
|
|
|
cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
|
2015-05-24 12:50:55 +03:00
|
|
|
cmLocalGenerator* parent,
|
|
|
|
cmState::Snapshot snapshot)
|
2015-04-12 14:15:51 +03:00
|
|
|
: cmOutputConverter(snapshot), StateSnapshot(snapshot)
|
2002-08-31 00:00:35 +04:00
|
|
|
{
|
2015-05-24 12:50:55 +03:00
|
|
|
assert(snapshot.IsValid());
|
2015-05-03 17:50:34 +03:00
|
|
|
this->GlobalGenerator = gg;
|
2015-04-28 08:50:52 +03:00
|
|
|
this->Parent = parent;
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
parent->AddChild(this);
|
|
|
|
}
|
2015-05-24 14:00:20 +03:00
|
|
|
|
2015-05-03 17:50:34 +03:00
|
|
|
this->Makefile = new cmMakefile(this);
|
|
|
|
|
2006-03-24 17:15:05 +03:00
|
|
|
this->EmitUniversalBinaryFlags = true;
|
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
|
|
|
}
|
|
|
|
|
2015-06-13 20:32:46 +03:00
|
|
|
void cmLocalGenerator::IssueMessage(cmake::MessageType t,
|
|
|
|
std::string const& text) const
|
|
|
|
{
|
|
|
|
cmListFileContext lfc;
|
|
|
|
lfc.FilePath = this->StateSnapshot.GetCurrentSourceDirectory();
|
|
|
|
lfc.FilePath += "/CMakeLists.txt";
|
|
|
|
|
|
|
|
if(!this->GlobalGenerator->GetCMakeInstance()->GetIsInTryCompile())
|
|
|
|
{
|
|
|
|
cmOutputConverter converter(this->StateSnapshot);
|
|
|
|
lfc.FilePath = converter.Convert(lfc.FilePath, cmLocalGenerator::HOME);
|
|
|
|
}
|
|
|
|
lfc.Line = 0;
|
|
|
|
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(t, text, lfc);
|
|
|
|
}
|
|
|
|
|
2009-09-03 16:26:46 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream w;
|
2008-08-21 17:54:36 +04:00
|
|
|
w << "CMAKE_OBJECT_PATH_MAX is set to " << pmax
|
|
|
|
<< ", which is less than the minimum of 128. "
|
|
|
|
<< "The value will be ignored.";
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
2008-08-21 17:54:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream w;
|
2008-08-21 17:54:36 +04:00
|
|
|
w << "CMAKE_OBJECT_PATH_MAX is set to \"" << plen
|
|
|
|
<< "\", which fails to parse as a positive integer. "
|
|
|
|
<< "The value will be ignored.";
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
2008-08-21 17:54:36 +04:00
|
|
|
}
|
|
|
|
}
|
2008-12-16 17:15:18 +03:00
|
|
|
this->ObjectMaxPathViolations.clear();
|
2005-07-27 17:49:37 +04:00
|
|
|
}
|
|
|
|
|
2007-05-09 16:25:45 +04:00
|
|
|
void cmLocalGenerator::TraceDependencies()
|
|
|
|
{
|
2014-11-05 01:24:54 +03:00
|
|
|
std::vector<std::string> configs;
|
|
|
|
this->Makefile->GetConfigurations(configs);
|
|
|
|
if (configs.empty())
|
|
|
|
{
|
|
|
|
configs.push_back("");
|
|
|
|
}
|
|
|
|
for(std::vector<std::string>::const_iterator ci = configs.begin();
|
|
|
|
ci != configs.end(); ++ci)
|
|
|
|
{
|
|
|
|
this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
|
|
|
|
}
|
2007-05-09 16:25:45 +04:00
|
|
|
// 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
|
|
|
{
|
2014-03-19 18:50:01 +04:00
|
|
|
if (t->second->Target->IsImported()
|
|
|
|
|| t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
|
2013-11-29 16:18:24 +04:00
|
|
|
{
|
|
|
|
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;
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config =
|
2010-09-08 22:54:49 +04:00
|
|
|
this->Makefile->GetConfigurations(configurationTypes, false);
|
2009-03-16 17:40:46 +03:00
|
|
|
|
2015-05-03 18:19:16 +03:00
|
|
|
std::string file = this->StateSnapshot.GetCurrentBinaryDirectory();
|
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: "
|
2015-05-03 18:19:16 +03:00
|
|
|
<< this->StateSnapshot.GetCurrentSourceDirectory() << std::endl
|
2011-11-29 17:58:45 +04:00
|
|
|
<< "# Build directory: "
|
2015-05-03 18:19:16 +03:00
|
|
|
<< this->StateSnapshot.GetCurrentBinaryDirectory() << std::endl
|
2006-05-12 19:56:09 +04:00
|
|
|
<< "# " << 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
|
|
|
}
|
2015-01-16 01:39:38 +03:00
|
|
|
if (!this->Children.empty())
|
2005-04-24 23:59:51 +04:00
|
|
|
{
|
|
|
|
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 =
|
2015-04-16 21:06:54 +03:00
|
|
|
this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory();
|
2014-03-11 03:04:11 +04:00
|
|
|
fout << this->Convert(outP,START_OUTPUT);
|
2008-01-18 18:25:25 +03:00
|
|
|
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;
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config =
|
2010-09-08 22:54:49 +04:00
|
|
|
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.
|
2015-02-03 21:01:03 +03:00
|
|
|
std::string default_config = config;
|
2006-05-05 22:57:19 +04:00
|
|
|
const char* default_order[] = {"RELEASE", "MINSIZEREL",
|
|
|
|
"RELWITHDEBINFO", "DEBUG", 0};
|
2015-02-03 21:01:03 +03:00
|
|
|
for(const char** c = default_order; *c && default_config.empty(); ++c)
|
2006-05-05 22:57:19 +04:00
|
|
|
{
|
|
|
|
for(std::vector<std::string>::iterator i = configurationTypes.begin();
|
|
|
|
i != configurationTypes.end(); ++i)
|
|
|
|
{
|
|
|
|
if(cmSystemTools::UpperCase(*i) == *c)
|
|
|
|
{
|
2015-02-03 21:01:03 +03:00
|
|
|
default_config = *i;
|
2006-05-05 22:57:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-03 21:01:03 +03:00
|
|
|
if(default_config.empty() && !configurationTypes.empty())
|
2006-05-05 22:57:19 +04:00
|
|
|
{
|
2015-02-03 21:01:03 +03:00
|
|
|
default_config = configurationTypes[0];
|
2006-05-05 22:57:19 +04:00
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Create the install script file.
|
2015-05-03 18:19:16 +03:00
|
|
|
std::string file = this->StateSnapshot.GetCurrentBinaryDirectory();
|
|
|
|
std::string homedir = this->GetState()->GetBinaryDirectory();
|
2004-03-29 02:59:46 +04:00
|
|
|
int toplevel_install = 0;
|
2015-05-16 09:03:04 +03:00
|
|
|
if (file == homedir)
|
2004-03-29 02:59:46 +04:00
|
|
|
{
|
|
|
|
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: "
|
2015-05-03 18:19:16 +03:00
|
|
|
<< this->StateSnapshot.GetCurrentSourceDirectory()
|
2015-04-16 22:17:41 +03:00
|
|
|
<< std::endl << std::endl;
|
2006-03-15 19:02:08 +03:00
|
|
|
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
|
|
|
{
|
2015-04-16 21:06:54 +03:00
|
|
|
std::string odir = (*ci)->GetMakefile()->GetCurrentBinaryDirectory();
|
2006-04-11 21:32:48 +04:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(odir);
|
2014-03-11 16:35:32 +04:00
|
|
|
fout << " include(\"" << odir
|
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"
|
2015-02-26 22:18:04 +03:00
|
|
|
"endif()\n"
|
|
|
|
"\n"
|
|
|
|
"string(REPLACE \";\" \"\\n\" CMAKE_INSTALL_MANIFEST_CONTENT\n"
|
|
|
|
" \"${CMAKE_INSTALL_MANIFEST_FILES}\")\n"
|
|
|
|
"file(WRITE \"" << homedir << "/${CMAKE_INSTALL_MANIFEST}\"\n"
|
|
|
|
" \"${CMAKE_INSTALL_MANIFEST_CONTENT}\")\n";
|
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);
|
2014-03-27 12:46:58 +04:00
|
|
|
if(configNames.empty())
|
|
|
|
{
|
|
|
|
configNames.push_back("");
|
|
|
|
}
|
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;
|
|
|
|
}
|
2014-03-27 12:46:58 +04:00
|
|
|
for(std::vector<std::string>::iterator ci = configNames.begin();
|
|
|
|
ci != configNames.end(); ++ci)
|
2006-04-04 19:48:19 +04:00
|
|
|
{
|
2014-03-27 12:46:58 +04:00
|
|
|
const char* config = ci->c_str();
|
|
|
|
target.GenerateTargetManifest(config);
|
2006-04-04 19:48:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-03 17:51:51 +03:00
|
|
|
cmState* cmLocalGenerator::GetState() const
|
|
|
|
{
|
|
|
|
return this->GlobalGenerator->GetCMakeInstance()->GetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const
|
|
|
|
{
|
|
|
|
return this->StateSnapshot;
|
|
|
|
}
|
|
|
|
|
2011-11-29 17:58:45 +04:00
|
|
|
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang,
|
2012-09-16 03:16:43 +04:00
|
|
|
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));
|
2014-03-11 03:04:11 +04:00
|
|
|
objectDir = this->Convert(objectDir,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 =
|
2015-06-01 21:23:11 +03:00
|
|
|
this->ConvertToOutputFormat(source.GetFullPath(), SHELL);
|
2004-10-21 22:34:02 +04:00
|
|
|
std::string varString = "CMAKE_";
|
|
|
|
varString += lang;
|
|
|
|
varString += "_COMPILE_OBJECT";
|
|
|
|
std::vector<std::string> rules;
|
2014-03-11 03:04:11 +04:00
|
|
|
rules.push_back(this->Makefile->GetRequiredDefinition(varString));
|
2004-10-21 22:34:02 +04:00
|
|
|
varString = "CMAKE_";
|
|
|
|
varString += lang;
|
|
|
|
varString += "_FLAGS";
|
|
|
|
std::string flags;
|
2014-03-11 03:04:11 +04:00
|
|
|
flags += this->Makefile->GetSafeDefinition(varString);
|
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;
|
2014-02-04 06:20:56 +04:00
|
|
|
vars.Language = lang.c_str();
|
2006-02-20 21:42:18 +03:00
|
|
|
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;
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
|
2014-11-22 13:00:45 +03:00
|
|
|
commandLine.insert(commandLine.end(), cmd.begin(), cmd.end());
|
2006-04-11 22:53:57 +04:00
|
|
|
|
|
|
|
// 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,
|
2014-03-11 03:04:11 +04:00
|
|
|
source.GetFullPath(),
|
2006-04-11 22:53:57 +04:00
|
|
|
commandLines,
|
|
|
|
comment.c_str(),
|
2015-05-03 18:19:16 +03:00
|
|
|
this->StateSnapshot.GetCurrentBinaryDirectory()
|
2006-04-11 22:53:57 +04:00
|
|
|
);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2014-02-04 06:20:56 +04:00
|
|
|
void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
|
2012-09-16 03:16:43 +04:00
|
|
|
cmGeneratorTarget& target)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string objs;
|
2004-10-21 22:34:02 +04:00
|
|
|
std::vector<std::string> objVector;
|
2014-05-21 17:38:24 +04:00
|
|
|
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
2004-10-21 22:34:02 +04:00
|
|
|
// Add all the sources outputs to the depends of the target
|
2013-07-14 20:22:57 +04:00
|
|
|
std::vector<cmSourceFile*> classes;
|
2014-05-21 17:38:24 +04:00
|
|
|
target.GetSourceFiles(classes, config);
|
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;
|
2015-05-03 18:19:16 +03:00
|
|
|
dir_max += this->StateSnapshot.GetCurrentBinaryDirectory();
|
2008-12-16 17:14:40 +03:00
|
|
|
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
|
|
|
{
|
2015-05-03 18:19:16 +03:00
|
|
|
std::string ofname = this->StateSnapshot.GetCurrentBinaryDirectory();
|
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);
|
2014-07-22 20:38:08 +04:00
|
|
|
objs += this->Convert(ofname,START_OUTPUT,SHELL);
|
2004-10-21 22:34:02 +04:00
|
|
|
objs += " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-21 17:38:24 +04:00
|
|
|
std::string createRule = target.GetCreateRuleVariable(llang, config);
|
2014-04-05 01:06:13 +04:00
|
|
|
bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
|
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,
|
2014-04-05 01:06:13 +04:00
|
|
|
&target, useWatcomQuote);
|
2012-09-26 16:38:15 +04:00
|
|
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
2006-02-20 21:42:18 +03:00
|
|
|
cmLocalGenerator::RuleVariables vars;
|
2014-02-04 06:20:56 +04:00
|
|
|
vars.Language = llang.c_str();
|
2006-02-20 21:42:18 +03:00
|
|
|
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;
|
2014-02-10 07:48:34 +04:00
|
|
|
this->AddLanguageFlags(langFlags, llang, "");
|
|
|
|
this->AddArchitectureFlags(langFlags, &target, llang, "");
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
rules.push_back(this->Makefile->GetRequiredDefinition(createRule));
|
2006-04-12 01:11:34 +04:00
|
|
|
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;
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
|
2014-11-22 13:00:45 +03:00
|
|
|
commandLine.insert(commandLine.end(), cmd.begin(), cmd.end());
|
2006-04-12 01:11:34 +04:00
|
|
|
|
|
|
|
// 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 ";
|
2014-03-11 03:04:11 +04:00
|
|
|
comment += this->Convert(targetFullPath, START_OUTPUT);
|
2006-04-12 01:11:34 +04:00
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
2014-03-11 03:04:11 +04:00
|
|
|
targetFullPath,
|
2006-04-12 01:11:34 +04:00
|
|
|
objVector,
|
2014-02-25 05:32:55 +04:00
|
|
|
"",
|
2006-04-12 01:11:34 +04:00
|
|
|
commandLines,
|
|
|
|
comment.c_str(),
|
2015-05-03 18:19:16 +03:00
|
|
|
this->StateSnapshot.GetCurrentBinaryDirectory()
|
2006-04-12 01:11:34 +04:00
|
|
|
);
|
2014-03-12 15:45:14 +04:00
|
|
|
this->Makefile->GetSource(targetFullPath);
|
|
|
|
target.Target->AddSource(targetFullPath);
|
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
|
2014-02-10 09:21:34 +04:00
|
|
|
::CreateCustomTargetsAndCommands(std::set<std::string> 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
|
|
|
{
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string llang = target.Target->GetLinkerLanguage();
|
|
|
|
if(llang.empty())
|
2004-10-27 18:53:01 +04:00
|
|
|
{
|
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: ",
|
2014-02-07 02:31:47 +04:00
|
|
|
target.Target->GetName().c_str());
|
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;
|
|
|
|
}
|
|
|
|
}
|
2014-06-05 16:57:17 +04:00
|
|
|
if(replaceValues.ObjectFileDir)
|
|
|
|
{
|
|
|
|
if(variable == "OBJECT_FILE_DIR")
|
|
|
|
{
|
|
|
|
return replaceValues.ObjectFileDir;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
2015-07-13 17:35:04 +03:00
|
|
|
if(replaceValues.Includes && variable == "INCLUDES")
|
|
|
|
{
|
|
|
|
return replaceValues.Includes;
|
|
|
|
}
|
2006-04-20 00:36:14 +04:00
|
|
|
if(replaceValues.TargetPDB )
|
|
|
|
{
|
|
|
|
if(variable == "TARGET_PDB")
|
|
|
|
{
|
|
|
|
return replaceValues.TargetPDB;
|
|
|
|
}
|
|
|
|
}
|
2014-02-24 23:15:21 +04:00
|
|
|
if(replaceValues.TargetCompilePDB)
|
|
|
|
{
|
|
|
|
if(variable == "TARGET_COMPILE_PDB")
|
|
|
|
{
|
|
|
|
return replaceValues.TargetCompilePDB;
|
|
|
|
}
|
|
|
|
}
|
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;
|
2015-01-16 01:04:33 +03:00
|
|
|
if(!targetQuoted.empty() && targetQuoted[0] != '\"')
|
2005-04-12 21:27:07 +04:00
|
|
|
{
|
|
|
|
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")
|
|
|
|
{
|
2015-05-20 16:10:52 +03:00
|
|
|
return this->Convert(cmSystemTools::GetCMakeCommand(), FULL, SHELL);
|
2008-03-01 17:08:34 +03:00
|
|
|
}
|
2015-05-20 00:14:18 +03:00
|
|
|
std::vector<std::string> enabledLanguages =
|
|
|
|
this->GetState()->GetEnabledLanguages();
|
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);
|
2014-03-11 03:04:11 +04:00
|
|
|
compilerArg1 = this->Makefile->GetDefinition(arg1);
|
2013-05-19 21:18:01 +04:00
|
|
|
compilerTarget
|
|
|
|
= this->Makefile->GetDefinition(
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string("CMAKE_") + lang + "_COMPILER_TARGET");
|
2013-05-19 21:18:01 +04:00
|
|
|
compilerOptionTarget
|
|
|
|
= this->Makefile->GetDefinition(
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILE_OPTIONS_TARGET");
|
2013-08-08 19:36:36 +04:00
|
|
|
compilerExternalToolchain
|
|
|
|
= this->Makefile->GetDefinition(
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILER_EXTERNAL_TOOLCHAIN");
|
2013-08-08 19:36:36 +04:00
|
|
|
compilerOptionExternalToolchain
|
|
|
|
= this->Makefile->GetDefinition(
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN");
|
2013-04-13 16:46:57 +04:00
|
|
|
compilerSysroot
|
|
|
|
= this->Makefile->GetDefinition("CMAKE_SYSROOT");
|
|
|
|
compilerOptionSysroot
|
|
|
|
= this->Makefile->GetDefinition(
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILE_OPTIONS_SYSROOT");
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetSafeDefinition(variable);
|
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)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string ret = this->ConvertToOutputForExisting(replace);
|
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
|
|
|
{
|
2013-09-03 00:27:32 +04:00
|
|
|
if(replaceValues.RuleLauncher)
|
|
|
|
{
|
|
|
|
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,
|
2013-09-03 00:27:32 +04:00
|
|
|
const std::string& prop)
|
2009-02-10 16:51:15 +03:00
|
|
|
{
|
|
|
|
if(target)
|
|
|
|
{
|
|
|
|
return target->GetProperty(prop);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this->Makefile->GetProperty(prop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
|
2013-09-03 00:27:32 +04:00
|
|
|
const std::string& prop)
|
2009-02-10 16:51:15 +03:00
|
|
|
{
|
|
|
|
if(const char* val = this->GetRuleLauncher(target, prop))
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream wrapped;
|
2009-02-10 16:51:15 +03:00
|
|
|
wrapped << val << " " << s;
|
|
|
|
s = wrapped.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-07 05:41:41 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
2014-03-04 22:04:02 +04:00
|
|
|
cmLocalGenerator::ConvertToIncludeReference(std::string const& path,
|
2014-10-10 17:57:07 +04:00
|
|
|
OutputFormat format,
|
|
|
|
bool forceFullPaths)
|
2011-09-07 05:41:41 +04:00
|
|
|
{
|
2014-10-10 17:57:07 +04:00
|
|
|
return this->ConvertToOutputForExisting(
|
|
|
|
path, forceFullPaths? FULL : START_OUTPUT, format);
|
2011-09-07 05:41:41 +04:00
|
|
|
}
|
|
|
|
|
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,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang,
|
2014-10-10 17:57:07 +04:00
|
|
|
bool forceFullPaths,
|
2014-02-04 06:20:56 +04:00
|
|
|
bool forResponseFile,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config)
|
2004-10-26 18:15:49 +04:00
|
|
|
{
|
2014-02-04 06:20:56 +04:00
|
|
|
if(lang.empty())
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2009-02-25 19:44:46 +03:00
|
|
|
|
2014-03-04 22:12:54 +04:00
|
|
|
OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream 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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetSafeDefinition(flagVar);
|
2004-10-26 18:15:49 +04:00
|
|
|
flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
|
|
|
|
flagVar += lang;
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* sep = this->Makefile->GetDefinition(flagVar);
|
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)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar);
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(fwSearchFlagVar);
|
2013-10-10 16:29:04 +04:00
|
|
|
|
2014-05-05 14:39:55 +04:00
|
|
|
std::string sysFwSearchFlagVar = "CMAKE_";
|
|
|
|
sysFwSearchFlagVar += lang;
|
|
|
|
sysFwSearchFlagVar += "_SYSTEM_FRAMEWORK_SEARCH_FLAG";
|
|
|
|
const char* sysFwSearchFlag =
|
|
|
|
this->Makefile->GetDefinition(sysFwSearchFlagVar);
|
|
|
|
|
2004-10-26 18:15:49 +04:00
|
|
|
bool flagUsed = false;
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> 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 += "/../";
|
2014-10-15 16:54:05 +04:00
|
|
|
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
|
2005-12-27 22:56:56 +03:00
|
|
|
if(emitted.insert(frameworkDir).second)
|
|
|
|
{
|
2014-05-05 14:39:55 +04:00
|
|
|
if (sysFwSearchFlag && target &&
|
|
|
|
target->IsSystemIncludeDirectory(*i, config))
|
|
|
|
{
|
|
|
|
includeFlags << sysFwSearchFlag;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
includeFlags << fwSearchFlag;
|
|
|
|
}
|
2015-06-01 21:23:11 +03:00
|
|
|
includeFlags << this->ConvertToOutputFormat(frameworkDir, shellFormat)
|
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 &&
|
2014-02-10 07:48:34 +04:00
|
|
|
target->IsSystemIncludeDirectory(*i, config))
|
2006-10-05 16:55:59 +04:00
|
|
|
{
|
|
|
|
includeFlags << sysIncludeFlag;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
includeFlags << includeFlag;
|
|
|
|
}
|
2004-10-26 18:15:49 +04:00
|
|
|
flagUsed = true;
|
|
|
|
}
|
2014-03-04 22:12:54 +04:00
|
|
|
std::string includePath =
|
2014-10-10 17:57:07 +04:00
|
|
|
this->ConvertToIncludeReference(*i, shellFormat, forceFullPaths);
|
2015-01-16 01:04:33 +03:00
|
|
|
if(quotePaths && !includePath.empty() && includePath[0] != '\"')
|
2006-01-23 21:50:23 +03:00
|
|
|
{
|
|
|
|
includeFlags << "\"";
|
|
|
|
}
|
|
|
|
includeFlags << includePath;
|
2015-01-16 01:04:33 +03:00
|
|
|
if(quotePaths && !includePath.empty() && includePath[0] != '\"')
|
2006-01-23 21:50:23 +03:00
|
|
|
{
|
|
|
|
includeFlags << "\"";
|
|
|
|
}
|
|
|
|
includeFlags << sep;
|
2004-10-26 18:15:49 +04:00
|
|
|
}
|
|
|
|
std::string flags = includeFlags.str();
|
|
|
|
// remove trailing separators
|
2015-01-15 02:06:11 +03:00
|
|
|
if((sep[0] != ' ') && !flags.empty() && 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,
|
2015-03-04 23:46:42 +03:00
|
|
|
const std::string& config,
|
|
|
|
const std::string& lang)
|
2013-06-06 20:13:35 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> targetDefines;
|
2015-03-04 23:46:42 +03:00
|
|
|
target->GetCompileDefinitions(targetDefines, config, lang);
|
2013-06-06 20:13:35 +04:00
|
|
|
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,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& lang, const std::string& config
|
2013-06-27 20:04:02 +04:00
|
|
|
)
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(langFlagRegexVar))
|
2013-06-27 20:04:02 +04:00
|
|
|
{
|
|
|
|
// 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);
|
|
|
|
}
|
2014-11-26 00:47:44 +03:00
|
|
|
target->GetCompileOptions(opts, config, lang);
|
2013-06-27 20:04:02 +04:00
|
|
|
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.
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlagEscape(flags, *i);
|
2013-06-27 20:04:02 +04:00
|
|
|
}
|
|
|
|
}
|
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;
|
2014-11-26 00:47:44 +03:00
|
|
|
target->GetCompileOptions(opts, config, lang);
|
2013-06-27 20:04:02 +04:00
|
|
|
for(std::vector<std::string>::const_iterator i = opts.begin();
|
|
|
|
i != opts.end(); ++i)
|
|
|
|
{
|
|
|
|
// COMPILE_OPTIONS are escaped.
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlagEscape(flags, *i);
|
2013-06-27 20:04:02 +04:00
|
|
|
}
|
2013-05-16 17:15:28 +04:00
|
|
|
}
|
2013-10-22 17:05:49 +04:00
|
|
|
std::vector<std::string> features;
|
2013-10-22 03:40:47 +04:00
|
|
|
target->GetCompileFeatures(features, config);
|
2013-10-22 17:05:49 +04:00
|
|
|
for(std::vector<std::string>::const_iterator it = features.begin();
|
|
|
|
it != features.end(); ++it)
|
2014-04-02 17:57:15 +04:00
|
|
|
{
|
2013-10-22 17:05:49 +04:00
|
|
|
if (!this->Makefile->AddRequiredTargetFeature(target, *it))
|
2014-04-02 17:57:15 +04:00
|
|
|
{
|
2013-10-22 17:05:49 +04:00
|
|
|
return;
|
2014-04-02 17:57:15 +04:00
|
|
|
}
|
|
|
|
}
|
2014-05-15 13:32:30 +04:00
|
|
|
|
|
|
|
for(std::map<std::string, std::string>::const_iterator it
|
|
|
|
= target->GetMaxLanguageStandards().begin();
|
|
|
|
it != target->GetMaxLanguageStandards().end(); ++it)
|
|
|
|
{
|
|
|
|
const char* standard = target->GetProperty(it->first + "_STANDARD");
|
|
|
|
if(!standard)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (this->Makefile->IsLaterStandard(it->first, standard, it->second))
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-05-15 13:32:30 +04:00
|
|
|
e << "The COMPILE_FEATURES property of target \""
|
|
|
|
<< target->GetName() << "\" was evaluated when computing the link "
|
|
|
|
"implementation, and the \"" << it->first << "_STANDARD\" was \""
|
|
|
|
<< it->second << "\" for that computation. Computing the "
|
|
|
|
"COMPILE_FEATURES based on the link implementation resulted in a "
|
|
|
|
"higher \"" << it->first << "_STANDARD\" \"" << standard << "\". "
|
|
|
|
"This is not permitted. The COMPILE_FEATURES may not both depend on "
|
|
|
|
"and be depended on by the link implementation." << std::endl;
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2014-05-15 13:32:30 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
this->AddCompilerRequirementFlag(flags, target, lang);
|
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,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config,
|
2012-12-08 00:24:28 +04:00
|
|
|
bool stripImplicitInclDirs
|
2015-06-06 13:57:19 +03:00
|
|
|
) const
|
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.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> emitted;
|
2006-02-18 19:51:23 +03:00
|
|
|
|
|
|
|
// Store the automatic include paths.
|
|
|
|
if(includeBinaryDir)
|
|
|
|
{
|
2011-12-04 19:45:39 +04:00
|
|
|
if(emitted.find(
|
2015-05-03 18:19:16 +03:00
|
|
|
this->StateSnapshot.GetCurrentBinaryDirectory()) == emitted.end())
|
2011-12-04 19:45:39 +04:00
|
|
|
{
|
2015-05-03 18:19:16 +03:00
|
|
|
dirs.push_back(this->StateSnapshot.GetCurrentBinaryDirectory());
|
|
|
|
emitted.insert(this->StateSnapshot.GetCurrentBinaryDirectory());
|
2011-12-04 19:45:39 +04:00
|
|
|
}
|
2006-02-18 19:51:23 +03:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
if(includeSourceDir)
|
|
|
|
{
|
2015-04-16 21:06:54 +03:00
|
|
|
if(emitted.find(
|
2015-05-03 18:19:16 +03:00
|
|
|
this->StateSnapshot.GetCurrentSourceDirectory()) == emitted.end())
|
2006-02-18 19:51:23 +03:00
|
|
|
{
|
2015-05-03 18:19:16 +03:00
|
|
|
dirs.push_back(this->StateSnapshot.GetCurrentSourceDirectory());
|
|
|
|
emitted.insert(this->StateSnapshot.GetCurrentSourceDirectory());
|
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";
|
2014-03-11 03:04:11 +04:00
|
|
|
if(const char* value = this->Makefile->GetDefinition(impDirVar))
|
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> 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
|
|
|
|
2015-03-04 23:53:15 +03:00
|
|
|
includes = target->GetIncludeDirectories(config, lang);
|
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"))
|
|
|
|
{
|
2015-05-03 18:19:16 +03:00
|
|
|
const char* topSourceDir = this->GetState()->GetSourceDirectory();
|
|
|
|
const char* topBinaryDir = this->GetState()->GetBinaryDirectory();
|
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.
|
2014-10-15 16:54:05 +04:00
|
|
|
if(cmSystemTools::ComparePath(*i, topSourceDir) ||
|
|
|
|
cmSystemTools::ComparePath(*i, topBinaryDir) ||
|
|
|
|
cmSystemTools::IsSubDirectory(*i, topSourceDir) ||
|
|
|
|
cmSystemTools::IsSubDirectory(*i, topBinaryDir))
|
2006-04-25 17:54:12 +04:00
|
|
|
{
|
|
|
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name));
|
2013-04-07 19:39:05 +04:00
|
|
|
}
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, target->GetProperty(name));
|
2013-07-10 21:11:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
2014-04-05 01:06:13 +04:00
|
|
|
cmGeneratorTarget* target,
|
|
|
|
bool useWatcomQuote)
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
linkFlags += this->Makefile->GetSafeDefinition(build);
|
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;
|
2014-02-13 20:25:00 +04:00
|
|
|
target->GetSourceFiles(sources, buildType);
|
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");
|
2014-03-11 03:04:11 +04:00
|
|
|
linkFlags += this->Convert(sf->GetFullPath(),
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
targetLinkFlags = target->GetProperty(configLinkFlags);
|
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,
|
2014-04-05 01:06:13 +04:00
|
|
|
*target, false, false, useWatcomQuote);
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
linkFlags += this->Makefile->GetSafeDefinition(build);
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2014-02-13 20:25:00 +04:00
|
|
|
std::string linkLanguage = target->Target->GetLinkerLanguage(buildType);
|
2014-02-04 06:20:56 +04:00
|
|
|
if(linkLanguage.empty())
|
2004-10-27 18:53:01 +04:00
|
|
|
{
|
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: ",
|
2014-02-07 02:31:47 +04:00
|
|
|
target->Target->GetName().c_str());
|
2004-10-27 18:53:01 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 07:48:34 +04:00
|
|
|
this->AddLanguageFlags(flags, linkLanguage, buildType);
|
2012-09-26 16:38:15 +04:00
|
|
|
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
|
2014-04-05 01:06:13 +04:00
|
|
|
*target, false, false, useWatcomQuote);
|
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");
|
2014-03-11 03:04:11 +04:00
|
|
|
linkFlags += this->Makefile->GetSafeDefinition(sFlagVar);
|
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 +=
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetSafeDefinition(exportFlagVar);
|
2011-11-11 23:11:38 +04:00
|
|
|
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;
|
2014-03-11 03:04:11 +04:00
|
|
|
targetLinkFlags = target->GetProperty(configLinkFlags);
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-04 22:06:29 +04:00
|
|
|
std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
|
|
|
|
OutputFormat format)
|
2008-01-23 21:03:03 +03:00
|
|
|
{
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2014-04-05 01:06:13 +04:00
|
|
|
// Work-ardound command line parsing limitations in MSVC 6.0
|
|
|
|
if(this->Makefile->IsOn("MSVC60"))
|
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.
|
2014-03-04 22:06:29 +04:00
|
|
|
return this->Convert(sp.c_str(), NONE, format);
|
2008-01-23 21:03:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Normal behavior.
|
2014-03-11 03:04:11 +04:00
|
|
|
return this->Convert(lib, START_OUTPUT, format);
|
2008-01-23 21:03:03 +03:00
|
|
|
}
|
|
|
|
|
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,
|
2014-03-04 22:20:04 +04:00
|
|
|
bool relink,
|
2014-04-05 01:06:13 +04:00
|
|
|
bool forResponseFile,
|
|
|
|
bool useWatcomQuote)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2014-04-05 01:06:13 +04:00
|
|
|
OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
|
|
|
|
((useWatcomQuote) ? WATCOMQUOTE : SHELL);
|
2014-03-04 22:20:04 +04:00
|
|
|
bool escapeAllowMakeVars = !forResponseFile;
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream fout;
|
2014-06-23 17:34:38 +04:00
|
|
|
std::string config = this->Makefile->GetSafeDefinition("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
|
|
|
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string 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 )
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar);
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(fwSearchFlagVar);
|
2013-10-10 16:29:04 +04:00
|
|
|
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;
|
2015-05-18 05:54:27 +03:00
|
|
|
frameworkPath += this->Convert(*fdi, NONE, shellFormat);
|
2013-10-10 16:29:04 +04:00
|
|
|
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)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string libpath = this->ConvertToOutputForExisting(*libDir,
|
2014-03-04 22:20:04 +04:00
|
|
|
START_OUTPUT,
|
|
|
|
shellFormat);
|
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)
|
|
|
|
{
|
2014-03-04 22:20:04 +04:00
|
|
|
linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
|
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
|
|
|
// 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")
|
2015-02-09 10:08:26 +03:00
|
|
|
std::vector<std::string> runtimeDirs;
|
|
|
|
cli.GetRPath(runtimeDirs, relink);
|
|
|
|
|
2008-01-29 23:07:33 +03:00
|
|
|
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();
|
2015-05-18 05:54:27 +03:00
|
|
|
rpath += this->Convert(*ri, NONE, shellFormat);
|
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();
|
2014-03-11 03:04:11 +04:00
|
|
|
fout << this->EscapeForShell(rpath, escapeAllowMakeVars);
|
2008-01-29 23:07:33 +03:00
|
|
|
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();
|
2014-03-11 03:04:11 +04:00
|
|
|
fout << this->EscapeForShell(rpath_link, escapeAllowMakeVars);
|
2008-02-01 16:56:00 +03:00
|
|
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(standardLibsVar))
|
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,
|
2015-03-30 05:56:21 +03:00
|
|
|
cmGeneratorTarget const* target,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config)
|
2009-10-21 21:00:49 +04:00
|
|
|
{
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(sysrootFlagVar);
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetDefinition(deploymentTargetFlagVar);
|
2014-02-04 06:20:56 +04:00
|
|
|
if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F'))
|
2012-09-21 16:53:42 +04:00
|
|
|
{
|
|
|
|
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 += " ";
|
2014-02-12 19:49:10 +04:00
|
|
|
flags += this->Convert(sysroot, NONE, SHELL);
|
2008-04-28 21:53:14 +04:00
|
|
|
}
|
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,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config)
|
2009-10-21 21:00:49 +04:00
|
|
|
{
|
|
|
|
// Add language-specific flags.
|
|
|
|
std::string flagsVar = "CMAKE_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_FLAGS";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddConfigVariableFlags(flags, flagsVar, config);
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2014-02-07 02:31:47 +04:00
|
|
|
bool cmLocalGenerator::GetRealDependency(const std::string& inName,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config,
|
2010-12-09 00:51:16 +03:00
|
|
|
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.
|
2014-01-16 02:56:38 +04:00
|
|
|
if(cmTarget* target = this->Makefile->FindTargetToUse(name))
|
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
|
2014-02-07 02:31:47 +04:00
|
|
|
if(cmSystemTools::FileIsFullPath(inName.c_str()))
|
2006-11-25 18:59:26 +03:00
|
|
|
{
|
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);
|
2014-10-15 16:54:05 +04:00
|
|
|
tLocation = cmSystemTools::CollapseFullPath(tLocation);
|
2009-09-25 21:23:19 +04:00
|
|
|
}
|
2006-11-25 18:59:26 +03:00
|
|
|
std::string depLocation = cmSystemTools::GetFilenamePath(
|
|
|
|
std::string(inName));
|
2014-10-15 16:54:05 +04:00
|
|
|
depLocation = cmSystemTools::CollapseFullPath(depLocation);
|
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.
|
2014-02-07 02:31:47 +04:00
|
|
|
if(cmSystemTools::FileIsFullPath(inName.c_str()))
|
2006-01-14 04:51:45 +03:00
|
|
|
{
|
|
|
|
// 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.
|
2015-05-03 18:19:16 +03:00
|
|
|
dep = this->StateSnapshot.GetCurrentSourceDirectory();
|
2010-12-09 00:51:16 +03:00
|
|
|
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,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang,
|
2006-02-24 19:13:31 +03:00
|
|
|
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";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-13 04:00:24 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::
|
2015-03-30 05:56:21 +03:00
|
|
|
AddCompilerRequirementFlag(std::string &flags, cmTarget const* target,
|
2013-10-13 04:00:24 +04:00
|
|
|
const std::string& lang)
|
|
|
|
{
|
|
|
|
if (lang.empty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-01-27 00:42:36 +03:00
|
|
|
const char* defaultStd
|
|
|
|
= this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
|
2015-02-05 01:26:11 +03:00
|
|
|
if (!defaultStd || !*defaultStd)
|
2015-01-27 00:42:36 +03:00
|
|
|
{
|
|
|
|
// This compiler has no notion of language standard levels.
|
|
|
|
return;
|
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
std::string stdProp = lang + "_STANDARD";
|
2014-03-28 19:09:35 +04:00
|
|
|
const char *standardProp = target->GetProperty(stdProp);
|
|
|
|
if (!standardProp)
|
2013-10-13 04:00:24 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string extProp = lang + "_EXTENSIONS";
|
2014-05-30 17:03:45 +04:00
|
|
|
std::string type = "EXTENSION";
|
|
|
|
bool ext = true;
|
|
|
|
if (const char* extPropValue = target->GetProperty(extProp))
|
|
|
|
{
|
|
|
|
if (cmSystemTools::IsOff(extPropValue))
|
|
|
|
{
|
|
|
|
ext = false;
|
|
|
|
type = "STANDARD";
|
|
|
|
}
|
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
|
2014-04-30 20:07:38 +04:00
|
|
|
if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED"))
|
2013-10-13 04:00:24 +04:00
|
|
|
{
|
2014-04-30 20:07:38 +04:00
|
|
|
std::string option_flag =
|
|
|
|
"CMAKE_" + lang + standardProp
|
|
|
|
+ "_" + type + "_COMPILE_OPTION";
|
|
|
|
|
|
|
|
const char *opt = target->GetMakefile()->GetDefinition(option_flag);
|
|
|
|
if (!opt)
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-04-30 20:07:38 +04:00
|
|
|
e << "Target \"" << target->GetName() << "\" requires the language "
|
|
|
|
"dialect \"" << lang << standardProp << "\" "
|
|
|
|
<< (ext ? "(with compiler extensions)" : "") << ", but CMake "
|
|
|
|
"does not know the compile flags to use to enable it.";
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2014-04-30 20:07:38 +04:00
|
|
|
}
|
2014-06-13 12:30:57 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
this->AppendFlagEscape(flags, opt);
|
|
|
|
}
|
2014-04-30 20:07:38 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-28 19:09:35 +04:00
|
|
|
static std::map<std::string, std::vector<std::string> > langStdMap;
|
|
|
|
if (langStdMap.empty())
|
2013-10-13 04:00:24 +04:00
|
|
|
{
|
2014-03-28 19:09:35 +04:00
|
|
|
// Maintain sorted order, most recent first.
|
2014-05-06 02:21:14 +04:00
|
|
|
langStdMap["CXX"].push_back("14");
|
2014-03-28 19:09:35 +04:00
|
|
|
langStdMap["CXX"].push_back("11");
|
|
|
|
langStdMap["CXX"].push_back("98");
|
2013-11-04 04:15:43 +04:00
|
|
|
|
|
|
|
langStdMap["C"].push_back("11");
|
|
|
|
langStdMap["C"].push_back("99");
|
|
|
|
langStdMap["C"].push_back("90");
|
2014-03-28 19:09:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string standard(standardProp);
|
|
|
|
|
|
|
|
std::vector<std::string>& stds = langStdMap[lang];
|
|
|
|
|
|
|
|
std::vector<std::string>::const_iterator stdIt =
|
|
|
|
std::find(stds.begin(), stds.end(), standard);
|
2015-02-28 00:48:39 +03:00
|
|
|
if (stdIt == stds.end())
|
|
|
|
{
|
|
|
|
std::string e =
|
|
|
|
lang + "_STANDARD is set to invalid value '" + standard + "'";
|
|
|
|
this->GetGlobalGenerator()->GetCMakeInstance()
|
|
|
|
->IssueMessage(cmake::FATAL_ERROR, e, target->GetBacktrace());
|
|
|
|
return;
|
|
|
|
}
|
2014-03-28 19:09:35 +04:00
|
|
|
|
2015-02-05 01:26:11 +03:00
|
|
|
std::vector<std::string>::const_iterator defaultStdIt =
|
|
|
|
std::find(stds.begin(), stds.end(), defaultStd);
|
|
|
|
if (defaultStdIt == stds.end())
|
2014-03-28 19:09:35 +04:00
|
|
|
{
|
2015-02-05 01:26:11 +03:00
|
|
|
std::string e =
|
|
|
|
"CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" +
|
|
|
|
std::string(defaultStd) + "'";
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::INTERNAL_ERROR, e);
|
2015-02-05 01:26:11 +03:00
|
|
|
return;
|
2014-03-28 19:09:35 +04:00
|
|
|
}
|
|
|
|
|
2015-02-04 21:14:00 +03:00
|
|
|
// Greater or equal because the standards are stored in
|
|
|
|
// backward chronological order.
|
|
|
|
if (stdIt >= defaultStdIt)
|
2014-03-28 19:09:35 +04:00
|
|
|
{
|
2015-02-04 21:14:00 +03:00
|
|
|
std::string option_flag =
|
|
|
|
"CMAKE_" + lang + *stdIt
|
|
|
|
+ "_" + type + "_COMPILE_OPTION";
|
|
|
|
|
|
|
|
const char *opt =
|
|
|
|
target->GetMakefile()->GetRequiredDefinition(option_flag);
|
|
|
|
this->AppendFlagEscape(flags, opt);
|
|
|
|
return;
|
2014-03-28 19:09:35 +04:00
|
|
|
}
|
|
|
|
|
2015-02-04 21:14:00 +03:00
|
|
|
for ( ; stdIt < defaultStdIt; ++stdIt)
|
2014-03-28 19:09:35 +04:00
|
|
|
{
|
|
|
|
std::string option_flag =
|
|
|
|
"CMAKE_" + lang + *stdIt
|
|
|
|
+ "_" + type + "_COMPILE_OPTION";
|
|
|
|
|
|
|
|
if (const char *opt = target->GetMakefile()->GetDefinition(option_flag))
|
|
|
|
{
|
2014-06-13 12:30:57 +04:00
|
|
|
this->AppendFlagEscape(flags, opt);
|
2014-03-28 19:09:35 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-30 05:56:21 +03:00
|
|
|
static void AddVisibilityCompileOption(std::string &flags,
|
|
|
|
cmTarget const* target,
|
2014-02-04 06:20:56 +04:00
|
|
|
cmLocalGenerator *lg,
|
2015-05-22 21:01:44 +03:00
|
|
|
const std::string& lang,
|
|
|
|
std::string* warnCMP0063)
|
2013-05-18 14:12:18 +04:00
|
|
|
{
|
|
|
|
std::string l(lang);
|
|
|
|
std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
|
2014-03-11 03:04:11 +04:00
|
|
|
const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
|
2013-05-18 14:12:18 +04:00
|
|
|
if (!opt)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string flagDefine = l + "_VISIBILITY_PRESET";
|
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
const char *prop = target->GetProperty(flagDefine);
|
2013-05-18 14:12:18 +04:00
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-05-22 21:01:44 +03:00
|
|
|
if (warnCMP0063)
|
|
|
|
{
|
|
|
|
*warnCMP0063 += " " + flagDefine + "\n";
|
|
|
|
return;
|
|
|
|
}
|
2013-05-18 14:12:18 +04:00
|
|
|
if (strcmp(prop, "hidden") != 0
|
|
|
|
&& strcmp(prop, "default") != 0
|
|
|
|
&& strcmp(prop, "protected") != 0
|
|
|
|
&& strcmp(prop, "internal") != 0 )
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2013-05-18 14:12:18 +04:00
|
|
|
e << "Target " << target->GetName() << " uses unsupported value \""
|
|
|
|
<< prop << "\" for " << flagDefine << ".";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string option = std::string(opt) + prop;
|
2014-05-02 00:07:26 +04:00
|
|
|
lg->AppendFlags(flags, option);
|
2013-05-23 17:32:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void AddInlineVisibilityCompileOption(std::string &flags,
|
2015-03-30 05:56:21 +03:00
|
|
|
cmTarget const* target,
|
2015-05-22 21:01:44 +03:00
|
|
|
cmLocalGenerator *lg,
|
|
|
|
std::string* warnCMP0063)
|
2013-05-23 17:32:17 +04:00
|
|
|
{
|
|
|
|
std::string compileOption
|
|
|
|
= "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
|
2014-03-11 03:04:11 +04:00
|
|
|
const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
|
2013-05-23 17:32:17 +04:00
|
|
|
if (!opt)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool prop = target->GetPropertyAsBool("VISIBILITY_INLINES_HIDDEN");
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-05-22 21:01:44 +03:00
|
|
|
if (warnCMP0063)
|
|
|
|
{
|
|
|
|
*warnCMP0063 += " VISIBILITY_INLINES_HIDDEN\n";
|
|
|
|
return;
|
|
|
|
}
|
2013-05-23 17:32:17 +04:00
|
|
|
lg->AppendFlags(flags, opt);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator
|
2015-03-30 05:56:21 +03:00
|
|
|
::AddVisibilityPresetFlags(std::string &flags, cmTarget const* target,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang)
|
2013-05-23 17:32:17 +04:00
|
|
|
{
|
2015-05-22 21:01:44 +03:00
|
|
|
if (lang.empty())
|
2013-05-23 17:32:17 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-22 21:01:44 +03:00
|
|
|
std::string warnCMP0063;
|
|
|
|
std::string *pWarnCMP0063 = 0;
|
|
|
|
if (target->GetType() != cmTarget::SHARED_LIBRARY &&
|
|
|
|
target->GetType() != cmTarget::MODULE_LIBRARY &&
|
|
|
|
!target->IsExecutableWithExports())
|
2013-05-23 17:32:17 +04:00
|
|
|
{
|
2015-05-22 21:01:44 +03:00
|
|
|
switch (target->GetPolicyStatusCMP0063())
|
|
|
|
{
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
return;
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
pWarnCMP0063 = &warnCMP0063;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-05-23 17:32:17 +04:00
|
|
|
}
|
2015-05-22 21:01:44 +03:00
|
|
|
|
|
|
|
AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063);
|
2014-01-31 19:09:06 +04:00
|
|
|
|
2014-02-04 06:20:56 +04:00
|
|
|
if(lang == "CXX")
|
2014-01-31 19:09:06 +04:00
|
|
|
{
|
2015-05-22 21:01:44 +03:00
|
|
|
AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!warnCMP0063.empty() &&
|
|
|
|
this->WarnCMP0063.insert(target).second)
|
|
|
|
{
|
|
|
|
std::ostringstream w;
|
|
|
|
w <<
|
|
|
|
cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n"
|
|
|
|
"Target \"" << target->GetName() << "\" of "
|
|
|
|
"type \"" << cmTarget::GetTargetTypeName(target->GetType()) << "\" "
|
|
|
|
"has the following visibility properties set for " << lang << ":\n" <<
|
|
|
|
warnCMP0063 <<
|
|
|
|
"For compatibility CMake is not honoring them for this target.";
|
|
|
|
target->GetMakefile()->GetCMakeInstance()
|
|
|
|
->IssueMessage(cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace());
|
2014-01-31 19:09:06 +04:00
|
|
|
}
|
2013-05-18 14:12:18 +04:00
|
|
|
}
|
|
|
|
|
2012-05-30 22:13:09 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2015-03-30 05:56:21 +03:00
|
|
|
void cmLocalGenerator::AddCMP0018Flags(std::string &flags,
|
|
|
|
cmTarget const* target,
|
2012-11-05 15:46:26 +04:00
|
|
|
std::string const& lang,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& 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))
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddSharedFlags(flags, lang, shared);
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFeatureOptions(flags, lang, "DLL");
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
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 =
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->GetSafeDefinition(flagsVar);
|
2012-05-30 22:13:09 +04:00
|
|
|
|
|
|
|
if (flags && flags != originalFlags)
|
|
|
|
{
|
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0018))
|
|
|
|
{
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2012-05-30 22:13:09 +04:00
|
|
|
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"
|
2015-05-03 11:12:10 +03:00
|
|
|
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0018);
|
2012-05-30 22:13:09 +04:00
|
|
|
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
2012-05-30 22:13:09 +04:00
|
|
|
// fall through to OLD behaviour
|
|
|
|
}
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
return true;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
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";
|
2014-03-11 03:04:11 +04:00
|
|
|
picFlags = this->Makefile->GetSafeDefinition(flagsVar);
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
|
|
|
if (!picFlags)
|
|
|
|
{
|
|
|
|
std::string flagsVar = "CMAKE_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_COMPILE_OPTIONS_PIC";
|
2014-03-11 03:04:11 +04:00
|
|
|
picFlags = this->Makefile->GetSafeDefinition(flagsVar);
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlagEscape(flags, *oi);
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-02 21:19:57 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
|
2014-02-05 01:06:56 +04:00
|
|
|
const std::string& var,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config)
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
|
|
|
// Add the flags from the variable itself.
|
|
|
|
std::string flagsVar = var;
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
|
2005-02-02 21:19:57 +03:00
|
|
|
// Add the flags from the build-type specific variable.
|
2014-02-10 07:48:34 +04:00
|
|
|
if(!config.empty())
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
|
|
|
flagsVar += "_";
|
2006-02-24 19:13:31 +03:00
|
|
|
flagsVar += cmSystemTools::UpperCase(config);
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AppendFlags(std::string& flags,
|
2014-05-02 00:07:26 +04:00
|
|
|
const std::string& newFlags)
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
2014-05-02 00:07:26 +04:00
|
|
|
if(!newFlags.empty())
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
2015-01-16 01:04:33 +03:00
|
|
|
if(!flags.empty())
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
|
|
|
flags += " ";
|
|
|
|
}
|
|
|
|
flags += newFlags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 00:07:26 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AppendFlags(std::string& flags,
|
|
|
|
const char* newFlags)
|
|
|
|
{
|
|
|
|
if(newFlags && *newFlags)
|
|
|
|
{
|
|
|
|
this->AppendFlags(flags, std::string(newFlags));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-27 19:49:06 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::AppendFlagEscape(std::string& flags,
|
2014-02-08 09:29:59 +04:00
|
|
|
const std::string& rawFlag)
|
2013-06-27 19:49:06 +04:00
|
|
|
{
|
2014-05-02 00:07:26 +04:00
|
|
|
this->AppendFlags(flags, this->EscapeForShell(rawFlag));
|
2013-06-27 19:49:06 +04:00
|
|
|
}
|
|
|
|
|
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,
|
2014-02-04 06:20:56 +04:00
|
|
|
const std::string& lang)
|
2012-08-09 11:44:15 +04:00
|
|
|
{
|
2008-01-17 18:00:19 +03:00
|
|
|
// Lookup the define flag for the current language.
|
|
|
|
std::string dflag = "-D";
|
2014-02-04 06:20:56 +04:00
|
|
|
if(!lang.empty())
|
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";
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* df = this->Makefile->GetDefinition(defineFlagVar);
|
2008-01-17 18:00:19 +03:00
|
|
|
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;
|
2015-05-24 12:46:30 +03:00
|
|
|
if(this->GetState()->UseWatcomWMake())
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
|
|
|
// 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(
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string& flags, const std::string& lang, const char* feature)
|
2009-10-02 21:52:01 +04:00
|
|
|
{
|
|
|
|
std::string optVar = "CMAKE_";
|
|
|
|
optVar += lang;
|
|
|
|
optVar += "_COMPILE_OPTIONS_";
|
|
|
|
optVar += feature;
|
2014-03-11 03:04:11 +04:00
|
|
|
if(const char* optionList = this->Makefile->GetDefinition(optVar))
|
2009-10-02 21:52:01 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> options;
|
|
|
|
cmSystemTools::ExpandListArgument(optionList, options);
|
|
|
|
for(std::vector<std::string>::const_iterator oi = options.begin();
|
|
|
|
oi != options.end(); ++oi)
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlagEscape(flags, *oi);
|
2009-10-02 21:52:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-06 16:42:31 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char* cmLocalGenerator::GetFeature(const std::string& feature,
|
|
|
|
const std::string& config)
|
|
|
|
{
|
|
|
|
// TODO: Define accumulation policy for features (prepend, append, replace).
|
|
|
|
// Currently we always replace.
|
|
|
|
if(!config.empty())
|
|
|
|
{
|
|
|
|
std::string featureConfig = feature;
|
|
|
|
featureConfig += "_";
|
|
|
|
featureConfig += cmSystemTools::UpperCase(config);
|
|
|
|
if(const char* value = this->Makefile->GetProperty(featureConfig))
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(const char* value = this->Makefile->GetProperty(feature))
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
if(cmLocalGenerator* parent = this->GetParent())
|
|
|
|
{
|
|
|
|
return parent->GetFeature(feature, config);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-11 19:06:19 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
2014-03-10 23:47:19 +04:00
|
|
|
cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,
|
2006-04-11 19:06:19 +04:00
|
|
|
const char* default_comment)
|
|
|
|
{
|
|
|
|
// Check for a comment provided with the command.
|
2014-03-10 23:47:19 +04:00
|
|
|
if(ccg.GetComment())
|
2006-04-11 19:06:19 +04:00
|
|
|
{
|
2014-03-10 23:47:19 +04:00
|
|
|
return ccg.GetComment();
|
2006-04-11 19:06:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Construct a reasonable default comment if possible.
|
2014-03-10 23:47:19 +04:00
|
|
|
if(!ccg.GetOutputs().empty())
|
2006-04-11 19:06:19 +04:00
|
|
|
{
|
|
|
|
std::string comment;
|
|
|
|
comment = "Generating ";
|
|
|
|
const char* sep = "";
|
2014-03-10 23:47:19 +04:00
|
|
|
for(std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
|
|
|
|
o != ccg.GetOutputs().end(); ++o)
|
2006-04-11 19:06:19 +04:00
|
|
|
{
|
|
|
|
comment += sep;
|
2014-03-11 03:04:11 +04:00
|
|
|
comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT);
|
2006-04-11 19:06:19 +04:00
|
|
|
sep = ", ";
|
|
|
|
}
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise use the provided default.
|
|
|
|
return default_comment;
|
|
|
|
}
|
|
|
|
|
2014-06-24 18:55:20 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class cmInstallTargetGeneratorLocal: public cmInstallTargetGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmInstallTargetGeneratorLocal(cmTarget& t, const char* dest, bool implib):
|
|
|
|
cmInstallTargetGenerator(
|
|
|
|
t, dest, implib, "", std::vector<std::string>(), "Unspecified",
|
2014-06-24 19:18:43 +04:00
|
|
|
cmInstallGenerator::SelectMessageLevel(t.GetMakefile()),
|
2014-06-24 18:55:20 +04:00
|
|
|
false) {}
|
|
|
|
};
|
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmLocalGenerator
|
|
|
|
::GenerateTargetInstallRules(
|
2014-02-10 07:48:34 +04:00
|
|
|
std::ostream& os, const std::string& config,
|
2006-02-19 23:25:27 +03:00
|
|
|
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.
|
2014-06-24 18:55:20 +04:00
|
|
|
cmInstallTargetGeneratorLocal
|
|
|
|
g(l->second, destination.c_str(), false);
|
2006-02-19 23:25:27 +03:00
|
|
|
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.
|
2014-06-24 18:55:20 +04:00
|
|
|
cmInstallTargetGeneratorLocal
|
|
|
|
g1(l->second, destination.c_str(), true);
|
2006-02-19 23:25:27 +03:00
|
|
|
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);
|
2014-06-24 18:55:20 +04:00
|
|
|
cmInstallTargetGeneratorLocal
|
|
|
|
g2(l->second, destination.c_str(), false);
|
2006-02-19 23:25:27 +03:00
|
|
|
g2.Generate(os, config, configurationTypes);
|
|
|
|
#else
|
|
|
|
// Use a target install generator.
|
2014-06-24 18:55:20 +04:00
|
|
|
cmInstallTargetGeneratorLocal
|
|
|
|
g(l->second, destination.c_str(), false);
|
2006-02-19 23:25:27 +03:00
|
|
|
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
|
2014-02-04 22:31:39 +04:00
|
|
|
::CreateSafeUniqueObjectFileName(const std::string& 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.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::map<std::string,std::string>::iterator it =
|
2006-07-11 19:41:38 +04:00
|
|
|
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.
|
2015-01-24 20:12:48 +03:00
|
|
|
ssin.erase(0, ssin.find_first_not_of("/"));
|
2006-07-11 19:41:38 +04:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream m;
|
2008-12-16 17:15:18 +03:00
|
|
|
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.";
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::WARNING, m.str());
|
2008-12-16 17:15:18 +03:00
|
|
|
}
|
|
|
|
}
|
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.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::map<std::string, std::string>::value_type e(sin, ssin);
|
2006-07-11 19:41:38 +04:00
|
|
|
it = this->UniqueObjectNamesMap.insert(e).first;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the map entry.
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
2014-03-11 20:37:26 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::ComputeObjectFilenames(
|
|
|
|
std::map<cmSourceFile const*, std::string>&,
|
|
|
|
cmGeneratorTarget const*)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-04 23:40:11 +03:00
|
|
|
bool cmLocalGenerator::IsWindowsShell() const
|
|
|
|
{
|
2015-05-24 12:46:30 +03:00
|
|
|
return this->GetState()->UseWindowsShell();
|
2015-05-04 23:40:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmLocalGenerator::IsWatcomWMake() const
|
|
|
|
{
|
2015-05-24 12:46:30 +03:00
|
|
|
return this->GetState()->UseWatcomWMake();
|
2015-05-04 23:40:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmLocalGenerator::IsMinGWMake() const
|
|
|
|
{
|
2015-05-24 12:46:30 +03:00
|
|
|
return this->GetState()->UseMinGWMake();
|
2015-05-04 23:40:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmLocalGenerator::IsNMake() const
|
|
|
|
{
|
2015-05-24 12:46:30 +03:00
|
|
|
return this->GetState()->UseNMake();
|
2015-05-04 23:40:11 +03:00
|
|
|
}
|
|
|
|
|
2006-07-11 19:41:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
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)
|
|
|
|
{
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string lang = source.GetLanguage();
|
|
|
|
if(!lang.empty())
|
2012-06-20 16:02:00 +04:00
|
|
|
{
|
|
|
|
std::string repVar = "CMAKE_";
|
|
|
|
repVar += lang;
|
|
|
|
repVar += "_OUTPUT_EXTENSION_REPLACE";
|
2014-03-11 03:04:11 +04:00
|
|
|
replaceExt = this->Makefile->IsOn(repVar);
|
2012-06-20 16:02:00 +04:00
|
|
|
}
|
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.
|
2014-03-11 03:04:11 +04:00
|
|
|
return this->CreateSafeUniqueObjectFileName(objectName, dir_max);
|
2006-07-11 19:41:38 +04:00
|
|
|
}
|
2006-08-03 17:26:07 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string
|
2006-08-03 17:26:07 +04:00
|
|
|
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
|
|
|
|
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
|
|
|
//----------------------------------------------------------------------------
|
2014-02-10 23:52:59 +04:00
|
|
|
cmIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility()
|
2007-12-29 07:07:14 +03:00
|
|
|
{
|
|
|
|
// 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);
|
2015-05-30 20:26:32 +03:00
|
|
|
this->BackwardsCompatibilityFinal = this->Makefile->IsConfigured();
|
2007-12-29 07:07:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2014-02-10 23:52:59 +04:00
|
|
|
cmIML_INT_uint64_t actual_compat = this->GetBackwardsCompatibility();
|
2007-12-29 07:07:14 +03:00
|
|
|
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.
|
2015-01-28 00:09:17 +03:00
|
|
|
std::string::size_type pos = define.find_first_of("(=");
|
|
|
|
if (pos != std::string::npos)
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
2015-01-28 00:13:45 +03:00
|
|
|
if (define[pos] == '(')
|
|
|
|
{
|
|
|
|
std::ostringstream 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;
|
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Many compilers do not support # in the value so we disable it.
|
|
|
|
if(define.find_first_of("#") != define.npos)
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream 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
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2013-09-03 00:27:32 +04:00
|
|
|
static void cmLGInfoProp(cmMakefile* mf, cmTarget* target,
|
|
|
|
const std::string& prop)
|
2008-02-14 23:31:08 +03:00
|
|
|
{
|
|
|
|
if(const char* val = target->GetProperty(prop))
|
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
mf->AddDefinition(prop, val);
|
2008-02-14 23:31:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
|
2014-02-07 02:31:47 +04:00
|
|
|
const std::string& targetName,
|
2008-02-14 23:31:08 +03:00
|
|
|
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))
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-05-17 20:53:56 +04:00
|
|
|
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();
|
2014-02-07 02:31:47 +04:00
|
|
|
mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str());
|
2008-05-17 20:53:56 +04:00
|
|
|
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,
|
2014-02-07 02:31:47 +04:00
|
|
|
const std::string& targetName,
|
|
|
|
const char* fname)
|
2008-09-02 20:06:32 +04:00
|
|
|
{
|
|
|
|
// 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))
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-09-02 20:06:32 +04:00
|
|
|
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();
|
2014-02-07 02:31:47 +04:00
|
|
|
mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str());
|
2008-09-02 20:06:32 +04:00
|
|
|
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();
|
|
|
|
}
|