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
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2008-01-22 17:13:04 +03:00
|
|
|
#include "cmComputeLinkInformation.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCustomCommandGenerator.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGeneratorExpressionEvaluationFile.h"
|
2002-09-04 23:24:49 +04:00
|
|
|
#include "cmGlobalGenerator.h"
|
2006-02-20 02:47:13 +03:00
|
|
|
#include "cmInstallFilesGenerator.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmInstallGenerator.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmInstallScriptGenerator.h"
|
|
|
|
#include "cmInstallTargetGenerator.h"
|
2002-08-31 00:00:35 +04:00
|
|
|
#include "cmMakefile.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmSourceFile.h"
|
2005-04-24 23:59:51 +04:00
|
|
|
#include "cmTest.h"
|
2009-03-16 17:40:46 +03:00
|
|
|
#include "cmTestGenerator.h"
|
2009-03-05 23:17:07 +03:00
|
|
|
#include "cmVersion.h"
|
2006-02-19 23:25:27 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
|
2007-03-16 17:34:25 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
#define CM_LG_ENCODE_OBJECT_NAMES
|
|
|
|
#include <cmsys/MD5.h>
|
2007-03-16 17:34:25 +03:00
|
|
|
#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
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
|
|
|
|
: cmOutputConverter(makefile->GetStateSnapshot())
|
|
|
|
, StateSnapshot(makefile->GetStateSnapshot())
|
2016-06-09 10:58:21 +03:00
|
|
|
, DirectoryBacktrace(makefile->GetBacktrace())
|
2002-08-31 00:00:35 +04:00
|
|
|
{
|
2015-05-03 17:50:34 +03:00
|
|
|
this->GlobalGenerator = gg;
|
2015-05-24 14:00:20 +03:00
|
|
|
|
2015-08-02 12:41:51 +03:00
|
|
|
this->Makefile = makefile;
|
2015-05-03 17:50:34 +03:00
|
|
|
|
2015-10-25 14:52:46 +03:00
|
|
|
this->AliasTargets = makefile->GetAliasTargets();
|
|
|
|
|
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;
|
2015-09-19 14:13:54 +03:00
|
|
|
|
|
|
|
this->ComputeObjectMaxPath();
|
2002-08-31 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmLocalGenerator::~cmLocalGenerator()
|
|
|
|
{
|
2015-10-25 15:22:42 +03:00
|
|
|
cmDeleteAll(this->GeneratorTargets);
|
|
|
|
cmDeleteAll(this->OwnedImportedGeneratorTargets);
|
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
|
|
|
|
{
|
2016-06-09 10:58:21 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(t, text, this->DirectoryBacktrace);
|
2015-06-13 20:32:46 +03:00
|
|
|
}
|
|
|
|
|
2009-09-03 16:26:46 +04:00
|
|
|
void cmLocalGenerator::ComputeObjectMaxPath()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
// Choose a maximum object file name length.
|
2008-08-21 17:54:36 +04:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
this->ObjectPathMax = 250;
|
|
|
|
#else
|
|
|
|
this->ObjectPathMax = 1000;
|
|
|
|
#endif
|
|
|
|
const char* plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (plen && *plen) {
|
2008-08-21 17:54:36 +04:00
|
|
|
unsigned int pmax;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sscanf(plen, "%u", &pmax) == 1) {
|
|
|
|
if (pmax >= 128) {
|
2008-08-21 17:54:36 +04:00
|
|
|
this->ObjectPathMax = pmax;
|
2016-05-16 17:34:04 +03: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 " << 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
|
|
|
}
|
2016-05-16 17:34:04 +03: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
|
|
|
}
|
2016-05-16 17:34:04 +03: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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configs.empty()) {
|
2014-11-05 01:24:54 +03:00
|
|
|
configs.push_back("");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator ci = configs.begin();
|
|
|
|
ci != configs.end(); ++ci) {
|
2014-11-05 01:24:54 +03:00
|
|
|
this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-05-09 16:25:45 +04:00
|
|
|
// Generate the rule files for each target.
|
2015-10-18 17:53:00 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t) {
|
|
|
|
if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) {
|
2013-11-29 16:18:24 +04:00
|
|
|
continue;
|
2007-05-09 16:25:45 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
(*t)->TraceDependencies();
|
|
|
|
}
|
2007-05-09 16:25:45 +04:00
|
|
|
}
|
|
|
|
|
2005-04-24 23:59:51 +04:00
|
|
|
void cmLocalGenerator::GenerateTestFiles()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->IsOn("CMAKE_TESTING_ENABLED")) {
|
2005-04-24 23:59:51 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
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: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->StateSnapshot.GetDirectory().GetCurrentSource() << std::endl
|
2011-11-29 17:58:45 +04:00
|
|
|
<< "# Build directory: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->StateSnapshot.GetDirectory().GetCurrentBinary() << 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");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (testIncludeFile) {
|
2013-08-22 13:30:19 +04:00
|
|
|
fout << "include(\"" << testIncludeFile << "\")" << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-03-16 17:40:46 +03:00
|
|
|
|
|
|
|
// Ask each test generator to write its code.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmTestGenerator*> const& testers =
|
|
|
|
this->Makefile->GetTestGenerators();
|
|
|
|
for (std::vector<cmTestGenerator*>::const_iterator gi = testers.begin();
|
|
|
|
gi != testers.end(); ++gi) {
|
2015-08-05 22:03:26 +03:00
|
|
|
(*gi)->Compute(this);
|
2009-03-16 17:40:46 +03:00
|
|
|
(*gi)->Generate(fout, config, configurationTypes);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-19 17:31:10 +03:00
|
|
|
size_t i;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmState::Snapshot> children =
|
|
|
|
this->Makefile->GetStateSnapshot().GetChildren();
|
|
|
|
for (i = 0; i < children.size(); ++i) {
|
2015-07-19 17:31:10 +03:00
|
|
|
// TODO: Use add_subdirectory instead?
|
|
|
|
fout << "subdirs(";
|
2015-07-19 17:33:54 +03:00
|
|
|
std::string outP = children[i].GetDirectory().GetCurrentBinary();
|
2016-05-16 17:34:04 +03:00
|
|
|
fout << this->Convert(outP, START_OUTPUT);
|
2015-07-19 17:31:10 +03:00
|
|
|
fout << ")" << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
|
2015-08-01 13:05:13 +03:00
|
|
|
void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config)
|
|
|
|
{
|
|
|
|
std::vector<cmGeneratorExpressionEvaluationFile*> ef =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetEvaluationFiles();
|
|
|
|
for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
|
|
|
|
ef.begin();
|
|
|
|
li != ef.end(); ++li) {
|
2015-08-01 13:19:32 +03:00
|
|
|
(*li)->CreateOutputFile(this, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-01 13:05:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmLocalGenerator::ProcessEvaluationFiles(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>& generatedFiles)
|
2015-08-01 13:05:13 +03:00
|
|
|
{
|
|
|
|
std::vector<cmGeneratorExpressionEvaluationFile*> ef =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetEvaluationFiles();
|
|
|
|
for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
|
|
|
|
ef.begin();
|
|
|
|
li != ef.end(); ++li) {
|
2015-08-01 13:19:32 +03:00
|
|
|
(*li)->Generate(this);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
2015-08-01 13:05:13 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-01 13:05:13 +03:00
|
|
|
std::vector<std::string> files = (*li)->GetFiles();
|
|
|
|
std::sort(files.begin(), files.end());
|
|
|
|
|
|
|
|
std::vector<std::string> intersection;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set_intersection(files.begin(), files.end(), generatedFiles.begin(),
|
|
|
|
generatedFiles.end(),
|
2015-08-01 13:05:13 +03:00
|
|
|
std::back_inserter(intersection));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!intersection.empty()) {
|
2015-08-01 13:05:13 +03:00
|
|
|
cmSystemTools::Error("Files to be generated by multiple different "
|
2016-05-16 17:34:04 +03:00
|
|
|
"commands: ",
|
|
|
|
cmWrap('"', intersection, '"', " ").c_str());
|
2015-08-01 13:05:13 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-01 13:05:13 +03:00
|
|
|
|
|
|
|
generatedFiles.insert(generatedFiles.end(), files.begin(), files.end());
|
|
|
|
std::vector<std::string>::iterator newIt =
|
2016-05-16 17:34:04 +03:00
|
|
|
generatedFiles.end() - files.size();
|
2015-08-01 13:05:13 +03:00
|
|
|
std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-01 13:05:13 +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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!prefix) {
|
|
|
|
if (!cmSystemTools::GetEnv("SystemDrive", prefix_win32)) {
|
2005-02-22 23:22:40 +03:00
|
|
|
prefix_win32 = "C:";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-15 19:02:08 +03:00
|
|
|
const char* project_name = this->Makefile->GetDefinition("PROJECT_NAME");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (project_name && project_name[0]) {
|
2005-02-22 23:22:40 +03:00
|
|
|
prefix_win32 += "/Program Files/";
|
|
|
|
prefix_win32 += project_name;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-02-22 23:22:40 +03:00
|
|
|
prefix_win32 += "/InstalledCMakeProject";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
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];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!prefix) {
|
|
|
|
if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) ==
|
|
|
|
B_OK) {
|
2013-10-05 18:31:36 +04:00
|
|
|
prefix = dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2013-10-05 18:31:36 +04:00
|
|
|
prefix = "/boot/system";
|
2009-09-30 16:31:53 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-22 23:22:40 +03:00
|
|
|
#else
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!prefix) {
|
2004-01-26 03:25:26 +03:00
|
|
|
prefix = "/usr/local";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-22 23:22:40 +03:00
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* stagingPrefix =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX")) {
|
2013-11-14 15:04:40 +04:00
|
|
|
prefix = stagingPrefix;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* default_order[] = { "RELEASE", "MINSIZEREL", "RELWITHDEBINFO",
|
|
|
|
"DEBUG", 0 };
|
|
|
|
for (const char** c = default_order; *c && default_config.empty(); ++c) {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (default_config.empty() && !configurationTypes.empty()) {
|
2015-02-03 21:01:03 +03:00
|
|
|
default_config = configurationTypes[0];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-05-05 22:57:19 +04:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Create the install script file.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
2015-05-03 18:19:16 +03:00
|
|
|
std::string homedir = this->GetState()->GetBinaryDirectory();
|
2004-03-29 02:59:46 +04:00
|
|
|
int toplevel_install = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (file == homedir) {
|
2004-03-29 02:59:46 +04:00
|
|
|
toplevel_install = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->StateSnapshot.GetDirectory().GetCurrentSource() << 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.
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
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";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
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.
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2006-03-30 22:33:48 +04:00
|
|
|
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";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2006-03-30 22:33:48 +04:00
|
|
|
|
2007-04-10 19:22:15 +04:00
|
|
|
// Copy user-specified install options to the install code.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* so_no_exe =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_INSTALL_SO_NO_EXE")) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2007-04-10 19:22:15 +04:00
|
|
|
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";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-04-10 19:22:15 +04:00
|
|
|
|
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();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmInstallGenerator*>::const_iterator gi =
|
|
|
|
installers.begin();
|
|
|
|
gi != installers.end(); ++gi) {
|
2006-02-19 23:25:27 +03:00
|
|
|
(*gi)->Generate(fout, config, configurationTypes);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmState::Snapshot> children =
|
|
|
|
this->Makefile->GetStateSnapshot().GetChildren();
|
|
|
|
if (!children.empty()) {
|
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";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmState::Snapshot>::const_iterator ci = children.begin();
|
|
|
|
ci != children.end(); ++ci) {
|
|
|
|
if (!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
|
2015-07-19 17:33:54 +03:00
|
|
|
std::string odir = ci->GetDirectory().GetCurrentBinary();
|
2006-04-11 21:32:48 +04:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(odir);
|
2016-05-16 17:34:04 +03:00
|
|
|
fout << " include(\"" << odir << "/cmake_install.cmake\")"
|
|
|
|
<< std::endl;
|
2004-01-26 03:25:26 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-11 21:32:48 +04:00
|
|
|
fout << "\n";
|
2013-08-22 13:30:19 +04:00
|
|
|
fout << "endif()\n\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
// Record the install manifest.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (toplevel_install) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
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";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-01-26 03:25:26 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 17:53:00 +03:00
|
|
|
void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
|
2015-09-16 06:21:07 +03:00
|
|
|
{
|
2015-10-18 17:53:00 +03:00
|
|
|
this->GeneratorTargets.push_back(gt);
|
2016-02-08 20:50:56 +03:00
|
|
|
this->GlobalGenerator->IndexGeneratorTarget(gt);
|
2015-09-16 06:21:07 +03:00
|
|
|
}
|
|
|
|
|
2015-10-25 14:56:31 +03:00
|
|
|
void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt)
|
|
|
|
{
|
|
|
|
this->ImportedGeneratorTargets.push_back(gt);
|
2016-02-08 20:50:56 +03:00
|
|
|
this->GlobalGenerator->IndexGeneratorTarget(gt);
|
2015-10-25 14:56:31 +03:00
|
|
|
}
|
|
|
|
|
2015-10-25 15:22:42 +03:00
|
|
|
void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt)
|
|
|
|
{
|
|
|
|
this->OwnedImportedGeneratorTargets.push_back(gt);
|
|
|
|
}
|
|
|
|
|
2015-10-25 14:52:46 +03:00
|
|
|
struct NamedGeneratorTargetFinder
|
|
|
|
{
|
|
|
|
NamedGeneratorTargetFinder(std::string const& name)
|
|
|
|
: Name(name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator()(cmGeneratorTarget* tgt)
|
|
|
|
{
|
|
|
|
return tgt->GetName() == this->Name;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2015-10-25 14:52:46 +03:00
|
|
|
private:
|
|
|
|
std::string Name;
|
|
|
|
};
|
|
|
|
|
2016-04-01 17:26:08 +03:00
|
|
|
cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& name) const
|
2015-10-19 00:49:12 +03:00
|
|
|
{
|
2015-10-25 14:52:46 +03:00
|
|
|
std::vector<cmGeneratorTarget*>::const_iterator ti =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::find_if(this->GeneratorTargets.begin(), this->GeneratorTargets.end(),
|
|
|
|
NamedGeneratorTargetFinder(name));
|
|
|
|
if (ti != this->GeneratorTargets.end()) {
|
2015-10-25 14:52:46 +03:00
|
|
|
return *ti;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-25 14:52:46 +03:00
|
|
|
return 0;
|
2015-10-19 00:49:12 +03:00
|
|
|
}
|
|
|
|
|
2015-08-25 09:25:12 +03:00
|
|
|
void cmLocalGenerator::ComputeTargetManifest()
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configNames.empty()) {
|
2014-03-27 12:46:58 +04:00
|
|
|
configNames.push_back("");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-04 19:48:19 +04:00
|
|
|
|
|
|
|
// Add our targets to the manifest for each configuration.
|
2015-10-18 17:53:00 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t) {
|
2015-10-18 17:53:00 +03:00
|
|
|
cmGeneratorTarget* target = *t;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (target->GetType() == cmState::INTERFACE_LIBRARY) {
|
2013-11-20 15:44:04 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::iterator ci = configNames.begin();
|
|
|
|
ci != configNames.end(); ++ci) {
|
2014-03-27 12:46:58 +04:00
|
|
|
const char* config = ci->c_str();
|
2015-10-18 17:53:00 +03:00
|
|
|
target->ComputeTargetManifest(config);
|
2006-04-04 19:48:19 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-04 19:48:19 +04:00
|
|
|
}
|
|
|
|
|
2015-10-23 02:17:32 +03:00
|
|
|
bool cmLocalGenerator::IsRootMakefile() const
|
|
|
|
{
|
|
|
|
return !this->StateSnapshot.GetBuildsystemDirectoryParent().IsValid();
|
|
|
|
}
|
|
|
|
|
2015-05-03 17:51:51 +03:00
|
|
|
cmState* cmLocalGenerator::GetState() const
|
|
|
|
{
|
|
|
|
return this->GlobalGenerator->GetCMakeInstance()->GetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const
|
|
|
|
{
|
2015-09-01 19:46:05 +03:00
|
|
|
return this->Makefile->GetStateSnapshot();
|
2015-05-03 17:51:51 +03:00
|
|
|
}
|
|
|
|
|
2004-10-21 22:34:02 +04:00
|
|
|
// 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.
|
2016-05-16 17:34:04 +03:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmLocalGenerator::ExpandRuleVariable(
|
|
|
|
std::string const& variable, const RuleVariables& replaceValues)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (replaceValues.LinkFlags) {
|
|
|
|
if (variable == "LINK_FLAGS") {
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.LinkFlags;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Manifests) {
|
|
|
|
if (variable == "MANIFESTS") {
|
2015-09-16 17:24:16 +03:00
|
|
|
return replaceValues.Manifests;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Flags) {
|
|
|
|
if (variable == "FLAGS") {
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Flags;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (replaceValues.Source) {
|
|
|
|
if (variable == "SOURCE") {
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Source;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.PreprocessedSource) {
|
|
|
|
if (variable == "PREPROCESSED_SOURCE") {
|
2006-08-08 07:25:21 +04:00
|
|
|
return replaceValues.PreprocessedSource;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.AssemblySource) {
|
|
|
|
if (variable == "ASSEMBLY_SOURCE") {
|
2006-08-08 07:25:21 +04:00
|
|
|
return replaceValues.AssemblySource;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Object) {
|
|
|
|
if (variable == "OBJECT") {
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Object;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.ObjectDir) {
|
|
|
|
if (variable == "OBJECT_DIR") {
|
2006-04-17 22:01:22 +04:00
|
|
|
return replaceValues.ObjectDir;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.ObjectFileDir) {
|
|
|
|
if (variable == "OBJECT_FILE_DIR") {
|
2014-06-05 16:57:17 +04:00
|
|
|
return replaceValues.ObjectFileDir;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Objects) {
|
|
|
|
if (variable == "OBJECTS") {
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.Objects;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.ObjectsQuoted) {
|
|
|
|
if (variable == "OBJECTS_QUOTED") {
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.ObjectsQuoted;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Defines && variable == "DEFINES") {
|
2008-01-14 17:20:58 +03:00
|
|
|
return replaceValues.Defines;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Includes && variable == "INCLUDES") {
|
2015-07-13 17:35:04 +03:00
|
|
|
return replaceValues.Includes;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.TargetPDB) {
|
|
|
|
if (variable == "TARGET_PDB") {
|
2006-04-20 00:36:14 +04:00
|
|
|
return replaceValues.TargetPDB;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.TargetCompilePDB) {
|
|
|
|
if (variable == "TARGET_COMPILE_PDB") {
|
2014-02-24 23:15:21 +04:00
|
|
|
return replaceValues.TargetCompilePDB;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.DependencyFile) {
|
|
|
|
if (variable == "DEP_FILE") {
|
2012-06-13 02:52:46 +04:00
|
|
|
return replaceValues.DependencyFile;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-20 00:36:14 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (replaceValues.Target) {
|
|
|
|
if (variable == "TARGET_QUOTED") {
|
2006-02-20 21:42:18 +03:00
|
|
|
std::string targetQuoted = replaceValues.Target;
|
2016-05-16 17:34:04 +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 += '\"';
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return targetQuoted;
|
|
|
|
}
|
|
|
|
if (variable == "TARGET_UNQUOTED") {
|
2009-11-30 19:16:24 +03:00
|
|
|
std::string unquoted = replaceValues.Target;
|
|
|
|
std::string::size_type sz = unquoted.size();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sz > 2 && unquoted[0] == '\"' && unquoted[sz - 1] == '\"') {
|
|
|
|
unquoted = unquoted.substr(1, sz - 2);
|
2009-11-30 19:16:24 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return unquoted;
|
|
|
|
}
|
|
|
|
if (replaceValues.LanguageCompileFlags) {
|
|
|
|
if (variable == "LANGUAGE_COMPILE_FLAGS") {
|
2006-08-08 21:44:25 +04:00
|
|
|
return replaceValues.LanguageCompileFlags;
|
2006-03-06 23:14:23 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Target) {
|
|
|
|
if (variable == "TARGET") {
|
2006-08-08 21:44:25 +04:00
|
|
|
return replaceValues.Target;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (variable == "TARGET_IMPLIB") {
|
2006-03-15 19:02:08 +03:00
|
|
|
return this->TargetImplib;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (variable == "TARGET_VERSION_MAJOR") {
|
|
|
|
if (replaceValues.TargetVersionMajor) {
|
2006-10-17 02:17:14 +04:00
|
|
|
return replaceValues.TargetVersionMajor;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-10-17 02:17:14 +04:00
|
|
|
return "0";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (variable == "TARGET_VERSION_MINOR") {
|
|
|
|
if (replaceValues.TargetVersionMinor) {
|
2006-10-17 02:17:14 +04:00
|
|
|
return replaceValues.TargetVersionMinor;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-10-17 02:17:14 +04:00
|
|
|
return "0";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Target) {
|
|
|
|
if (variable == "TARGET_BASE") {
|
2006-08-08 21:44:25 +04:00
|
|
|
// Strip the last extension off the target name.
|
|
|
|
std::string targetBase = replaceValues.Target;
|
2016-05-24 22:24:10 +03:00
|
|
|
std::string::size_type pos = targetBase.rfind('.');
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != targetBase.npos) {
|
|
|
|
return targetBase.substr(0, pos);
|
|
|
|
} else {
|
2006-08-08 21:44:25 +04:00
|
|
|
return targetBase;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
|
|
|
|
variable == "TARGET_INSTALLNAME_DIR") {
|
2012-04-22 17:42:55 +04:00
|
|
|
// All these variables depend on TargetSOName
|
2016-05-16 17:34:04 +03:00
|
|
|
if (replaceValues.TargetSOName) {
|
|
|
|
if (variable == "TARGET_SONAME") {
|
2012-04-22 17:42:55 +04:00
|
|
|
return replaceValues.TargetSOName;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (variable == "SONAME_FLAG" && replaceValues.SONameFlag) {
|
2012-04-22 17:42:55 +04:00
|
|
|
return replaceValues.SONameFlag;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.TargetInstallNameDir &&
|
|
|
|
variable == "TARGET_INSTALLNAME_DIR") {
|
2012-04-22 17:42:55 +04:00
|
|
|
return replaceValues.TargetInstallNameDir;
|
2006-02-24 21:13:14 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
if (replaceValues.LinkLibraries) {
|
|
|
|
if (variable == "LINK_LIBRARIES") {
|
2006-02-20 21:42:18 +03:00
|
|
|
return replaceValues.LinkLibraries;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Language) {
|
|
|
|
if (variable == "LANGUAGE") {
|
2009-02-10 16:52:07 +03:00
|
|
|
return replaceValues.Language;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.CMTarget) {
|
|
|
|
if (variable == "TARGET_NAME") {
|
2009-02-10 16:52:07 +03:00
|
|
|
return replaceValues.CMTarget->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (variable == "TARGET_TYPE") {
|
2015-10-08 01:26:50 +03:00
|
|
|
return cmState::GetTargetTypeName(replaceValues.CMTarget->GetType());
|
2009-02-10 16:52:07 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (replaceValues.Output) {
|
|
|
|
if (variable == "OUTPUT") {
|
2009-02-10 16:52:07 +03:00
|
|
|
return replaceValues.Output;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (variable == "CMAKE_COMMAND") {
|
2015-05-20 16:10:52 +03:00
|
|
|
return this->Convert(cmSystemTools::GetCMakeCommand(), FULL, SHELL);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-20 00:14:18 +03:00
|
|
|
std::vector<std::string> enabledLanguages =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetState()->GetEnabledLanguages();
|
2004-10-21 22:34:02 +04:00
|
|
|
// loop over language specific replace variables
|
|
|
|
int pos = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (ruleReplaceVars[pos]) {
|
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (actualReplace == "CMAKE_${LANG}_COMPILER") {
|
2005-07-20 23:44:55 +04:00
|
|
|
std::string arg1 = actualReplace + "_ARG1";
|
|
|
|
cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
|
2014-03-11 03:04:11 +04:00
|
|
|
compilerArg1 = this->Makefile->GetDefinition(arg1);
|
2016-05-16 17:34:04 +03:00
|
|
|
compilerTarget = this->Makefile->GetDefinition(
|
|
|
|
std::string("CMAKE_") + lang + "_COMPILER_TARGET");
|
|
|
|
compilerOptionTarget = this->Makefile->GetDefinition(
|
|
|
|
std::string("CMAKE_") + lang + "_COMPILE_OPTIONS_TARGET");
|
|
|
|
compilerExternalToolchain = this->Makefile->GetDefinition(
|
|
|
|
std::string("CMAKE_") + lang + "_COMPILER_EXTERNAL_TOOLCHAIN");
|
|
|
|
compilerOptionExternalToolchain =
|
|
|
|
this->Makefile->GetDefinition(std::string("CMAKE_") + lang +
|
|
|
|
"_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN");
|
|
|
|
compilerSysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT");
|
|
|
|
compilerOptionSysroot = this->Makefile->GetDefinition(
|
|
|
|
std::string("CMAKE_") + lang + "_COMPILE_OPTIONS_SYSROOT");
|
|
|
|
}
|
|
|
|
if (actualReplace.find("${LANG}") != actualReplace.npos) {
|
2005-04-12 21:27:07 +04:00
|
|
|
cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (actualReplace == variable) {
|
|
|
|
std::string replace = 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
|
2016-05-16 17:34:04 +03:00
|
|
|
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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (compilerArg1) {
|
2005-07-20 23:44:55 +04:00
|
|
|
ret += " ";
|
|
|
|
ret += compilerArg1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (compilerTarget && compilerOptionTarget) {
|
2013-05-19 21:18:01 +04:00
|
|
|
ret += " ";
|
|
|
|
ret += compilerOptionTarget;
|
|
|
|
ret += compilerTarget;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (compilerExternalToolchain && compilerOptionExternalToolchain) {
|
2013-08-08 19:36:36 +04:00
|
|
|
ret += " ";
|
|
|
|
ret += compilerOptionExternalToolchain;
|
|
|
|
ret += this->EscapeForShell(compilerExternalToolchain, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (compilerSysroot && compilerOptionSysroot) {
|
2013-04-13 16:46:57 +04:00
|
|
|
ret += " ";
|
|
|
|
ret += compilerOptionSysroot;
|
|
|
|
ret += this->EscapeForShell(compilerSysroot, true);
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return ret;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return replace;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
pos++;
|
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
return variable;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::ExpandRuleVariables(std::string& s,
|
|
|
|
const RuleVariables& replaceValues)
|
2005-04-12 21:27:07 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (replaceValues.RuleLauncher) {
|
2013-09-03 00:27:32 +04:00
|
|
|
this->InsertRuleLauncher(s, replaceValues.CMTarget,
|
|
|
|
replaceValues.RuleLauncher);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
std::string::size_type start = s.find('<');
|
|
|
|
// no variables to expand
|
2016-05-16 17:34:04 +03:00
|
|
|
if (start == s.npos) {
|
2005-04-12 21:27:07 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
std::string::size_type pos = 0;
|
|
|
|
std::string expandedInput;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (start != s.npos && start < s.size() - 2) {
|
2005-04-12 21:27:07 +04:00
|
|
|
std::string::size_type end = s.find('>', start);
|
|
|
|
// if we find a < with no > we are done
|
2016-05-16 17:34:04 +03:00
|
|
|
if (end == s.npos) {
|
2005-04-12 21:27:07 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
char c = s[start + 1];
|
2005-04-12 21:27:07 +04:00
|
|
|
// if the next char after the < is not A-Za-z then
|
|
|
|
// skip it and try to find the next < in the string
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!isalpha(c)) {
|
|
|
|
start = s.find('<', start + 1);
|
|
|
|
} else {
|
2005-04-12 21:27:07 +04:00
|
|
|
// extract the var
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string var = s.substr(start + 1, end - start - 1);
|
|
|
|
std::string replace = this->ExpandRuleVariable(var, replaceValues);
|
|
|
|
expandedInput += s.substr(pos, start - pos);
|
2005-04-12 21:27:07 +04:00
|
|
|
expandedInput += replace;
|
|
|
|
// move to next one
|
2016-05-16 17:34:04 +03:00
|
|
|
start = s.find('<', start + var.size() + 2);
|
|
|
|
pos = end + 1;
|
2005-04-12 21:27:07 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-04-12 21:27:07 +04:00
|
|
|
// add the rest of the input
|
2016-05-16 17:34:04 +03:00
|
|
|
expandedInput += s.substr(pos, s.size() - pos);
|
2005-04-12 21:27:07 +04:00
|
|
|
s = expandedInput;
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2015-10-09 23:19:57 +03:00
|
|
|
const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
|
2013-09-03 00:27:32 +04:00
|
|
|
const std::string& prop)
|
2009-02-10 16:51:15 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (target) {
|
2009-02-10 16:51:15 +03:00
|
|
|
return target->GetProperty(prop);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-02-10 16:51:15 +03:00
|
|
|
return this->Makefile->GetProperty(prop);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-10 16:51:15 +03:00
|
|
|
}
|
|
|
|
|
2015-10-09 23:19:57 +03:00
|
|
|
void cmLocalGenerator::InsertRuleLauncher(std::string& s,
|
|
|
|
cmGeneratorTarget* target,
|
2013-09-03 00:27:32 +04:00
|
|
|
const std::string& prop)
|
2009-02-10 16:51:15 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +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();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-10 16:51:15 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmLocalGenerator::ConvertToIncludeReference(
|
|
|
|
std::string const& path, OutputFormat format, bool forceFullPaths)
|
2011-09-07 05:41:41 +04:00
|
|
|
{
|
2014-10-10 17:57:07 +04:00
|
|
|
return this->ConvertToOutputForExisting(
|
2016-05-16 17:34:04 +03:00
|
|
|
path, forceFullPaths ? FULL : START_OUTPUT, format);
|
2011-09-07 05:41:41 +04:00
|
|
|
}
|
|
|
|
|
2011-11-07 14:49:33 +04:00
|
|
|
std::string cmLocalGenerator::GetIncludeFlags(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::vector<std::string>& includes, cmGeneratorTarget* target,
|
|
|
|
const std::string& lang, bool forceFullPaths, bool forResponseFile,
|
|
|
|
const std::string& config)
|
|
|
|
{
|
|
|
|
if (lang.empty()) {
|
2004-10-21 22:34:02 +04:00
|
|
|
return "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-25 19:44:46 +03:00
|
|
|
|
2016-05-16 17:34:04 +03: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;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* includeFlag = 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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) {
|
2006-01-23 21:50:23 +03:00
|
|
|
quotePaths = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!sep) {
|
2004-10-26 18:15:49 +04:00
|
|
|
sep = " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
} 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;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (repeatFlag) {
|
2014-03-11 03:04:11 +04:00
|
|
|
sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* fwSearchFlag = 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;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (i = includes.begin(); i != includes.end(); ++i) {
|
|
|
|
if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") &&
|
|
|
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emitted.insert(frameworkDir).second) {
|
2014-05-05 14:39:55 +04:00
|
|
|
if (sysFwSearchFlag && target &&
|
2016-05-16 17:34:04 +03:00
|
|
|
target->IsSystemIncludeDirectory(*i, config)) {
|
2014-05-05 14:39:55 +04:00
|
|
|
includeFlags << sysFwSearchFlag;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-05-05 14:39:55 +04:00
|
|
|
includeFlags << fwSearchFlag;
|
2005-12-27 22:56:56 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
includeFlags << this->ConvertToOutputFormat(frameworkDir, shellFormat)
|
|
|
|
<< " ";
|
2005-12-27 22:56:56 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
continue;
|
|
|
|
}
|
2010-05-01 16:29:13 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!flagUsed || repeatFlag) {
|
|
|
|
if (sysIncludeFlag && target &&
|
|
|
|
target->IsSystemIncludeDirectory(*i, config)) {
|
2006-10-05 16:55:59 +04:00
|
|
|
includeFlags << sysIncludeFlag;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-10-05 16:55:59 +04:00
|
|
|
includeFlags << includeFlag;
|
2004-10-26 18:15:49 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03: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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
|
2006-01-23 21:50:23 +03:00
|
|
|
includeFlags << "\"";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-23 21:50:23 +03:00
|
|
|
includeFlags << includePath;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
|
2006-01-23 21:50:23 +03:00
|
|
|
includeFlags << "\"";
|
2004-10-26 18:15:49 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
includeFlags << sep;
|
|
|
|
}
|
2004-10-26 18:15:49 +04:00
|
|
|
std::string flags = includeFlags.str();
|
|
|
|
// remove trailing separators
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((sep[0] != ' ') && !flags.empty() && flags[flags.size() - 1] == sep[0]) {
|
|
|
|
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,
|
2015-10-09 23:19:57 +03:00
|
|
|
cmGeneratorTarget const* target,
|
2015-03-04 23:46:42 +03:00
|
|
|
const std::string& config,
|
2016-06-10 16:23:14 +03:00
|
|
|
const std::string& lang) const
|
2013-06-06 20:13:35 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> targetDefines;
|
2015-10-09 23:19:57 +03:00
|
|
|
target->GetCompileDefinitions(targetDefines, config, lang);
|
2013-06-06 20:13:35 +04:00
|
|
|
this->AppendDefines(defines, targetDefines);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::AddCompileOptions(std::string& flags,
|
|
|
|
cmGeneratorTarget* target,
|
|
|
|
const std::string& lang,
|
|
|
|
const std::string& config)
|
2013-05-16 16:59:04 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string langFlagRegexVar = std::string("CMAKE_") + lang + "_FLAG_REGEX";
|
2015-08-05 00:43:56 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* langFlagRegexStr =
|
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
|
2013-06-27 20:04:02 +04:00
|
|
|
cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-09 23:19:57 +03:00
|
|
|
target->GetCompileOptions(opts, config, lang);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = opts.begin();
|
|
|
|
i != opts.end(); ++i) {
|
|
|
|
if (r.find(i->c_str())) {
|
2013-06-27 20:04:02 +04:00
|
|
|
// (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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2013-06-27 20:04:02 +04:00
|
|
|
// Use all flags.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
|
2013-06-27 20:04:02 +04:00
|
|
|
// COMPILE_FLAGS are not escaped for historical reasons.
|
|
|
|
this->AppendFlags(flags, targetFlags);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-07-18 13:49:11 +04:00
|
|
|
std::vector<std::string> opts;
|
2015-10-09 23:19:57 +03:00
|
|
|
target->GetCompileOptions(opts, config, lang);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = opts.begin();
|
|
|
|
i != opts.end(); ++i) {
|
2013-06-27 20:04:02 +04:00
|
|
|
// COMPILE_OPTIONS are escaped.
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlagEscape(flags, *i);
|
2013-05-16 17:15:28 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-22 17:05:49 +04:00
|
|
|
std::vector<std::string> features;
|
2015-10-09 23:19:57 +03:00
|
|
|
target->GetCompileFeatures(features, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator it = features.begin();
|
|
|
|
it != features.end(); ++it) {
|
|
|
|
if (!this->Makefile->AddRequiredTargetFeature(target->Target, *it)) {
|
2013-10-22 17:05:49 +04:00
|
|
|
return;
|
2014-04-02 17:57:15 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:32:30 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::map<std::string, std::string>::const_iterator it =
|
|
|
|
target->GetMaxLanguageStandards().begin();
|
|
|
|
it != target->GetMaxLanguageStandards().end(); ++it) {
|
2014-05-15 13:32:30 +04:00
|
|
|
const char* standard = target->GetProperty(it->first + "_STANDARD");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!standard) {
|
2014-05-15 13:32:30 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->Makefile->IsLaterStandard(it->first, standard, it->second)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03: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;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
this->AddCompilerRequirementFlag(flags, target, lang);
|
2013-05-16 16:59:04 +04:00
|
|
|
}
|
|
|
|
|
2009-02-26 17:16:16 +03:00
|
|
|
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
|
2015-10-05 20:15:56 +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,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool stripImplicitInclDirs) 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.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) {
|
2006-02-19 21:10:25 +03:00
|
|
|
includeSourceDir = true;
|
|
|
|
includeBinaryDir = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-19 21:10:25 +03:00
|
|
|
|
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.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (includeBinaryDir) {
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emitted.find(binDir) == emitted.end()) {
|
2015-07-18 20:11:05 +03:00
|
|
|
dirs.push_back(binDir);
|
|
|
|
emitted.insert(binDir);
|
2006-02-18 19:51:23 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (includeSourceDir) {
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string srcDir = this->StateSnapshot.GetDirectory().GetCurrentSource();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emitted.find(srcDir) == emitted.end()) {
|
2015-07-18 20:11:05 +03:00
|
|
|
dirs.push_back(srcDir);
|
|
|
|
emitted.insert(srcDir);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!target) {
|
2012-08-20 01:14:15 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-08-20 01:14:15 +04:00
|
|
|
|
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";
|
2016-05-16 17:34:04 +03: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);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = impDirVec.begin();
|
|
|
|
i != impDirVec.end(); ++i) {
|
2013-04-13 16:46:57 +04:00
|
|
|
std::string d = rootPath + *i;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(d);
|
|
|
|
emitted.insert(d);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!stripImplicitInclDirs) {
|
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);
|
2009-02-26 17:16:16 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03: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.
|
2016-05-16 17:34:04 +03:00
|
|
|
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();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = includes.begin();
|
|
|
|
i != includes.end(); ++i) {
|
2006-04-25 17:54:12 +04:00
|
|
|
// Emit this directory only if it is a subdirectory of the
|
|
|
|
// top-level source or binary tree.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::ComparePath(*i, topSourceDir) ||
|
|
|
|
cmSystemTools::ComparePath(*i, topBinaryDir) ||
|
|
|
|
cmSystemTools::IsSubDirectory(*i, topSourceDir) ||
|
|
|
|
cmSystemTools::IsSubDirectory(*i, topBinaryDir)) {
|
|
|
|
if (emitted.insert(*i).second) {
|
2006-04-25 17:54:12 +04:00
|
|
|
dirs.push_back(*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-25 17:54:12 +04:00
|
|
|
|
|
|
|
// Construct the final ordered include directory list.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = includes.begin();
|
|
|
|
i != includes.end(); ++i) {
|
|
|
|
if (emitted.insert(*i).second) {
|
2004-10-26 18:15:49 +04:00
|
|
|
dirs.push_back(*i);
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03: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
|
|
|
|
2016-05-16 17:34:04 +03: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()) {
|
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
|
|
|
dirs.push_back(*i);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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,
|
2015-10-09 23:19:57 +03:00
|
|
|
cmGeneratorTarget* target)
|
2013-07-10 21:11:04 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AppendFlags(
|
|
|
|
flags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
|
|
|
|
if (!config.empty()) {
|
2013-04-07 19:39:05 +04:00
|
|
|
std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-07-10 21:11:04 +04:00
|
|
|
this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS"));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2013-07-10 21:11:04 +04:00
|
|
|
std::string name = "STATIC_LIBRARY_FLAGS_" + config;
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, target->GetProperty(name));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-07-10 21:11:04 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::GetTargetFlags(
|
2016-06-07 17:30:58 +03:00
|
|
|
const std::string& config, std::string& linkLibs, std::string& flags,
|
|
|
|
std::string& linkFlags, std::string& frameworkPath, std::string& linkPath,
|
|
|
|
cmGeneratorTarget* target, bool useWatcomQuote)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2016-06-07 17:30:58 +03:00
|
|
|
const std::string buildType = cmSystemTools::UpperCase(config);
|
2011-11-29 17:58:45 +04:00
|
|
|
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
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (target->GetType()) {
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::STATIC_LIBRARY:
|
2015-10-09 23:19:57 +03:00
|
|
|
this->GetStaticLibraryFlags(linkFlags, buildType, target);
|
2011-11-29 17:58:45 +04:00
|
|
|
break;
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::MODULE_LIBRARY:
|
2004-10-21 22:34:02 +04:00
|
|
|
libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
|
2016-05-16 17:34:04 +03:00
|
|
|
case cmState::SHARED_LIBRARY: {
|
2006-03-15 19:02:08 +03:00
|
|
|
linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable);
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
2016-05-16 17:34:04 +03: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 += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->Makefile->IsOn("WIN32") &&
|
|
|
|
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) {
|
2013-07-14 20:22:57 +04:00
|
|
|
std::vector<cmSourceFile*> sources;
|
2014-02-13 20:25:00 +04:00
|
|
|
target->GetSourceFiles(sources, buildType);
|
2016-05-16 17:34:04 +03: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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sf->GetExtension() == "def") {
|
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");
|
2016-05-16 17:34:04 +03:00
|
|
|
linkFlags += this->Convert(sf->GetFullPath(), FULL, SHELL);
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
|
|
|
}
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-09-16 03:35:08 +04:00
|
|
|
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (targetLinkFlags) {
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += targetLinkFlags;
|
|
|
|
linkFlags += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!buildType.empty()) {
|
2011-09-22 06:59:55 +04:00
|
|
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (targetLinkFlags) {
|
2006-04-03 20:57:51 +04:00
|
|
|
linkFlags += targetLinkFlags;
|
|
|
|
linkFlags += " ";
|
2011-11-29 17:58:45 +04:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target,
|
|
|
|
false, false, useWatcomQuote);
|
|
|
|
} break;
|
|
|
|
case cmState::EXECUTABLE: {
|
|
|
|
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += " ";
|
2016-05-16 17:34:04 +03: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 += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
std::string linkLanguage = target->GetLinkerLanguage(buildType);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (linkLanguage.empty()) {
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"CMake can not determine linker language for target: ",
|
|
|
|
target->GetName().c_str());
|
2004-10-27 18:53:01 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-10 07:48:34 +04:00
|
|
|
this->AddLanguageFlags(flags, linkLanguage, buildType);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target,
|
|
|
|
false, false, useWatcomQuote);
|
|
|
|
if (cmSystemTools::IsOn(
|
|
|
|
this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
|
|
|
|
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") +
|
|
|
|
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 += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
|
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 += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
} 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 += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (target->IsExecutableWithExports()) {
|
2011-11-11 23:11:38 +04:00
|
|
|
std::string exportFlagVar = "CMAKE_EXE_EXPORTS_";
|
|
|
|
exportFlagVar += linkLanguage;
|
|
|
|
exportFlagVar += "_FLAG";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
linkFlags += this->Makefile->GetSafeDefinition(exportFlagVar);
|
2011-11-11 23:11:38 +04:00
|
|
|
linkFlags += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-09-16 03:35:08 +04:00
|
|
|
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (targetLinkFlags) {
|
2004-10-21 22:34:02 +04:00
|
|
|
linkFlags += targetLinkFlags;
|
2011-09-22 06:59:55 +04:00
|
|
|
linkFlags += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!buildType.empty()) {
|
2011-09-22 06:59:55 +04:00
|
|
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (targetLinkFlags) {
|
2006-04-03 20:57:51 +04:00
|
|
|
linkFlags += targetLinkFlags;
|
|
|
|
linkFlags += " ";
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2008-08-18 19:26:51 +04:00
|
|
|
default:
|
2004-10-21 22:34:02 +04:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
|
|
|
|
2016-06-08 12:29:35 +03:00
|
|
|
static std::string GetFrameworkFlags(const std::string& lang,
|
|
|
|
const std::string& config,
|
|
|
|
cmGeneratorTarget* target)
|
2016-06-08 12:29:35 +03:00
|
|
|
{
|
2016-06-08 12:29:35 +03:00
|
|
|
cmLocalGenerator* lg = target->GetLocalGenerator();
|
|
|
|
cmMakefile* mf = lg->GetMakefile();
|
|
|
|
|
|
|
|
if (!mf->IsOn("APPLE")) {
|
2016-06-08 12:29:35 +03:00
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2016-06-08 12:29:35 +03:00
|
|
|
std::string fwSearchFlagVar = "CMAKE_" + lang + "_FRAMEWORK_SEARCH_FLAG";
|
|
|
|
const char* fwSearchFlag = mf->GetDefinition(fwSearchFlagVar);
|
2016-06-08 12:29:35 +03:00
|
|
|
if (!(fwSearchFlag && *fwSearchFlag)) {
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::set<std::string> emitted;
|
|
|
|
#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */
|
|
|
|
emitted.insert("/System/Library/Frameworks");
|
|
|
|
#endif
|
|
|
|
std::vector<std::string> includes;
|
|
|
|
|
2016-06-08 12:29:35 +03:00
|
|
|
lg->GetIncludeDirectories(includes, target, "C", config);
|
2016-06-08 12:29:35 +03:00
|
|
|
// check all include directories for frameworks as this
|
|
|
|
// will already have added a -F for the framework
|
|
|
|
for (std::vector<std::string>::iterator i = includes.begin();
|
|
|
|
i != includes.end(); ++i) {
|
2016-06-08 12:29:35 +03:00
|
|
|
if (lg->GetGlobalGenerator()->NameResolvesToFramework(*i)) {
|
2016-06-08 12:29:35 +03:00
|
|
|
std::string frameworkDir = *i;
|
|
|
|
frameworkDir += "/../";
|
|
|
|
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
|
|
|
|
emitted.insert(frameworkDir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string flags;
|
|
|
|
if (cmComputeLinkInformation* cli = target->GetLinkInformation(config)) {
|
|
|
|
std::vector<std::string> const& frameworks = cli->GetFrameworkPaths();
|
|
|
|
for (std::vector<std::string>::const_iterator i = frameworks.begin();
|
|
|
|
i != frameworks.end(); ++i) {
|
|
|
|
if (emitted.insert(*i).second) {
|
|
|
|
flags += fwSearchFlag;
|
2016-06-08 12:29:35 +03:00
|
|
|
flags += lg->ConvertToOutputFormat(*i, cmOutputConverter::SHELL);
|
2016-06-08 12:29:35 +03:00
|
|
|
flags += " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2016-06-08 12:29:35 +03:00
|
|
|
std::string cmLocalGenerator::GetFrameworkFlags(std::string const& l,
|
|
|
|
std::string const& config,
|
|
|
|
cmGeneratorTarget* target)
|
|
|
|
{
|
|
|
|
return ::GetFrameworkFlags(l, config, target);
|
|
|
|
}
|
|
|
|
|
2016-06-08 14:23:25 +03:00
|
|
|
void cmLocalGenerator::GetTargetDefines(cmGeneratorTarget const* target,
|
|
|
|
std::string const& config,
|
|
|
|
std::string const& lang,
|
|
|
|
std::set<std::string>& defines) const
|
|
|
|
{
|
|
|
|
// Add the export symbol definition for shared library objects.
|
|
|
|
if (const char* exportMacro = target->GetExportMacro()) {
|
|
|
|
this->AppendDefines(defines, exportMacro);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add preprocessor definitions for this target and configuration.
|
|
|
|
this->AddCompileDefinitions(defines, target, config, lang.c_str());
|
|
|
|
}
|
|
|
|
|
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
|
2016-05-16 17:34:04 +03:00
|
|
|
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(' ');
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != lib.npos) {
|
2008-01-23 21:03:03 +03:00
|
|
|
// 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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetShortPath(lib.substr(0, pos).c_str(), sp)) {
|
2008-01-23 21:03:03 +03:00
|
|
|
// 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
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget& tgt, bool relink,
|
2014-04-05 01:06:13 +04:00
|
|
|
bool forResponseFile,
|
|
|
|
bool useWatcomQuote)
|
2004-10-21 22:34:02 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03: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");
|
2015-08-04 20:19:42 +03:00
|
|
|
cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!pcli) {
|
2008-01-29 23:07:33 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03: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.
|
2015-10-08 01:21:51 +03:00
|
|
|
if (tgt.GetType() == cmState::EXECUTABLE &&
|
2016-05-16 17:34:04 +03:00
|
|
|
this->StateSnapshot.GetState()->GetGlobalPropertyAsBool(
|
|
|
|
"TARGET_SUPPORTS_SHARED_LIBS")) {
|
2015-08-24 21:33:31 +03:00
|
|
|
bool add_shlib_flags = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (tgt.GetPolicyStatusCMP0065()) {
|
2015-08-24 21:33:31 +03:00
|
|
|
case cmPolicies::WARN:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!tgt.GetPropertyAsBool("ENABLE_EXPORTS") &&
|
|
|
|
this->Makefile->PolicyOptionalWarningEnabled(
|
|
|
|
"CMAKE_POLICY_WARNING_CMP0065")) {
|
2015-08-24 21:33:31 +03:00
|
|
|
std::ostringstream w;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-08-24 21:33:31 +03:00
|
|
|
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n"
|
|
|
|
"For compatibility with older versions of CMake, "
|
|
|
|
"additional flags may be added to export symbols on all "
|
|
|
|
"executables regardless of thier ENABLE_EXPORTS property.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-04-14 23:35:12 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-24 21:33:31 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior is to always add the flags
|
|
|
|
add_shlib_flags = true;
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
2016-04-14 23:35:12 +03:00
|
|
|
this->IssueMessage(
|
2015-08-24 21:33:31 +03:00
|
|
|
cmake::FATAL_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065));
|
2015-08-24 21:33:31 +03:00
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior is to only add the flags if ENABLE_EXPORTS is on
|
|
|
|
add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS");
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-24 21:33:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (add_shlib_flags) {
|
2015-08-24 21:33:31 +03:00
|
|
|
std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
|
|
|
|
linkFlagsVar += linkLanguage;
|
|
|
|
linkFlagsVar += "_FLAGS";
|
|
|
|
linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar);
|
|
|
|
linkLibs += " ";
|
2004-10-21 22:34:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar);
|
|
|
|
if (fwSearchFlag && *fwSearchFlag) {
|
2013-10-10 16:29:04 +04:00
|
|
|
std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
|
|
|
|
fdi != fwDirs.end(); ++fdi) {
|
2013-10-10 16:29:04 +04:00
|
|
|
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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Append the library search path flags.
|
|
|
|
std::vector<std::string> const& libDirs = cli.GetDirectories();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator libDir = libDirs.begin();
|
|
|
|
libDir != libDirs.end(); ++libDir) {
|
|
|
|
std::string libpath =
|
|
|
|
this->ConvertToOutputForExisting(*libDir, START_OUTPUT, shellFormat);
|
2012-09-26 16:38:15 +04:00
|
|
|
linkPath += " " + libPathFlag;
|
|
|
|
linkPath += libpath;
|
|
|
|
linkPath += libPathTerminator;
|
|
|
|
linkPath += " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Append the link items.
|
|
|
|
typedef cmComputeLinkInformation::ItemVector ItemVector;
|
|
|
|
ItemVector const& items = cli.GetItems();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (ItemVector::const_iterator li = items.begin(); li != items.end();
|
|
|
|
++li) {
|
|
|
|
if (li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY) {
|
2012-11-02 18:47:40 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (li->IsPath) {
|
2014-03-04 22:20:04 +04:00
|
|
|
linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-01-22 17:13:04 +03:00
|
|
|
linkLibs += li->Value;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
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.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cli.GetRuntimeSep().empty()) {
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator ri = runtimeDirs.begin();
|
|
|
|
ri != runtimeDirs.end(); ++ri) {
|
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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
fout << rpath;
|
|
|
|
} else {
|
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.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!rpath.empty()) {
|
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
|
|
|
}
|
2016-05-16 17:34:04 +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();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) {
|
2008-02-01 16:56:00 +03:00
|
|
|
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 << " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-01 16:56:00 +03:00
|
|
|
|
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";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* stdLibs = this->Makefile->GetDefinition(standardLibsVar)) {
|
2006-04-12 00:55:49 +04:00
|
|
|
fout << stdLibs << " ";
|
2016-05-16 17:34:04 +03: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
|
|
|
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):
|
2016-06-02 16:47:29 +03:00
|
|
|
if (this->Makefile->IsOn("APPLE") && 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");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sysroot && sysroot[0] == '/' && !sysroot[1]) {
|
|
|
|
sysroot = 0;
|
|
|
|
}
|
2012-09-21 16:53:42 +04:00
|
|
|
std::string sysrootFlagVar =
|
|
|
|
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* sysrootFlag = 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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!archs.empty() && !lang.empty() &&
|
|
|
|
(lang[0] == 'C' || lang[0] == 'F')) {
|
|
|
|
for (std::vector<std::string>::iterator i = archs.begin();
|
|
|
|
i != archs.end(); ++i) {
|
2012-09-21 16:53:42 +04:00
|
|
|
flags += " -arch ";
|
|
|
|
flags += *i;
|
2006-03-24 17:15:05 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-27 18:30:55 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sysrootFlag && *sysrootFlag && sysroot && *sysroot) {
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-27 18:30:55 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget &&
|
|
|
|
*deploymentTarget) {
|
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
|
|
|
}
|
2016-05-16 17:34:04 +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
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget* cmLocalGenerator::FindGeneratorTargetToUse(
|
|
|
|
const std::string& name) const
|
2015-09-16 06:21:07 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmGeneratorTarget*>::const_iterator imported = std::find_if(
|
|
|
|
this->ImportedGeneratorTargets.begin(),
|
|
|
|
this->ImportedGeneratorTargets.end(), NamedGeneratorTargetFinder(name));
|
|
|
|
if (imported != this->ImportedGeneratorTargets.end()) {
|
2015-10-25 15:14:44 +03:00
|
|
|
return *imported;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-25 15:14:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name)) {
|
2015-10-25 15:14:44 +03:00
|
|
|
return t;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-25 15:14:44 +03:00
|
|
|
|
|
|
|
return this->GetGlobalGenerator()->FindGeneratorTarget(name);
|
2015-09-16 06:21:07 +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:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == "") {
|
2012-11-21 20:23:14 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-21 20:23:14 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetFilenameLastExtension(name) == ".exe") {
|
2006-01-14 02:18:32 +03:00
|
|
|
name = cmSystemTools::GetFilenameWithoutLastExtension(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-14 02:18:32 +03:00
|
|
|
|
2006-01-14 04:51:45 +03:00
|
|
|
// Look for a CMake target with the given name.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorTarget* target = this->FindGeneratorTargetToUse(name)) {
|
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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsFullPath(inName.c_str())) {
|
2009-09-25 21:23:19 +04:00
|
|
|
std::string tLocation;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (target->GetType() >= cmState::EXECUTABLE &&
|
|
|
|
target->GetType() <= cmState::MODULE_LIBRARY) {
|
2013-10-28 22:47:46 +04:00
|
|
|
tLocation = target->GetLocation(config);
|
2009-09-25 21:23:19 +04:00
|
|
|
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
2014-10-15 16:54:05 +04:00
|
|
|
tLocation = cmSystemTools::CollapseFullPath(tLocation);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string depLocation =
|
|
|
|
cmSystemTools::GetFilenamePath(std::string(inName));
|
2014-10-15 16:54:05 +04:00
|
|
|
depLocation = cmSystemTools::CollapseFullPath(depLocation);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (depLocation != tLocation) {
|
2006-11-25 18:59:26 +03:00
|
|
|
// 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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
switch (target->GetType()) {
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::EXECUTABLE:
|
|
|
|
case cmState::STATIC_LIBRARY:
|
|
|
|
case cmState::SHARED_LIBRARY:
|
|
|
|
case cmState::MODULE_LIBRARY:
|
|
|
|
case cmState::UNKNOWN_LIBRARY:
|
2013-10-28 22:47:46 +04:00
|
|
|
dep = target->GetLocation(config);
|
2012-02-25 13:20:57 +04:00
|
|
|
return true;
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::OBJECT_LIBRARY:
|
2012-03-12 18:47:40 +04:00
|
|
|
// An object library has no single file on which to depend.
|
|
|
|
// This was listed to get the target-level dependency.
|
|
|
|
return false;
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::INTERFACE_LIBRARY:
|
2012-11-02 18:47:40 +04:00
|
|
|
// An interface library has no file on which to depend.
|
|
|
|
// This was listed to get the target-level dependency.
|
|
|
|
return false;
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::UTILITY:
|
|
|
|
case cmState::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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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.
|
2016-05-16 17:34:04 +03: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;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-08-05 21:27:06 +04:00
|
|
|
|
|
|
|
// Check for a source file in this directory that matches the
|
|
|
|
// dependency.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSourceFile* sf = this->Makefile->GetSource(inName)) {
|
2010-12-09 00:51:16 +03:00
|
|
|
dep = sf->GetFullPath();
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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-07-18 20:11:05 +03:00
|
|
|
dep = this->StateSnapshot.GetDirectory().GetCurrentSource();
|
2010-12-09 00:51:16 +03:00
|
|
|
dep += "/";
|
|
|
|
dep += inName;
|
|
|
|
return true;
|
2006-01-14 02:18:32 +03:00
|
|
|
}
|
|
|
|
|
2005-02-02 21:19:57 +03:00
|
|
|
void cmLocalGenerator::AddSharedFlags(std::string& flags,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& lang, bool shared)
|
2005-02-02 21:19:57 +03:00
|
|
|
{
|
|
|
|
std::string flagsVar;
|
|
|
|
|
|
|
|
// Add flags for dealing with shared libraries for this language.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (shared) {
|
2005-02-02 21:19:57 +03:00
|
|
|
flagsVar = "CMAKE_SHARED_LIBRARY_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_FLAGS";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::AddCompilerRequirementFlag(
|
|
|
|
std::string& flags, cmGeneratorTarget const* target, const std::string& lang)
|
2013-10-13 04:00:24 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (lang.empty()) {
|
2013-10-13 04:00:24 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
const char* defaultStd =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
|
|
|
|
if (!defaultStd || !*defaultStd) {
|
2015-01-27 00:42:36 +03:00
|
|
|
// This compiler has no notion of language standard levels.
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
std::string stdProp = lang + "_STANDARD";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* standardProp = target->GetProperty(stdProp);
|
|
|
|
if (!standardProp) {
|
2013-10-13 04:00:24 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
std::string extProp = lang + "_EXTENSIONS";
|
2014-05-30 17:03:45 +04:00
|
|
|
std::string type = "EXTENSION";
|
|
|
|
bool ext = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* extPropValue = target->GetProperty(extProp)) {
|
|
|
|
if (cmSystemTools::IsOff(extPropValue)) {
|
2014-05-30 17:03:45 +04:00
|
|
|
ext = false;
|
|
|
|
type = "STANDARD";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED")) {
|
2014-04-30 20:07:38 +04:00
|
|
|
std::string option_flag =
|
2016-05-16 17:34:04 +03:00
|
|
|
"CMAKE_" + lang + standardProp + "_" + type + "_COMPILE_OPTION";
|
2014-04-30 20:07:38 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* opt =
|
|
|
|
target->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 "
|
2016-05-16 17:34:04 +03:00
|
|
|
"dialect \""
|
|
|
|
<< lang << standardProp << "\" "
|
|
|
|
<< (ext ? "(with compiler extensions)" : "")
|
|
|
|
<< ", but CMake "
|
2014-04-30 20:07:38 +04:00
|
|
|
"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());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-06-13 12:30:57 +04:00
|
|
|
this->AppendFlagEscape(flags, opt);
|
2014-04-30 20:07:38 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
|
|
|
}
|
2014-04-30 20:07:38 +04:00
|
|
|
|
2014-03-28 19:09:35 +04:00
|
|
|
static std::map<std::string, std::vector<std::string> > langStdMap;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (langStdMap.empty()) {
|
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");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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 =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::find(stds.begin(), stds.end(), standard);
|
|
|
|
if (stdIt == stds.end()) {
|
2015-02-28 00:48:39 +03:00
|
|
|
std::string e =
|
|
|
|
lang + "_STANDARD is set to invalid value '" + standard + "'";
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR, e, target->GetBacktrace());
|
2015-02-28 00:48:39 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (defaultStdIt == stds.end()) {
|
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (stdIt >= defaultStdIt) {
|
2015-02-04 21:14:00 +03:00
|
|
|
std::string option_flag =
|
2016-05-16 17:34:04 +03:00
|
|
|
"CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
|
2015-02-04 21:14:00 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* opt =
|
|
|
|
target->Target->GetMakefile()->GetRequiredDefinition(option_flag);
|
2015-02-04 21:14:00 +03:00
|
|
|
this->AppendFlagEscape(flags, opt);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-28 19:09:35 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; stdIt < defaultStdIt; ++stdIt) {
|
2014-03-28 19:09:35 +04:00
|
|
|
std::string option_flag =
|
2016-05-16 17:34:04 +03:00
|
|
|
"CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
|
2014-03-28 19:09:35 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* opt =
|
|
|
|
target->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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-13 04:00:24 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void AddVisibilityCompileOption(std::string& flags,
|
2015-10-25 02:19:14 +03:00
|
|
|
cmGeneratorTarget const* target,
|
2016-05-16 17:34:04 +03: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
|
|
|
{
|
2016-05-26 23:21:15 +03:00
|
|
|
std::string compileOption = "CMAKE_" + lang + "_COMPILE_OPTIONS_VISIBILITY";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* opt = lg->GetMakefile()->GetDefinition(compileOption);
|
|
|
|
if (!opt) {
|
2013-05-18 14:12:18 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-05-26 23:21:15 +03:00
|
|
|
std::string flagDefine = lang + "_VISIBILITY_PRESET";
|
2013-05-18 14:12:18 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* prop = target->GetProperty(flagDefine);
|
|
|
|
if (!prop) {
|
2013-05-18 14:12:18 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (warnCMP0063) {
|
2015-05-22 21:01:44 +03:00
|
|
|
*warnCMP0063 += " " + flagDefine + "\n";
|
|
|
|
return;
|
2016-05-16 17:34:04 +03: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;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Target " << target->GetName() << " uses unsupported value \"" << prop
|
|
|
|
<< "\" for " << flagDefine << ".";
|
2013-05-18 14:12:18 +04:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-05-18 14:12:18 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void AddInlineVisibilityCompileOption(std::string& flags,
|
|
|
|
cmGeneratorTarget const* target,
|
|
|
|
cmLocalGenerator* lg,
|
|
|
|
std::string* warnCMP0063)
|
2013-05-23 17:32:17 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string compileOption =
|
|
|
|
"CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
|
|
|
|
const char* opt = lg->GetMakefile()->GetDefinition(compileOption);
|
|
|
|
if (!opt) {
|
2013-05-23 17:32:17 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-05-23 17:32:17 +04:00
|
|
|
|
|
|
|
bool prop = target->GetPropertyAsBool("VISIBILITY_INLINES_HIDDEN");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!prop) {
|
2013-05-23 17:32:17 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (warnCMP0063) {
|
2015-05-22 21:01:44 +03:00
|
|
|
*warnCMP0063 += " VISIBILITY_INLINES_HIDDEN\n";
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-05-23 17:32:17 +04:00
|
|
|
lg->AppendFlags(flags, opt);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::AddVisibilityPresetFlags(
|
|
|
|
std::string& flags, cmGeneratorTarget const* target, const std::string& lang)
|
2013-05-23 17:32:17 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (lang.empty()) {
|
2013-05-23 17:32:17 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-05-23 17:32:17 +04:00
|
|
|
|
2015-05-22 21:01:44 +03:00
|
|
|
std::string warnCMP0063;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string* pWarnCMP0063 = 0;
|
2015-10-08 01:21:51 +03:00
|
|
|
if (target->GetType() != cmState::SHARED_LIBRARY &&
|
|
|
|
target->GetType() != cmState::MODULE_LIBRARY &&
|
2016-05-16 17:34:04 +03:00
|
|
|
!target->IsExecutableWithExports()) {
|
|
|
|
switch (target->GetPolicyStatusCMP0063()) {
|
2015-05-22 21:01:44 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
return;
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
pWarnCMP0063 = &warnCMP0063;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-23 17:32:17 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-22 21:01:44 +03:00
|
|
|
|
2015-10-25 02:19:14 +03:00
|
|
|
AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063);
|
2014-01-31 19:09:06 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (lang == "CXX") {
|
2015-10-25 02:19:14 +03:00
|
|
|
AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-22 21:01:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!warnCMP0063.empty() && this->WarnCMP0063.insert(target).second) {
|
2015-05-22 21:01:44 +03:00
|
|
|
std::ostringstream w;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-05-22 21:01:44 +03:00
|
|
|
w <<
|
|
|
|
cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n"
|
|
|
|
"Target \"" << target->GetName() << "\" of "
|
2015-10-08 01:26:50 +03:00
|
|
|
"type \"" << cmState::GetTargetTypeName(target->GetType()) << "\" "
|
2015-05-22 21:01:44 +03:00
|
|
|
"has the following visibility properties set for " << lang << ":\n" <<
|
|
|
|
warnCMP0063 <<
|
|
|
|
"For compatibility CMake is not honoring them for this target.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
|
|
|
|
cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace());
|
|
|
|
}
|
2013-05-18 14:12:18 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::AddCMP0018Flags(std::string& flags,
|
2015-10-09 23:19:57 +03:00
|
|
|
cmGeneratorTarget 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();
|
|
|
|
|
2015-10-08 01:21:51 +03:00
|
|
|
bool shared = ((targetType == cmState::SHARED_LIBRARY) ||
|
2016-05-16 17:34:04 +03:00
|
|
|
(targetType == cmState::MODULE_LIBRARY));
|
2012-05-30 22:13:09 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetShouldUseOldFlags(shared, lang)) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddSharedFlags(flags, lang, shared);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (target->GetType() == cmState::OBJECT_LIBRARY) {
|
|
|
|
if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE")) {
|
2012-11-05 15:46:26 +04:00
|
|
|
this->AddPositionIndependentFlags(flags, lang, targetType);
|
2013-05-18 11:54:50 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
|
|
|
}
|
2012-11-05 15:46:26 +04:00
|
|
|
|
2015-10-09 23:19:57 +03:00
|
|
|
if (target->GetLinkInterfaceDependentBoolProperty(
|
2016-05-16 17:34:04 +03:00
|
|
|
"POSITION_INDEPENDENT_CODE", config)) {
|
2012-05-30 22:13:09 +04:00
|
|
|
this->AddPositionIndependentFlags(flags, lang, targetType);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (shared) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AppendFeatureOptions(flags, lang, "DLL");
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-05-30 22:13:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& lang) const
|
2012-05-30 22:13:09 +04:00
|
|
|
{
|
|
|
|
std::string originalFlags =
|
|
|
|
this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (shared) {
|
2012-05-30 22:13:09 +04:00
|
|
|
std::string flagsVar = "CMAKE_SHARED_LIBRARY_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_FLAGS";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* flags = this->Makefile->GetSafeDefinition(flagsVar);
|
|
|
|
|
|
|
|
if (flags && flags != originalFlags) {
|
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0018)) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03: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 "
|
2012-05-30 22:13:09 +04:00
|
|
|
<< 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;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-05-30 22:13:09 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
|
|
|
|
std::string const& lang,
|
|
|
|
int targetType)
|
|
|
|
{
|
|
|
|
const char* picFlags = 0;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (targetType == cmState::EXECUTABLE) {
|
2012-05-30 22:13:09 +04:00
|
|
|
std::string flagsVar = "CMAKE_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_COMPILE_OPTIONS_PIE";
|
2014-03-11 03:04:11 +04:00
|
|
|
picFlags = this->Makefile->GetSafeDefinition(flagsVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!picFlags) {
|
2012-05-30 22:13:09 +04:00
|
|
|
std::string flagsVar = "CMAKE_";
|
|
|
|
flagsVar += lang;
|
|
|
|
flagsVar += "_COMPILE_OPTIONS_PIC";
|
2014-03-11 03:04:11 +04:00
|
|
|
picFlags = this->Makefile->GetSafeDefinition(flagsVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (picFlags) {
|
2012-05-30 22:13:09 +04:00
|
|
|
std::vector<std::string> options;
|
|
|
|
cmSystemTools::ExpandListArgument(picFlags, options);
|
2016-05-16 17:34:04 +03:00
|
|
|
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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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.
|
2016-05-16 17:34:04 +03: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));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!newFlags.empty()) {
|
|
|
|
if (!flags.empty()) {
|
2005-02-02 21:19:57 +03:00
|
|
|
flags += " ";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
flags += newFlags;
|
|
|
|
}
|
2005-02-02 21:19:57 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::AppendFlags(std::string& flags, const char* newFlags)
|
2014-05-02 00:07:26 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (newFlags && *newFlags) {
|
2014-05-02 00:07:26 +04:00
|
|
|
this->AppendFlags(flags, std::string(newFlags));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-02 00:07:26 +04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-08-09 11:44:15 +04:00
|
|
|
void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
|
2016-06-10 16:23:14 +03:00
|
|
|
const char* defines_list) const
|
2008-01-14 17:20:58 +03:00
|
|
|
{
|
|
|
|
// Short-circuit if there are no definitions.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!defines_list) {
|
2008-01-14 17:20:58 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::AppendDefines(
|
2016-06-10 16:23:14 +03:00
|
|
|
std::set<std::string>& defines,
|
|
|
|
const std::vector<std::string>& defines_vec) const
|
2013-06-06 20:17:10 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator di = defines_vec.begin();
|
|
|
|
di != defines_vec.end(); ++di) {
|
2012-08-09 11:44:15 +04:00
|
|
|
// Skip unsupported definitions.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CheckDefinition(*di)) {
|
2012-08-09 11:44:15 +04:00
|
|
|
continue;
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
defines.insert(*di);
|
|
|
|
}
|
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,
|
2016-05-16 17:34:04 +03:00
|
|
|
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";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!lang.empty()) {
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (df && *df) {
|
2008-01-17 18:00:19 +03:00
|
|
|
dflag = df;
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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() ? "" : " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
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;
|
2016-05-16 17:34:04 +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
|
|
|
|
// '$#'.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (const char* c = defineIt->c_str(); *c; ++c) {
|
|
|
|
if (*c == '$' || *c == '#') {
|
2012-08-09 11:44:15 +04:00
|
|
|
def += '$';
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
def += *c;
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-04-24 19:18:06 +04:00
|
|
|
// Make the definition appear properly on the command line. Use
|
2016-03-09 17:42:18 +03:00
|
|
|
// -DNAME="value" instead of -D"NAME=value" for historical reasons.
|
2012-08-09 11:44:15 +04:00
|
|
|
std::string::size_type eq = defineIt->find("=");
|
|
|
|
def += defineIt->substr(0, eq);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (eq != defineIt->npos) {
|
2012-08-09 11:44:15 +04:00
|
|
|
def += "=";
|
|
|
|
def += this->EscapeForShell(defineIt->c_str() + eq + 1, true);
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-08-09 11:44:15 +04:00
|
|
|
definesString += itemSeparator;
|
|
|
|
itemSeparator = " ";
|
|
|
|
definesString += def;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::AppendFeatureOptions(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;
|
2016-05-16 17:34:04 +03: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);
|
2016-05-16 17:34:04 +03:00
|
|
|
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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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)
|
|
|
|
{
|
2015-08-02 10:14:28 +03:00
|
|
|
std::string featureName = feature;
|
2015-06-06 16:42:31 +03:00
|
|
|
// TODO: Define accumulation policy for features (prepend, append, replace).
|
|
|
|
// Currently we always replace.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-08-02 10:14:28 +03:00
|
|
|
featureName += "_";
|
|
|
|
featureName += cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-02 10:18:37 +03:00
|
|
|
cmState::Snapshot snp = this->StateSnapshot;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (snp.IsValid()) {
|
|
|
|
if (const char* value = snp.GetDirectory().GetProperty(featureName)) {
|
2015-08-02 10:16:17 +03:00
|
|
|
return value;
|
2015-06-06 16:42:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
snp = snp.GetBuildsystemDirectoryParent();
|
|
|
|
}
|
2015-08-02 10:16:17 +03:00
|
|
|
return 0;
|
2015-06-06 16:42:31 +03:00
|
|
|
}
|
|
|
|
|
2015-10-07 01:29:25 +03:00
|
|
|
std::string cmLocalGenerator::GetProjectName() const
|
|
|
|
{
|
|
|
|
return this->StateSnapshot.GetProjectName();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmLocalGenerator::ConstructComment(
|
|
|
|
cmCustomCommandGenerator const& ccg, const char* default_comment)
|
2006-04-11 19:06:19 +04:00
|
|
|
{
|
|
|
|
// Check for a comment provided with the command.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ccg.GetComment()) {
|
2014-03-10 23:47:19 +04:00
|
|
|
return ccg.GetComment();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-11 19:06:19 +04:00
|
|
|
|
|
|
|
// Construct a reasonable default comment if possible.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ccg.GetOutputs().empty()) {
|
2006-04-11 19:06:19 +04:00
|
|
|
std::string comment;
|
|
|
|
comment = "Generating ";
|
|
|
|
const char* sep = "";
|
2016-05-16 17:34:04 +03: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;
|
2016-05-20 00:11:40 +03:00
|
|
|
comment += this->Convert(*o, cmOutputConverter::START_OUTPUT);
|
2006-04-11 19:06:19 +04:00
|
|
|
sep = ", ";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return comment;
|
|
|
|
}
|
2006-04-11 19:06:19 +04:00
|
|
|
|
|
|
|
// Otherwise use the provided default.
|
|
|
|
return default_comment;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmInstallTargetGeneratorLocal : public cmInstallTargetGenerator
|
2014-06-24 18:55:20 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-07-28 20:32:03 +03:00
|
|
|
cmInstallTargetGeneratorLocal(cmLocalGenerator* lg, std::string const& t,
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* dest, bool implib)
|
|
|
|
: cmInstallTargetGenerator(
|
|
|
|
t, dest, implib, "", std::vector<std::string>(), "Unspecified",
|
|
|
|
cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()), false,
|
|
|
|
false)
|
2015-07-28 20:32:03 +03:00
|
|
|
{
|
|
|
|
this->Compute(lg);
|
|
|
|
}
|
2014-06-24 18:55:20 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +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.
|
2015-10-18 18:06:14 +03:00
|
|
|
std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
|
|
|
|
l != tgts.end(); ++l) {
|
|
|
|
if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) {
|
2013-11-20 15:44:04 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-20 15:44:04 +04:00
|
|
|
|
2006-02-19 23:25:27 +03:00
|
|
|
// Include the user-specified pre-install script for this target.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT")) {
|
2016-02-01 13:01:39 +03:00
|
|
|
cmInstallScriptGenerator g(preinstall, false, 0, false);
|
2006-02-19 23:25:27 +03:00
|
|
|
g.Generate(os, config, configurationTypes);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
// Install this target if a destination is given.
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((*l)->Target->GetInstallPath() != "") {
|
2006-02-19 23:25:27 +03:00
|
|
|
// 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.
|
2015-10-18 18:06:14 +03:00
|
|
|
std::string destination = (*l)->Target->GetInstallPath().substr(1);
|
2006-02-19 23:25:27 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(destination);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (destination.empty()) {
|
2009-02-04 18:34:10 +03:00
|
|
|
destination = ".";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
// Generate the proper install generator for this target type.
|
2016-05-16 17:34:04 +03:00
|
|
|
switch ((*l)->GetType()) {
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::EXECUTABLE:
|
|
|
|
case cmState::STATIC_LIBRARY:
|
2016-05-16 17:34:04 +03:00
|
|
|
case cmState::MODULE_LIBRARY: {
|
2006-02-19 23:25:27 +03:00
|
|
|
// Use a target install generator.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
|
|
|
|
destination.c_str(), false);
|
2006-02-19 23:25:27 +03:00
|
|
|
g.Generate(os, config, configurationTypes);
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
|
|
|
case cmState::SHARED_LIBRARY: {
|
2006-02-19 23:25:27 +03:00
|
|
|
#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.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstallTargetGeneratorLocal g1(this, (*l)->GetName(),
|
|
|
|
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.
|
2015-10-18 18:06:14 +03:00
|
|
|
destination = (*l)->Target->GetRuntimeInstallPath().substr(1);
|
2006-02-19 23:25:27 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(destination);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstallTargetGeneratorLocal g2(this, (*l)->GetName(),
|
|
|
|
destination.c_str(), false);
|
2006-02-19 23:25:27 +03:00
|
|
|
g2.Generate(os, config, configurationTypes);
|
|
|
|
#else
|
|
|
|
// Use a target install generator.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
|
|
|
|
destination.c_str(), false);
|
2006-02-19 23:25:27 +03:00
|
|
|
g.Generate(os, config, configurationTypes);
|
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2006-02-19 23:25:27 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
|
|
|
|
// Include the user-specified post-install script for this target.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT")) {
|
2016-02-01 13:01:39 +03:00
|
|
|
cmInstallScriptGenerator g(postinstall, false, 0, false);
|
2006-02-19 23:25:27 +03:00
|
|
|
g.Generate(os, config, configurationTypes);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-19 23:25:27 +03:00
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static bool cmLocalGeneratorShortenObjectName(std::string& objName,
|
|
|
|
std::string::size_type max_len)
|
2007-03-16 17:34:25 +03:00
|
|
|
{
|
|
|
|
// Replace the beginning of the path portion of the object name with
|
|
|
|
// its own md5 sum.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string::size_type pos =
|
|
|
|
objName.find('/', objName.size() - max_len + 32);
|
|
|
|
if (pos != objName.npos) {
|
2007-03-16 17:34:25 +03:00
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-03-16 17:34:25 +03:00
|
|
|
// The object name could not be shortened enough.
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-03-16 17:34:25 +03:00
|
|
|
}
|
|
|
|
|
2008-08-21 17:54:36 +04:00
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dir_len < max_total_len) {
|
2007-03-16 17:34:25 +03:00
|
|
|
max_obj_len = max_total_len - dir_len;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (objName.size() > max_obj_len) {
|
2007-03-16 17:34:25 +03:00
|
|
|
// The current object file name is too long. Try to shorten it.
|
|
|
|
return cmLocalGeneratorShortenObjectName(objName, max_obj_len);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-03-16 17:34:25 +03:00
|
|
|
// The object file name is short enough.
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-03-16 17:34:25 +03:00
|
|
|
// The build directory in which the object will be stored is
|
|
|
|
// already too deep.
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-03-16 17:34:25 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName(
|
|
|
|
const std::string& sin, std::string const& dir_max)
|
2006-07-11 19:41:38 +04:00
|
|
|
{
|
|
|
|
// Look for an existing mapped name for this object file.
|
2016-05-16 17:34:04 +03: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.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (it == this->UniqueObjectNamesMap.end()) {
|
2006-07-11 19:41:38 +04:00
|
|
|
// Start with the original name.
|
|
|
|
std::string ssin = sin;
|
|
|
|
|
|
|
|
// Avoid full paths by removing leading slashes.
|
2016-05-24 22:24:10 +03:00
|
|
|
ssin.erase(0, ssin.find_first_not_of('/'));
|
2006-07-11 19:41:38 +04:00
|
|
|
|
|
|
|
// Avoid full paths by removing colons.
|
Use std::replace for replacing chars in strings.
Find uses of `cmSystemTools::ReplaceString` where both `replace` and
`with` are string literals with a size of one.
Automate with:
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\2', '\3');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\\\\\\\\\");|std::replace(\1.begin(), \1.end(), '\2', '\\\\\\\\');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\\\\\\\\\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\\\\\\\\', '\2');|g"
2016-05-24 23:58:11 +03:00
|
|
|
std::replace(ssin.begin(), ssin.end(), ':', '_');
|
2006-07-11 19:41:38 +04:00
|
|
|
|
|
|
|
// Avoid relative paths that go up the tree.
|
|
|
|
cmSystemTools::ReplaceString(ssin, "../", "__/");
|
|
|
|
|
|
|
|
// Avoid spaces.
|
Use std::replace for replacing chars in strings.
Find uses of `cmSystemTools::ReplaceString` where both `replace` and
`with` are string literals with a size of one.
Automate with:
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\2', '\3');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\\\\\\\\\");|std::replace(\1.begin(), \1.end(), '\2', '\\\\\\\\');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\\\\\\\\\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\\\\\\\\', '\2');|g"
2016-05-24 23:58:11 +03:00
|
|
|
std::replace(ssin.begin(), ssin.end(), ' ', '_');
|
2006-07-11 19:41:38 +04:00
|
|
|
|
|
|
|
// Mangle the name if necessary.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES")) {
|
2006-07-11 19:41:38 +04:00
|
|
|
bool done;
|
|
|
|
int cc = 0;
|
|
|
|
char rpstr[100];
|
|
|
|
sprintf(rpstr, "_p_");
|
|
|
|
cmSystemTools::ReplaceString(ssin, "+", rpstr);
|
|
|
|
std::string sssin = sin;
|
2016-05-16 17:34:04 +03:00
|
|
|
do {
|
2006-07-11 19:41:38 +04:00
|
|
|
done = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->UniqueObjectNamesMap.begin();
|
|
|
|
it != this->UniqueObjectNamesMap.end(); ++it) {
|
|
|
|
if (it->second == ssin) {
|
2006-07-11 19:41:38 +04:00
|
|
|
done = false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (done) {
|
2006-07-11 19:41:38 +04:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
sssin = ssin;
|
|
|
|
cmSystemTools::ReplaceString(ssin, "_p_", rpstr);
|
|
|
|
sprintf(rpstr, "_p%d_", cc++);
|
2016-05-16 17:34:04 +03:00
|
|
|
} while (!done);
|
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
|
2007-03-16 17:34:25 +03:00
|
|
|
#if defined(CM_LG_ENCODE_OBJECT_NAMES)
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmLocalGeneratorCheckObjectName(ssin, dir_max.size(),
|
|
|
|
this->ObjectPathMax)) {
|
2008-12-16 17:15:18 +03:00
|
|
|
// Warn if this is the first time the path has been seen.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ObjectMaxPathViolations.insert(dir_max).second) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream m;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
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.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2015-06-13 20:32:46 +03:00
|
|
|
this->IssueMessage(cmake::WARNING, m.str());
|
2008-12-16 17:15:18 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +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;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-11 19:41:38 +04:00
|
|
|
|
|
|
|
// Return the map entry.
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
2014-03-11 20:37:26 +04:00
|
|
|
void cmLocalGenerator::ComputeObjectFilenames(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<cmSourceFile const*, std::string>&, cmGeneratorTarget const*)
|
2014-03-11 20:37:26 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
|
|
|
|
const cmSourceFile& source, std::string const& dir_max,
|
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((relSource && !relBinary) || (subSource && !subBinary)) {
|
2007-03-09 18:30:07 +03:00
|
|
|
objectName = relFromSource;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((relBinary && !relSource) || (subBinary && !subSource)) {
|
2007-03-09 18:30:07 +03:00
|
|
|
objectName = relFromBinary;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (relFromBinary.length() < relFromSource.length()) {
|
2007-03-09 18:30:07 +03:00
|
|
|
objectName = relFromBinary;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-03-09 18:30:07 +03:00
|
|
|
objectName = relFromSource;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-03-09 18:30:07 +03:00
|
|
|
|
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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsFullPath(objectName.c_str())) {
|
|
|
|
if (this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) {
|
2007-02-01 00:49:25 +03:00
|
|
|
objectName = cmSystemTools::GetFilenameName(source.GetFullPath());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!source.GetPropertyAsBool("KEEP_EXTENSION")) {
|
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();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!replaceExt) {
|
2014-02-04 06:20:56 +04:00
|
|
|
std::string lang = source.GetLanguage();
|
2016-05-16 17:34:04 +03:00
|
|
|
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);
|
2008-01-08 00:12:37 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-08 00:12:37 +03:00
|
|
|
|
|
|
|
// Remove the source extension if it is to be replaced.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (replaceExt) {
|
2008-01-08 00:12:37 +03:00
|
|
|
keptSourceExtension = false;
|
2016-05-24 22:24:10 +03:00
|
|
|
std::string::size_type dot_pos = objectName.rfind('.');
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dot_pos != std::string::npos) {
|
2007-12-29 07:07:26 +03:00
|
|
|
objectName = objectName.substr(0, dot_pos);
|
2006-07-11 19:41:38 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
// Store the new extension.
|
2016-05-16 17:34:04 +03:00
|
|
|
objectName += this->GlobalGenerator->GetLanguageOutputExtension(source);
|
|
|
|
}
|
|
|
|
if (hasSourceExtension) {
|
2008-01-08 00:12:37 +03:00
|
|
|
*hasSourceExtension = keptSourceExtension;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmLocalGenerator::GetSourceFileLanguage(const cmSourceFile& source)
|
2006-08-03 17:26:07 +04:00
|
|
|
{
|
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
|
|
|
|
2015-10-07 01:37:31 +03:00
|
|
|
cmake* cmLocalGenerator::GetCMakeInstance() const
|
|
|
|
{
|
|
|
|
return this->GlobalGenerator->GetCMakeInstance();
|
|
|
|
}
|
|
|
|
|
2015-10-07 02:17:48 +03:00
|
|
|
const char* cmLocalGenerator::GetSourceDirectory() const
|
|
|
|
{
|
|
|
|
return this->GetCMakeInstance()->GetHomeDirectory();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmLocalGenerator::GetBinaryDirectory() const
|
|
|
|
{
|
|
|
|
return this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
|
|
}
|
|
|
|
|
2015-09-25 01:13:20 +03:00
|
|
|
const char* cmLocalGenerator::GetCurrentBinaryDirectory() const
|
|
|
|
{
|
|
|
|
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
|
|
|
}
|
|
|
|
|
2015-10-07 20:25:29 +03:00
|
|
|
const char* cmLocalGenerator::GetCurrentSourceDirectory() const
|
|
|
|
{
|
|
|
|
return this->StateSnapshot.GetDirectory().GetCurrentSource();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmLocalGenerator::GetTargetDirectory(
|
|
|
|
const cmGeneratorTarget*) const
|
2007-08-01 23:25:40 +04:00
|
|
|
{
|
|
|
|
cmSystemTools::Error("GetTargetDirectory"
|
|
|
|
" called on cmLocalGenerator");
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-12-17 23:03:42 +03:00
|
|
|
KWIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility()
|
2007-12-29 07:07:14 +03:00
|
|
|
{
|
|
|
|
// The computed version may change until the project is fully
|
|
|
|
// configured.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->BackwardsCompatibilityFinal) {
|
2007-12-29 07:07:14 +03:00
|
|
|
unsigned int major = 0;
|
|
|
|
unsigned int minor = 0;
|
|
|
|
unsigned int patch = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
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;
|
2007-12-29 07:07:14 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-29 07:07:14 +03:00
|
|
|
this->BackwardsCompatibility = CMake_VERSION_ENCODE(major, minor, patch);
|
2015-09-18 02:42:45 +03:00
|
|
|
this->BackwardsCompatibilityFinal = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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.
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0001)) {
|
2008-03-07 23:30:35 +03:00
|
|
|
case cmPolicies::WARN:
|
2016-05-16 17:34:04 +03:00
|
|
|
// WARN is just OLD without warning because user code does not
|
|
|
|
// always affect whether this check is done.
|
2008-03-07 23:30:35 +03:00
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-07 23:30:35 +03:00
|
|
|
|
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.
|
2015-12-17 23:03:42 +03:00
|
|
|
KWIML_INT_uint64_t actual_compat = this->GetBackwardsCompatibility();
|
2016-05-16 17:34:04 +03:00
|
|
|
return (actual_compat && actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
|
2007-12-29 07:07:14 +03:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmPolicies::PolicyStatus cmLocalGenerator::GetPolicyStatus(
|
|
|
|
cmPolicies::PolicyID id) const
|
2015-10-23 02:13:36 +03:00
|
|
|
{
|
|
|
|
return this->Makefile->GetPolicyStatus(id);
|
|
|
|
}
|
|
|
|
|
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("(=");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != std::string::npos) {
|
|
|
|
if (define[pos] == '(') {
|
2015-01-28 00:13:45 +03:00
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-01-28 00:13:45 +03:00
|
|
|
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";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2015-01-28 00:13:45 +03:00
|
|
|
cmSystemTools::Message(e.str().c_str());
|
|
|
|
return false;
|
2008-01-14 17:20:58 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
|
|
|
|
// Many compilers do not support # in the value so we disable it.
|
2016-05-24 22:24:10 +03:00
|
|
|
if (define.find_first_of('#') != define.npos) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
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";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2008-01-14 17:20:58 +03:00
|
|
|
cmSystemTools::Message(e.str().c_str());
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-14 17:20:58 +03:00
|
|
|
|
|
|
|
// Assume it is supported.
|
|
|
|
return true;
|
|
|
|
}
|
2008-02-14 23:31:08 +03:00
|
|
|
|
2015-10-09 23:31:05 +03:00
|
|
|
static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& prop)
|
2008-02-14 23:31:08 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* val = target->GetProperty(prop)) {
|
2014-03-11 03:04:11 +04:00
|
|
|
mf->AddDefinition(prop, val);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-14 23:31:08 +03:00
|
|
|
}
|
|
|
|
|
2015-10-09 23:31:05 +03:00
|
|
|
void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* 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");
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in";
|
|
|
|
if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
|
2008-05-17 20:53:56 +04:00
|
|
|
std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!inMod.empty()) {
|
2008-05-17 20:53:56 +04:00
|
|
|
inFile = inMod;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
|
|
|
|
<< "\" could not be found.";
|
2008-05-17 20:53:56 +04:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-05-17 20:53:56 +04:00
|
|
|
|
|
|
|
// 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;
|
2015-11-24 21:11:09 +03:00
|
|
|
cmMakefile::ScopePushPop varScope(mf);
|
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);
|
2008-02-14 23:31:08 +03:00
|
|
|
}
|
2008-09-02 20:06:32 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmLocalGenerator::GenerateFrameworkInfoPList(
|
|
|
|
cmGeneratorTarget* target, 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");
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in";
|
|
|
|
if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
|
2008-09-02 20:06:32 +04:00
|
|
|
std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!inMod.empty()) {
|
2008-09-02 20:06:32 +04:00
|
|
|
inFile = inMod;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
|
|
|
|
<< "\" could not be found.";
|
2008-09-02 20:06:32 +04:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-09-02 20:06:32 +04:00
|
|
|
|
|
|
|
// 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;
|
2015-11-24 21:11:09 +03:00
|
|
|
cmMakefile::ScopePushPop varScope(mf);
|
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);
|
|
|
|
}
|