2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2001-01-11 22:55:47 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2001-01-11 22:55:47 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2000-08-29 23:26:29 +04:00
|
|
|
#include "cmMakefile.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-08-24 01:29:15 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2001-01-18 19:20:24 +03:00
|
|
|
#include "cmCommand.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCommandArgumentParserHelper.h"
|
2016-08-24 01:29:15 +03:00
|
|
|
#include "cmCustomCommand.h"
|
|
|
|
#include "cmCustomCommandLines.h"
|
|
|
|
#include "cmExecutionStatus.h"
|
|
|
|
#include "cmExpandedCommandArgument.h"
|
|
|
|
#include "cmFileLockPool.h"
|
2001-04-20 01:39:03 +04:00
|
|
|
#include "cmFunctionBlocker.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGeneratorExpression.h"
|
2015-08-01 13:05:13 +03:00
|
|
|
#include "cmGeneratorExpressionEvaluationFile.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGlobalGenerator.h"
|
2001-08-29 02:28:31 +04:00
|
|
|
#include "cmListFileCache.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmSourceFile.h"
|
|
|
|
#include "cmSourceFileLocation.h"
|
|
|
|
#include "cmState.h"
|
|
|
|
#include "cmSystemTools.h"
|
2005-04-24 23:59:51 +04:00
|
|
|
#include "cmTest.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmVersion.h"
|
2016-08-24 01:29:15 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmInstallGenerator.h" // IWYU pragma: keep
|
|
|
|
#include "cmTestGenerator.h" // IWYU pragma: keep
|
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2016-05-16 17:34:04 +03:00
|
|
|
#include "cmVariableWatch.h"
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2003-06-23 22:10:12 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <algorithm>
|
|
|
|
#include <assert.h>
|
2016-06-28 17:17:52 +03:00
|
|
|
#include <cm_auto_ptr.hxx>
|
2014-01-04 09:47:13 +04:00
|
|
|
#include <cmsys/FStream.hxx>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2016-08-24 01:29:15 +03:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <utility>
|
2006-05-23 20:51:26 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
class cmMessenger;
|
|
|
|
|
2000-08-29 23:26:29 +04:00
|
|
|
// default is not to be building executables
|
2015-08-02 12:20:28 +03:00
|
|
|
cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
|
|
|
|
cmState::Snapshot const& snapshot)
|
2016-05-16 17:34:04 +03:00
|
|
|
: GlobalGenerator(globalGenerator)
|
|
|
|
, StateSnapshot(snapshot)
|
|
|
|
, Backtrace(snapshot)
|
2000-08-29 23:26:29 +04:00
|
|
|
{
|
2015-08-25 23:19:57 +03:00
|
|
|
this->IsSourceFileTryCompile = false;
|
2007-12-03 21:35:41 +03:00
|
|
|
|
2015-05-16 17:39:36 +03:00
|
|
|
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
|
|
|
|
this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
|
2007-12-03 21:35:41 +03:00
|
|
|
|
2015-05-04 17:16:34 +03:00
|
|
|
this->SuppressWatches = false;
|
|
|
|
|
2001-06-21 23:02:52 +04:00
|
|
|
// Setup the default include complaint regular expression (match nothing).
|
2006-03-15 19:02:08 +03:00
|
|
|
this->ComplainFileRegularExpression = "^$";
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2006-03-15 19:02:08 +03:00
|
|
|
this->DefineFlags = " ";
|
2006-03-22 17:58:11 +03:00
|
|
|
|
2007-06-11 18:25:40 +04:00
|
|
|
this->cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
|
|
|
|
this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
|
|
|
|
this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
|
2014-02-08 07:37:54 +04:00
|
|
|
this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
|
2008-03-06 18:57:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->StateSnapshot =
|
|
|
|
this->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
|
|
|
|
this->StateSnapshot);
|
2015-07-26 13:56:10 +03:00
|
|
|
|
2008-03-06 18:57:59 +03:00
|
|
|
// Enter a policy level for this directory.
|
|
|
|
this->PushPolicy();
|
2008-03-31 21:33:09 +04:00
|
|
|
|
2014-11-18 18:34:30 +03:00
|
|
|
// push empty loop block
|
|
|
|
this->PushLoopBlockBarrier();
|
|
|
|
|
2008-03-31 21:33:09 +04:00
|
|
|
// By default the check is not done. It is enabled by
|
|
|
|
// cmListFileCache in the top level if necessary.
|
|
|
|
this->CheckCMP0000 = false;
|
2015-04-27 23:38:45 +03:00
|
|
|
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
this->AddSourceGroup("", "^.*$");
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddSourceGroup("Source Files",
|
|
|
|
"\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp"
|
|
|
|
"|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
|
2015-04-27 23:38:45 +03:00
|
|
|
this->AddSourceGroup("Header Files", CM_HEADER_REGEX);
|
|
|
|
this->AddSourceGroup("CMake Rules", "\\.rule$");
|
|
|
|
this->AddSourceGroup("Resources", "\\.plist$");
|
|
|
|
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
|
|
|
#endif
|
2007-06-11 18:25:40 +04:00
|
|
|
}
|
2003-02-14 05:57:05 +03:00
|
|
|
|
2001-01-05 19:41:20 +03:00
|
|
|
cmMakefile::~cmMakefile()
|
|
|
|
{
|
2015-01-04 15:33:16 +03:00
|
|
|
cmDeleteAll(this->InstallGenerators);
|
|
|
|
cmDeleteAll(this->TestGenerators);
|
|
|
|
cmDeleteAll(this->SourceFiles);
|
|
|
|
cmDeleteAll(this->Tests);
|
|
|
|
cmDeleteAll(this->ImportedTargetsOwned);
|
|
|
|
cmDeleteAll(this->FinalPassCommands);
|
|
|
|
cmDeleteAll(this->FunctionBlockers);
|
2015-08-01 13:05:13 +03:00
|
|
|
cmDeleteAll(this->EvaluationFiles);
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2016-06-09 10:57:47 +03:00
|
|
|
void cmMakefile::IssueMessage(cmake::MessageType t,
|
|
|
|
std::string const& text) const
|
2008-03-07 16:40:36 +03:00
|
|
|
{
|
2016-09-06 22:25:26 +03:00
|
|
|
if (!this->ExecutionStatusStack.empty()) {
|
|
|
|
if ((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) {
|
|
|
|
this->ExecutionStatusStack.back()->SetNestedError(true);
|
|
|
|
}
|
|
|
|
}
|
2016-06-09 10:57:47 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace());
|
2008-03-13 20:48:57 +03:00
|
|
|
}
|
2008-03-07 16:40:36 +03:00
|
|
|
|
2015-07-18 11:52:09 +03:00
|
|
|
cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
|
2015-07-08 23:58:30 +03:00
|
|
|
{
|
2015-07-18 13:28:49 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetIncludeDirectoriesEntries();
|
2015-07-08 23:58:30 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 11:52:09 +03:00
|
|
|
cmBacktraceRange cmMakefile::GetIncludeDirectoriesBacktraces() const
|
2015-07-09 00:35:01 +03:00
|
|
|
{
|
2015-07-18 13:28:49 +03:00
|
|
|
return this->StateSnapshot.GetDirectory()
|
2016-05-16 17:34:04 +03:00
|
|
|
.GetIncludeDirectoriesEntryBacktraces();
|
2015-07-09 00:35:01 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 11:52:09 +03:00
|
|
|
cmStringRange cmMakefile::GetCompileOptionsEntries() const
|
2015-07-08 23:58:30 +03:00
|
|
|
{
|
2015-07-18 13:28:49 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetCompileOptionsEntries();
|
2015-07-09 00:17:16 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 11:52:09 +03:00
|
|
|
cmBacktraceRange cmMakefile::GetCompileOptionsBacktraces() const
|
2015-07-09 00:17:16 +03:00
|
|
|
{
|
2015-07-18 13:28:49 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetCompileOptionsEntryBacktraces();
|
2015-07-08 23:58:30 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 11:52:09 +03:00
|
|
|
cmStringRange cmMakefile::GetCompileDefinitionsEntries() const
|
2015-07-08 23:58:30 +03:00
|
|
|
{
|
2015-07-18 13:28:49 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetCompileDefinitionsEntries();
|
2015-07-09 00:11:22 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 11:52:09 +03:00
|
|
|
cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const
|
2015-07-09 00:11:22 +03:00
|
|
|
{
|
2015-07-18 13:28:49 +03:00
|
|
|
return this->StateSnapshot.GetDirectory()
|
2016-05-16 17:34:04 +03:00
|
|
|
.GetCompileDefinitionsEntryBacktraces();
|
2015-07-08 23:58:30 +03:00
|
|
|
}
|
|
|
|
|
2014-05-23 22:41:46 +04:00
|
|
|
cmListFileBacktrace cmMakefile::GetBacktrace() const
|
2008-03-13 20:48:57 +03:00
|
|
|
{
|
2016-04-14 18:24:08 +03:00
|
|
|
return this->Backtrace;
|
2008-03-07 16:40:36 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 18:24:08 +03:00
|
|
|
cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const
|
2015-05-29 02:14:19 +03:00
|
|
|
{
|
2016-04-14 18:24:08 +03:00
|
|
|
cmListFileContext lfc;
|
|
|
|
lfc.Name = cc.Name;
|
|
|
|
lfc.Line = cc.Line;
|
|
|
|
lfc.FilePath = this->StateSnapshot.GetExecutionListFile();
|
|
|
|
return this->Backtrace.Push(lfc);
|
2008-03-07 16:40:36 +03:00
|
|
|
}
|
|
|
|
|
2015-05-18 22:35:29 +03:00
|
|
|
cmListFileContext cmMakefile::GetExecutionContext() const
|
|
|
|
{
|
2016-04-14 18:24:08 +03:00
|
|
|
cmListFileContext const& cur = this->Backtrace.Top();
|
|
|
|
cmListFileContext lfc;
|
|
|
|
lfc.Name = cur.Name;
|
|
|
|
lfc.Line = cur.Line;
|
|
|
|
lfc.FilePath = this->StateSnapshot.GetExecutionListFile();
|
|
|
|
return lfc;
|
2015-05-18 22:35:29 +03:00
|
|
|
}
|
|
|
|
|
2014-01-22 18:00:29 +04:00
|
|
|
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
|
2012-05-15 02:50:30 +04:00
|
|
|
{
|
2016-06-13 22:27:58 +03:00
|
|
|
// Check if current file in the list of requested to trace...
|
|
|
|
std::vector<std::string> const& trace_only_this_files =
|
|
|
|
this->GetCMakeInstance()->GetTraceSources();
|
|
|
|
std::string const& full_path = this->GetExecutionFilePath();
|
|
|
|
std::string const& only_filename = cmSystemTools::GetFilenameName(full_path);
|
|
|
|
bool trace = trace_only_this_files.empty();
|
|
|
|
if (!trace) {
|
|
|
|
for (std::vector<std::string>::const_iterator i =
|
|
|
|
trace_only_this_files.begin();
|
|
|
|
!trace && i != trace_only_this_files.end(); ++i) {
|
|
|
|
std::string::size_type const pos = full_path.rfind(*i);
|
|
|
|
trace = (pos != std::string::npos) &&
|
|
|
|
((pos + i->size()) == full_path.size()) &&
|
|
|
|
(only_filename == cmSystemTools::GetFilenameName(*i));
|
|
|
|
}
|
|
|
|
// Do nothing if current file wasn't requested for trace...
|
|
|
|
if (!trace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2016-06-13 22:27:58 +03:00
|
|
|
msg << full_path << "(" << lff.Line << "): ";
|
2012-05-15 02:50:30 +04:00
|
|
|
msg << lff.Name << "(";
|
2015-07-22 00:18:53 +03:00
|
|
|
bool expand = this->GetCMakeInstance()->GetTraceExpand();
|
|
|
|
std::string temp;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmListFileArgument>::const_iterator i =
|
|
|
|
lff.Arguments.begin();
|
|
|
|
i != lff.Arguments.end(); ++i) {
|
|
|
|
if (expand) {
|
2015-07-22 00:18:53 +03:00
|
|
|
temp = i->Value;
|
|
|
|
this->ExpandVariablesInString(temp);
|
|
|
|
msg << temp;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-07-22 00:18:53 +03:00
|
|
|
msg << i->Value;
|
2012-05-15 02:50:30 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
msg << " ";
|
|
|
|
}
|
2012-05-15 02:50:30 +04:00
|
|
|
msg << ")";
|
|
|
|
cmSystemTools::Message(msg.str().c_str());
|
|
|
|
}
|
|
|
|
|
2016-04-14 18:02:40 +03:00
|
|
|
// Helper class to make sure the call stack is valid.
|
|
|
|
class cmMakefileCall
|
|
|
|
{
|
|
|
|
public:
|
2016-04-14 18:24:08 +03:00
|
|
|
cmMakefileCall(cmMakefile* mf, cmCommandContext const& cc,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExecutionStatus& status)
|
|
|
|
: Makefile(mf)
|
|
|
|
{
|
|
|
|
cmListFileContext const& lfc = cmListFileContext::FromCommandContext(
|
|
|
|
cc, this->Makefile->StateSnapshot.GetExecutionListFile());
|
2016-04-14 18:24:08 +03:00
|
|
|
this->Makefile->Backtrace = this->Makefile->Backtrace.Push(lfc);
|
2016-04-14 18:02:40 +03:00
|
|
|
this->Makefile->ExecutionStatusStack.push_back(&status);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-04-14 18:02:40 +03:00
|
|
|
|
|
|
|
~cmMakefileCall()
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2016-04-14 18:02:40 +03:00
|
|
|
this->Makefile->ExecutionStatusStack.pop_back();
|
2016-04-14 18:24:08 +03:00
|
|
|
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 18:02:40 +03:00
|
|
|
private:
|
|
|
|
cmMakefile* Makefile;
|
|
|
|
};
|
|
|
|
|
2008-01-23 18:28:26 +03:00
|
|
|
bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExecutionStatus& status)
|
2001-07-26 00:53:13 +04:00
|
|
|
{
|
2002-12-12 19:36:28 +03:00
|
|
|
bool result = true;
|
2008-01-23 18:28:26 +03:00
|
|
|
|
2002-07-17 18:48:39 +04:00
|
|
|
// quick return if blocked
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsFunctionBlocked(lff, status)) {
|
2002-12-12 19:36:28 +03:00
|
|
|
// No error.
|
|
|
|
return result;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-28 23:44:22 +04:00
|
|
|
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string name = lff.Name;
|
2008-01-23 18:28:26 +03:00
|
|
|
|
2008-03-07 16:40:36 +03:00
|
|
|
// Place this call on the call stack.
|
|
|
|
cmMakefileCall stack_manager(this, lff, status);
|
|
|
|
static_cast<void>(stack_manager);
|
|
|
|
|
|
|
|
// Lookup the command prototype.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmCommand* proto = this->GetState()->GetCommand(name)) {
|
2008-03-07 16:40:36 +03:00
|
|
|
// Clone the prototype.
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCommand> pcmd(proto->Clone());
|
2008-03-07 16:40:36 +03:00
|
|
|
pcmd->SetMakefile(this);
|
|
|
|
|
|
|
|
// Decide whether to invoke the command.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() &&
|
|
|
|
(this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE ||
|
|
|
|
pcmd->IsScriptable()))
|
2011-07-02 19:50:05 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2012-05-15 02:50:30 +04:00
|
|
|
// if trace is enabled, print out invoke information
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetCMakeInstance()->GetTrace()) {
|
2012-05-15 02:50:30 +04:00
|
|
|
this->PrintCommandTrace(lff);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-09-06 22:25:26 +03:00
|
|
|
// Try invoking the command.
|
2016-01-29 00:10:28 +03:00
|
|
|
bool invokeSucceeded = pcmd->InvokeInitialPass(lff.Arguments, status);
|
2016-09-06 22:25:26 +03:00
|
|
|
bool hadNestedError = status.GetNestedError();
|
2016-01-29 00:10:28 +03:00
|
|
|
if (!invokeSucceeded || hadNestedError) {
|
2016-09-06 22:25:26 +03:00
|
|
|
if (!hadNestedError) {
|
2008-03-07 16:40:36 +03:00
|
|
|
// The command invocation requested that we report an error.
|
2008-03-11 17:29:56 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-18 18:41:41 +03:00
|
|
|
result = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) {
|
2005-03-18 18:41:41 +03:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2001-07-26 00:53:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (pcmd->HasFinalPass()) {
|
2005-03-18 18:41:41 +03:00
|
|
|
// use the command
|
2012-02-29 11:49:42 +04:00
|
|
|
this->FinalPassCommands.push_back(pcmd.release());
|
2001-07-26 00:53:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GetCMakeInstance()->GetWorkingMode() ==
|
|
|
|
cmake::SCRIPT_MODE &&
|
|
|
|
!pcmd->IsScriptable()) {
|
2008-03-07 16:40:36 +03:00
|
|
|
std::string error = "Command ";
|
|
|
|
error += pcmd->GetName();
|
|
|
|
error += "() is not scriptable";
|
2008-03-11 17:29:56 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, error);
|
2003-10-29 17:45:26 +03:00
|
|
|
result = false;
|
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2001-07-26 00:53:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (!cmSystemTools::GetFatalErrorOccured()) {
|
2008-03-07 16:40:36 +03:00
|
|
|
std::string error = "Unknown CMake command \"";
|
|
|
|
error += lff.Name;
|
|
|
|
error += "\".";
|
2008-03-11 17:29:56 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, error);
|
2003-01-21 20:50:48 +03:00
|
|
|
result = false;
|
2006-06-15 18:24:46 +04:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2001-07-26 00:53:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2002-12-12 19:36:28 +03:00
|
|
|
return result;
|
2001-07-26 00:53:13 +04:00
|
|
|
}
|
|
|
|
|
2009-01-22 18:57:16 +03:00
|
|
|
class cmMakefile::IncludeScope
|
|
|
|
{
|
|
|
|
public:
|
2015-06-21 21:09:13 +03:00
|
|
|
IncludeScope(cmMakefile* mf, std::string const& filenametoread,
|
|
|
|
bool noPolicyScope);
|
2009-01-22 18:57:16 +03:00
|
|
|
~IncludeScope();
|
|
|
|
void Quiet() { this->ReportError = false; }
|
|
|
|
private:
|
|
|
|
cmMakefile* Makefile;
|
2009-01-22 21:18:40 +03:00
|
|
|
bool NoPolicyScope;
|
|
|
|
bool CheckCMP0011;
|
2009-01-22 18:57:16 +03:00
|
|
|
bool ReportError;
|
2009-01-22 21:18:40 +03:00
|
|
|
void EnforceCMP0011();
|
2009-01-22 18:57:16 +03:00
|
|
|
};
|
|
|
|
|
2015-06-21 20:50:18 +03:00
|
|
|
cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
|
2015-06-21 21:09:13 +03:00
|
|
|
std::string const& filenametoread,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool noPolicyScope)
|
|
|
|
: Makefile(mf)
|
|
|
|
, NoPolicyScope(noPolicyScope)
|
|
|
|
, CheckCMP0011(false)
|
|
|
|
, ReportError(true)
|
2009-01-22 18:57:16 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->Backtrace = this->Makefile->Backtrace.Push(filenametoread);
|
2016-04-14 18:24:08 +03:00
|
|
|
|
2015-07-28 09:09:49 +03:00
|
|
|
this->Makefile->PushFunctionBlockerBarrier();
|
|
|
|
|
|
|
|
this->Makefile->StateSnapshot =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetState()->CreateIncludeFileSnapshot(
|
|
|
|
this->Makefile->StateSnapshot, filenametoread);
|
|
|
|
if (!this->NoPolicyScope) {
|
2009-01-22 21:18:40 +03:00
|
|
|
// Check CMP0011 to determine the policy scope type.
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011)) {
|
2009-01-22 21:18:40 +03:00
|
|
|
case cmPolicies::WARN:
|
|
|
|
// We need to push a scope to detect whether the script sets
|
|
|
|
// any policies that would affect the includer and therefore
|
|
|
|
// requires a warning. We use a weak scope to simulate OLD
|
|
|
|
// behavior by allowing policy changes to affect the includer.
|
|
|
|
this->Makefile->PushPolicy(true);
|
|
|
|
this->CheckCMP0011 = true;
|
|
|
|
break;
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior is to not push a scope at all.
|
|
|
|
this->NoPolicyScope = true;
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
// We should never make this policy required, but we handle it
|
|
|
|
// here just in case.
|
|
|
|
this->CheckCMP0011 = true;
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior is to push a (strong) scope.
|
|
|
|
this->Makefile->PushPolicy();
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-22 18:57:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmMakefile::IncludeScope::~IncludeScope()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->NoPolicyScope) {
|
2009-01-22 21:18:40 +03:00
|
|
|
// If we need to enforce policy CMP0011 then the top entry is the
|
|
|
|
// one we pushed above. If the entry is empty, then the included
|
|
|
|
// script did not set any policies that might affect the includer so
|
|
|
|
// we do not need to enforce the policy.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CheckCMP0011 &&
|
|
|
|
!this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) {
|
2009-01-22 21:18:40 +03:00
|
|
|
this->CheckCMP0011 = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-22 21:18:40 +03:00
|
|
|
|
|
|
|
// Pop the scope we pushed for the script.
|
|
|
|
this->Makefile->PopPolicy();
|
|
|
|
|
|
|
|
// We enforce the policy after the script's policy stack entry has
|
|
|
|
// been removed.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CheckCMP0011) {
|
2009-01-22 21:18:40 +03:00
|
|
|
this->EnforceCMP0011();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-24 19:44:57 +03:00
|
|
|
this->Makefile->PopSnapshot(this->ReportError);
|
2015-07-28 09:09:49 +03:00
|
|
|
|
|
|
|
this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
|
2016-04-14 18:24:08 +03:00
|
|
|
|
|
|
|
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
|
2009-01-22 21:18:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::IncludeScope::EnforceCMP0011()
|
|
|
|
{
|
|
|
|
// We check the setting of this policy again because the included
|
|
|
|
// script might actually set this policy for its includer.
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011)) {
|
2009-01-22 21:18:40 +03:00
|
|
|
case cmPolicies::WARN:
|
|
|
|
// Warn because the user did not set this policy.
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::ostringstream w;
|
|
|
|
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0011) << "\n"
|
|
|
|
<< "The included script\n "
|
|
|
|
<< this->Makefile->GetExecutionFilePath() << "\n"
|
|
|
|
<< "affects policy settings. "
|
|
|
|
<< "CMake is implying the NO_POLICY_SCOPE option for compatibility, "
|
|
|
|
<< "so the effects are applied to the including context.";
|
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
2009-01-22 21:18:40 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
2016-05-16 17:34:04 +03:00
|
|
|
case cmPolicies::REQUIRED_ALWAYS: {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-05-03 11:12:10 +03:00
|
|
|
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0011) << "\n"
|
2015-06-21 20:50:18 +03:00
|
|
|
<< "The included script\n "
|
2015-07-18 14:18:34 +03:00
|
|
|
<< this->Makefile->GetExecutionFilePath() << "\n"
|
2009-01-22 21:18:40 +03:00
|
|
|
<< "affects policy settings, so it requires this policy to be set.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-01-22 21:18:40 +03:00
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2009-01-22 21:18:40 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// The script set this policy. We assume the purpose of the
|
|
|
|
// script is to initialize policies for its includer, and since
|
|
|
|
// the policy is now set for later scripts, we do not warn.
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-22 18:57:16 +03:00
|
|
|
}
|
|
|
|
|
2015-06-21 21:02:16 +03:00
|
|
|
bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
|
2015-04-18 15:50:32 +03:00
|
|
|
{
|
2015-05-15 00:47:40 +03:00
|
|
|
this->AddDefinition("CMAKE_PARENT_LIST_FILE",
|
|
|
|
this->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string filenametoread = cmSystemTools::CollapseFullPath(
|
|
|
|
filename, this->GetCurrentSourceDirectory());
|
2015-06-21 21:07:40 +03:00
|
|
|
|
2015-06-21 21:09:13 +03:00
|
|
|
IncludeScope incScope(this, filenametoread, noPolicyScope);
|
2015-06-21 21:07:40 +03:00
|
|
|
|
|
|
|
cmListFile listFile;
|
2016-01-29 00:10:28 +03:00
|
|
|
if (!listFile.ParseFile(filenametoread.c_str(), this->GetMessenger(),
|
|
|
|
this->Backtrace)) {
|
2015-06-21 21:07:40 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-05 20:28:45 +03:00
|
|
|
|
2015-06-21 21:07:40 +03:00
|
|
|
this->ReadListFile(listFile, filenametoread);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
2015-06-21 20:51:46 +03:00
|
|
|
incScope.Quiet();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 21:07:40 +03:00
|
|
|
return true;
|
2015-05-15 01:09:53 +03:00
|
|
|
}
|
|
|
|
|
2015-06-21 23:50:13 +03:00
|
|
|
class cmMakefile::ListFileScope
|
|
|
|
{
|
|
|
|
public:
|
2015-06-21 23:56:15 +03:00
|
|
|
ListFileScope(cmMakefile* mf, std::string const& filenametoread)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Makefile(mf)
|
|
|
|
, ReportError(true)
|
2015-06-21 23:50:13 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->Backtrace = this->Makefile->Backtrace.Push(filenametoread);
|
2016-04-14 18:24:08 +03:00
|
|
|
|
2015-06-21 22:26:36 +03:00
|
|
|
this->Makefile->StateSnapshot =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetState()->CreateInlineListFileSnapshot(
|
|
|
|
this->Makefile->StateSnapshot, filenametoread);
|
2015-06-21 22:26:36 +03:00
|
|
|
assert(this->Makefile->StateSnapshot.IsValid());
|
2015-07-28 09:09:49 +03:00
|
|
|
|
2015-06-21 23:53:16 +03:00
|
|
|
this->Makefile->PushFunctionBlockerBarrier();
|
2015-06-21 23:50:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
~ListFileScope()
|
|
|
|
{
|
2015-11-24 19:44:57 +03:00
|
|
|
this->Makefile->PopSnapshot(this->ReportError);
|
2015-06-21 23:53:16 +03:00
|
|
|
this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
|
2016-04-14 18:24:08 +03:00
|
|
|
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
|
2015-06-21 23:50:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Quiet() { this->ReportError = false; }
|
|
|
|
private:
|
|
|
|
cmMakefile* Makefile;
|
|
|
|
bool ReportError;
|
|
|
|
};
|
|
|
|
|
2015-06-21 21:02:16 +03:00
|
|
|
bool cmMakefile::ReadListFile(const char* filename)
|
2015-05-15 01:09:53 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string filenametoread = cmSystemTools::CollapseFullPath(
|
|
|
|
filename, this->GetCurrentSourceDirectory());
|
2007-04-04 20:05:10 +04:00
|
|
|
|
2015-06-21 23:56:15 +03:00
|
|
|
ListFileScope scope(this, filenametoread);
|
2015-06-21 20:43:55 +03:00
|
|
|
|
|
|
|
cmListFile listFile;
|
2016-01-29 00:10:28 +03:00
|
|
|
if (!listFile.ParseFile(filenametoread.c_str(), this->GetMessenger(),
|
|
|
|
this->Backtrace)) {
|
2015-06-21 20:44:37 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 20:43:55 +03:00
|
|
|
|
2015-06-21 21:07:40 +03:00
|
|
|
this->ReadListFile(listFile, filenametoread);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
2015-06-21 23:50:13 +03:00
|
|
|
scope.Quiet();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 21:07:40 +03:00
|
|
|
return true;
|
2015-04-18 15:50:32 +03:00
|
|
|
}
|
|
|
|
|
2015-06-21 21:07:40 +03:00
|
|
|
void cmMakefile::ReadListFile(cmListFile const& listFile,
|
|
|
|
std::string const& filenametoread)
|
2000-08-29 23:26:29 +04:00
|
|
|
{
|
2015-06-21 20:44:37 +03:00
|
|
|
// add this list file to the list of dependencies
|
|
|
|
this->ListFiles.push_back(filenametoread);
|
2007-04-04 20:05:10 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string currentParentFile =
|
|
|
|
this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
|
|
|
|
std::string currentFile = this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE");
|
2015-04-18 15:50:33 +03:00
|
|
|
|
2015-04-18 15:50:38 +03:00
|
|
|
this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread.c_str());
|
|
|
|
this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::GetFilenamePath(filenametoread).c_str());
|
2015-04-18 15:50:38 +03:00
|
|
|
|
2015-04-18 15:50:33 +03:00
|
|
|
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
|
2015-04-18 15:50:38 +03:00
|
|
|
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
|
|
|
|
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
|
|
|
|
|
2009-01-15 22:37:14 +03:00
|
|
|
// Run the parsed commands.
|
2015-06-21 20:38:02 +03:00
|
|
|
const size_t numberFunctions = listFile.Functions.size();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < numberFunctions; ++i) {
|
2008-01-23 18:28:26 +03:00
|
|
|
cmExecutionStatus status;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExecuteCommand(listFile.Functions[i], status);
|
|
|
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
2009-01-21 17:48:00 +03:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (status.GetReturnInvoked()) {
|
2009-01-21 17:48:00 +03:00
|
|
|
// Exit early due to return command.
|
2008-03-10 22:41:07 +03:00
|
|
|
break;
|
2000-08-29 23:26:29 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 20:57:15 +03:00
|
|
|
this->CheckForUnusedVariables();
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2015-06-21 20:57:15 +03:00
|
|
|
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
|
|
|
|
this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
|
|
|
|
this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
|
|
|
|
cmSystemTools::GetFilenamePath(currentFile).c_str());
|
|
|
|
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
|
|
|
|
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
|
|
|
|
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
|
2000-08-29 23:26:29 +04:00
|
|
|
}
|
2001-02-13 03:49:52 +03:00
|
|
|
|
2014-01-22 18:00:29 +04:00
|
|
|
void cmMakefile::EnforceDirectoryLevelRules() const
|
2008-03-31 21:33:09 +04:00
|
|
|
{
|
|
|
|
// Diagnose a violation of CMP0000 if necessary.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CheckCMP0000) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2008-03-31 21:33:09 +04:00
|
|
|
msg << "No cmake_minimum_required command is present. "
|
|
|
|
<< "A line of code such as\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< " cmake_minimum_required(VERSION " << cmVersion::GetMajorVersion()
|
|
|
|
<< "." << cmVersion::GetMinorVersion() << ")\n"
|
2008-03-31 21:33:09 +04:00
|
|
|
<< "should be added at the top of the file. "
|
|
|
|
<< "The version specified may be lower if you wish to "
|
|
|
|
<< "support older CMake versions for this project. "
|
|
|
|
<< "For more information run "
|
|
|
|
<< "\"cmake --help-policy CMP0000\".";
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0000)) {
|
2008-03-31 21:33:09 +04:00
|
|
|
case cmPolicies::WARN:
|
|
|
|
// Warn because the user did not provide a mimimum required
|
|
|
|
// version.
|
2016-01-29 00:10:27 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
|
|
|
msg.str(), this->Backtrace);
|
2008-03-31 21:33:09 +04:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior is to use policy version 2.4 set in
|
|
|
|
// cmListFileCache.
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior is to issue an error.
|
2016-01-29 00:10:27 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str(),
|
|
|
|
this->Backtrace);
|
2008-03-31 21:33:09 +04:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
|
return;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-31 21:33:09 +04:00
|
|
|
}
|
2001-04-11 22:59:02 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddEvaluationFile(
|
|
|
|
const std::string& inputFile,
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName,
|
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent)
|
2015-08-01 13:05:13 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile(
|
|
|
|
inputFile, outputName, condition, inputIsContent));
|
2015-08-01 13:05:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<cmGeneratorExpressionEvaluationFile*>
|
|
|
|
cmMakefile::GetEvaluationFiles() const
|
|
|
|
{
|
|
|
|
return this->EvaluationFiles;
|
|
|
|
}
|
|
|
|
|
2015-09-16 23:08:22 +03:00
|
|
|
std::vector<cmExportBuildFileGenerator*>
|
|
|
|
cmMakefile::GetExportBuildFileGenerators() const
|
|
|
|
{
|
|
|
|
return this->ExportBuildFileGenerators;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::RemoveExportBuildFileGeneratorCMP0024(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExportBuildFileGenerator* gen)
|
2015-09-16 23:08:22 +03:00
|
|
|
{
|
|
|
|
std::vector<cmExportBuildFileGenerator*>::iterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::find(this->ExportBuildFileGenerators.begin(),
|
|
|
|
this->ExportBuildFileGenerators.end(), gen);
|
|
|
|
if (it != this->ExportBuildFileGenerators.end()) {
|
2015-09-16 23:08:22 +03:00
|
|
|
this->ExportBuildFileGenerators.erase(it);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-16 23:08:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen)
|
|
|
|
{
|
|
|
|
this->ExportBuildFileGenerators.push_back(gen);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
namespace {
|
|
|
|
struct file_not_persistent
|
2013-08-28 20:49:53 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
bool operator()(const std::string& path) const
|
2013-08-28 20:49:53 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return !(path.find("CMakeTmp") == path.npos &&
|
|
|
|
cmSystemTools::FileExists(path.c_str()));
|
|
|
|
}
|
|
|
|
};
|
2013-08-28 20:49:53 +04:00
|
|
|
}
|
|
|
|
|
2001-07-26 02:30:27 +04:00
|
|
|
void cmMakefile::FinalPass()
|
2001-01-05 19:41:20 +03:00
|
|
|
{
|
|
|
|
// do all the variable expansions here
|
2012-12-06 18:59:18 +04:00
|
|
|
this->ExpandVariablesCMP0019();
|
2001-07-27 21:06:05 +04:00
|
|
|
|
2001-01-18 19:20:24 +03:00
|
|
|
// give all the commands a chance to do something
|
2001-01-05 19:41:20 +03:00
|
|
|
// after the file has been parsed before generation
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmCommand*>::iterator i = this->FinalPassCommands.begin();
|
|
|
|
i != this->FinalPassCommands.end(); ++i) {
|
2001-01-05 19:41:20 +03:00
|
|
|
(*i)->FinalPass();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-07-26 02:30:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// go through all configured files and see which ones still exist.
|
|
|
|
// we don't want cmake to re-run if a configured file is created and deleted
|
|
|
|
// during processing as that would make it a transient file that can't
|
|
|
|
// influence the build process
|
2013-08-28 20:49:53 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// remove_if will move all items that don't have a valid file name to the
|
|
|
|
// back of the vector
|
2013-09-03 23:31:12 +04:00
|
|
|
std::vector<std::string>::iterator new_output_files_end = std::remove_if(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->OutputFiles.begin(), this->OutputFiles.end(), file_not_persistent());
|
|
|
|
// we just have to erase all items at the back
|
|
|
|
this->OutputFiles.erase(new_output_files_end, this->OutputFiles.end());
|
|
|
|
|
|
|
|
// if a configured file is used as input for another configured file,
|
|
|
|
// and then deleted it will show up in the input list files so we
|
|
|
|
// need to scan those too
|
2013-09-03 23:31:12 +04:00
|
|
|
std::vector<std::string>::iterator new_list_files_end = std::remove_if(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ListFiles.begin(), this->ListFiles.end(), file_not_persistent());
|
2013-08-28 20:49:53 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ListFiles.erase(new_list_files_end, this->ListFiles.end());
|
2001-07-26 02:30:27 +04:00
|
|
|
}
|
|
|
|
|
2005-07-13 19:21:30 +04:00
|
|
|
// Generate the output file
|
2002-09-15 16:52:24 +04:00
|
|
|
void cmMakefile::ConfigureFinalPass()
|
2001-07-26 02:30:27 +04:00
|
|
|
{
|
|
|
|
this->FinalPass();
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
|
|
|
|
if (oldValue &&
|
|
|
|
cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue, "2.4")) {
|
2016-01-29 00:10:27 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(
|
2013-10-18 19:25:49 +04:00
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less "
|
|
|
|
"than 2.4. This version of CMake only supports backwards compatibility "
|
|
|
|
"with CMake 2.4 or later. For compatibility with older versions please "
|
2016-01-29 00:10:27 +03:00
|
|
|
"use any CMake 2.8.x release or lower.",
|
|
|
|
this->Backtrace);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-06-06 04:34:01 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddCustomCommandToTarget(
|
|
|
|
const std::string& target, const std::vector<std::string>& byproducts,
|
|
|
|
const std::vector<std::string>& depends,
|
|
|
|
const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
|
|
|
|
const char* comment, const char* workingDir, bool escapeOldStyle,
|
2016-08-05 15:39:31 +03:00
|
|
|
bool uses_terminal, const std::string& depfile)
|
2003-06-03 18:30:23 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
// Find the target to which to add the custom command.
|
2006-03-15 19:02:08 +03:00
|
|
|
cmTargets::iterator ti = this->Targets.find(target);
|
2013-11-20 12:53:06 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ti == this->Targets.end()) {
|
2013-11-20 12:53:06 +04:00
|
|
|
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
|
|
|
bool issueMessage = false;
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0040)) {
|
2013-11-20 12:53:06 +04:00
|
|
|
case cmPolicies::WARN:
|
2015-05-03 11:12:10 +03:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0040) << "\n";
|
2013-11-20 12:53:06 +04:00
|
|
|
issueMessage = true;
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
break;
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
issueMessage = true;
|
|
|
|
messageType = cmake::FATAL_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-20 12:53:06 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (issueMessage) {
|
|
|
|
if (cmTarget const* t = this->FindTargetToUse(target)) {
|
|
|
|
if (t->IsImported()) {
|
2016-01-28 18:12:26 +03:00
|
|
|
e << "TARGET '" << target
|
|
|
|
<< "' is IMPORTED and does not build here.";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
e << "TARGET '" << target << "' was not created in this directory.";
|
2016-01-28 18:12:26 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-01-28 18:12:26 +03:00
|
|
|
e << "No TARGET '" << target
|
|
|
|
<< "' has been created in this directory.";
|
2005-02-22 18:32:44 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
IssueMessage(messageType, e.str());
|
2013-11-20 12:53:06 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ti->second.GetType() == cmState::OBJECT_LIBRARY) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Target \"" << target
|
|
|
|
<< "\" is an OBJECT library "
|
|
|
|
"that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
|
2013-11-20 12:53:06 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (ti->second.GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Target \"" << target
|
|
|
|
<< "\" is an INTERFACE library "
|
|
|
|
"that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
|
2014-03-19 18:50:01 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-11-14 02:54:52 +03:00
|
|
|
|
|
|
|
// Always create the byproduct sources and mark them generated.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator o = byproducts.begin();
|
|
|
|
o != byproducts.end(); ++o) {
|
|
|
|
if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
|
2014-11-14 02:54:52 +03:00
|
|
|
out->SetProperty("GENERATED", "1");
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-11-14 02:54:52 +03:00
|
|
|
|
2013-11-20 12:53:06 +04:00
|
|
|
// Add the command to the appropriate build step for the target.
|
|
|
|
std::vector<std::string> no_output;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCustomCommand cc(this, no_output, byproducts, depends, commandLines,
|
|
|
|
comment, workingDir);
|
2013-11-20 12:53:06 +04:00
|
|
|
cc.SetEscapeOldStyle(escapeOldStyle);
|
|
|
|
cc.SetEscapeAllowMakeVars(true);
|
2014-11-05 23:37:52 +03:00
|
|
|
cc.SetUsesTerminal(uses_terminal);
|
2016-08-05 15:39:31 +03:00
|
|
|
cc.SetDepfile(depfile);
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (type) {
|
2013-11-20 12:53:06 +04:00
|
|
|
case cmTarget::PRE_BUILD:
|
|
|
|
ti->second.AddPreBuildCommand(cc);
|
|
|
|
break;
|
|
|
|
case cmTarget::PRE_LINK:
|
|
|
|
ti->second.AddPreLinkCommand(cc);
|
|
|
|
break;
|
|
|
|
case cmTarget::POST_BUILD:
|
|
|
|
ti->second.AddPostBuildCommand(cc);
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSourceFile* cmMakefile::AddCustomCommandToOutput(
|
|
|
|
const std::vector<std::string>& outputs,
|
|
|
|
const std::vector<std::string>& byproducts,
|
|
|
|
const std::vector<std::string>& depends, const std::string& main_dependency,
|
|
|
|
const cmCustomCommandLines& commandLines, const char* comment,
|
|
|
|
const char* workingDir, bool replace, bool escapeOldStyle,
|
2016-08-05 15:39:31 +03:00
|
|
|
bool uses_terminal, const std::string& depfile)
|
2003-06-03 18:30:23 +04:00
|
|
|
{
|
2006-04-11 19:06:19 +04:00
|
|
|
// Make sure there is at least one output.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (outputs.empty()) {
|
2006-04-11 19:06:19 +04:00
|
|
|
cmSystemTools::Error("Attempt to add a custom rule with no output!");
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-11 19:06:19 +04:00
|
|
|
|
2011-03-15 00:47:31 +03:00
|
|
|
// Validate custom commands. TODO: More strict?
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmCustomCommandLines::const_iterator i = commandLines.begin();
|
|
|
|
i != commandLines.end(); ++i) {
|
2011-03-15 00:47:31 +03:00
|
|
|
cmCustomCommandLine const& cl = *i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2011-03-15 00:47:31 +03:00
|
|
|
e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
|
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2011-03-15 00:47:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-15 00:47:31 +03:00
|
|
|
|
2005-02-22 18:32:44 +03:00
|
|
|
// Choose a source file on which to store the custom command.
|
2016-06-27 23:44:16 +03:00
|
|
|
cmSourceFile* file = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!commandLines.empty() && !main_dependency.empty()) {
|
2005-02-22 18:32:44 +03:00
|
|
|
// The main dependency was specified. Use it unless a different
|
|
|
|
// custom command already used it.
|
|
|
|
file = this->GetSource(main_dependency);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (file && file->GetCustomCommand() && !replace) {
|
2005-02-22 18:32:44 +03:00
|
|
|
// The main dependency already has a custom command.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (commandLines == file->GetCustomCommand()->GetCommandLines()) {
|
2005-02-22 18:32:44 +03:00
|
|
|
// The existing custom command is identical. Silently ignore
|
|
|
|
// the duplicate.
|
2012-04-18 22:42:43 +04:00
|
|
|
return file;
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2016-08-18 21:36:29 +03:00
|
|
|
// The existing custom command is different. We need to
|
|
|
|
// generate a rule file for this new command.
|
|
|
|
file = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (!file) {
|
2014-03-12 02:04:11 +04:00
|
|
|
file = this->CreateSource(main_dependency);
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-06-03 18:30:23 +04:00
|
|
|
|
2005-02-22 18:32:44 +03:00
|
|
|
// Generate a rule file if the main dependency is not available.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!file) {
|
2015-05-03 12:10:30 +03:00
|
|
|
cmGlobalGenerator* gg = this->GetGlobalGenerator();
|
2012-04-18 23:28:12 +04:00
|
|
|
|
2006-04-11 19:06:19 +04:00
|
|
|
// Construct a rule file associated with the first output produced.
|
2012-04-18 23:28:12 +04:00
|
|
|
std::string outName = gg->GenerateRuleFile(outputs[0]);
|
|
|
|
|
2005-02-22 18:32:44 +03:00
|
|
|
// Check if the rule file already exists.
|
2014-03-11 03:04:11 +04:00
|
|
|
file = this->GetSource(outName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (file && file->GetCustomCommand() && !replace) {
|
2005-02-22 18:32:44 +03:00
|
|
|
// The rule file already exists.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (commandLines != file->GetCustomCommand()->GetCommandLines()) {
|
2005-02-22 18:32:44 +03:00
|
|
|
cmSystemTools::Error("Attempt to add a custom rule to output \"",
|
2006-04-11 19:06:19 +04:00
|
|
|
outName.c_str(),
|
|
|
|
"\" which already has a custom rule.");
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return file;
|
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Create a cmSourceFile for the rule file.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!file) {
|
2014-03-12 02:04:11 +04:00
|
|
|
file = this->CreateSource(outName, true);
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
file->SetProperty("__CMAKE_RULE", "1");
|
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
2006-04-11 19:06:19 +04:00
|
|
|
// Always create the output sources and mark them generated.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator o = outputs.begin();
|
|
|
|
o != outputs.end(); ++o) {
|
|
|
|
if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
|
2006-04-11 19:06:19 +04:00
|
|
|
out->SetProperty("GENERATED", "1");
|
2004-08-05 01:24:21 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator o = byproducts.begin();
|
|
|
|
o != byproducts.end(); ++o) {
|
|
|
|
if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
|
2014-11-14 02:54:52 +03:00
|
|
|
out->SetProperty("GENERATED", "1");
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Attach the custom command to the file.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (file) {
|
2014-03-22 06:27:59 +04:00
|
|
|
// Construct a complete list of dependencies.
|
|
|
|
std::vector<std::string> depends2(depends);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!main_dependency.empty()) {
|
2014-03-22 06:27:59 +04:00
|
|
|
depends2.push_back(main_dependency);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-22 06:27:59 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCustomCommand* cc = new cmCustomCommand(
|
|
|
|
this, outputs, byproducts, depends2, commandLines, comment, workingDir);
|
2006-09-28 19:30:49 +04:00
|
|
|
cc->SetEscapeOldStyle(escapeOldStyle);
|
2008-06-04 20:10:52 +04:00
|
|
|
cc->SetEscapeAllowMakeVars(true);
|
2014-11-05 23:37:52 +03:00
|
|
|
cc->SetUsesTerminal(uses_terminal);
|
2016-08-05 15:39:31 +03:00
|
|
|
cc->SetDepfile(depfile);
|
2004-08-05 01:24:21 +04:00
|
|
|
file->SetCustomCommand(cc);
|
2013-08-06 20:12:50 +04:00
|
|
|
this->UpdateOutputToSourceMap(outputs, file);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-04-18 22:42:43 +04:00
|
|
|
return file;
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::UpdateOutputToSourceMap(
|
|
|
|
std::vector<std::string> const& outputs, cmSourceFile* source)
|
2013-08-06 20:12:50 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator o = outputs.begin();
|
|
|
|
o != outputs.end(); ++o) {
|
2013-08-06 20:12:50 +04:00
|
|
|
this->UpdateOutputToSourceMap(*o, source);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-08-06 20:12:50 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::UpdateOutputToSourceMap(std::string const& output,
|
|
|
|
cmSourceFile* source)
|
2013-08-06 20:12:50 +04:00
|
|
|
{
|
2013-09-30 17:27:49 +04:00
|
|
|
OutputToSourceMap::iterator i = this->OutputToSource.find(output);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != this->OutputToSource.end()) {
|
2013-09-30 17:27:49 +04:00
|
|
|
// Multiple custom commands produce the same output but may
|
|
|
|
// be attached to a different source file (MAIN_DEPENDENCY).
|
|
|
|
// LinearGetSourceFileWithOutput would return the first one,
|
|
|
|
// so keep the mapping for the first one.
|
|
|
|
//
|
|
|
|
// TODO: Warn the user about this case. However, the VS 8 generator
|
|
|
|
// triggers it for separate generate.stamp rules in ZERO_CHECK and
|
|
|
|
// individual targets.
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-08-06 20:12:50 +04:00
|
|
|
this->OutputToSource[output] = source;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSourceFile* cmMakefile::AddCustomCommandToOutput(
|
|
|
|
const std::string& output, const std::vector<std::string>& depends,
|
|
|
|
const std::string& main_dependency, const cmCustomCommandLines& commandLines,
|
|
|
|
const char* comment, const char* workingDir, bool replace,
|
2016-08-05 15:39:31 +03:00
|
|
|
bool escapeOldStyle, bool uses_terminal, const std::string& depfile)
|
2006-04-11 19:06:19 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> outputs;
|
|
|
|
outputs.push_back(output);
|
2014-11-14 02:54:52 +03:00
|
|
|
std::vector<std::string> no_byproducts;
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->AddCustomCommandToOutput(
|
|
|
|
outputs, no_byproducts, depends, main_dependency, commandLines, comment,
|
2016-08-05 15:39:31 +03:00
|
|
|
workingDir, replace, escapeOldStyle, uses_terminal, depfile);
|
2006-04-11 19:06:19 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddCustomCommandOldStyle(
|
|
|
|
const std::string& target, const std::vector<std::string>& outputs,
|
|
|
|
const std::vector<std::string>& depends, const std::string& source,
|
|
|
|
const cmCustomCommandLines& commandLines, const char* comment)
|
2003-06-06 00:45:06 +04:00
|
|
|
{
|
2005-02-22 18:32:44 +03:00
|
|
|
// Translate the old-style signature to one of the new-style
|
|
|
|
// signatures.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (source == target) {
|
2005-02-22 18:32:44 +03:00
|
|
|
// In the old-style signature if the source and target were the
|
|
|
|
// same then it added a post-build rule to the target. Preserve
|
|
|
|
// this behavior.
|
2014-11-14 02:54:52 +03:00
|
|
|
std::vector<std::string> no_byproducts;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddCustomCommandToTarget(target, no_byproducts, depends,
|
|
|
|
commandLines, cmTarget::POST_BUILD, comment,
|
2016-06-27 23:44:16 +03:00
|
|
|
CM_NULLPTR);
|
2005-02-22 18:32:44 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-06-06 00:45:06 +04:00
|
|
|
|
2005-02-22 18:32:44 +03:00
|
|
|
// Each output must get its own copy of this rule.
|
|
|
|
cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|"
|
|
|
|
"rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|"
|
|
|
|
"hm|hpp|hxx|in|txx|inl)$");
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator oi = outputs.begin();
|
|
|
|
oi != outputs.end(); ++oi) {
|
2005-02-22 18:32:44 +03:00
|
|
|
// Get the name of this output.
|
|
|
|
const char* output = oi->c_str();
|
2012-04-18 22:42:43 +04:00
|
|
|
cmSourceFile* sf;
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// Choose whether to use a main dependency.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sourceFiles.find(source)) {
|
2005-02-22 18:32:44 +03:00
|
|
|
// The source looks like a real file. Use it as the main dependency.
|
2012-04-18 22:42:43 +04:00
|
|
|
sf = this->AddCustomCommandToOutput(output, depends, source,
|
2016-06-27 23:44:16 +03:00
|
|
|
commandLines, comment, CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-02-22 18:32:44 +03:00
|
|
|
// The source may not be a real file. Do not use a main dependency.
|
2014-02-25 05:32:55 +04:00
|
|
|
std::string no_main_dependency = "";
|
2005-02-22 18:32:44 +03:00
|
|
|
std::vector<std::string> depends2 = depends;
|
|
|
|
depends2.push_back(source);
|
2012-04-18 22:42:43 +04:00
|
|
|
sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
|
2016-06-27 23:44:16 +03:00
|
|
|
commandLines, comment, CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
// If the rule was added to the source (and not a .rule file),
|
|
|
|
// then add the source to the target to make sure the rule is
|
|
|
|
// included.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) {
|
2016-09-14 20:42:27 +03:00
|
|
|
cmTargets::iterator ti = this->Targets.find(target);
|
|
|
|
if (ti != this->Targets.end()) {
|
|
|
|
ti->second.AddSource(sf->GetFullPath());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-02-22 18:32:44 +03:00
|
|
|
cmSystemTools::Error("Attempt to add a custom rule to a target "
|
2014-02-07 02:31:47 +04:00
|
|
|
"that does not exist yet for target ",
|
|
|
|
target.c_str());
|
2005-02-22 18:32:44 +03:00
|
|
|
return;
|
2001-06-07 22:52:29 +04:00
|
|
|
}
|
2001-04-11 22:59:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-03-20 21:20:59 +03:00
|
|
|
}
|
2001-01-05 19:41:20 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTarget* cmMakefile::AddUtilityCommand(
|
|
|
|
const std::string& utilityName, bool excludeFromAll,
|
|
|
|
const std::vector<std::string>& depends, const char* workingDirectory,
|
|
|
|
const char* command, const char* arg1, const char* arg2, const char* arg3,
|
|
|
|
const char* arg4)
|
2005-02-22 18:32:44 +03:00
|
|
|
{
|
|
|
|
// Construct the command line for the custom command.
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
commandLine.push_back(command);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg1) {
|
2005-02-22 18:32:44 +03:00
|
|
|
commandLine.push_back(arg1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (arg2) {
|
2005-02-22 18:32:44 +03:00
|
|
|
commandLine.push_back(arg2);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (arg3) {
|
2005-02-22 18:32:44 +03:00
|
|
|
commandLine.push_back(arg3);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (arg4) {
|
2005-06-17 00:33:24 +04:00
|
|
|
commandLine.push_back(arg4);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-22 18:32:44 +03:00
|
|
|
cmCustomCommandLines commandLines;
|
|
|
|
commandLines.push_back(commandLine);
|
|
|
|
|
|
|
|
// Call the real signature of this method.
|
2015-07-29 17:41:30 +03:00
|
|
|
return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
|
|
|
|
depends, commandLines);
|
2005-02-22 18:32:44 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTarget* cmMakefile::AddUtilityCommand(
|
|
|
|
const std::string& utilityName, bool excludeFromAll,
|
|
|
|
const char* workingDirectory, const std::vector<std::string>& depends,
|
|
|
|
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
|
|
|
|
const char* comment, bool uses_terminal)
|
2014-11-14 02:54:52 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string> no_byproducts;
|
|
|
|
return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
|
|
|
|
no_byproducts, depends, commandLines,
|
|
|
|
escapeOldStyle, comment, uses_terminal);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTarget* cmMakefile::AddUtilityCommand(
|
|
|
|
const std::string& utilityName, bool excludeFromAll,
|
|
|
|
const char* workingDirectory, const std::vector<std::string>& byproducts,
|
|
|
|
const std::vector<std::string>& depends,
|
|
|
|
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
|
|
|
|
const char* comment, bool uses_terminal)
|
2005-02-22 18:32:44 +03:00
|
|
|
{
|
|
|
|
// Create a target instance for this utility.
|
2015-10-08 01:21:51 +03:00
|
|
|
cmTarget* target = this->AddNewTarget(cmState::UTILITY, utilityName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (excludeFromAll) {
|
2007-05-22 18:24:59 +04:00
|
|
|
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!comment) {
|
2006-10-05 02:10:30 +04:00
|
|
|
// Use an empty comment to avoid generation of default comment.
|
|
|
|
comment = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-10-05 02:10:30 +04:00
|
|
|
|
2005-02-22 18:32:44 +03:00
|
|
|
// Store the custom command in the target.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!commandLines.empty() || !depends.empty()) {
|
2015-04-16 21:06:54 +03:00
|
|
|
std::string force = this->GetCurrentBinaryDirectory();
|
2014-03-13 01:29:04 +04:00
|
|
|
force += cmake::GetCMakeFilesDirectory();
|
|
|
|
force += "/";
|
|
|
|
force += utilityName;
|
2014-11-14 02:54:52 +03:00
|
|
|
std::vector<std::string> forced;
|
|
|
|
forced.push_back(force);
|
2014-03-13 01:29:04 +04:00
|
|
|
std::string no_main_dependency = "";
|
|
|
|
bool no_replace = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddCustomCommandToOutput(
|
|
|
|
forced, byproducts, depends, no_main_dependency, commandLines, comment,
|
|
|
|
workingDirectory, no_replace, escapeOldStyle, uses_terminal);
|
2014-03-13 01:29:04 +04:00
|
|
|
cmSourceFile* sf = target->AddSourceCMP0049(force);
|
|
|
|
|
|
|
|
// The output is not actually created so mark it symbolic.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sf) {
|
2014-03-13 01:29:04 +04:00
|
|
|
sf->SetProperty("SYMBOLIC", "1");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-03-13 01:29:04 +04:00
|
|
|
cmSystemTools::Error("Could not get source file entry for ",
|
2016-05-16 17:34:04 +03:00
|
|
|
force.c_str());
|
|
|
|
}
|
2014-11-14 02:54:52 +03:00
|
|
|
|
|
|
|
// Always create the byproduct sources and mark them generated.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator o = byproducts.begin();
|
|
|
|
o != byproducts.end(); ++o) {
|
|
|
|
if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
|
2014-11-14 02:54:52 +03:00
|
|
|
out->SetProperty("GENERATED", "1");
|
|
|
|
}
|
2006-10-02 18:20:53 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-10-09 19:00:54 +04:00
|
|
|
return target;
|
2005-02-22 18:32:44 +03:00
|
|
|
}
|
|
|
|
|
2001-01-05 19:41:20 +03:00
|
|
|
void cmMakefile::AddDefineFlag(const char* flag)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!flag) {
|
2007-03-07 19:03:57 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-03-07 19:03:57 +03:00
|
|
|
|
2008-06-26 21:30:10 +04:00
|
|
|
// Update the string used for the old DEFINITIONS property.
|
|
|
|
this->AddDefineFlag(flag, this->DefineFlagsOrig);
|
|
|
|
|
2008-01-18 03:29:43 +03:00
|
|
|
// If this is really a definition, update COMPILE_DEFINITIONS.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ParseDefineFlag(flag, false)) {
|
2008-01-18 03:29:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-18 03:29:43 +03:00
|
|
|
|
2008-06-26 21:30:10 +04:00
|
|
|
// Add this flag that does not look like a definition.
|
|
|
|
this->AddDefineFlag(flag, this->DefineFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags)
|
|
|
|
{
|
2007-03-07 19:03:57 +03:00
|
|
|
// remove any \n\r
|
2015-02-18 02:44:45 +03:00
|
|
|
std::string::size_type initSize = dflags.size();
|
|
|
|
dflags += std::string(" ") + flag;
|
|
|
|
std::string::iterator flagStart = dflags.begin() + initSize + 1;
|
|
|
|
std::replace(flagStart, dflags.end(), '\n', ' ');
|
|
|
|
std::replace(flagStart, dflags.end(), '\r', ' ');
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2004-04-15 21:58:10 +04:00
|
|
|
void cmMakefile::RemoveDefineFlag(const char* flag)
|
|
|
|
{
|
2006-05-23 20:51:26 +04:00
|
|
|
// Check the length of the flag to remove.
|
|
|
|
std::string::size_type len = strlen(flag);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (len < 1) {
|
2006-05-23 20:51:26 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-05-23 20:51:26 +04:00
|
|
|
|
2008-06-26 21:30:10 +04:00
|
|
|
// Update the string used for the old DEFINITIONS property.
|
|
|
|
this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig);
|
|
|
|
|
2008-01-18 03:29:43 +03:00
|
|
|
// If this is really a definition, update COMPILE_DEFINITIONS.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ParseDefineFlag(flag, true)) {
|
2008-01-18 03:29:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-18 03:29:43 +03:00
|
|
|
|
2008-06-26 21:30:10 +04:00
|
|
|
// Remove this flag that does not look like a definition.
|
|
|
|
this->RemoveDefineFlag(flag, len, this->DefineFlags);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::RemoveDefineFlag(const char* flag, std::string::size_type len,
|
2008-06-26 21:30:10 +04:00
|
|
|
std::string& dflags)
|
|
|
|
{
|
2006-05-23 20:51:26 +04:00
|
|
|
// Remove all instances of the flag that are surrounded by
|
|
|
|
// whitespace or the beginning/end of the string.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::string::size_type lpos = dflags.find(flag, 0);
|
|
|
|
lpos != std::string::npos; lpos = dflags.find(flag, lpos)) {
|
2006-05-23 20:51:26 +04:00
|
|
|
std::string::size_type rpos = lpos + len;
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((lpos <= 0 || isspace(dflags[lpos - 1])) &&
|
|
|
|
(rpos >= dflags.size() || isspace(dflags[rpos]))) {
|
2008-06-26 21:30:10 +04:00
|
|
|
dflags.erase(lpos, len);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-05-23 20:51:26 +04:00
|
|
|
++lpos;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-15 21:58:10 +04:00
|
|
|
}
|
|
|
|
|
2013-06-04 12:30:24 +04:00
|
|
|
void cmMakefile::AddCompileOption(const char* option)
|
|
|
|
{
|
|
|
|
this->AppendProperty("COMPILE_OPTIONS", option);
|
|
|
|
}
|
|
|
|
|
2008-01-18 03:29:43 +03:00
|
|
|
bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
|
|
|
|
{
|
|
|
|
// Create a regular expression to match valid definitions.
|
2016-05-16 17:34:04 +03:00
|
|
|
static cmsys::RegularExpression valid("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=.*)?$");
|
2008-01-18 03:29:43 +03:00
|
|
|
|
|
|
|
// Make sure the definition matches.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!valid.find(def.c_str())) {
|
2008-01-18 03:29:43 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-18 03:29:43 +03:00
|
|
|
|
2008-03-14 00:11:57 +03:00
|
|
|
// Definitions with non-trivial values require a policy check.
|
2016-05-16 17:34:04 +03:00
|
|
|
static cmsys::RegularExpression trivial(
|
|
|
|
"^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$");
|
|
|
|
if (!trivial.find(def.c_str())) {
|
2008-03-14 00:11:57 +03:00
|
|
|
// This definition has a non-trivial value.
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0005)) {
|
2008-03-14 00:11:57 +03:00
|
|
|
case cmPolicies::WARN:
|
2016-05-16 17:34:04 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING,
|
|
|
|
cmPolicies::GetPolicyWarning(cmPolicies::CMP0005));
|
2008-03-14 00:11:57 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior is to not escape the value. We should not
|
|
|
|
// convert the definition to use the property.
|
|
|
|
return false;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
this->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0005));
|
2008-03-14 00:11:57 +03:00
|
|
|
return false;
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior is to escape the value. Proceed to convert it
|
|
|
|
// to an entry in the property.
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-14 00:11:57 +03:00
|
|
|
|
2008-01-18 03:29:43 +03:00
|
|
|
// Get the definition part after the flag.
|
|
|
|
const char* define = def.c_str() + 2;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (remove) {
|
|
|
|
if (const char* cdefs = this->GetProperty("COMPILE_DEFINITIONS")) {
|
2008-01-18 03:29:43 +03:00
|
|
|
// Expand the list.
|
|
|
|
std::vector<std::string> defs;
|
|
|
|
cmSystemTools::ExpandListArgument(cdefs, defs);
|
|
|
|
|
|
|
|
// Recompose the list without the definition.
|
2015-01-28 00:39:46 +03:00
|
|
|
std::vector<std::string>::const_iterator defEnd =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::remove(defs.begin(), defs.end(), define);
|
|
|
|
std::vector<std::string>::const_iterator defBegin = defs.begin();
|
2015-07-18 11:45:18 +03:00
|
|
|
std::string ndefs = cmJoin(cmMakeRange(defBegin, defEnd), ";");
|
2008-01-18 03:29:43 +03:00
|
|
|
|
|
|
|
// Store the new list.
|
|
|
|
this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-01-18 03:29:43 +03:00
|
|
|
// Append the definition to the directory property.
|
|
|
|
this->AppendProperty("COMPILE_DEFINITIONS", define);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-18 03:29:43 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-07 02:31:47 +04:00
|
|
|
void cmMakefile::AddLinkLibrary(const std::string& lib,
|
2015-10-10 14:56:36 +03:00
|
|
|
cmTargetLinkLibraryType llt)
|
2001-04-27 00:22:53 +04:00
|
|
|
{
|
2006-11-30 01:10:29 +03:00
|
|
|
cmTarget::LibraryID tmp;
|
2006-11-29 23:45:49 +03:00
|
|
|
tmp.first = lib;
|
|
|
|
tmp.second = llt;
|
|
|
|
this->LinkLibraries.push_back(tmp);
|
2001-04-30 18:44:00 +04:00
|
|
|
}
|
|
|
|
|
2014-02-07 02:31:47 +04:00
|
|
|
void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
|
|
|
|
const std::string& lib,
|
2015-10-10 14:56:36 +03:00
|
|
|
cmTargetLinkLibraryType llt)
|
2007-06-08 19:57:16 +04:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
cmTargets::iterator i = this->Targets.find(target);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != this->Targets.end()) {
|
2015-05-03 12:10:30 +03:00
|
|
|
cmTarget* tgt = this->GetGlobalGenerator()->FindTarget(lib);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (tgt) {
|
2006-05-05 01:54:31 +04:00
|
|
|
// if it is not a static or shared library then you can not link to it
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!((tgt->GetType() == cmState::STATIC_LIBRARY) ||
|
|
|
|
(tgt->GetType() == cmState::SHARED_LIBRARY) ||
|
|
|
|
(tgt->GetType() == cmState::INTERFACE_LIBRARY) ||
|
|
|
|
tgt->IsExecutableWithExports())) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-08-19 18:28:22 +04:00
|
|
|
e << "Target \"" << lib << "\" of type "
|
2015-10-08 01:26:50 +03:00
|
|
|
<< cmState::GetTargetTypeName(tgt->GetType())
|
2008-08-19 18:28:22 +04:00
|
|
|
<< " may not be linked into another target. "
|
|
|
|
<< "One may link only to STATIC or SHARED libraries, or "
|
2007-03-22 16:45:25 +03:00
|
|
|
<< "to executables with the ENABLE_EXPORTS property set.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2006-05-05 01:54:31 +04:00
|
|
|
}
|
2001-04-30 18:44:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
i->second.AddLinkLibrary(*this, target, lib, llt);
|
|
|
|
} else {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Attempt to add link library \"" << lib << "\" to target \"" << target
|
|
|
|
<< "\" which is not built in this directory.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-04-27 00:22:53 +04:00
|
|
|
}
|
|
|
|
|
2014-02-07 02:31:47 +04:00
|
|
|
void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
|
|
|
|
const std::string& d)
|
2002-05-02 21:17:10 +04:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
cmTargets::iterator i = this->Targets.find(target);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != this->Targets.end()) {
|
|
|
|
if (this->IsAlias(target)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2013-07-12 11:14:31 +04:00
|
|
|
e << "ALIAS target \"" << target << "\" "
|
|
|
|
<< "may not be linked into another target.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2013-07-12 11:14:31 +04:00
|
|
|
return;
|
2002-05-02 21:17:10 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
i->second.AddLinkDirectory(d);
|
|
|
|
} else {
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"Attempt to add link directories to non-existent target: ",
|
|
|
|
target.c_str(), " for directory ", d.c_str());
|
|
|
|
}
|
2002-05-02 21:17:10 +04:00
|
|
|
}
|
|
|
|
|
2014-02-07 02:31:47 +04:00
|
|
|
void cmMakefile::AddLinkLibrary(const std::string& lib)
|
2001-01-05 19:41:20 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddLinkLibrary(lib, GENERAL_LibraryType);
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2015-06-06 10:17:45 +03:00
|
|
|
void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
2005-03-18 18:41:41 +03:00
|
|
|
{
|
2006-10-05 16:55:59 +04:00
|
|
|
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2005-03-18 18:41:41 +03:00
|
|
|
// define flags
|
2006-03-15 19:02:08 +03:00
|
|
|
this->DefineFlags = parent->DefineFlags;
|
2008-10-09 21:52:25 +04:00
|
|
|
this->DefineFlagsOrig = parent->DefineFlagsOrig;
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2008-05-14 19:54:52 +04:00
|
|
|
// Include transform property. There is no per-config version.
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* prop = "IMPLICIT_DEPENDS_INCLUDE_TRANSFORM";
|
|
|
|
this->SetProperty(prop, parent->GetProperty(prop));
|
2008-05-14 19:54:52 +04:00
|
|
|
}
|
|
|
|
|
2008-01-18 04:34:10 +03:00
|
|
|
// compile definitions property and per-config versions
|
2013-12-30 16:33:02 +04:00
|
|
|
cmPolicies::PolicyStatus polSt = this->GetPolicyStatus(cmPolicies::CMP0043);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
|
2013-12-30 16:33:02 +04:00
|
|
|
this->SetProperty("COMPILE_DEFINITIONS",
|
|
|
|
parent->GetProperty("COMPILE_DEFINITIONS"));
|
|
|
|
std::vector<std::string> configs;
|
|
|
|
this->GetConfigurations(configs);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator ci = configs.begin();
|
|
|
|
ci != configs.end(); ++ci) {
|
2013-12-30 16:33:02 +04:00
|
|
|
std::string defPropName = "COMPILE_DEFINITIONS_";
|
|
|
|
defPropName += cmSystemTools::UpperCase(*ci);
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* prop = parent->GetProperty(defPropName);
|
|
|
|
this->SetProperty(defPropName, prop);
|
2008-01-18 04:34:10 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-18 03:50:39 +03:00
|
|
|
|
2005-03-18 18:41:41 +03:00
|
|
|
// link libraries
|
2006-03-15 19:02:08 +03:00
|
|
|
this->LinkLibraries = parent->LinkLibraries;
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2005-03-22 18:23:04 +03:00
|
|
|
// link directories
|
2015-07-18 14:52:46 +03:00
|
|
|
this->SetProperty("LINK_DIRECTORIES",
|
|
|
|
parent->GetProperty("LINK_DIRECTORIES"));
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2005-03-18 18:41:41 +03:00
|
|
|
// the initial project name
|
2015-10-07 01:17:20 +03:00
|
|
|
this->StateSnapshot.SetProjectName(parent->StateSnapshot.GetProjectName());
|
2005-07-28 01:23:39 +04:00
|
|
|
|
|
|
|
// Copy include regular expressions.
|
2006-03-15 19:02:08 +03:00
|
|
|
this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression;
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Imported targets.
|
|
|
|
this->ImportedTargets = parent->ImportedTargets;
|
2005-03-18 18:41:41 +03:00
|
|
|
}
|
|
|
|
|
2015-05-31 20:37:08 +03:00
|
|
|
void cmMakefile::PushFunctionScope(std::string const& fileName,
|
|
|
|
const cmPolicies::PolicyMap& pm)
|
2015-05-31 19:19:58 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->StateSnapshot = this->GetState()->CreateFunctionCallSnapshot(
|
|
|
|
this->StateSnapshot, fileName);
|
2015-06-21 22:26:36 +03:00
|
|
|
assert(this->StateSnapshot.IsValid());
|
|
|
|
|
2015-06-01 00:45:52 +03:00
|
|
|
this->PushLoopBlockBarrier();
|
|
|
|
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
|
|
|
|
#endif
|
2015-05-31 19:19:58 +03:00
|
|
|
|
|
|
|
this->PushFunctionBlockerBarrier();
|
|
|
|
|
|
|
|
this->PushPolicy(true, pm);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PopFunctionScope(bool reportError)
|
|
|
|
{
|
|
|
|
this->PopPolicy();
|
|
|
|
|
2015-11-24 19:44:57 +03:00
|
|
|
this->PopSnapshot(reportError);
|
2015-06-21 22:26:36 +03:00
|
|
|
|
2015-05-31 19:19:58 +03:00
|
|
|
this->PopFunctionBlockerBarrier(reportError);
|
|
|
|
|
2015-06-01 00:45:52 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
this->PopLoopBlockBarrier();
|
|
|
|
|
|
|
|
this->CheckForUnusedVariables();
|
2015-05-31 19:19:58 +03:00
|
|
|
}
|
|
|
|
|
2015-05-31 20:37:08 +03:00
|
|
|
void cmMakefile::PushMacroScope(std::string const& fileName,
|
|
|
|
const cmPolicies::PolicyMap& pm)
|
2015-05-31 19:32:01 +03:00
|
|
|
{
|
2015-06-21 22:26:36 +03:00
|
|
|
this->StateSnapshot =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetState()->CreateMacroCallSnapshot(this->StateSnapshot, fileName);
|
2015-06-21 22:26:36 +03:00
|
|
|
assert(this->StateSnapshot.IsValid());
|
|
|
|
|
2015-05-31 19:32:01 +03:00
|
|
|
this->PushFunctionBlockerBarrier();
|
|
|
|
|
|
|
|
this->PushPolicy(true, pm);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PopMacroScope(bool reportError)
|
|
|
|
{
|
|
|
|
this->PopPolicy();
|
2015-11-24 19:44:57 +03:00
|
|
|
this->PopSnapshot(reportError);
|
2015-06-21 22:26:36 +03:00
|
|
|
|
2015-05-31 19:32:01 +03:00
|
|
|
this->PopFunctionBlockerBarrier(reportError);
|
|
|
|
}
|
|
|
|
|
2015-06-06 15:07:15 +03:00
|
|
|
bool cmMakefile::IsRootMakefile() const
|
|
|
|
{
|
|
|
|
return !this->StateSnapshot.GetBuildsystemDirectoryParent().IsValid();
|
|
|
|
}
|
|
|
|
|
2015-06-22 00:13:24 +03:00
|
|
|
class cmMakefile::BuildsystemFileScope
|
|
|
|
{
|
|
|
|
public:
|
2015-06-22 00:19:50 +03:00
|
|
|
BuildsystemFileScope(cmMakefile* mf)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Makefile(mf)
|
|
|
|
, ReportError(true)
|
2015-06-22 00:13:24 +03:00
|
|
|
{
|
2015-06-22 00:19:50 +03:00
|
|
|
std::string currentStart =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource();
|
2015-06-22 00:19:50 +03:00
|
|
|
currentStart += "/CMakeLists.txt";
|
2015-05-31 20:37:08 +03:00
|
|
|
this->Makefile->StateSnapshot.SetListFile(currentStart);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->StateSnapshot =
|
|
|
|
this->Makefile->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
|
|
|
|
this->Makefile->StateSnapshot);
|
2015-06-22 00:13:24 +03:00
|
|
|
this->Makefile->PushFunctionBlockerBarrier();
|
2015-06-26 01:13:22 +03:00
|
|
|
|
|
|
|
this->GG = mf->GetGlobalGenerator();
|
|
|
|
this->CurrentMakefile = this->GG->GetCurrentMakefile();
|
|
|
|
this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
|
2015-07-08 00:50:54 +03:00
|
|
|
this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
|
2015-06-26 01:13:22 +03:00
|
|
|
this->GG->SetCurrentMakefile(mf);
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
this->GG->GetFileLockPool().PushFileScope();
|
|
|
|
#endif
|
2015-06-22 00:13:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
~BuildsystemFileScope()
|
|
|
|
{
|
|
|
|
this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
|
2015-11-24 19:44:57 +03:00
|
|
|
this->Makefile->PopSnapshot(this->ReportError);
|
2015-06-26 01:13:22 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
this->GG->GetFileLockPool().PopFileScope();
|
|
|
|
#endif
|
|
|
|
this->GG->SetCurrentMakefile(this->CurrentMakefile);
|
|
|
|
this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
|
2015-06-22 00:13:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Quiet() { this->ReportError = false; }
|
|
|
|
private:
|
|
|
|
cmMakefile* Makefile;
|
2015-06-26 01:13:22 +03:00
|
|
|
cmGlobalGenerator* GG;
|
|
|
|
cmMakefile* CurrentMakefile;
|
|
|
|
cmState::Snapshot Snapshot;
|
2015-06-22 00:13:24 +03:00
|
|
|
bool ReportError;
|
|
|
|
};
|
|
|
|
|
2015-05-30 20:50:58 +03:00
|
|
|
void cmMakefile::Configure()
|
|
|
|
{
|
2016-04-14 18:24:08 +03:00
|
|
|
std::string currentStart =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->StateSnapshot.GetDirectory().GetCurrentSource();
|
2016-04-14 18:24:08 +03:00
|
|
|
currentStart += "/CMakeLists.txt";
|
|
|
|
|
|
|
|
// Add the bottom of all backtraces within this directory.
|
|
|
|
// We will never pop this scope because it should be available
|
|
|
|
// for messages during the generate step too.
|
|
|
|
this->Backtrace = this->Backtrace.Push(currentStart);
|
|
|
|
|
2015-06-26 01:11:10 +03:00
|
|
|
BuildsystemFileScope scope(this);
|
2015-05-30 20:50:58 +03:00
|
|
|
|
|
|
|
// make sure the CMakeFiles dir is there
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string filesDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
2015-05-30 20:50:58 +03:00
|
|
|
filesDir += cmake::GetCMakeFilesDirectory();
|
|
|
|
cmSystemTools::MakeDirectory(filesDir.c_str());
|
|
|
|
|
|
|
|
assert(cmSystemTools::FileExists(currentStart.c_str(), true));
|
2015-06-22 00:13:24 +03:00
|
|
|
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
|
|
|
|
|
|
|
|
cmListFile listFile;
|
2016-01-29 00:10:28 +03:00
|
|
|
if (!listFile.ParseFile(currentStart.c_str(), this->GetMessenger(),
|
|
|
|
this->Backtrace)) {
|
2015-06-22 00:13:24 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-01-29 00:10:26 +03:00
|
|
|
if (this->IsRootMakefile()) {
|
|
|
|
bool hasVersion = false;
|
|
|
|
// search for the right policy command
|
|
|
|
for (std::vector<cmListFileFunction>::iterator i =
|
|
|
|
listFile.Functions.begin();
|
|
|
|
i != listFile.Functions.end(); ++i) {
|
|
|
|
if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") {
|
|
|
|
hasVersion = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if no policy command is found this is an error if they use any
|
|
|
|
// non advanced functions or a lot of functions
|
|
|
|
if (!hasVersion) {
|
|
|
|
bool isProblem = true;
|
|
|
|
if (listFile.Functions.size() < 30) {
|
|
|
|
// the list of simple commands DO NOT ADD TO THIS LIST!!!!!
|
|
|
|
// these commands must have backwards compatibility forever and
|
|
|
|
// and that is a lot longer than your tiny mind can comprehend mortal
|
|
|
|
std::set<std::string> allowedCommands;
|
|
|
|
allowedCommands.insert("project");
|
|
|
|
allowedCommands.insert("set");
|
|
|
|
allowedCommands.insert("if");
|
|
|
|
allowedCommands.insert("endif");
|
|
|
|
allowedCommands.insert("else");
|
|
|
|
allowedCommands.insert("elseif");
|
|
|
|
allowedCommands.insert("add_executable");
|
|
|
|
allowedCommands.insert("add_library");
|
|
|
|
allowedCommands.insert("target_link_libraries");
|
|
|
|
allowedCommands.insert("option");
|
|
|
|
allowedCommands.insert("message");
|
|
|
|
isProblem = false;
|
|
|
|
for (std::vector<cmListFileFunction>::iterator i =
|
|
|
|
listFile.Functions.begin();
|
|
|
|
i != listFile.Functions.end(); ++i) {
|
|
|
|
std::string name = cmSystemTools::LowerCase(i->Name);
|
|
|
|
if (allowedCommands.find(name) == allowedCommands.end()) {
|
|
|
|
isProblem = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isProblem) {
|
|
|
|
// Tell the top level cmMakefile to diagnose
|
|
|
|
// this violation of CMP0000.
|
|
|
|
this->SetCheckCMP0000(true);
|
|
|
|
|
|
|
|
// Implicitly set the version for the user.
|
|
|
|
this->SetPolicyVersion("2.4");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool hasProject = false;
|
|
|
|
// search for a project command
|
|
|
|
for (std::vector<cmListFileFunction>::iterator i =
|
|
|
|
listFile.Functions.begin();
|
|
|
|
i != listFile.Functions.end(); ++i) {
|
|
|
|
if (cmSystemTools::LowerCase(i->Name) == "project") {
|
|
|
|
hasProject = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if no project command is found, add one
|
|
|
|
if (!hasProject) {
|
|
|
|
cmListFileFunction project;
|
|
|
|
project.Name = "PROJECT";
|
|
|
|
cmListFileArgument prj("Project", cmListFileArgument::Unquoted, 0);
|
|
|
|
project.Arguments.push_back(prj);
|
|
|
|
listFile.Functions.insert(listFile.Functions.begin(), project);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-22 00:13:24 +03:00
|
|
|
this->ReadListFile(listFile, currentStart);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
2015-06-22 00:13:24 +03:00
|
|
|
scope.Quiet();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-30 20:50:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// at the end handle any old style subdirs
|
2015-06-03 01:55:00 +03:00
|
|
|
std::vector<cmMakefile*> subdirs = this->UnConfiguredDirectories;
|
2015-05-30 20:50:58 +03:00
|
|
|
|
|
|
|
// for each subdir recurse
|
2015-06-03 01:55:00 +03:00
|
|
|
std::vector<cmMakefile*>::iterator sdi = subdirs.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; sdi != subdirs.end(); ++sdi) {
|
2015-10-12 20:34:06 +03:00
|
|
|
(*sdi)->StateSnapshot.InitializeFromParent_ForSubdirsCommand();
|
2015-06-03 01:55:00 +03:00
|
|
|
this->ConfigureSubDirectory(*sdi);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-30 20:50:58 +03:00
|
|
|
|
|
|
|
this->AddCMakeDependFilesFromUser();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
|
2005-03-18 18:41:41 +03:00
|
|
|
{
|
2015-06-06 10:17:45 +03:00
|
|
|
mf->InitializeFromParent(this);
|
2015-05-30 20:53:02 +03:00
|
|
|
std::string currentStart = mf->GetCurrentSourceDirectory();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetCMakeInstance()->GetDebugOutput()) {
|
|
|
|
std::string msg = " Entering ";
|
2015-05-14 22:18:06 +03:00
|
|
|
msg += currentStart;
|
2007-07-20 16:48:32 +04:00
|
|
|
cmSystemTools::Message(msg.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-14 22:18:06 +03:00
|
|
|
|
2015-08-04 23:39:31 +03:00
|
|
|
std::string const currentStartFile = currentStart + "/CMakeLists.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(currentStartFile, true)) {
|
2015-05-14 22:18:06 +03:00
|
|
|
// The file is missing. Check policy CMP0014.
|
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-05-14 22:18:06 +03:00
|
|
|
e << "The source directory\n"
|
|
|
|
<< " " << currentStart << "\n"
|
|
|
|
<< "does not contain a CMakeLists.txt file.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0014)) {
|
2015-05-14 22:18:06 +03:00
|
|
|
case cmPolicies::WARN:
|
|
|
|
// Print the warning.
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-05-14 22:18:06 +03:00
|
|
|
e << "\n"
|
|
|
|
<< "CMake does not support this case but it used "
|
|
|
|
<< "to work accidentally and is being allowed for "
|
|
|
|
<< "compatibility."
|
|
|
|
<< "\n"
|
|
|
|
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0014);
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2015-05-14 22:18:06 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior does not warn.
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "\n" << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0014);
|
2015-05-14 22:18:06 +03:00
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior prints the error.
|
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
|
|
|
}
|
2005-03-18 18:41:41 +03:00
|
|
|
// finally configure the subdir
|
2015-05-30 20:53:02 +03:00
|
|
|
mf->Configure();
|
2015-05-30 20:39:08 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetCMakeInstance()->GetDebugOutput()) {
|
|
|
|
std::string msg = " Returning to ";
|
2015-04-16 22:17:41 +03:00
|
|
|
msg += this->GetCurrentSourceDirectory();
|
2007-07-20 16:48:32 +04:00
|
|
|
cmSystemTools::Message(msg.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-18 18:41:41 +03:00
|
|
|
}
|
|
|
|
|
2014-02-08 00:33:35 +04:00
|
|
|
void cmMakefile::AddSubDirectory(const std::string& srcPath,
|
|
|
|
const std::string& binPath,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool excludeFromAll, bool immediate)
|
2005-03-14 19:29:15 +03:00
|
|
|
{
|
2009-02-27 19:23:14 +03:00
|
|
|
// Make sure the binary directory is unique.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->EnforceUniqueDir(srcPath, binPath)) {
|
2009-02-27 19:23:14 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-27 19:23:14 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot newSnapshot =
|
|
|
|
this->GetState()->CreateBuildsystemDirectorySnapshot(this->StateSnapshot);
|
2015-05-24 12:50:55 +03:00
|
|
|
|
2015-05-31 02:57:04 +03:00
|
|
|
newSnapshot.GetDirectory().SetCurrentSource(srcPath);
|
|
|
|
newSnapshot.GetDirectory().SetCurrentBinary(binPath);
|
2015-10-06 01:04:30 +03:00
|
|
|
|
2015-10-13 22:57:54 +03:00
|
|
|
cmSystemTools::MakeDirectory(binPath.c_str());
|
|
|
|
|
2015-05-31 02:57:04 +03:00
|
|
|
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
|
|
|
|
this->GetGlobalGenerator()->AddMakefile(subMf);
|
2015-10-06 01:04:30 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (excludeFromAll) {
|
2015-06-03 01:57:31 +03:00
|
|
|
subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (immediate) {
|
2015-06-03 01:57:31 +03:00
|
|
|
this->ConfigureSubDirectory(subMf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-06-03 01:57:31 +03:00
|
|
|
this->UnConfiguredDirectories.push_back(subMf);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2015-04-16 10:24:16 +03:00
|
|
|
const char* cmMakefile::GetCurrentSourceDirectory() const
|
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetCurrentSource();
|
2015-04-16 10:24:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmMakefile::GetCurrentBinaryDirectory() const
|
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
2015-04-16 10:24:16 +03:00
|
|
|
}
|
|
|
|
|
2015-10-27 00:18:20 +03:00
|
|
|
std::vector<cmTarget*> cmMakefile::GetImportedTargets() const
|
|
|
|
{
|
|
|
|
std::vector<cmTarget*> tgts;
|
|
|
|
tgts.reserve(this->ImportedTargets.size());
|
|
|
|
for (TargetMap::const_iterator it = this->ImportedTargets.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != this->ImportedTargets.end(); ++it) {
|
2015-10-27 00:18:20 +03:00
|
|
|
tgts.push_back(it->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-27 00:18:20 +03:00
|
|
|
return tgts;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddIncludeDirectories(const std::vector<std::string>& incs,
|
2013-01-20 15:28:59 +04:00
|
|
|
bool before)
|
2012-01-24 20:54:46 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (incs.empty()) {
|
2012-01-24 20:54:46 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-01-24 20:54:46 +04:00
|
|
|
|
2014-05-23 22:41:46 +04:00
|
|
|
cmListFileBacktrace lfbt = this->GetBacktrace();
|
2015-07-08 01:29:41 +03:00
|
|
|
std::string entryString = cmJoin(incs, ";");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (before) {
|
|
|
|
this->StateSnapshot.GetDirectory().PrependIncludeDirectoriesEntry(
|
|
|
|
entryString, lfbt);
|
|
|
|
} else {
|
|
|
|
this->StateSnapshot.GetDirectory().AppendIncludeDirectoriesEntry(
|
|
|
|
entryString, lfbt);
|
|
|
|
}
|
2011-12-04 19:40:39 +04:00
|
|
|
|
|
|
|
// Property on each target:
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
|
|
|
|
++l) {
|
|
|
|
cmTarget& t = l->second;
|
2015-07-09 00:35:01 +03:00
|
|
|
t.InsertInclude(entryString, lfbt, before);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddSystemIncludeDirectories(const std::set<std::string>& incs)
|
2006-10-05 16:55:59 +04:00
|
|
|
{
|
2016-05-24 18:38:18 +03:00
|
|
|
if (incs.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-25 18:33:00 +03:00
|
|
|
this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
|
2006-10-05 16:55:59 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
|
|
|
|
++l) {
|
|
|
|
cmTarget& t = l->second;
|
2013-07-02 00:55:25 +04:00
|
|
|
t.AddSystemIncludeDirectories(incs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-10-05 16:55:59 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmMakefile::AddDefinition(const std::string& name, const char* value)
|
2001-01-05 19:41:20 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!value) {
|
2002-09-11 22:05:45 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->VariableInitialized(name)) {
|
2015-05-17 17:28:39 +03:00
|
|
|
this->LogUnused("changing definition", name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 22:26:43 +03:00
|
|
|
this->StateSnapshot.SetDefinition(name, value);
|
2004-10-27 18:47:14 +04:00
|
|
|
|
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2003-01-08 20:59:52 +03:00
|
|
|
cmVariableWatch* vv = this->GetVariableWatch();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (vv) {
|
|
|
|
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
|
|
|
|
value, this);
|
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
2001-05-11 00:21:45 +04:00
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
|
2001-08-08 19:54:46 +04:00
|
|
|
const char* doc,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::CacheEntryType type, bool force)
|
2001-08-08 19:54:46 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* existingValue = this->GetState()->GetInitializedCacheValue(name);
|
2016-04-20 23:40:58 +03:00
|
|
|
// must be outside the following if() to keep it alive long enough
|
|
|
|
std::string nvalue;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (existingValue &&
|
|
|
|
(this->GetState()->GetCacheEntryType(name) == cmState::UNINITIALIZED)) {
|
2008-11-22 00:32:39 +03:00
|
|
|
// if this is not a force, then use the value from the cache
|
|
|
|
// if it is a force, then use the value being passed in
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!force) {
|
2016-04-20 23:40:58 +03:00
|
|
|
value = existingValue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (type == cmState::PATH || type == cmState::FILEPATH) {
|
2003-08-08 18:07:09 +04:00
|
|
|
std::vector<std::string>::size_type cc;
|
|
|
|
std::vector<std::string> files;
|
2016-04-20 23:40:58 +03:00
|
|
|
nvalue = value ? value : "";
|
|
|
|
|
|
|
|
cmSystemTools::ExpandListArgument(nvalue, files);
|
|
|
|
nvalue = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cc = 0; cc < files.size(); cc++) {
|
|
|
|
if (!cmSystemTools::IsOff(files[cc].c_str())) {
|
2014-10-15 16:54:05 +04:00
|
|
|
files[cc] = cmSystemTools::CollapseFullPath(files[cc]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cc > 0) {
|
2003-08-08 18:07:09 +04:00
|
|
|
nvalue += ";";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
nvalue += files[cc];
|
|
|
|
}
|
2003-08-08 18:07:09 +04:00
|
|
|
|
2015-10-10 16:03:41 +03:00
|
|
|
this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type);
|
2016-04-20 23:40:58 +03:00
|
|
|
nvalue = this->GetState()->GetInitializedCacheValue(name);
|
|
|
|
value = nvalue.c_str();
|
2003-08-01 22:10:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-04-20 23:40:58 +03:00
|
|
|
this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
|
2007-03-15 20:48:15 +03:00
|
|
|
// if there was a definition then remove it
|
2015-06-21 22:26:43 +03:00
|
|
|
this->StateSnapshot.RemoveDefinition(name);
|
2001-08-08 19:54:46 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmMakefile::AddDefinition(const std::string& name, bool value)
|
2001-04-24 20:40:37 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->VariableInitialized(name)) {
|
2015-05-17 17:28:39 +03:00
|
|
|
this->LogUnused("changing definition", name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 22:26:43 +03:00
|
|
|
|
|
|
|
this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF");
|
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2003-01-08 20:59:52 +03:00
|
|
|
cmVariableWatch* vv = this->GetVariableWatch();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (vv) {
|
2007-04-11 23:13:05 +04:00
|
|
|
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
|
2016-05-16 17:34:04 +03:00
|
|
|
value ? "ON" : "OFF", this);
|
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2001-04-24 20:40:37 +04:00
|
|
|
}
|
2001-01-05 19:41:20 +03:00
|
|
|
|
2010-09-22 20:40:43 +04:00
|
|
|
void cmMakefile::CheckForUnusedVariables() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->WarnUnused) {
|
2011-06-21 23:59:10 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 22:26:43 +03:00
|
|
|
const std::vector<std::string>& unused = this->StateSnapshot.UnusedKeys();
|
2015-05-17 17:19:55 +03:00
|
|
|
std::vector<std::string>::const_iterator it = unused.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; it != unused.end(); ++it) {
|
2015-05-17 17:28:39 +03:00
|
|
|
this->LogUnused("out of scope", *it);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-22 20:40:43 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmMakefile::MarkVariableAsUsed(const std::string& var)
|
2010-09-15 19:34:35 +04:00
|
|
|
{
|
2015-06-21 22:26:43 +03:00
|
|
|
this->StateSnapshot.GetDefinition(var);
|
2010-09-15 19:34:35 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
bool cmMakefile::VariableInitialized(const std::string& var) const
|
2010-08-24 22:38:06 +04:00
|
|
|
{
|
2015-06-21 22:26:43 +03:00
|
|
|
return this->StateSnapshot.IsInitialized(var);
|
2010-08-24 22:38:06 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::LogUnused(const char* reason, const std::string& name) const
|
2010-09-14 23:22:31 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->WarnUnused) {
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string path;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->ExecutionStatusStack.empty()) {
|
2016-04-15 17:13:12 +03:00
|
|
|
path = this->GetExecutionContext().FilePath;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-04-16 21:06:54 +03:00
|
|
|
path = this->GetCurrentSourceDirectory();
|
2010-09-22 20:41:58 +04:00
|
|
|
path += "/CMakeLists.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-22 01:38:03 +03:00
|
|
|
|
2010-09-14 23:22:31 +04:00
|
|
|
if (this->CheckSystemVars ||
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::IsSubDirectory(path, this->GetHomeDirectory()) ||
|
|
|
|
(cmSystemTools::IsSubDirectory(path, this->GetHomeOutputDirectory()) &&
|
|
|
|
!cmSystemTools::IsSubDirectory(path,
|
|
|
|
cmake::GetCMakeFilesDirectory()))) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2010-12-08 00:38:25 +03:00
|
|
|
msg << "unused variable (" << reason << ") \'" << name << "\'";
|
2016-04-15 17:13:12 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
|
2010-09-14 23:22:31 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-14 23:22:31 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmMakefile::RemoveDefinition(const std::string& name)
|
2002-09-18 18:39:41 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->VariableInitialized(name)) {
|
2015-05-17 17:28:39 +03:00
|
|
|
this->LogUnused("unsetting", name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 22:26:43 +03:00
|
|
|
this->StateSnapshot.RemoveDefinition(name);
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2003-01-08 20:59:52 +03:00
|
|
|
cmVariableWatch* vv = this->GetVariableWatch();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (vv) {
|
2016-06-27 23:44:16 +03:00
|
|
|
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS,
|
|
|
|
CM_NULLPTR, this);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2002-09-18 18:39:41 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmMakefile::RemoveCacheDefinition(const std::string& name)
|
2008-08-25 18:31:29 +04:00
|
|
|
{
|
2015-04-06 11:52:45 +03:00
|
|
|
this->GetState()->RemoveCacheEntry(name);
|
2008-08-25 18:31:29 +04:00
|
|
|
}
|
|
|
|
|
2015-08-02 11:57:31 +03:00
|
|
|
void cmMakefile::SetProjectName(std::string const& p)
|
2001-01-05 19:41:20 +03:00
|
|
|
{
|
2015-08-02 10:41:06 +03:00
|
|
|
this->StateSnapshot.SetProjectName(p);
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2014-02-07 02:31:47 +04:00
|
|
|
void cmMakefile::AddGlobalLinkInformation(const std::string& name,
|
|
|
|
cmTarget& target)
|
2002-05-02 23:56:13 +04:00
|
|
|
{
|
2002-06-03 18:25:55 +04:00
|
|
|
// for these targets do not add anything
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (target.GetType()) {
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::UTILITY:
|
|
|
|
case cmState::GLOBAL_TARGET:
|
|
|
|
case cmState::INTERFACE_LIBRARY:
|
2002-10-24 18:23:11 +04:00
|
|
|
return;
|
2002-06-19 01:20:27 +04:00
|
|
|
default:;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
|
2015-07-18 14:52:46 +03:00
|
|
|
std::vector<std::string> linkDirs;
|
|
|
|
cmSystemTools::ExpandListArgument(linkDirsProp, linkDirs);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator j = linkDirs.begin();
|
|
|
|
j != linkDirs.end(); ++j) {
|
2015-07-18 14:52:46 +03:00
|
|
|
std::string newdir = *j;
|
|
|
|
// remove trailing slashes
|
2016-05-16 17:34:04 +03:00
|
|
|
if (*j->rbegin() == '/') {
|
|
|
|
newdir = j->substr(0, j->size() - 1);
|
|
|
|
}
|
|
|
|
if (std::find(this->LinkDirectories.begin(), this->LinkDirectories.end(),
|
|
|
|
newdir) == this->LinkDirectories.end()) {
|
2015-08-24 08:45:26 +03:00
|
|
|
target.AddLinkDirectory(*j);
|
2015-07-18 14:52:46 +03:00
|
|
|
}
|
2002-05-02 23:56:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
target.MergeLinkLibraries(*this, name, this->LinkLibraries);
|
2002-05-02 23:56:13 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName)
|
2013-07-12 11:14:31 +04:00
|
|
|
{
|
2015-10-25 14:43:00 +03:00
|
|
|
this->AliasTargets[lname] = tgtName;
|
|
|
|
this->GetGlobalGenerator()->AddAlias(lname, tgtName);
|
2013-07-12 11:14:31 +04:00
|
|
|
}
|
|
|
|
|
2014-02-07 02:31:47 +04:00
|
|
|
cmTarget* cmMakefile::AddLibrary(const std::string& lname,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::TargetType type,
|
|
|
|
const std::vector<std::string>& srcs,
|
|
|
|
bool excludeFromAll)
|
2001-04-11 22:59:02 +04:00
|
|
|
{
|
2007-06-22 17:58:10 +04:00
|
|
|
// wrong type ? default to STATIC
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((type != cmState::STATIC_LIBRARY) && (type != cmState::SHARED_LIBRARY) &&
|
|
|
|
(type != cmState::MODULE_LIBRARY) && (type != cmState::OBJECT_LIBRARY) &&
|
|
|
|
(type != cmState::INTERFACE_LIBRARY)) {
|
2012-03-12 18:47:40 +04:00
|
|
|
this->IssueMessage(cmake::INTERNAL_ERROR,
|
|
|
|
"cmMakefile::AddLibrary given invalid target type.");
|
2015-10-08 01:21:51 +03:00
|
|
|
type = cmState::STATIC_LIBRARY;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-11-20 02:01:05 +03:00
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
cmTarget* target = this->AddNewTarget(type, lname);
|
2002-05-02 23:10:19 +04:00
|
|
|
// Clear its dependencies. Otherwise, dependencies might persist
|
|
|
|
// over changes in CMakeLists.txt, making the information stale and
|
|
|
|
// hence useless.
|
2016-05-16 17:34:04 +03:00
|
|
|
target->ClearDependencyInformation(*this, lname);
|
|
|
|
if (excludeFromAll) {
|
2007-05-22 18:24:59 +04:00
|
|
|
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
target->AddSources(srcs);
|
2007-05-22 18:24:59 +04:00
|
|
|
this->AddGlobalLinkInformation(lname, *target);
|
2011-08-10 21:51:07 +04:00
|
|
|
return target;
|
2001-04-11 22:59:02 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTarget* cmMakefile::AddExecutable(const char* exeName,
|
|
|
|
const std::vector<std::string>& srcs,
|
2007-03-12 17:26:59 +03:00
|
|
|
bool excludeFromAll)
|
2001-01-05 19:41:20 +03:00
|
|
|
{
|
2015-10-08 01:21:51 +03:00
|
|
|
cmTarget* target = this->AddNewTarget(cmState::EXECUTABLE, exeName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (excludeFromAll) {
|
2007-05-22 18:24:59 +04:00
|
|
|
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
target->AddSources(srcs);
|
2007-05-22 18:24:59 +04:00
|
|
|
this->AddGlobalLinkInformation(exeName, *target);
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTarget* cmMakefile::AddNewTarget(cmState::TargetType type,
|
|
|
|
const std::string& name)
|
2007-05-22 18:24:59 +04:00
|
|
|
{
|
2008-03-13 20:48:57 +03:00
|
|
|
cmTargets::iterator it =
|
2016-09-14 21:28:07 +03:00
|
|
|
this->Targets
|
|
|
|
.insert(cmTargets::value_type(
|
|
|
|
name, cmTarget(name, type, cmTarget::VisibilityNormal, this)))
|
|
|
|
.first;
|
2016-02-08 20:37:47 +03:00
|
|
|
this->GetGlobalGenerator()->IndexTarget(&it->second);
|
2016-09-16 23:23:40 +03:00
|
|
|
this->GetStateSnapshot().GetDirectory().AddNormalTargetName(name);
|
2004-02-29 02:59:19 +03:00
|
|
|
return &it->second;
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput(
|
|
|
|
const std::string& name) const
|
2003-06-03 18:30:23 +04:00
|
|
|
{
|
2005-02-24 21:45:37 +03:00
|
|
|
std::string out;
|
2003-06-20 19:23:47 +04:00
|
|
|
|
2003-06-03 18:30:23 +04:00
|
|
|
// look through all the source files that have custom commands
|
|
|
|
// and see if the custom command has the passed source file as an output
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile*>::const_iterator i =
|
|
|
|
this->SourceFiles.begin();
|
|
|
|
i != this->SourceFiles.end(); ++i) {
|
2003-06-03 18:30:23 +04:00
|
|
|
// does this source file have a custom command?
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((*i)->GetCustomCommand()) {
|
2014-03-17 18:33:54 +04:00
|
|
|
// Does the output of the custom command match the source file name?
|
2006-04-11 19:06:19 +04:00
|
|
|
const std::vector<std::string>& outputs =
|
|
|
|
(*i)->GetCustomCommand()->GetOutputs();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator o = outputs.begin();
|
|
|
|
o != outputs.end(); ++o) {
|
2006-04-11 19:06:19 +04:00
|
|
|
out = *o;
|
|
|
|
std::string::size_type pos = out.rfind(name);
|
|
|
|
// If the output matches exactly
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != out.npos && pos == out.size() - name.size() &&
|
|
|
|
(pos == 0 || out[pos - 1] == '/')) {
|
2006-04-11 19:06:19 +04:00
|
|
|
return *i;
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2003-06-03 18:30:23 +04:00
|
|
|
// otherwise return NULL
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSourceFile* cmMakefile::GetSourceFileWithOutput(
|
|
|
|
const std::string& name) const
|
2013-08-06 20:12:50 +04:00
|
|
|
{
|
|
|
|
// If the queried path is not absolute we use the backward compatible
|
|
|
|
// linear-time search for an output with a matching suffix.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsFullPath(name.c_str())) {
|
2014-03-17 18:34:53 +04:00
|
|
|
return this->LinearGetSourceFileWithOutput(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-08-06 20:12:50 +04:00
|
|
|
// Otherwise we use an efficient lookup map.
|
2014-01-22 18:00:29 +04:00
|
|
|
OutputToSourceMap::const_iterator o = this->OutputToSource.find(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (o != this->OutputToSource.end()) {
|
2013-08-06 20:12:50 +04:00
|
|
|
return (*o).second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2013-08-06 20:12:50 +04:00
|
|
|
}
|
|
|
|
|
2006-03-22 17:58:11 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSourceGroup* cmMakefile::GetSourceGroup(
|
|
|
|
const std::vector<std::string>& name) const
|
2002-10-05 02:16:13 +04:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
cmSourceGroup* sg = CM_NULLPTR;
|
2007-08-24 22:21:49 +04:00
|
|
|
|
2015-10-25 17:03:55 +03:00
|
|
|
// first look for source group starting with the same as the one we want
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceGroup>::const_iterator sgIt =
|
|
|
|
this->SourceGroups.begin();
|
|
|
|
sgIt != this->SourceGroups.end(); ++sgIt) {
|
2007-08-24 22:21:49 +04:00
|
|
|
std::string sgName = sgIt->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sgName == name[0]) {
|
2014-01-21 18:16:43 +04:00
|
|
|
sg = const_cast<cmSourceGroup*>(&(*sgIt));
|
2007-08-24 22:21:49 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-07-13 19:21:30 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
if (sg != CM_NULLPTR) {
|
2007-08-24 22:21:49 +04:00
|
|
|
// iterate through its children to find match source group
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int i = 1; i < name.size(); ++i) {
|
2014-01-22 17:45:13 +04:00
|
|
|
sg = sg->LookupChild(name[i].c_str());
|
2016-06-27 23:44:16 +03:00
|
|
|
if (sg == CM_NULLPTR) {
|
2007-08-24 22:21:49 +04:00
|
|
|
break;
|
2002-10-05 02:16:13 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-24 22:21:49 +04:00
|
|
|
return sg;
|
2002-10-05 02:16:13 +04:00
|
|
|
}
|
2001-05-02 00:55:32 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddSourceGroup(const std::string& name, const char* regex)
|
2001-03-20 21:20:59 +03:00
|
|
|
{
|
2014-02-06 23:05:57 +04:00
|
|
|
std::vector<std::string> nameVector;
|
|
|
|
nameVector.push_back(name);
|
2015-10-25 17:04:07 +03:00
|
|
|
this->AddSourceGroup(nameVector, regex);
|
2007-08-24 22:21:49 +04:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2007-08-24 22:21:49 +04:00
|
|
|
void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
|
2007-08-26 11:17:11 +04:00
|
|
|
const char* regex)
|
2007-08-24 22:21:49 +04:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
cmSourceGroup* sg = CM_NULLPTR;
|
2007-08-24 22:21:49 +04:00
|
|
|
std::vector<std::string> currentName;
|
|
|
|
int i = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
const int lastElement = static_cast<int>(name.size() - 1);
|
|
|
|
for (i = lastElement; i >= 0; --i) {
|
|
|
|
currentName.assign(name.begin(), name.begin() + i + 1);
|
2007-08-24 22:21:49 +04:00
|
|
|
sg = this->GetSourceGroup(currentName);
|
2016-06-27 23:44:16 +03:00
|
|
|
if (sg != CM_NULLPTR) {
|
2007-08-24 22:21:49 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-07-13 19:21:30 +04:00
|
|
|
|
2007-08-24 22:21:49 +04:00
|
|
|
// i now contains the index of the last found component
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == lastElement) {
|
2007-08-24 22:21:49 +04:00
|
|
|
// group already exists, replace its regular expression
|
2016-05-16 17:34:04 +03:00
|
|
|
if (regex && sg) {
|
2007-08-24 22:21:49 +04:00
|
|
|
// We only want to set the regular expression. If there are already
|
|
|
|
// source files in the group, we don't want to remove them.
|
|
|
|
sg->SetGroupRegex(regex);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
2016-08-18 21:36:29 +03:00
|
|
|
}
|
|
|
|
if (i == -1) {
|
2012-11-07 20:13:09 +04:00
|
|
|
// group does not exist nor belong to any existing group
|
2007-08-24 22:21:49 +04:00
|
|
|
// add its first component
|
|
|
|
this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex));
|
|
|
|
sg = this->GetSourceGroup(currentName);
|
|
|
|
i = 0; // last component found
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!sg) {
|
2015-03-25 19:38:37 +03:00
|
|
|
cmSystemTools::Error("Could not create source group ");
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-24 22:21:49 +04:00
|
|
|
// build the whole source group path
|
2016-05-16 17:34:04 +03:00
|
|
|
for (++i; i <= lastElement; ++i) {
|
2016-06-27 23:44:16 +03:00
|
|
|
sg->AddChild(
|
|
|
|
cmSourceGroup(name[i].c_str(), CM_NULLPTR, sg->GetFullName()));
|
2014-01-22 17:45:13 +04:00
|
|
|
sg = sg->LookupChild(name[i].c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-24 22:21:49 +04:00
|
|
|
|
|
|
|
sg->SetGroupRegex(regex);
|
2001-03-20 21:20:59 +03:00
|
|
|
}
|
2007-08-24 22:21:49 +04:00
|
|
|
|
2006-03-22 17:58:11 +03:00
|
|
|
#endif
|
2001-01-05 19:41:20 +03:00
|
|
|
|
2012-12-06 18:59:18 +04:00
|
|
|
static bool mightExpandVariablesCMP0019(const char* s)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return s && *s && strstr(s, "${") && strchr(s, '}');
|
2012-12-06 18:59:18 +04:00
|
|
|
}
|
2000-08-30 21:35:41 +04:00
|
|
|
|
2012-12-06 18:59:18 +04:00
|
|
|
void cmMakefile::ExpandVariablesCMP0019()
|
2001-01-05 19:41:20 +03:00
|
|
|
{
|
2012-12-06 18:59:18 +04:00
|
|
|
// Drop this ancient compatibility behavior with a policy.
|
|
|
|
cmPolicies::PolicyStatus pol = this->GetPolicyStatus(cmPolicies::CMP0019);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pol != cmPolicies::OLD && pol != cmPolicies::WARN) {
|
2012-12-06 18:59:18 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream w;
|
2012-01-24 20:54:46 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
|
|
|
|
if (mightExpandVariablesCMP0019(includeDirs)) {
|
2012-01-24 20:54:46 +04:00
|
|
|
std::string dirs = includeDirs;
|
|
|
|
this->ExpandVariablesInString(dirs, true, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pol == cmPolicies::WARN && dirs != includeDirs) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2012-12-06 18:59:18 +04:00
|
|
|
w << "Evaluated directory INCLUDE_DIRECTORIES\n"
|
|
|
|
<< " " << includeDirs << "\n"
|
|
|
|
<< "as\n"
|
|
|
|
<< " " << dirs << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
|
|
|
|
}
|
2012-01-24 20:54:46 +04:00
|
|
|
|
2012-02-22 16:14:11 +04:00
|
|
|
// Also for each target's INCLUDE_DIRECTORIES property:
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
|
|
|
|
++l) {
|
|
|
|
cmTarget& t = l->second;
|
|
|
|
if (t.GetType() == cmState::INTERFACE_LIBRARY ||
|
|
|
|
t.GetType() == cmState::GLOBAL_TARGET) {
|
2013-11-20 15:44:04 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-23 17:11:09 +04:00
|
|
|
includeDirs = t.GetProperty("INCLUDE_DIRECTORIES");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (mightExpandVariablesCMP0019(includeDirs)) {
|
2012-02-22 16:14:11 +04:00
|
|
|
std::string dirs = includeDirs;
|
|
|
|
this->ExpandVariablesInString(dirs, true, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pol == cmPolicies::WARN && dirs != includeDirs) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2012-12-06 18:59:18 +04:00
|
|
|
w << "Evaluated target " << t.GetName() << " INCLUDE_DIRECTORIES\n"
|
|
|
|
<< " " << includeDirs << "\n"
|
|
|
|
<< "as\n"
|
|
|
|
<< " " << dirs << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2012-02-22 16:14:11 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-22 16:14:11 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
|
|
|
|
if (mightExpandVariablesCMP0019(linkDirsProp)) {
|
2015-07-18 14:52:46 +03:00
|
|
|
std::string d = linkDirsProp;
|
|
|
|
std::string orig = linkDirsProp;
|
|
|
|
this->ExpandVariablesInString(d, true, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pol == cmPolicies::WARN && d != orig) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-07-18 14:52:46 +03:00
|
|
|
w << "Evaluated link directories\n"
|
2012-12-06 18:59:18 +04:00
|
|
|
<< " " << orig << "\n"
|
|
|
|
<< "as\n"
|
2015-07-18 14:52:46 +03:00
|
|
|
<< " " << d << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2012-12-06 18:59:18 +04:00
|
|
|
}
|
2001-02-16 19:34:23 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (cmTarget::LinkLibraryVectorType::iterator l =
|
|
|
|
this->LinkLibraries.begin();
|
|
|
|
l != this->LinkLibraries.end(); ++l) {
|
|
|
|
if (mightExpandVariablesCMP0019(l->first.c_str())) {
|
2012-12-06 18:59:18 +04:00
|
|
|
std::string orig = l->first;
|
|
|
|
this->ExpandVariablesInString(l->first, true, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pol == cmPolicies::WARN && l->first != orig) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2012-12-06 18:59:18 +04:00
|
|
|
w << "Evaluated link library\n"
|
|
|
|
<< " " << orig << "\n"
|
|
|
|
<< "as\n"
|
|
|
|
<< " " << l->first << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2012-12-06 18:59:18 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-12-06 18:59:18 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!w.str().empty()) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream m;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-05-03 11:12:10 +03:00
|
|
|
m << cmPolicies::GetPolicyWarning(cmPolicies::CMP0019)
|
2012-12-06 18:59:18 +04:00
|
|
|
<< "\n"
|
|
|
|
<< "The following variable evaluations were encountered:\n"
|
|
|
|
<< w.str();
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-01-29 00:10:27 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, m.str(),
|
|
|
|
this->Backtrace);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
bool cmMakefile::IsOn(const std::string& name) const
|
2001-08-08 19:54:46 +04:00
|
|
|
{
|
|
|
|
const char* value = this->GetDefinition(name);
|
|
|
|
return cmSystemTools::IsOn(value);
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
bool cmMakefile::IsSet(const std::string& name) const
|
2005-04-02 00:48:46 +04:00
|
|
|
{
|
|
|
|
const char* value = this->GetDefinition(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!value) {
|
2005-04-02 00:48:46 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-04-02 00:48:46 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!*value) {
|
2005-04-02 00:48:46 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-04-02 00:48:46 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsNOTFOUND(value)) {
|
2005-04-02 00:48:46 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-04-02 00:48:46 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-10 17:11:18 +03:00
|
|
|
bool cmMakefile::PlatformIs32Bit() const
|
|
|
|
{
|
|
|
|
if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) {
|
|
|
|
return atoi(sizeof_dptr) == 4;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-09-30 21:45:14 +04:00
|
|
|
bool cmMakefile::PlatformIs64Bit() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) {
|
2009-09-30 21:45:14 +04:00
|
|
|
return atoi(sizeof_dptr) == 8;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-30 21:45:14 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-18 22:30:54 +03:00
|
|
|
bool cmMakefile::PlatformIsAppleIos() const
|
|
|
|
{
|
|
|
|
std::string sdkRoot;
|
|
|
|
sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT");
|
|
|
|
sdkRoot = cmSystemTools::LowerCase(sdkRoot);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string embedded[] = {
|
|
|
|
"appletvos", "appletvsimulator", "iphoneos",
|
|
|
|
"iphonesimulator", "watchos", "watchsimulator",
|
|
|
|
};
|
2015-10-23 23:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < sizeof(embedded) / sizeof(embedded[0]); ++i) {
|
|
|
|
if (sdkRoot.find(embedded[i]) == 0 ||
|
|
|
|
sdkRoot.find(std::string("/") + embedded[i]) != std::string::npos) {
|
2015-10-23 23:19:43 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-23 23:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
return false;
|
2015-08-18 22:30:54 +03:00
|
|
|
}
|
|
|
|
|
2014-02-04 06:20:56 +04:00
|
|
|
const char* cmMakefile::GetSONameFlag(const std::string& language) const
|
2012-04-22 17:42:55 +04:00
|
|
|
{
|
2012-06-20 19:04:35 +04:00
|
|
|
std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!language.empty()) {
|
2012-06-20 19:04:35 +04:00
|
|
|
name += "_";
|
|
|
|
name += language;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-04-22 17:42:55 +04:00
|
|
|
name += "_FLAG";
|
2014-03-11 03:04:11 +04:00
|
|
|
return GetDefinition(name);
|
2012-04-22 17:42:55 +04:00
|
|
|
}
|
|
|
|
|
2014-01-22 18:00:29 +04:00
|
|
|
bool cmMakefile::CanIWriteThisFile(const char* fileName) const
|
2006-03-22 22:40:36 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES")) {
|
2006-03-22 22:45:12 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-01-22 06:44:08 +04:00
|
|
|
// If we are doing an in-source build, then the test will always fail
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::SameFile(this->GetHomeDirectory(),
|
|
|
|
this->GetHomeOutputDirectory())) {
|
2016-06-02 00:29:53 +03:00
|
|
|
return !this->IsOn("CMAKE_DISABLE_IN_SOURCE_BUILD");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-22 22:40:36 +03:00
|
|
|
|
2016-06-02 00:29:53 +03:00
|
|
|
return !cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) ||
|
|
|
|
cmSystemTools::IsSubDirectory(fileName, this->GetHomeOutputDirectory());
|
2006-03-22 22:40:36 +03:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
|
2004-08-06 22:51:41 +04:00
|
|
|
{
|
|
|
|
const char* ret = this->GetDefinition(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ret) {
|
2006-05-12 20:29:09 +04:00
|
|
|
cmSystemTools::Error("Error required internal CMake variable not "
|
|
|
|
"set, cmake may be not be built correctly.\n",
|
2016-05-16 17:34:04 +03:00
|
|
|
"Missing variable is:\n", name.c_str());
|
2004-08-06 22:51:41 +04:00
|
|
|
return "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-08-06 22:51:41 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
bool cmMakefile::IsDefinitionSet(const std::string& name) const
|
2001-01-05 19:41:20 +03:00
|
|
|
{
|
2015-06-21 22:26:43 +03:00
|
|
|
const char* def = this->StateSnapshot.GetDefinition(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!def) {
|
2015-04-06 11:52:45 +03:00
|
|
|
def = this->GetState()->GetInitializedCacheValue(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-05-18 01:40:59 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmVariableWatch* vv = this->GetVariableWatch()) {
|
|
|
|
if (!def) {
|
|
|
|
vv->VariableAccessed(
|
|
|
|
name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS, def, this);
|
2007-05-18 01:40:59 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-05-18 01:40:59 +04:00
|
|
|
#endif
|
2016-06-27 23:44:16 +03:00
|
|
|
return def != CM_NULLPTR;
|
2007-05-17 23:12:13 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
const char* cmMakefile::GetDefinition(const std::string& name) const
|
2007-05-17 23:12:13 +04:00
|
|
|
{
|
2015-06-21 22:26:43 +03:00
|
|
|
const char* def = this->StateSnapshot.GetDefinition(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!def) {
|
2015-04-06 11:52:45 +03:00
|
|
|
def = this->GetState()->GetInitializedCacheValue(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2003-01-08 20:59:52 +03:00
|
|
|
cmVariableWatch* vv = this->GetVariableWatch();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (vv && !this->SuppressWatches) {
|
|
|
|
bool const watch_function_executed = vv->VariableAccessed(
|
|
|
|
name, def ? cmVariableWatch::VARIABLE_READ_ACCESS
|
|
|
|
: cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
|
|
|
|
def, this);
|
2016-03-23 12:37:51 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (watch_function_executed) {
|
2016-03-23 12:37:51 +03:00
|
|
|
// A callback was executed and may have caused re-allocation of the
|
|
|
|
// variable storage. Look it up again for now.
|
|
|
|
// FIXME: Refactor variable storage to avoid this problem.
|
|
|
|
def = this->StateSnapshot.GetDefinition(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!def) {
|
2016-03-23 12:37:51 +03:00
|
|
|
def = this->GetState()->GetInitializedCacheValue(name);
|
2003-01-08 20:59:52 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2003-01-08 20:59:52 +03:00
|
|
|
return def;
|
2001-01-05 19:41:20 +03:00
|
|
|
}
|
2001-01-12 20:43:00 +03:00
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
const char* cmMakefile::GetSafeDefinition(const std::string& def) const
|
2004-04-27 19:30:31 +04:00
|
|
|
{
|
|
|
|
const char* ret = this->GetDefinition(def);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ret) {
|
2004-04-27 19:30:31 +04:00
|
|
|
return "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-27 19:30:31 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-07 16:12:51 +03:00
|
|
|
std::vector<std::string> cmMakefile::GetDefinitions() const
|
2003-03-06 19:19:28 +03:00
|
|
|
{
|
2015-06-21 22:26:43 +03:00
|
|
|
std::vector<std::string> res = this->StateSnapshot.ClosureKeys();
|
2015-06-07 16:12:51 +03:00
|
|
|
std::vector<std::string> cacheKeys = this->GetState()->GetCacheEntryKeys();
|
2015-04-05 11:48:04 +03:00
|
|
|
res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
|
2015-04-06 13:30:21 +03:00
|
|
|
std::sort(res.begin(), res.end());
|
2003-03-06 19:19:28 +03:00
|
|
|
return res;
|
|
|
|
}
|
2001-01-12 20:43:00 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmMakefile::ExpandVariablesInString(std::string& source) const
|
2001-06-22 19:14:32 +04:00
|
|
|
{
|
2005-06-17 23:50:08 +04:00
|
|
|
return this->ExpandVariablesInString(source, false, false);
|
2001-06-22 19:14:32 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmMakefile::ExpandVariablesInString(
|
|
|
|
std::string& source, bool escapeQuotes, bool noEscapes, bool atOnly,
|
|
|
|
const char* filename, long line, bool removeEmpty, bool replaceAt) const
|
2001-02-13 03:49:52 +03:00
|
|
|
{
|
2014-02-08 07:37:54 +04:00
|
|
|
bool compareResults = false;
|
|
|
|
cmake::MessageType mtype = cmake::LOG;
|
|
|
|
std::string errorstr;
|
|
|
|
std::string original;
|
|
|
|
|
|
|
|
// Sanity check the @ONLY mode.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (atOnly && (!noEscapes || !removeEmpty)) {
|
2014-02-08 07:37:54 +04:00
|
|
|
// This case should never be called. At-only is for
|
|
|
|
// configure-file/string which always does no escapes.
|
|
|
|
this->IssueMessage(cmake::INTERNAL_ERROR,
|
|
|
|
"ExpandVariablesInString @ONLY called "
|
|
|
|
"on something with escapes.");
|
2005-06-13 19:00:29 +04:00
|
|
|
return source.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-07 00:20:02 +04:00
|
|
|
|
2014-02-08 07:37:54 +04:00
|
|
|
// Variables used in the WARN case.
|
|
|
|
std::string newResult;
|
|
|
|
std::string newErrorstr;
|
|
|
|
cmake::MessageType newError = cmake::LOG;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0053)) {
|
|
|
|
case cmPolicies::WARN: {
|
2014-02-08 07:37:54 +04:00
|
|
|
// Save the original string for the warning.
|
|
|
|
original = source;
|
|
|
|
newResult = source;
|
|
|
|
compareResults = true;
|
2014-05-21 01:00:28 +04:00
|
|
|
// Suppress variable watches to avoid calling hooks twice. Suppress new
|
|
|
|
// dereferences since the OLD behavior is still what is actually used.
|
|
|
|
this->SuppressWatches = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
newError = ExpandVariablesInStringNew(
|
|
|
|
newErrorstr, newResult, escapeQuotes, noEscapes, atOnly, filename,
|
|
|
|
line, removeEmpty, replaceAt);
|
2014-05-21 01:00:28 +04:00
|
|
|
this->SuppressWatches = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
case cmPolicies::OLD:
|
2016-05-16 17:34:04 +03:00
|
|
|
mtype =
|
|
|
|
ExpandVariablesInStringOld(errorstr, source, escapeQuotes, noEscapes,
|
|
|
|
atOnly, filename, line, removeEmpty, true);
|
2014-02-08 07:37:54 +04:00
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
2016-05-16 17:34:04 +03:00
|
|
|
// Messaging here would be *very* verbose.
|
2014-02-08 07:37:54 +04:00
|
|
|
case cmPolicies::NEW:
|
|
|
|
mtype = ExpandVariablesInStringNew(errorstr, source, escapeQuotes,
|
2016-05-16 17:34:04 +03:00
|
|
|
noEscapes, atOnly, filename, line,
|
|
|
|
removeEmpty, replaceAt);
|
2014-02-08 07:37:54 +04:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
|
|
|
|
// If it's an error in either case, just report the error...
|
2016-05-16 17:34:04 +03:00
|
|
|
if (mtype != cmake::LOG) {
|
|
|
|
if (mtype == cmake::FATAL_ERROR) {
|
2014-02-08 07:37:54 +04:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->IssueMessage(mtype, errorstr);
|
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
// ...otherwise, see if there's a difference that needs to be warned about.
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (compareResults && (newResult != source || newError != mtype)) {
|
|
|
|
std::string msg = cmPolicies::GetPolicyWarning(cmPolicies::CMP0053);
|
2014-02-08 07:37:54 +04:00
|
|
|
msg += "\n";
|
|
|
|
|
|
|
|
std::string msg_input = original;
|
|
|
|
cmSystemTools::ReplaceString(msg_input, "\n", "\n ");
|
|
|
|
msg += "For input:\n '";
|
|
|
|
msg += msg_input;
|
|
|
|
msg += "'\n";
|
|
|
|
|
|
|
|
std::string msg_old = source;
|
|
|
|
cmSystemTools::ReplaceString(msg_old, "\n", "\n ");
|
|
|
|
msg += "the old evaluation rules produce:\n '";
|
|
|
|
msg += msg_old;
|
|
|
|
msg += "'\n";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (newError == mtype) {
|
2014-02-08 07:37:54 +04:00
|
|
|
std::string msg_new = newResult;
|
|
|
|
cmSystemTools::ReplaceString(msg_new, "\n", "\n ");
|
|
|
|
msg += "but the new evaluation rules produce:\n '";
|
|
|
|
msg += msg_new;
|
|
|
|
msg += "'\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-08 07:37:54 +04:00
|
|
|
std::string msg_err = newErrorstr;
|
|
|
|
cmSystemTools::ReplaceString(msg_err, "\n", "\n ");
|
|
|
|
msg += "but the new evaluation rules produce an error:\n ";
|
|
|
|
msg += msg_err;
|
|
|
|
msg += "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-07 00:20:02 +04:00
|
|
|
|
2014-02-08 07:37:54 +04:00
|
|
|
msg +=
|
|
|
|
"Using the old result for compatibility since the policy is not set.";
|
|
|
|
|
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, msg);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
|
|
|
|
return source.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string& errorstr, std::string& source, bool escapeQuotes,
|
|
|
|
bool noEscapes, bool atOnly, const char* filename, long line,
|
|
|
|
bool removeEmpty, bool replaceAt) const
|
2014-02-08 07:37:54 +04:00
|
|
|
{
|
|
|
|
// Fast path strings without any special characters.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (source.find_first_of("$@\\") == source.npos) {
|
2014-02-08 07:37:54 +04:00
|
|
|
return cmake::LOG;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
|
|
|
|
// Special-case the @ONLY mode.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (atOnly) {
|
2007-06-07 00:20:02 +04:00
|
|
|
// Store an original copy of the input.
|
|
|
|
std::string input = source;
|
|
|
|
|
|
|
|
// Start with empty output.
|
|
|
|
source = "";
|
|
|
|
|
|
|
|
// Look for one @VAR@ at a time.
|
|
|
|
const char* in = input.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
while (this->cmAtVarRegex.find(in)) {
|
2007-06-07 00:20:02 +04:00
|
|
|
// Get the range of the string to replace.
|
|
|
|
const char* first = in + this->cmAtVarRegex.start();
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* last = in + this->cmAtVarRegex.end();
|
2007-06-07 00:20:02 +04:00
|
|
|
|
|
|
|
// Store the unchanged part of the string now.
|
2016-05-16 17:34:04 +03:00
|
|
|
source.append(in, first - in);
|
2007-06-07 00:20:02 +04:00
|
|
|
|
|
|
|
// Lookup the definition of VAR.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string var(first + 1, last - first - 2);
|
|
|
|
if (const char* val = this->GetDefinition(var)) {
|
2007-06-07 00:20:02 +04:00
|
|
|
// Store the value in the output escaping as requested.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (escapeQuotes) {
|
2007-06-07 00:20:02 +04:00
|
|
|
source.append(cmSystemTools::EscapeQuotes(val));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-06-07 00:20:02 +04:00
|
|
|
source.append(val);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-07 00:20:02 +04:00
|
|
|
|
|
|
|
// Continue looking for @VAR@ further along the string.
|
|
|
|
in = last;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-07 00:20:02 +04:00
|
|
|
|
|
|
|
// Append the rest of the unchanged part of the string.
|
|
|
|
source.append(in);
|
|
|
|
|
2014-02-08 07:37:54 +04:00
|
|
|
return cmake::LOG;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-07 00:20:02 +04:00
|
|
|
|
2001-07-28 00:29:50 +04:00
|
|
|
// This method replaces ${VAR} and @VAR@ where VAR is looked up
|
2002-01-22 18:17:37 +03:00
|
|
|
// with GetDefinition(), if not found in the map, nothing is expanded.
|
2001-08-18 20:52:19 +04:00
|
|
|
// It also supports the $ENV{VAR} syntax where VAR is looked up in
|
|
|
|
// the current environment variables.
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2007-02-09 21:44:37 +03:00
|
|
|
cmCommandArgumentParserHelper parser;
|
|
|
|
parser.SetMakefile(this);
|
|
|
|
parser.SetLineFile(line, filename);
|
|
|
|
parser.SetEscapeQuotes(escapeQuotes);
|
|
|
|
parser.SetNoEscapeMode(noEscapes);
|
|
|
|
parser.SetReplaceAtSyntax(replaceAt);
|
|
|
|
parser.SetRemoveEmpty(removeEmpty);
|
|
|
|
int res = parser.ParseString(source.c_str(), 0);
|
2008-09-24 16:51:19 +04:00
|
|
|
const char* emsg = parser.GetError();
|
2014-02-08 07:37:54 +04:00
|
|
|
cmake::MessageType mtype = cmake::LOG;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res && !emsg[0]) {
|
2007-02-09 21:44:37 +03:00
|
|
|
source = parser.GetResult();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-09-24 16:51:19 +04:00
|
|
|
// Construct the main error message.
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream error;
|
2008-09-24 16:51:19 +04:00
|
|
|
error << "Syntax error in cmake code ";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (filename && line > 0) {
|
2008-09-24 16:51:19 +04:00
|
|
|
// This filename and line number may be more specific than the
|
|
|
|
// command context because one command invocation can have
|
|
|
|
// arguments on multiple lines.
|
|
|
|
error << "at\n"
|
|
|
|
<< " " << filename << ":" << line << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-09-24 16:51:19 +04:00
|
|
|
error << "when parsing string\n"
|
2014-03-11 16:35:32 +04:00
|
|
|
<< " " << source << "\n";
|
2008-09-24 16:51:19 +04:00
|
|
|
error << emsg;
|
|
|
|
|
|
|
|
// If the parser failed ("res" is false) then this is a real
|
|
|
|
// argument parsing error, so the policy applies. Otherwise the
|
|
|
|
// parser reported an error message without failing because the
|
|
|
|
// helper implementation is unhappy, which has always reported an
|
|
|
|
// error.
|
2014-02-08 07:37:54 +04:00
|
|
|
mtype = cmake::FATAL_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!res) {
|
2008-09-24 16:51:19 +04:00
|
|
|
// This is a real argument parsing error. Use policy CMP0010 to
|
|
|
|
// decide whether it is an error.
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0010)) {
|
2008-09-24 16:51:19 +04:00
|
|
|
case cmPolicies::WARN:
|
2015-05-03 11:12:10 +03:00
|
|
|
error << "\n" << cmPolicies::GetPolicyWarning(cmPolicies::CMP0010);
|
2008-09-24 16:51:19 +04:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior is to just warn and continue.
|
|
|
|
mtype = cmake::AUTHOR_WARNING;
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
error << "\n"
|
2015-05-03 11:12:10 +03:00
|
|
|
<< cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0010);
|
2008-09-24 16:51:19 +04:00
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior is to report the error.
|
|
|
|
break;
|
2001-07-28 00:29:50 +04:00
|
|
|
}
|
2001-09-02 00:12:52 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
errorstr = error.str();
|
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
return mtype;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
typedef enum { NORMAL, ENVIRONMENT, CACHE } t_domain;
|
2014-02-08 07:37:54 +04:00
|
|
|
struct t_lookup
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
t_lookup()
|
|
|
|
: domain(NORMAL)
|
|
|
|
, loc(0)
|
2014-02-08 07:37:54 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
t_domain domain;
|
|
|
|
size_t loc;
|
2016-05-16 17:34:04 +03:00
|
|
|
};
|
2014-02-08 07:37:54 +04:00
|
|
|
|
|
|
|
cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string& errorstr, std::string& source, bool escapeQuotes,
|
|
|
|
bool noEscapes, bool atOnly, const char* filename, long line,
|
|
|
|
bool removeEmpty, bool replaceAt) const
|
2014-02-08 07:37:54 +04:00
|
|
|
{
|
|
|
|
// This method replaces ${VAR} and @VAR@ where VAR is looked up
|
|
|
|
// with GetDefinition(), if not found in the map, nothing is expanded.
|
|
|
|
// It also supports the $ENV{VAR} syntax where VAR is looked up in
|
|
|
|
// the current environment variables.
|
|
|
|
|
|
|
|
const char* in = source.c_str();
|
|
|
|
const char* last = in;
|
|
|
|
std::string result;
|
|
|
|
result.reserve(source.size());
|
2016-01-15 16:37:25 +03:00
|
|
|
std::vector<t_lookup> openstack;
|
2014-02-08 07:37:54 +04:00
|
|
|
bool error = false;
|
|
|
|
bool done = false;
|
|
|
|
cmake::MessageType mtype = cmake::LOG;
|
|
|
|
|
2015-04-06 11:52:45 +03:00
|
|
|
cmState* state = this->GetCMakeInstance()->GetState();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
do {
|
2014-02-08 07:37:54 +04:00
|
|
|
char inc = *in;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (inc) {
|
2014-02-08 07:37:54 +04:00
|
|
|
case '}':
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!openstack.empty()) {
|
2016-01-15 16:37:25 +03:00
|
|
|
t_lookup var = openstack.back();
|
|
|
|
openstack.pop_back();
|
2014-02-08 07:37:54 +04:00
|
|
|
result.append(last, in - last);
|
|
|
|
std::string const& lookup = result.substr(var.loc);
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* value = CM_NULLPTR;
|
2014-02-08 07:37:54 +04:00
|
|
|
std::string varresult;
|
2016-07-08 00:54:05 +03:00
|
|
|
std::string svalue;
|
2014-02-08 07:37:54 +04:00
|
|
|
static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (var.domain) {
|
2014-02-08 07:37:54 +04:00
|
|
|
case NORMAL:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (filename && lookup == lineVar) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream ostr;
|
2014-02-08 07:37:54 +04:00
|
|
|
ostr << line;
|
|
|
|
varresult = ostr.str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-08 07:37:54 +04:00
|
|
|
value = this->GetDefinition(lookup);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
break;
|
|
|
|
case ENVIRONMENT:
|
2016-07-08 00:54:05 +03:00
|
|
|
if (cmSystemTools::GetEnv(lookup, svalue)) {
|
|
|
|
value = svalue.c_str();
|
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
break;
|
|
|
|
case CACHE:
|
2015-04-06 11:52:45 +03:00
|
|
|
value = state->GetCacheEntryValue(lookup);
|
2014-02-08 07:37:54 +04:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
// Get the string we're meant to append to.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (value) {
|
|
|
|
if (escapeQuotes) {
|
2014-02-08 07:37:54 +04:00
|
|
|
varresult = cmSystemTools::EscapeQuotes(value);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-08 07:37:54 +04:00
|
|
|
varresult = value;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (!removeEmpty) {
|
2014-02-08 07:37:54 +04:00
|
|
|
// check to see if we need to print a warning
|
|
|
|
// if strict mode is on and the variable has
|
|
|
|
// not been "cleared"/initialized with a set(foo ) call
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetCMakeInstance()->GetWarnUninitialized() &&
|
|
|
|
!this->VariableInitialized(lookup)) {
|
2014-02-08 07:37:54 +04:00
|
|
|
if (this->CheckSystemVars ||
|
|
|
|
cmSystemTools::IsSubDirectory(filename,
|
|
|
|
this->GetHomeDirectory()) ||
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::IsSubDirectory(
|
|
|
|
filename, this->GetHomeOutputDirectory())) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2014-02-08 07:37:54 +04:00
|
|
|
msg << "uninitialized variable \'" << lookup << "\'";
|
2016-04-15 17:13:12 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
|
2014-02-08 07:37:54 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
result.replace(var.loc, result.size() - var.loc, varresult);
|
|
|
|
// Start looking from here on out.
|
|
|
|
last = in + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
break;
|
|
|
|
case '$':
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!atOnly) {
|
2014-02-08 07:37:54 +04:00
|
|
|
t_lookup lookup;
|
|
|
|
const char* next = in + 1;
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* start = CM_NULLPTR;
|
2014-02-08 07:37:54 +04:00
|
|
|
char nextc = *next;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nextc == '{') {
|
2014-02-08 07:37:54 +04:00
|
|
|
// Looking for a variable.
|
|
|
|
start = in + 2;
|
|
|
|
lookup.domain = NORMAL;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (nextc == '<') {
|
|
|
|
} else if (!nextc) {
|
2014-02-08 07:37:54 +04:00
|
|
|
result.append(last, next - last);
|
|
|
|
last = next;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cmHasLiteralPrefix(next, "ENV{")) {
|
2014-02-08 07:37:54 +04:00
|
|
|
// Looking for an environment variable.
|
|
|
|
start = in + 5;
|
|
|
|
lookup.domain = ENVIRONMENT;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cmHasLiteralPrefix(next, "CACHE{")) {
|
2014-02-08 07:37:54 +04:00
|
|
|
// Looking for a cache variable.
|
|
|
|
start = in + 7;
|
|
|
|
lookup.domain = CACHE;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (this->cmNamedCurly.find(next)) {
|
|
|
|
errorstr = "Syntax $" +
|
|
|
|
std::string(next, this->cmNamedCurly.end()) +
|
|
|
|
"{} is not supported. Only ${}, $ENV{}, "
|
|
|
|
"and $CACHE{} are allowed.";
|
2014-02-08 07:37:54 +04:00
|
|
|
mtype = cmake::FATAL_ERROR;
|
|
|
|
error = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (start) {
|
2014-02-08 07:37:54 +04:00
|
|
|
result.append(last, in - last);
|
|
|
|
last = start;
|
|
|
|
in = start - 1;
|
|
|
|
lookup.loc = result.size();
|
2016-01-15 16:37:25 +03:00
|
|
|
openstack.push_back(lookup);
|
2014-02-08 07:37:54 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
break;
|
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
case '\\':
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!noEscapes) {
|
2014-02-08 07:37:54 +04:00
|
|
|
const char* next = in + 1;
|
|
|
|
char nextc = *next;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nextc == 't') {
|
2014-02-08 07:37:54 +04:00
|
|
|
result.append(last, in - last);
|
|
|
|
result.append("\t");
|
|
|
|
last = next + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (nextc == 'n') {
|
2014-02-08 07:37:54 +04:00
|
|
|
result.append(last, in - last);
|
|
|
|
result.append("\n");
|
|
|
|
last = next + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (nextc == 'r') {
|
2014-02-08 07:37:54 +04:00
|
|
|
result.append(last, in - last);
|
|
|
|
result.append("\r");
|
|
|
|
last = next + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (nextc == ';' && openstack.empty()) {
|
2014-02-08 07:37:54 +04:00
|
|
|
// Handled in ExpandListArgument; pass the backslash literally.
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (isalnum(nextc) || nextc == '\0') {
|
2014-02-08 07:37:54 +04:00
|
|
|
errorstr += "Invalid character escape '\\";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nextc) {
|
2014-02-08 07:37:54 +04:00
|
|
|
errorstr += nextc;
|
|
|
|
errorstr += "'.";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-08 07:37:54 +04:00
|
|
|
errorstr += "' (at end of input).";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
error = true;
|
|
|
|
} else {
|
2014-02-08 07:37:54 +04:00
|
|
|
// Take what we've found so far, skipping the escape character.
|
|
|
|
result.append(last, in - last);
|
|
|
|
// Start tracking from the next character.
|
|
|
|
last = in + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
// Skip the next character since it was escaped, but don't read past
|
|
|
|
// the end of the string.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (*last) {
|
2014-02-08 07:37:54 +04:00
|
|
|
++in;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
break;
|
|
|
|
case '\n':
|
|
|
|
// Onto the next line.
|
|
|
|
++line;
|
|
|
|
break;
|
|
|
|
case '\0':
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
case '@':
|
2016-05-16 17:34:04 +03:00
|
|
|
if (replaceAt) {
|
2014-02-08 07:37:54 +04:00
|
|
|
const char* nextAt = strchr(in + 1, '@');
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nextAt && nextAt != in + 1 &&
|
|
|
|
nextAt ==
|
|
|
|
in + 1 + strspn(in + 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
|
|
"abcdefghijklmnopqrstuvwxyz"
|
|
|
|
"0123456789/_.+-")) {
|
2014-02-08 07:37:54 +04:00
|
|
|
std::string variable(in + 1, nextAt - in - 1);
|
|
|
|
std::string varresult = this->GetSafeDefinition(variable);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (escapeQuotes) {
|
2014-02-08 07:37:54 +04:00
|
|
|
varresult = cmSystemTools::EscapeQuotes(varresult);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
// Skip over the variable.
|
|
|
|
result.append(last, in - last);
|
|
|
|
result.append(varresult);
|
|
|
|
in = nextAt;
|
|
|
|
last = in + 1;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
// Failed to find a valid @ expansion; treat it as literal.
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default: {
|
|
|
|
if (!openstack.empty() &&
|
|
|
|
!(isalnum(inc) || inc == '_' || inc == '/' || inc == '.' ||
|
|
|
|
inc == '+' || inc == '-')) {
|
2014-02-08 07:37:54 +04:00
|
|
|
errorstr += "Invalid character (\'";
|
|
|
|
errorstr += inc;
|
|
|
|
result.append(last, in - last);
|
|
|
|
errorstr += "\') in a variable name: "
|
2016-05-16 17:34:04 +03:00
|
|
|
"'" +
|
|
|
|
result.substr(openstack.back().loc) + "'";
|
2014-02-08 07:37:54 +04:00
|
|
|
mtype = cmake::FATAL_ERROR;
|
|
|
|
error = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
break;
|
2014-02-08 07:37:54 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
// Look at the next character.
|
2016-05-16 17:34:04 +03:00
|
|
|
} while (!error && !done && *++in);
|
2014-02-08 07:37:54 +04:00
|
|
|
|
|
|
|
// Check for open variable references yet.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!error && !openstack.empty()) {
|
2014-02-08 07:37:54 +04:00
|
|
|
// There's an open variable reference waiting. Policy CMP0010 flags
|
|
|
|
// whether this is an error or not. The new parser now enforces
|
|
|
|
// CMP0010 as well.
|
|
|
|
errorstr += "There is an unterminated variable reference.";
|
|
|
|
error = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (error) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream emsg;
|
2014-02-08 07:37:54 +04:00
|
|
|
emsg << "Syntax error in cmake code ";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (filename) {
|
2014-02-08 07:37:54 +04:00
|
|
|
// This filename and line number may be more specific than the
|
|
|
|
// command context because one command invocation can have
|
|
|
|
// arguments on multiple lines.
|
|
|
|
emsg << "at\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< " " << filename << ":" << line << "\n";
|
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
emsg << "when parsing string\n"
|
|
|
|
<< " " << source << "\n";
|
|
|
|
emsg << errorstr;
|
|
|
|
mtype = cmake::FATAL_ERROR;
|
|
|
|
errorstr = emsg.str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-08 07:37:54 +04:00
|
|
|
// Append the rest of the unchanged part of the string.
|
|
|
|
result.append(last);
|
|
|
|
|
|
|
|
source = result;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-08 07:37:54 +04:00
|
|
|
|
|
|
|
return mtype;
|
2001-02-13 03:49:52 +03:00
|
|
|
}
|
|
|
|
|
2001-10-30 22:05:07 +03:00
|
|
|
void cmMakefile::RemoveVariablesInString(std::string& source,
|
|
|
|
bool atOnly) const
|
2001-04-30 18:44:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!atOnly) {
|
2003-06-23 22:10:12 +04:00
|
|
|
cmsys::RegularExpression var("(\\${[A-Za-z_0-9]*})");
|
2016-05-16 17:34:04 +03:00
|
|
|
while (var.find(source)) {
|
|
|
|
source.erase(var.start(), var.end() - var.start());
|
2001-04-30 18:44:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!atOnly) {
|
2003-06-23 22:10:12 +04:00
|
|
|
cmsys::RegularExpression varb("(\\$ENV{[A-Za-z_0-9]*})");
|
2016-05-16 17:34:04 +03:00
|
|
|
while (varb.find(source)) {
|
|
|
|
source.erase(varb.start(), varb.end() - varb.start());
|
2001-08-18 20:52:19 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-06-23 22:10:12 +04:00
|
|
|
cmsys::RegularExpression var2("(@[A-Za-z_0-9]*@)");
|
2016-05-16 17:34:04 +03:00
|
|
|
while (var2.find(source)) {
|
|
|
|
source.erase(var2.start(), var2.end() - var2.start());
|
|
|
|
}
|
2001-04-30 18:44:00 +04:00
|
|
|
}
|
2001-02-23 03:24:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
|
|
|
|
bool singleConfig) const
|
2010-09-08 22:54:49 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetGlobalGenerator()->IsMultiConfig()) {
|
|
|
|
if (const char* configTypes =
|
|
|
|
this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
|
2010-09-08 22:54:49 +04:00
|
|
|
cmSystemTools::ExpandListArgument(configTypes, configs);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return "";
|
|
|
|
}
|
2016-08-18 21:36:29 +03:00
|
|
|
const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
|
|
|
if (singleConfig && !buildType.empty()) {
|
|
|
|
configs.push_back(buildType);
|
|
|
|
}
|
|
|
|
return buildType;
|
2010-09-08 22:54:49 +04:00
|
|
|
}
|
|
|
|
|
2006-03-22 17:58:11 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2001-03-20 21:20:59 +03:00
|
|
|
/**
|
|
|
|
* Find a source group whose regular expression matches the filename
|
|
|
|
* part of the given source name. Search backward through the list of
|
|
|
|
* source groups, and take the first matching group found. This way
|
|
|
|
* non-inherited SOURCE_GROUP commands will have precedence over
|
|
|
|
* inherited ones.
|
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSourceGroup* cmMakefile::FindSourceGroup(
|
|
|
|
const char* source, std::vector<cmSourceGroup>& groups) const
|
2001-03-20 21:20:59 +03:00
|
|
|
{
|
2003-07-23 23:32:54 +04:00
|
|
|
// First search for a group that lists the file explicitly.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
|
|
|
|
sg != groups.rend(); ++sg) {
|
|
|
|
cmSourceGroup* result = sg->MatchChildrenFiles(source);
|
|
|
|
if (result) {
|
2014-01-21 19:43:47 +04:00
|
|
|
return result;
|
2001-03-20 21:20:59 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2003-07-23 23:32:54 +04:00
|
|
|
// Now search for a group whose regex matches the file.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
|
|
|
|
sg != groups.rend(); ++sg) {
|
|
|
|
cmSourceGroup* result = sg->MatchChildrenRegex(source);
|
|
|
|
if (result) {
|
2014-01-21 19:43:47 +04:00
|
|
|
return result;
|
2001-03-20 21:20:59 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2001-03-20 21:20:59 +03:00
|
|
|
// Shouldn't get here, but just in case, return the default group.
|
2014-01-21 19:43:47 +04:00
|
|
|
return &groups.front();
|
2001-03-20 21:20:59 +03:00
|
|
|
}
|
2006-03-22 17:58:11 +03:00
|
|
|
#endif
|
2001-04-11 22:59:02 +04:00
|
|
|
|
2008-01-23 18:28:26 +03:00
|
|
|
bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExecutionStatus& status)
|
2001-04-20 01:39:03 +04:00
|
|
|
{
|
2002-06-28 05:17:25 +04:00
|
|
|
// if there are no blockers get out of here
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FunctionBlockers.begin() == this->FunctionBlockers.end()) {
|
2002-06-28 05:17:25 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-06-28 05:17:25 +04:00
|
|
|
|
2001-04-20 01:39:03 +04:00
|
|
|
// loop over all function blockers to see if any block this command
|
2002-08-09 20:00:49 +04:00
|
|
|
// evaluate in reverse, this is critical for balanced IF statements etc
|
2009-01-21 17:48:00 +03:00
|
|
|
std::vector<cmFunctionBlocker*>::reverse_iterator pos;
|
2007-06-08 19:57:16 +04:00
|
|
|
for (pos = this->FunctionBlockers.rbegin();
|
2016-05-16 17:34:04 +03:00
|
|
|
pos != this->FunctionBlockers.rend(); ++pos) {
|
|
|
|
if ((*pos)->IsFunctionBlocked(lff, *this, status)) {
|
2002-12-12 02:13:33 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2002-12-12 02:13:33 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-21 17:48:00 +03:00
|
|
|
void cmMakefile::PushFunctionBlockerBarrier()
|
|
|
|
{
|
|
|
|
this->FunctionBlockerBarriers.push_back(this->FunctionBlockers.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
|
|
|
|
{
|
|
|
|
// Remove any extra entries pushed on the barrier.
|
|
|
|
FunctionBlockersType::size_type barrier =
|
|
|
|
this->FunctionBlockerBarriers.back();
|
2016-05-16 17:34:04 +03:00
|
|
|
while (this->FunctionBlockers.size() > barrier) {
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmFunctionBlocker> fb(this->FunctionBlockers.back());
|
2009-01-21 17:48:00 +03:00
|
|
|
this->FunctionBlockers.pop_back();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (reportError) {
|
2009-01-21 17:48:20 +03:00
|
|
|
// Report the context in which the unclosed block was opened.
|
|
|
|
cmListFileContext const& lfc = fb->GetStartingContext();
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2009-01-21 17:48:20 +03:00
|
|
|
e << "A logical block opening on the line\n"
|
|
|
|
<< " " << lfc << "\n"
|
|
|
|
<< "is not closed.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-01-21 17:48:20 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
reportError = false;
|
2009-01-21 17:48:00 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-21 17:48:00 +03:00
|
|
|
|
|
|
|
// Remove the barrier.
|
|
|
|
this->FunctionBlockerBarriers.pop_back();
|
|
|
|
}
|
|
|
|
|
2014-11-18 18:34:30 +03:00
|
|
|
void cmMakefile::PushLoopBlock()
|
|
|
|
{
|
|
|
|
assert(!this->LoopBlockCounter.empty());
|
|
|
|
this->LoopBlockCounter.top()++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PopLoopBlock()
|
|
|
|
{
|
|
|
|
assert(!this->LoopBlockCounter.empty());
|
|
|
|
assert(this->LoopBlockCounter.top() > 0);
|
|
|
|
this->LoopBlockCounter.top()--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PushLoopBlockBarrier()
|
|
|
|
{
|
|
|
|
this->LoopBlockCounter.push(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PopLoopBlockBarrier()
|
|
|
|
{
|
|
|
|
assert(!this->LoopBlockCounter.empty());
|
|
|
|
assert(this->LoopBlockCounter.top() == 0);
|
|
|
|
this->LoopBlockCounter.pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmMakefile::IsLoopBlock() const
|
|
|
|
{
|
|
|
|
assert(!this->LoopBlockCounter.empty());
|
|
|
|
return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0;
|
|
|
|
}
|
|
|
|
|
2015-05-23 21:32:05 +03:00
|
|
|
std::string cmMakefile::GetExecutionFilePath() const
|
|
|
|
{
|
2015-07-04 13:20:47 +03:00
|
|
|
assert(this->StateSnapshot.IsValid());
|
|
|
|
return this->StateSnapshot.GetExecutionListFile();
|
2015-05-23 21:32:05 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
|
|
|
|
std::vector<std::string>& outArgs,
|
|
|
|
const char* filename) const
|
2002-12-12 02:13:33 +03:00
|
|
|
{
|
2015-05-23 21:32:05 +03:00
|
|
|
std::string efp = this->GetExecutionFilePath();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!filename) {
|
2015-05-23 21:32:05 +03:00
|
|
|
filename = efp.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-12-12 02:13:33 +03:00
|
|
|
std::vector<cmListFileArgument>::const_iterator i;
|
2003-06-24 23:23:34 +04:00
|
|
|
std::string value;
|
|
|
|
outArgs.reserve(inArgs.size());
|
2016-05-16 17:34:04 +03:00
|
|
|
for (i = inArgs.begin(); i != inArgs.end(); ++i) {
|
2013-08-06 23:58:22 +04:00
|
|
|
// No expansion in a bracket argument.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i->Delim == cmListFileArgument::Bracket) {
|
2013-08-06 23:58:22 +04:00
|
|
|
outArgs.push_back(i->Value);
|
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-12-12 02:13:33 +03:00
|
|
|
// Expand the variables in the argument.
|
2003-06-24 23:23:34 +04:00
|
|
|
value = i->Value;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExpandVariablesInString(value, false, false, false, filename,
|
|
|
|
i->Line, false, false);
|
2004-08-04 18:45:11 +04:00
|
|
|
|
2002-12-12 02:13:33 +03:00
|
|
|
// If the argument is quoted, it should be one argument.
|
|
|
|
// Otherwise, it may be a list of arguments.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i->Delim == cmListFileArgument::Quoted) {
|
2002-12-12 02:13:33 +03:00
|
|
|
outArgs.push_back(value);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2002-12-12 02:13:33 +03:00
|
|
|
cmSystemTools::ExpandListArgument(value, outArgs);
|
2001-04-20 01:39:03 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-09-24 16:51:33 +04:00
|
|
|
return !cmSystemTools::GetFatalErrorOccured();
|
2001-04-20 01:39:03 +04:00
|
|
|
}
|
|
|
|
|
2014-09-04 22:21:28 +04:00
|
|
|
bool cmMakefile::ExpandArguments(
|
|
|
|
std::vector<cmListFileArgument> const& inArgs,
|
2015-05-23 21:32:05 +03:00
|
|
|
std::vector<cmExpandedCommandArgument>& outArgs, const char* filename) const
|
2014-09-04 22:21:28 +04:00
|
|
|
{
|
2015-05-23 21:32:05 +03:00
|
|
|
std::string efp = this->GetExecutionFilePath();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!filename) {
|
2015-05-23 21:32:05 +03:00
|
|
|
filename = efp.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-09-04 22:21:28 +04:00
|
|
|
std::vector<cmListFileArgument>::const_iterator i;
|
|
|
|
std::string value;
|
|
|
|
outArgs.reserve(inArgs.size());
|
2016-05-16 17:34:04 +03:00
|
|
|
for (i = inArgs.begin(); i != inArgs.end(); ++i) {
|
2014-09-04 22:21:28 +04:00
|
|
|
// No expansion in a bracket argument.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i->Delim == cmListFileArgument::Bracket) {
|
2014-09-04 22:21:28 +04:00
|
|
|
outArgs.push_back(cmExpandedCommandArgument(i->Value, true));
|
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-09-04 22:21:28 +04:00
|
|
|
// Expand the variables in the argument.
|
|
|
|
value = i->Value;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExpandVariablesInString(value, false, false, false, filename,
|
|
|
|
i->Line, false, false);
|
2014-09-04 22:21:28 +04:00
|
|
|
|
|
|
|
// If the argument is quoted, it should be one argument.
|
|
|
|
// Otherwise, it may be a list of arguments.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i->Delim == cmListFileArgument::Quoted) {
|
2014-09-04 22:21:28 +04:00
|
|
|
outArgs.push_back(cmExpandedCommandArgument(value, true));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-09-04 22:21:28 +04:00
|
|
|
std::vector<std::string> stringArgs;
|
|
|
|
cmSystemTools::ExpandListArgument(value, stringArgs);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t j = 0; j < stringArgs.size(); ++j) {
|
2014-09-04 22:21:28 +04:00
|
|
|
outArgs.push_back(cmExpandedCommandArgument(stringArgs[j], false));
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-09-04 22:21:28 +04:00
|
|
|
return !cmSystemTools::GetFatalErrorOccured();
|
|
|
|
}
|
|
|
|
|
2009-01-21 17:48:20 +03:00
|
|
|
void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->ExecutionStatusStack.empty()) {
|
2009-01-21 17:48:20 +03:00
|
|
|
// Record the context in which the blocker is created.
|
2015-05-18 22:35:29 +03:00
|
|
|
fb->SetStartingContext(this->GetExecutionContext());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-21 17:48:20 +03:00
|
|
|
|
|
|
|
this->FunctionBlockers.push_back(fb);
|
|
|
|
}
|
|
|
|
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFunctionBlocker* fb, const cmListFileFunction& lff)
|
2001-04-20 01:39:03 +04:00
|
|
|
{
|
2009-01-21 17:48:00 +03:00
|
|
|
// Find the function blocker stack barrier for the current scope.
|
|
|
|
// We only remove a blocker whose index is not less than the barrier.
|
|
|
|
FunctionBlockersType::size_type barrier = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->FunctionBlockerBarriers.empty()) {
|
2009-01-21 17:48:00 +03:00
|
|
|
barrier = this->FunctionBlockerBarriers.back();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-21 17:48:00 +03:00
|
|
|
|
|
|
|
// Search for the function blocker whose scope this command ends.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (FunctionBlockersType::size_type i = this->FunctionBlockers.size();
|
|
|
|
i > barrier; --i) {
|
2009-01-21 17:48:00 +03:00
|
|
|
std::vector<cmFunctionBlocker*>::iterator pos =
|
|
|
|
this->FunctionBlockers.begin() + (i - 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (*pos == fb) {
|
2009-01-21 17:49:00 +03:00
|
|
|
// Warn if the arguments do not match, but always remove.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!(*pos)->ShouldRemove(lff, *this)) {
|
2009-01-21 17:49:00 +03:00
|
|
|
cmListFileContext const& lfc = fb->GetStartingContext();
|
2015-07-04 14:12:50 +03:00
|
|
|
cmListFileContext closingContext =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmListFileContext::FromCommandContext(lff, lfc.FilePath);
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2009-01-21 17:49:00 +03:00
|
|
|
e << "A logical block opening on the line\n"
|
|
|
|
<< " " << lfc << "\n"
|
|
|
|
<< "closes on the line\n"
|
2015-07-04 14:12:50 +03:00
|
|
|
<< " " << closingContext << "\n"
|
2009-01-21 17:49:00 +03:00
|
|
|
<< "with mis-matching arguments.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-01-21 17:49:00 +03:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-06-04 18:18:03 +04:00
|
|
|
cmFunctionBlocker* b = *pos;
|
2009-01-21 17:48:00 +03:00
|
|
|
this->FunctionBlockers.erase(pos);
|
2016-06-28 17:17:52 +03:00
|
|
|
return CM_AUTO_PTR<cmFunctionBlocker>(b);
|
2001-04-20 01:39:03 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2016-06-28 17:17:52 +03:00
|
|
|
return CM_AUTO_PTR<cmFunctionBlocker>();
|
2001-04-20 01:39:03 +04:00
|
|
|
}
|
2001-04-30 18:44:00 +04:00
|
|
|
|
2015-04-12 21:10:45 +03:00
|
|
|
const char* cmMakefile::GetHomeDirectory() const
|
|
|
|
{
|
2015-04-26 18:18:27 +03:00
|
|
|
return this->GetCMakeInstance()->GetHomeDirectory();
|
2015-04-12 21:10:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmMakefile::GetHomeOutputDirectory() const
|
|
|
|
{
|
2015-04-26 18:18:27 +03:00
|
|
|
return this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2015-04-12 21:10:45 +03:00
|
|
|
}
|
|
|
|
|
2011-02-03 02:18:14 +03:00
|
|
|
void cmMakefile::SetScriptModeFile(const char* scriptfile)
|
|
|
|
{
|
|
|
|
this->AddDefinition("CMAKE_SCRIPT_MODE_FILE", scriptfile);
|
|
|
|
}
|
|
|
|
|
2011-02-03 05:17:23 +03:00
|
|
|
void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream strStream;
|
2011-02-03 05:17:23 +03:00
|
|
|
strStream << args.size();
|
|
|
|
this->AddDefinition("CMAKE_ARGC", strStream.str().c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
// this->MarkVariableAsUsed("CMAKE_ARGC");
|
2011-02-03 05:17:23 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int t = 0; t < args.size(); ++t) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream tmpStream;
|
2011-02-03 05:17:23 +03:00
|
|
|
tmpStream << "CMAKE_ARGV" << t;
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddDefinition(tmpStream.str(), args[t].c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
// this->MarkVariableAsUsed(tmpStream.str().c_str());
|
2011-02-03 05:17:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-06 23:05:57 +04:00
|
|
|
cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
|
2002-03-29 18:06:30 +03:00
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
cmSourceFileLocation sfl(this, sourceName);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile*>::const_iterator sfi =
|
|
|
|
this->SourceFiles.begin();
|
|
|
|
sfi != this->SourceFiles.end(); ++sfi) {
|
2007-06-18 19:59:23 +04:00
|
|
|
cmSourceFile* sf = *sfi;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sf->Matches(sfl)) {
|
2007-06-18 19:59:23 +04:00
|
|
|
return sf;
|
2007-06-08 19:57:16 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2002-03-29 18:06:30 +03:00
|
|
|
}
|
|
|
|
|
2014-03-12 02:04:11 +04:00
|
|
|
cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
|
|
|
|
bool generated)
|
|
|
|
{
|
|
|
|
cmSourceFile* sf = new cmSourceFile(this, sourceName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (generated) {
|
2014-03-12 02:04:11 +04:00
|
|
|
sf->SetProperty("GENERATED", "1");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-12 02:04:11 +04:00
|
|
|
this->SourceFiles.push_back(sf);
|
|
|
|
return sf;
|
|
|
|
}
|
|
|
|
|
2014-02-06 23:05:57 +04:00
|
|
|
cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
2003-06-03 18:30:23 +04:00
|
|
|
bool generated)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSourceFile* esf = this->GetSource(sourceName)) {
|
2007-06-18 19:59:23 +04:00
|
|
|
return esf;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-08-18 21:36:29 +03:00
|
|
|
return this->CreateSource(sourceName, generated);
|
2003-06-03 18:30:23 +04:00
|
|
|
}
|
2002-03-29 18:06:30 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
|
|
|
|
bool optional)
|
2002-04-03 00:43:23 +04:00
|
|
|
{
|
2006-02-25 01:35:35 +03:00
|
|
|
this->AddDefinition("CMAKE_CFG_INTDIR",
|
2015-05-03 12:10:30 +03:00
|
|
|
this->GetGlobalGenerator()->GetCMakeCFGIntDir());
|
|
|
|
this->GetGlobalGenerator()->EnableLanguage(lang, this, optional);
|
2002-04-03 00:43:23 +04:00
|
|
|
}
|
2002-05-02 00:33:27 +04:00
|
|
|
|
2014-02-25 02:38:30 +04:00
|
|
|
int cmMakefile::TryCompile(const std::string& srcdir,
|
|
|
|
const std::string& bindir,
|
2014-02-08 00:40:05 +04:00
|
|
|
const std::string& projectName,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& targetName, bool fast,
|
|
|
|
const std::vector<std::string>* cmakeArgs,
|
2014-07-31 20:48:46 +04:00
|
|
|
std::string& output)
|
2002-08-28 22:51:10 +04:00
|
|
|
{
|
2015-08-25 23:19:57 +03:00
|
|
|
this->IsSourceFileTryCompile = fast;
|
2002-08-28 22:51:10 +04:00
|
|
|
// does the binary directory exist ? If not create it...
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsDirectory(bindir)) {
|
2014-02-25 02:38:30 +04:00
|
|
|
cmSystemTools::MakeDirectory(bindir.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2002-08-28 22:51:10 +04:00
|
|
|
// change to the tests directory and run cmake
|
|
|
|
// use the cmake object instead of calling cmake
|
|
|
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(bindir);
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2002-08-28 22:51:10 +04:00
|
|
|
// make sure the same generator is used
|
|
|
|
// use this program as the cmake to be run, it should not
|
|
|
|
// be run that way but the cmake object requires a vailid path
|
2002-09-06 21:06:23 +04:00
|
|
|
cmake cm;
|
2002-09-12 19:08:06 +04:00
|
|
|
cm.SetIsInTryCompile(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGlobalGenerator* gg =
|
|
|
|
cm.CreateGlobalGenerator(this->GetGlobalGenerator()->GetName());
|
|
|
|
if (!gg) {
|
2002-09-06 21:06:23 +04:00
|
|
|
cmSystemTools::Error(
|
|
|
|
"Internal CMake error, TryCompile bad GlobalGenerator");
|
|
|
|
// return to the original directory
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(cwd);
|
2015-08-25 23:19:57 +03:00
|
|
|
this->IsSourceFileTryCompile = false;
|
2002-09-06 21:06:23 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-11 20:52:11 +04:00
|
|
|
cm.SetGlobalGenerator(gg);
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2002-09-06 21:06:23 +04:00
|
|
|
// do a configure
|
|
|
|
cm.SetHomeDirectory(srcdir);
|
|
|
|
cm.SetHomeOutputDirectory(bindir);
|
2014-09-05 22:25:27 +04:00
|
|
|
cm.SetGeneratorPlatform(this->GetCMakeInstance()->GetGeneratorPlatform());
|
2012-12-10 19:42:33 +04:00
|
|
|
cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset());
|
2002-09-17 21:59:58 +04:00
|
|
|
cm.LoadCache();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gg->IsMultiConfig()) {
|
|
|
|
if (const char* config =
|
|
|
|
this->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION")) {
|
2011-01-18 01:21:30 +03:00
|
|
|
// Tell the single-configuration generator which one to use.
|
|
|
|
// Add this before the user-provided CMake arguments in case
|
|
|
|
// one of the arguments is -DCMAKE_BUILD_TYPE=...
|
2016-05-16 17:34:04 +03:00
|
|
|
cm.AddCacheEntry("CMAKE_BUILD_TYPE", config, "Build configuration",
|
|
|
|
cmState::STRING);
|
2011-01-18 01:21:30 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-18 19:37:40 +04:00
|
|
|
// if cmake args were provided then pass them in
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmakeArgs) {
|
2011-01-12 01:10:28 +03:00
|
|
|
// FIXME: Workaround to ignore unused CLI variables in try-compile.
|
|
|
|
//
|
|
|
|
// Ideally we should use SetArgs to honor options like --warn-unused-vars.
|
|
|
|
// However, there is a subtle problem when certain arguments are passed to
|
|
|
|
// a macro wrapping around try_compile or try_run that does not escape
|
|
|
|
// semicolons in its parameters but just passes ${ARGV} or ${ARGN}. In
|
|
|
|
// this case a list argument like "-DVAR=a;b" gets split into multiple
|
|
|
|
// cmake arguments "-DVAR=a" and "b". Currently SetCacheArgs ignores
|
|
|
|
// argument "b" and uses just "-DVAR=a", leading to a subtle bug in that
|
|
|
|
// the try_compile or try_run does not get the proper value of VAR. If we
|
|
|
|
// call SetArgs here then it would treat "b" as the source directory and
|
|
|
|
// cause an error such as "The source directory .../CMakeFiles/CMakeTmp/b
|
|
|
|
// does not exist", thus breaking the try_compile or try_run completely.
|
|
|
|
//
|
|
|
|
// Strictly speaking the bug is in the wrapper macro because the CMake
|
|
|
|
// language has always flattened nested lists and the macro should escape
|
|
|
|
// the semicolons in its arguments before forwarding them. However, this
|
|
|
|
// bug is so subtle that projects typically work anyway, usually because
|
|
|
|
// the value VAR=a is sufficient for the try_compile or try_run to get the
|
|
|
|
// correct result. Calling SetArgs here would break such projects that
|
|
|
|
// previously built. Instead we work around the issue by never reporting
|
|
|
|
// unused arguments and ignoring options such as --warn-unused-vars.
|
2010-10-07 20:28:25 +04:00
|
|
|
cm.SetWarnUnusedCli(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
// cm.SetArgs(*cmakeArgs, true);
|
2010-10-07 20:22:00 +04:00
|
|
|
|
2002-09-18 19:37:40 +04:00
|
|
|
cm.SetCacheArgs(*cmakeArgs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-13 18:42:50 +04:00
|
|
|
// to save time we pass the EnableLanguage info directly
|
2015-05-03 12:10:30 +03:00
|
|
|
gg->EnableLanguagesFromGenerator(this->GetGlobalGenerator(), this);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
|
|
|
|
cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", "",
|
|
|
|
cmState::INTERNAL);
|
|
|
|
} else {
|
|
|
|
cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "",
|
|
|
|
cmState::INTERNAL);
|
|
|
|
}
|
|
|
|
if (cm.Configure() != 0) {
|
2002-08-28 22:51:10 +04:00
|
|
|
cmSystemTools::Error(
|
2002-09-06 21:06:23 +04:00
|
|
|
"Internal CMake error, TryCompile configure of cmake failed");
|
2002-08-28 22:51:10 +04:00
|
|
|
// return to the original directory
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(cwd);
|
2015-08-25 23:19:57 +03:00
|
|
|
this->IsSourceFileTryCompile = false;
|
2002-08-28 22:51:10 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-08-28 22:51:10 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cm.Generate() != 0) {
|
2002-08-28 22:51:10 +04:00
|
|
|
cmSystemTools::Error(
|
2002-09-06 21:06:23 +04:00
|
|
|
"Internal CMake error, TryCompile generation of cmake failed");
|
2002-08-28 22:51:10 +04:00
|
|
|
// return to the original directory
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(cwd);
|
2015-08-25 23:19:57 +03:00
|
|
|
this->IsSourceFileTryCompile = false;
|
2002-08-28 22:51:10 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-08-28 22:51:10 +04:00
|
|
|
|
|
|
|
// finally call the generator to actually build the resulting project
|
2016-05-16 17:34:04 +03:00
|
|
|
int ret = this->GetGlobalGenerator()->TryCompile(
|
|
|
|
srcdir, bindir, projectName, targetName, fast, output, this);
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(cwd);
|
2015-08-25 23:19:57 +03:00
|
|
|
this->IsSourceFileTryCompile = false;
|
2002-09-11 00:52:39 +04:00
|
|
|
return ret;
|
2002-08-28 22:51:10 +04:00
|
|
|
}
|
|
|
|
|
2012-09-05 03:44:11 +04:00
|
|
|
bool cmMakefile::GetIsSourceFileTryCompile() const
|
|
|
|
{
|
2015-08-25 23:19:57 +03:00
|
|
|
return this->IsSourceFileTryCompile;
|
2012-09-05 03:44:11 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmake* cmMakefile::GetCMakeInstance() const
|
2003-01-08 20:59:52 +03:00
|
|
|
{
|
2015-08-02 12:20:28 +03:00
|
|
|
return this->GlobalGenerator->GetCMakeInstance();
|
2015-05-03 12:08:21 +03:00
|
|
|
}
|
|
|
|
|
2016-01-29 00:10:28 +03:00
|
|
|
cmMessenger* cmMakefile::GetMessenger() const
|
|
|
|
{
|
|
|
|
return this->GetCMakeInstance()->GetMessenger();
|
|
|
|
}
|
|
|
|
|
2015-05-03 12:08:21 +03:00
|
|
|
cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
|
|
|
|
{
|
2015-08-02 12:20:28 +03:00
|
|
|
return this->GlobalGenerator;
|
2003-01-08 20:59:52 +03:00
|
|
|
}
|
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2016-05-16 17:34:04 +03:00
|
|
|
cmVariableWatch* cmMakefile::GetVariableWatch() const
|
2003-01-08 20:59:52 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetCMakeInstance() &&
|
|
|
|
this->GetCMakeInstance()->GetVariableWatch()) {
|
2003-01-08 20:59:52 +03:00
|
|
|
return this->GetCMakeInstance()->GetVariableWatch();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2003-01-08 20:59:52 +03:00
|
|
|
}
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2003-01-08 20:59:52 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState* cmMakefile::GetState() const
|
2002-09-06 21:06:23 +04:00
|
|
|
{
|
2015-04-04 22:20:12 +03:00
|
|
|
return this->GetCMakeInstance()->GetState();
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
2002-09-20 23:01:00 +04:00
|
|
|
|
2014-01-22 18:00:29 +04:00
|
|
|
void cmMakefile::DisplayStatus(const char* message, float s) const
|
2002-11-13 23:59:40 +03:00
|
|
|
{
|
2015-05-03 12:41:29 +03:00
|
|
|
cmake* cm = this->GetCMakeInstance();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) {
|
2011-08-16 02:40:59 +04:00
|
|
|
// don't output any STATUS message in FIND_PACKAGE_MODE, since they will
|
|
|
|
// directly be fed to the compiler, which will be confused.
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-08-16 02:40:59 +04:00
|
|
|
cm->UpdateProgress(message, s);
|
2002-11-13 23:59:40 +03:00
|
|
|
}
|
2002-12-02 23:59:59 +03:00
|
|
|
|
2014-01-22 18:00:29 +04:00
|
|
|
std::string cmMakefile::GetModulesFile(const char* filename) const
|
2004-02-29 02:59:19 +03:00
|
|
|
{
|
2010-11-18 00:32:53 +03:00
|
|
|
std::string result;
|
|
|
|
|
|
|
|
// We search the module always in CMAKE_ROOT and in CMAKE_MODULE_PATH,
|
|
|
|
// and then decide based on the policy setting which one to return.
|
|
|
|
// See CMP0017 for more details.
|
|
|
|
// The specific problem was that KDE 4.5.0 installs a
|
|
|
|
// FindPackageHandleStandardArgs.cmake which doesn't have the new features
|
|
|
|
// of FPHSA.cmake introduced in CMake 2.8.3 yet, and by setting
|
|
|
|
// CMAKE_MODULE_PATH also e.g. FindZLIB.cmake from cmake included
|
|
|
|
// FPHSA.cmake from kdelibs and not from CMake, and tried to use the
|
|
|
|
// new features, which were not there in the version from kdelibs, and so
|
|
|
|
// failed ("
|
|
|
|
std::string moduleInCMakeRoot;
|
|
|
|
std::string moduleInCMakeModulePath;
|
|
|
|
|
|
|
|
// Always search in CMAKE_MODULE_PATH:
|
|
|
|
const char* cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmakeModulePath) {
|
2010-11-18 00:32:53 +03:00
|
|
|
std::vector<std::string> modulePath;
|
|
|
|
cmSystemTools::ExpandListArgument(cmakeModulePath, modulePath);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// Look through the possible module directories.
|
|
|
|
for (std::vector<std::string>::iterator i = modulePath.begin();
|
|
|
|
i != modulePath.end(); ++i) {
|
2010-11-18 00:32:53 +03:00
|
|
|
std::string itempl = *i;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(itempl);
|
|
|
|
itempl += "/";
|
|
|
|
itempl += filename;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(itempl.c_str())) {
|
2010-11-18 00:32:53 +03:00
|
|
|
moduleInCMakeModulePath = itempl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-18 00:32:53 +03:00
|
|
|
|
|
|
|
// Always search in the standard modules location.
|
2016-03-14 17:38:19 +03:00
|
|
|
moduleInCMakeRoot = cmSystemTools::GetCMakeRoot();
|
|
|
|
moduleInCMakeRoot += "/Modules/";
|
|
|
|
moduleInCMakeRoot += filename;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(moduleInCMakeRoot.c_str())) {
|
2016-03-14 17:38:19 +03:00
|
|
|
moduleInCMakeRoot = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-02-29 02:59:19 +03:00
|
|
|
|
2010-11-18 00:32:53 +03:00
|
|
|
// Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file
|
|
|
|
// from which we are being called is located itself in CMAKE_ROOT, then
|
|
|
|
// prefer results from CMAKE_ROOT depending on the policy setting.
|
|
|
|
result = moduleInCMakeModulePath;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result.empty()) {
|
2010-11-18 00:32:53 +03:00
|
|
|
result = moduleInCMakeRoot;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-18 00:32:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty()) {
|
2010-11-18 00:32:53 +03:00
|
|
|
const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
|
2016-03-14 17:38:19 +03:00
|
|
|
std::string mods = cmSystemTools::GetCMakeRoot() + "/Modules/";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0) {
|
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0017)) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2010-11-18 00:32:53 +03:00
|
|
|
e << "File " << currentFile << " includes "
|
|
|
|
<< moduleInCMakeModulePath
|
|
|
|
<< " (found via CMAKE_MODULE_PATH) which shadows "
|
|
|
|
<< moduleInCMakeRoot << ". This may cause errors later on .\n"
|
2015-05-03 11:12:10 +03:00
|
|
|
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0017);
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2010-11-18 00:32:53 +03:00
|
|
|
|
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
// break; // fall through to OLD behaviour
|
2010-11-18 00:32:53 +03:00
|
|
|
}
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
result = moduleInCMakeModulePath;
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
result = moduleInCMakeRoot;
|
|
|
|
break;
|
2004-02-29 02:59:19 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-18 00:32:53 +03:00
|
|
|
|
|
|
|
return result;
|
2004-02-29 02:59:19 +03:00
|
|
|
}
|
2004-03-04 02:18:47 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::ConfigureString(const std::string& input, std::string& output,
|
|
|
|
bool atOnly, bool escapeQuotes) const
|
2004-03-04 02:18:47 +03:00
|
|
|
{
|
|
|
|
// Split input to handle one line at a time.
|
2007-06-08 19:57:16 +04:00
|
|
|
std::string::const_iterator lineStart = input.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
while (lineStart != input.end()) {
|
2004-03-04 02:18:47 +03:00
|
|
|
// Find the end of this line.
|
|
|
|
std::string::const_iterator lineEnd = lineStart;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (lineEnd != input.end() && *lineEnd != '\n') {
|
2004-03-04 02:18:47 +03:00
|
|
|
++lineEnd;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-04 02:18:47 +03:00
|
|
|
|
|
|
|
// Copy the line.
|
|
|
|
std::string line(lineStart, lineEnd);
|
|
|
|
|
|
|
|
// Skip the newline character.
|
|
|
|
bool haveNewline = (lineEnd != input.end());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (haveNewline) {
|
2004-03-04 02:18:47 +03:00
|
|
|
++lineEnd;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-04 02:18:47 +03:00
|
|
|
|
|
|
|
// Replace #cmakedefine instances.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->cmDefineRegex.find(line)) {
|
|
|
|
const char* def = this->GetDefinition(this->cmDefineRegex.match(1));
|
|
|
|
if (!cmSystemTools::IsOff(def)) {
|
2004-03-04 02:18:47 +03:00
|
|
|
cmSystemTools::ReplaceString(line, "#cmakedefine", "#define");
|
|
|
|
output += line;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-07-11 23:50:32 +04:00
|
|
|
output += "/* #undef ";
|
|
|
|
output += this->cmDefineRegex.match(1);
|
2004-03-04 02:18:47 +03:00
|
|
|
output += " */";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->cmDefine01Regex.find(line)) {
|
|
|
|
const char* def = this->GetDefinition(this->cmDefine01Regex.match(1));
|
2006-01-04 00:40:51 +03:00
|
|
|
cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define");
|
|
|
|
output += line;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::IsOff(def)) {
|
2006-01-04 00:40:51 +03:00
|
|
|
output += " 1";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-01-04 00:40:51 +03:00
|
|
|
output += " 0";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2004-03-04 02:18:47 +03:00
|
|
|
output += line;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-04 02:18:47 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (haveNewline) {
|
2004-03-04 02:18:47 +03:00
|
|
|
output += "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-04 02:18:47 +03:00
|
|
|
|
|
|
|
// Move to the next line.
|
|
|
|
lineStart = lineEnd;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-04 02:18:47 +03:00
|
|
|
|
|
|
|
// Perform variable replacements.
|
2016-06-27 23:44:16 +03:00
|
|
|
this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, CM_NULLPTR,
|
|
|
|
-1, true, true);
|
2004-03-04 02:18:47 +03:00
|
|
|
}
|
2004-03-09 03:05:04 +03:00
|
|
|
|
2007-06-08 19:57:16 +04:00
|
|
|
int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
|
2011-11-20 17:04:11 +04:00
|
|
|
bool copyonly, bool atOnly, bool escapeQuotes,
|
|
|
|
const cmNewLineStyle& newLine)
|
2004-03-09 03:05:04 +03:00
|
|
|
{
|
2004-05-27 20:53:15 +04:00
|
|
|
int res = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CanIWriteThisFile(outfile)) {
|
|
|
|
cmSystemTools::Error("Attempt to write file: ", outfile,
|
|
|
|
" into a source directory.");
|
2006-03-22 22:40:36 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cmSystemTools::FileExists(infile)) {
|
2004-03-29 01:00:57 +04:00
|
|
|
cmSystemTools::Error("File ", infile, " does not exist.");
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-09 03:05:04 +03:00
|
|
|
std::string soutfile = outfile;
|
|
|
|
std::string sinfile = infile;
|
2013-06-18 21:41:50 +04:00
|
|
|
this->AddCMakeDependFile(sinfile);
|
2004-03-09 03:05:04 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(soutfile);
|
2013-08-28 20:49:53 +04:00
|
|
|
|
2013-07-30 22:39:31 +04:00
|
|
|
// Re-generate if non-temporary outputs are missing.
|
2016-05-16 17:34:04 +03:00
|
|
|
// when we finalize the configuration we will remove all
|
|
|
|
// output files that now don't exist.
|
2013-08-28 20:49:53 +04:00
|
|
|
this->AddCMakeOutputFile(soutfile);
|
|
|
|
|
2004-03-09 03:05:04 +03:00
|
|
|
mode_t perm = 0;
|
|
|
|
cmSystemTools::GetPermissions(sinfile.c_str(), perm);
|
|
|
|
std::string::size_type pos = soutfile.rfind('/');
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != std::string::npos) {
|
2004-03-09 03:05:04 +03:00
|
|
|
std::string path = soutfile.substr(0, pos);
|
|
|
|
cmSystemTools::MakeDirectory(path.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (copyonly) {
|
|
|
|
if (!cmSystemTools::CopyFileIfDifferent(sinfile.c_str(),
|
|
|
|
soutfile.c_str())) {
|
2004-03-09 03:05:04 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2011-11-20 17:04:11 +04:00
|
|
|
std::string newLineCharacters;
|
2016-06-14 00:04:16 +03:00
|
|
|
std::ios::openmode omode = std::ios::out | std::ios::trunc;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (newLine.IsValid()) {
|
2011-11-20 17:04:11 +04:00
|
|
|
newLineCharacters = newLine.GetCharacters();
|
|
|
|
omode |= std::ios::binary;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2011-11-20 17:04:11 +04:00
|
|
|
newLineCharacters = "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-09 03:05:04 +03:00
|
|
|
std::string tempOutputFile = soutfile;
|
|
|
|
tempOutputFile += ".tmp";
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ofstream fout(tempOutputFile.c_str(), omode);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fout) {
|
|
|
|
cmSystemTools::Error("Could not open file for write in copy operation ",
|
|
|
|
tempOutputFile.c_str());
|
2004-09-08 00:55:25 +04:00
|
|
|
cmSystemTools::ReportLastSystemError("");
|
2004-03-09 03:05:04 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ifstream fin(sinfile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fin) {
|
2004-07-09 22:18:44 +04:00
|
|
|
cmSystemTools::Error("Could not open file for read in copy operation ",
|
2004-03-09 03:05:04 +03:00
|
|
|
sinfile.c_str());
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-09 03:05:04 +03:00
|
|
|
|
2014-03-07 09:55:07 +04:00
|
|
|
cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (bom != cmsys::FStream::BOM_None && bom != cmsys::FStream::BOM_UTF8) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-03-07 09:55:07 +04:00
|
|
|
e << "File starts with a Byte-Order-Mark that is not UTF-8:\n "
|
|
|
|
<< sinfile;
|
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-07 09:55:07 +04:00
|
|
|
// rewind to copy BOM to output file
|
|
|
|
fin.seekg(0);
|
|
|
|
|
2004-03-09 03:05:04 +03:00
|
|
|
// now copy input to output and expand variables in the
|
|
|
|
// input file at the same time
|
|
|
|
std::string inLine;
|
|
|
|
std::string outLine;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (cmSystemTools::GetLineFromStream(fin, inLine)) {
|
2004-03-09 03:05:04 +03:00
|
|
|
outLine = "";
|
|
|
|
this->ConfigureString(inLine, outLine, atOnly, escapeQuotes);
|
2016-06-07 00:53:32 +03:00
|
|
|
fout << outLine << newLineCharacters;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-09 03:05:04 +03:00
|
|
|
// close the files before attempting to copy
|
|
|
|
fin.close();
|
|
|
|
fout.close();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
|
|
|
|
soutfile.c_str())) {
|
2004-05-27 20:53:15 +04:00
|
|
|
res = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2004-05-27 20:53:15 +04:00
|
|
|
cmSystemTools::SetPermissions(soutfile.c_str(), perm);
|
2004-03-09 03:05:04 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::RemoveFile(tempOutputFile);
|
|
|
|
}
|
2004-05-27 20:53:15 +04:00
|
|
|
return res;
|
2004-03-09 03:05:04 +03:00
|
|
|
}
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
void cmMakefile::SetProperty(const std::string& prop, const char* value)
|
2004-05-21 00:56:34 +04:00
|
|
|
{
|
2015-07-18 16:18:59 +03:00
|
|
|
cmListFileBacktrace lfbt = this->GetBacktrace();
|
|
|
|
this->StateSnapshot.GetDirectory().SetProperty(prop, value, lfbt);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AppendProperty(const std::string& prop, const char* value,
|
2011-07-14 01:14:41 +04:00
|
|
|
bool asString)
|
2008-01-18 02:13:55 +03:00
|
|
|
{
|
2015-07-18 16:18:59 +03:00
|
|
|
cmListFileBacktrace lfbt = this->GetBacktrace();
|
2016-05-16 17:34:04 +03:00
|
|
|
this->StateSnapshot.GetDirectory().AppendProperty(prop, value, asString,
|
|
|
|
lfbt);
|
2008-01-18 02:13:55 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmMakefile::GetProperty(const std::string& prop) const
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2015-07-18 16:18:59 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetProperty(prop);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmMakefile::GetProperty(const std::string& prop, bool chain) const
|
2004-05-21 00:56:34 +04:00
|
|
|
{
|
2015-07-18 16:18:59 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetProperty(prop, chain);
|
2004-05-21 00:56:34 +04:00
|
|
|
}
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
|
2004-05-21 00:56:34 +04:00
|
|
|
{
|
2006-12-07 17:45:32 +03:00
|
|
|
return cmSystemTools::IsOn(this->GetProperty(prop));
|
2004-05-21 00:56:34 +04:00
|
|
|
}
|
2005-02-17 00:35:32 +03:00
|
|
|
|
2015-07-18 19:59:18 +03:00
|
|
|
std::vector<std::string> cmMakefile::GetPropertyKeys() const
|
|
|
|
{
|
2015-07-18 16:18:59 +03:00
|
|
|
return this->StateSnapshot.GetDirectory().GetPropertyKeys();
|
2015-07-18 19:59:18 +03:00
|
|
|
}
|
|
|
|
|
2016-04-01 17:26:08 +03:00
|
|
|
cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const
|
2005-02-17 00:35:32 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTargets::iterator i = this->Targets.find(name);
|
|
|
|
if (i != this->Targets.end()) {
|
2007-05-22 18:24:59 +04:00
|
|
|
return &i->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2005-02-17 00:35:32 +03:00
|
|
|
}
|
2005-04-24 23:59:51 +04:00
|
|
|
|
2014-02-04 06:20:33 +04:00
|
|
|
cmTest* cmMakefile::CreateTest(const std::string& testName)
|
2005-04-24 23:59:51 +04:00
|
|
|
{
|
|
|
|
cmTest* test = this->GetTest(testName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (test) {
|
2005-04-24 23:59:51 +04:00
|
|
|
return test;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-08-11 17:07:28 +04:00
|
|
|
test = new cmTest(this);
|
2005-04-24 23:59:51 +04:00
|
|
|
test->SetName(testName);
|
2009-01-05 23:00:57 +03:00
|
|
|
this->Tests[testName] = test;
|
2005-04-24 23:59:51 +04:00
|
|
|
return test;
|
|
|
|
}
|
|
|
|
|
2014-02-04 06:20:33 +04:00
|
|
|
cmTest* cmMakefile::GetTest(const std::string& testName) const
|
2005-04-24 23:59:51 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<std::string, cmTest*>::const_iterator mi =
|
|
|
|
this->Tests.find(testName);
|
|
|
|
if (mi != this->Tests.end()) {
|
2014-02-04 06:20:33 +04:00
|
|
|
return mi->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2005-04-24 23:59:51 +04:00
|
|
|
}
|
|
|
|
|
2014-01-21 23:14:49 +04:00
|
|
|
void cmMakefile::AddCMakeDependFilesFromUser()
|
|
|
|
{
|
|
|
|
std::vector<std::string> deps;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) {
|
2014-01-21 23:14:49 +04:00
|
|
|
cmSystemTools::ExpandListArgument(deps_str, deps);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::iterator i = deps.begin(); i != deps.end();
|
|
|
|
++i) {
|
|
|
|
if (cmSystemTools::FileIsFullPath(i->c_str())) {
|
2014-01-21 23:14:49 +04:00
|
|
|
this->AddCMakeDependFile(*i);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-04-16 22:17:41 +03:00
|
|
|
std::string f = this->GetCurrentSourceDirectory();
|
2014-01-21 23:14:49 +04:00
|
|
|
f += "/";
|
|
|
|
f += *i;
|
|
|
|
this->AddCMakeDependFile(f);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-21 23:14:49 +04:00
|
|
|
}
|
|
|
|
|
2015-05-16 08:30:33 +03:00
|
|
|
std::string cmMakefile::FormatListFileStack() const
|
2006-06-22 23:31:19 +04:00
|
|
|
{
|
2015-07-08 00:37:20 +03:00
|
|
|
std::vector<std::string> listFiles;
|
|
|
|
cmState::Snapshot snp = this->StateSnapshot;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (snp.IsValid()) {
|
2015-07-08 00:37:20 +03:00
|
|
|
listFiles.push_back(snp.GetExecutionListFile());
|
|
|
|
snp = snp.GetCallStackParent();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-08 00:37:20 +03:00
|
|
|
std::reverse(listFiles.begin(), listFiles.end());
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream tmp;
|
2015-07-08 00:37:20 +03:00
|
|
|
size_t depth = listFiles.size();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (depth > 0) {
|
2015-07-08 00:37:20 +03:00
|
|
|
std::vector<std::string>::const_iterator it = listFiles.end();
|
2016-05-16 17:34:04 +03:00
|
|
|
do {
|
|
|
|
if (depth != listFiles.size()) {
|
2007-07-19 19:13:01 +04:00
|
|
|
tmp << "\n ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-07-17 17:25:08 +04:00
|
|
|
--it;
|
|
|
|
tmp << "[";
|
|
|
|
tmp << depth;
|
|
|
|
tmp << "]\t";
|
|
|
|
tmp << *it;
|
|
|
|
depth--;
|
2016-05-16 17:34:04 +03:00
|
|
|
} while (it != listFiles.begin());
|
|
|
|
}
|
2007-05-01 19:46:47 +04:00
|
|
|
return tmp.str();
|
2006-06-22 23:31:19 +04:00
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
|
2007-12-03 21:35:41 +03:00
|
|
|
void cmMakefile::PushScope()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->StateSnapshot =
|
|
|
|
this->GetState()->CreateVariableScopeSnapshot(this->StateSnapshot);
|
2014-11-18 18:34:30 +03:00
|
|
|
this->PushLoopBlockBarrier();
|
2014-11-26 01:49:25 +03:00
|
|
|
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2015-05-03 12:10:30 +03:00
|
|
|
this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
|
2014-11-26 01:49:25 +03:00
|
|
|
#endif
|
2007-12-03 21:35:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PopScope()
|
|
|
|
{
|
2014-11-26 01:49:25 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2015-05-03 12:10:30 +03:00
|
|
|
this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
|
2014-11-26 01:49:25 +03:00
|
|
|
#endif
|
|
|
|
|
2014-11-18 18:34:30 +03:00
|
|
|
this->PopLoopBlockBarrier();
|
|
|
|
|
2015-05-17 17:19:55 +03:00
|
|
|
this->CheckForUnusedVariables();
|
2015-04-25 17:03:04 +03:00
|
|
|
|
2015-11-24 21:37:34 +03:00
|
|
|
this->PopSnapshot();
|
2007-12-03 21:35:41 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::RaiseScope(const std::string& var, const char* varDef)
|
2007-12-03 21:35:41 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (var.empty()) {
|
2008-01-03 19:22:33 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-03 21:35:41 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->StateSnapshot.RaiseScope(var, varDef)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream m;
|
2009-11-02 19:56:17 +03:00
|
|
|
m << "Cannot set \"" << var << "\": current scope has no parent.";
|
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-03 21:35:41 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
|
|
|
|
cmState::TargetType type, bool global)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// Create the target.
|
2016-09-14 21:28:07 +03:00
|
|
|
CM_AUTO_PTR<cmTarget> target(
|
|
|
|
new cmTarget(name, type, global ? cmTarget::VisibilityImportedGlobally
|
|
|
|
: cmTarget::VisibilityImported,
|
|
|
|
this));
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Add to the set of available imported targets.
|
|
|
|
this->ImportedTargets[name] = target.get();
|
2016-02-08 20:37:47 +03:00
|
|
|
this->GetGlobalGenerator()->IndexTarget(target.get());
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Transfer ownership to this cmMakefile object.
|
|
|
|
this->ImportedTargetsOwned.push_back(target.get());
|
|
|
|
return target.release();
|
|
|
|
}
|
|
|
|
|
2014-01-16 02:56:38 +04:00
|
|
|
cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
|
2014-01-22 18:00:29 +04:00
|
|
|
bool excludeAliases) const
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// Look for an imported target. These take priority because they
|
|
|
|
// are more local in scope and do not have to be globally unique.
|
2016-05-16 17:34:04 +03:00
|
|
|
TargetMap::const_iterator imported = this->ImportedTargets.find(name);
|
|
|
|
if (imported != this->ImportedTargets.end()) {
|
2008-01-28 16:38:36 +03:00
|
|
|
return imported->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2010-12-13 19:26:53 +03:00
|
|
|
// Look for a target built in this directory.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmTarget* t = this->FindLocalNonAliasTarget(name)) {
|
2010-12-13 19:26:53 +03:00
|
|
|
return t;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-12-13 19:26:53 +03:00
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
// Look for a target built in this project.
|
2015-05-03 12:10:30 +03:00
|
|
|
return this->GetGlobalGenerator()->FindTarget(name, excludeAliases);
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
2008-02-11 21:35:39 +03:00
|
|
|
|
2014-01-22 18:00:29 +04:00
|
|
|
bool cmMakefile::IsAlias(const std::string& name) const
|
2013-07-12 11:14:31 +04:00
|
|
|
{
|
2016-06-10 19:36:24 +03:00
|
|
|
if (this->AliasTargets.find(name) != this->AliasTargets.end()) {
|
2013-07-12 11:14:31 +04:00
|
|
|
return true;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2015-05-03 12:10:30 +03:00
|
|
|
return this->GetGlobalGenerator()->IsAlias(name);
|
2013-07-12 11:14:31 +04:00
|
|
|
}
|
|
|
|
|
2008-02-15 00:42:29 +03:00
|
|
|
bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
|
2014-01-22 18:00:29 +04:00
|
|
|
bool isCustom) const
|
2008-02-11 21:35:39 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsAlias(name)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2013-07-12 11:14:31 +04:00
|
|
|
e << "cannot create target \"" << name
|
|
|
|
<< "\" because an alias with the same name already exists.";
|
|
|
|
msg = e.str();
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmTarget* existing = this->FindTargetToUse(name)) {
|
2008-02-11 21:35:39 +03:00
|
|
|
// The name given conflicts with an existing target. Produce an
|
|
|
|
// error in a compatible way.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (existing->IsImported()) {
|
2008-02-11 21:35:39 +03:00
|
|
|
// Imported targets were not supported in previous versions.
|
|
|
|
// This is new code, so we can make it an error.
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-02-11 21:35:39 +03:00
|
|
|
e << "cannot create target \"" << name
|
|
|
|
<< "\" because an imported target with the same name already exists.";
|
|
|
|
msg = e.str();
|
|
|
|
return false;
|
2016-08-18 21:36:29 +03:00
|
|
|
}
|
|
|
|
// target names must be globally unique
|
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0002)) {
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING,
|
|
|
|
cmPolicies::GetPolicyWarning(cmPolicies::CMP0002));
|
|
|
|
case cmPolicies::OLD:
|
2008-02-15 00:42:29 +03:00
|
|
|
return true;
|
2016-08-18 21:36:29 +03:00
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
this->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0002));
|
|
|
|
return true;
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
break;
|
|
|
|
}
|
2008-02-15 00:42:29 +03:00
|
|
|
|
2016-08-18 21:36:29 +03:00
|
|
|
// The conflict is with a non-imported target.
|
|
|
|
// Allow this if the user has requested support.
|
|
|
|
cmake* cm = this->GetCMakeInstance();
|
|
|
|
if (isCustom && existing->GetType() == cmState::UTILITY &&
|
|
|
|
this != existing->GetMakefile() &&
|
|
|
|
cm->GetState()->GetGlobalPropertyAsBool(
|
|
|
|
"ALLOW_DUPLICATE_CUSTOM_TARGETS")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Produce an error that tells the user how to work around the
|
|
|
|
// problem.
|
|
|
|
std::ostringstream e;
|
|
|
|
e << "cannot create target \"" << name
|
|
|
|
<< "\" because another target with the same name already exists. "
|
|
|
|
<< "The existing target is ";
|
|
|
|
switch (existing->GetType()) {
|
|
|
|
case cmState::EXECUTABLE:
|
|
|
|
e << "an executable ";
|
|
|
|
break;
|
|
|
|
case cmState::STATIC_LIBRARY:
|
|
|
|
e << "a static library ";
|
|
|
|
break;
|
|
|
|
case cmState::SHARED_LIBRARY:
|
|
|
|
e << "a shared library ";
|
|
|
|
break;
|
|
|
|
case cmState::MODULE_LIBRARY:
|
|
|
|
e << "a module library ";
|
|
|
|
break;
|
|
|
|
case cmState::UTILITY:
|
|
|
|
e << "a custom target ";
|
|
|
|
break;
|
|
|
|
case cmState::INTERFACE_LIBRARY:
|
|
|
|
e << "an interface library ";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2008-02-11 21:35:39 +03:00
|
|
|
}
|
2016-08-18 21:36:29 +03:00
|
|
|
e << "created in source directory \""
|
|
|
|
<< existing->GetMakefile()->GetCurrentSourceDirectory() << "\". "
|
|
|
|
<< "See documentation for policy CMP0002 for more details.";
|
|
|
|
msg = e.str();
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-11 21:35:39 +03:00
|
|
|
return true;
|
|
|
|
}
|
2008-03-01 23:20:35 +03:00
|
|
|
|
2014-02-08 00:33:35 +04:00
|
|
|
bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
|
|
|
|
const std::string& binPath) const
|
2009-06-17 21:40:09 +04:00
|
|
|
{
|
|
|
|
// Make sure the binary directory is unique.
|
2015-05-03 12:10:30 +03:00
|
|
|
cmGlobalGenerator* gg = this->GetGlobalGenerator();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (gg->BinaryDirectoryIsNew(binPath)) {
|
2009-06-17 21:40:09 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0013)) {
|
2009-06-17 21:40:09 +04:00
|
|
|
case cmPolicies::WARN:
|
|
|
|
// Print the warning.
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-05-03 11:12:10 +03:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0013)
|
2009-06-17 21:40:09 +04:00
|
|
|
<< "\n"
|
|
|
|
<< "The binary directory\n"
|
|
|
|
<< " " << binPath << "\n"
|
|
|
|
<< "is already used to build a source directory. "
|
|
|
|
<< "This command uses it to build source directory\n"
|
|
|
|
<< " " << srcPath << "\n"
|
|
|
|
<< "which can generate conflicting build files. "
|
|
|
|
<< "CMake does not support this use case but it used "
|
|
|
|
<< "to work accidentally and is being allowed for "
|
|
|
|
<< "compatibility.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-06-17 21:40:09 +04:00
|
|
|
this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
// OLD behavior does not warn.
|
|
|
|
return true;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
2016-05-16 17:34:04 +03:00
|
|
|
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0013) << "\n";
|
2009-06-17 21:40:09 +04:00
|
|
|
case cmPolicies::NEW:
|
|
|
|
// NEW behavior prints the error.
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2009-06-17 21:40:09 +04:00
|
|
|
e << "The binary directory\n"
|
|
|
|
<< " " << binPath << "\n"
|
|
|
|
<< "is already used to build a source directory. "
|
|
|
|
<< "It cannot be used to build source directory\n"
|
|
|
|
<< " " << srcPath << "\n"
|
|
|
|
<< "Specify a unique binary directory name.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-06-17 21:40:09 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-06-17 21:40:09 +04:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmMakefile::AddQtUiFileWithOptions(cmSourceFile* sf)
|
2013-07-25 11:24:53 +04:00
|
|
|
{
|
|
|
|
this->QtUiFilesWithOptions.push_back(sf);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
|
|
|
|
{
|
|
|
|
return this->QtUiFilesWithOptions;
|
|
|
|
}
|
|
|
|
|
2014-12-01 18:51:49 +03:00
|
|
|
static std::string const matchVariables[] = {
|
2016-05-16 17:34:04 +03:00
|
|
|
"CMAKE_MATCH_0", "CMAKE_MATCH_1", "CMAKE_MATCH_2", "CMAKE_MATCH_3",
|
|
|
|
"CMAKE_MATCH_4", "CMAKE_MATCH_5", "CMAKE_MATCH_6", "CMAKE_MATCH_7",
|
|
|
|
"CMAKE_MATCH_8", "CMAKE_MATCH_9"
|
2014-12-01 18:51:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static std::string const nMatchesVariable = "CMAKE_MATCH_COUNT";
|
|
|
|
|
|
|
|
void cmMakefile::ClearMatches()
|
|
|
|
{
|
|
|
|
const char* nMatchesStr = this->GetDefinition(nMatchesVariable);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!nMatchesStr) {
|
2014-12-01 18:51:49 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-12-01 18:51:49 +03:00
|
|
|
int nMatches = atoi(nMatchesStr);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 0; i <= nMatches; i++) {
|
2014-12-01 18:51:49 +03:00
|
|
|
std::string const& var = matchVariables[i];
|
|
|
|
std::string const& s = this->GetSafeDefinition(var);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!s.empty()) {
|
2014-12-01 18:51:49 +03:00
|
|
|
this->AddDefinition(var, "");
|
|
|
|
this->MarkVariableAsUsed(var);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-12-01 18:51:49 +03:00
|
|
|
this->AddDefinition(nMatchesVariable, "0");
|
|
|
|
this->MarkVariableAsUsed(nMatchesVariable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
|
|
|
|
{
|
|
|
|
char highest = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 0; i < 10; i++) {
|
2014-12-01 18:51:49 +03:00
|
|
|
std::string const& m = re.match(i);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!m.empty()) {
|
2014-12-01 18:51:49 +03:00
|
|
|
std::string const& var = matchVariables[i];
|
|
|
|
this->AddDefinition(var, m.c_str());
|
|
|
|
this->MarkVariableAsUsed(var);
|
|
|
|
highest = static_cast<char>('0' + i);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
char nMatches[] = { highest, '\0' };
|
2014-12-01 18:51:49 +03:00
|
|
|
this->AddDefinition(nMatchesVariable, nMatches);
|
|
|
|
this->MarkVariableAsUsed(nMatchesVariable);
|
|
|
|
}
|
|
|
|
|
2015-06-04 20:42:32 +03:00
|
|
|
cmState::Snapshot cmMakefile::GetStateSnapshot() const
|
|
|
|
{
|
|
|
|
return this->StateSnapshot;
|
|
|
|
}
|
|
|
|
|
2015-06-07 15:50:54 +03:00
|
|
|
const char* cmMakefile::GetDefineFlagsCMP0059() const
|
|
|
|
{
|
|
|
|
return this->DefineFlagsOrig.c_str();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(
|
|
|
|
cmPolicies::PolicyID id) const
|
2008-03-01 23:20:35 +03:00
|
|
|
{
|
2015-07-26 14:04:09 +03:00
|
|
|
return this->StateSnapshot.GetPolicy(id);
|
2008-03-01 23:20:35 +03:00
|
|
|
}
|
|
|
|
|
2014-04-02 22:02:03 +04:00
|
|
|
bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var)
|
|
|
|
{
|
|
|
|
// Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!var.empty()) {
|
|
|
|
if (const char* val = this->GetDefinition(var)) {
|
2014-04-02 22:02:03 +04:00
|
|
|
return cmSystemTools::IsOn(val);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-22 00:18:53 +03:00
|
|
|
// Enable optional policy warnings with --debug-output, --trace,
|
|
|
|
// or --trace-expand.
|
2014-04-02 22:02:03 +04:00
|
|
|
cmake* cm = this->GetCMakeInstance();
|
|
|
|
return cm->GetDebugOutput() || cm->GetTrace();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::SetPolicy(const char* id, cmPolicies::PolicyStatus status)
|
2008-03-01 23:20:35 +03:00
|
|
|
{
|
|
|
|
cmPolicies::PolicyID pid;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmPolicies::GetPolicyID(id, /* out */ pid)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-03-13 21:13:44 +03:00
|
|
|
e << "Policy \"" << id << "\" is not known to this version of CMake.";
|
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2008-03-01 23:20:35 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
return this->SetPolicy(pid, status);
|
2008-03-01 23:20:35 +03:00
|
|
|
}
|
|
|
|
|
2008-08-19 00:29:00 +04:00
|
|
|
bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
|
2008-03-01 23:20:35 +03:00
|
|
|
cmPolicies::PolicyStatus status)
|
|
|
|
{
|
2008-08-19 00:29:00 +04:00
|
|
|
// A REQUIRED_ALWAYS policy may be set only to NEW.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (status != cmPolicies::NEW &&
|
|
|
|
cmPolicies::GetPolicyStatus(id) == cmPolicies::REQUIRED_ALWAYS) {
|
|
|
|
std::string msg = cmPolicies::GetRequiredAlwaysPolicyError(id);
|
2014-03-11 03:04:11 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, msg);
|
2008-08-19 00:29:00 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-07 23:30:35 +03:00
|
|
|
|
2015-07-26 14:04:09 +03:00
|
|
|
this->StateSnapshot.SetPolicy(id, status);
|
2008-08-19 00:29:00 +04:00
|
|
|
return true;
|
2008-03-01 23:20:35 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m)
|
|
|
|
: Makefile(m)
|
2009-01-22 18:56:50 +03:00
|
|
|
{
|
2015-11-24 21:06:42 +03:00
|
|
|
this->Makefile->PushPolicy();
|
2009-01-22 18:56:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmMakefile::PolicyPushPop::~PolicyPushPop()
|
|
|
|
{
|
2009-01-22 18:57:16 +03:00
|
|
|
this->Makefile->PopPolicy();
|
|
|
|
}
|
|
|
|
|
2009-01-22 21:16:27 +03:00
|
|
|
void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm)
|
2009-01-22 18:57:16 +03:00
|
|
|
{
|
2015-07-26 14:04:09 +03:00
|
|
|
this->StateSnapshot.PushPolicy(pm, weak);
|
2009-01-22 18:57:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmMakefile::PopPolicy()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->StateSnapshot.PopPolicy()) {
|
2009-01-22 18:57:16 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR,
|
|
|
|
"cmake_policy POP without matching PUSH");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-22 18:56:50 +03:00
|
|
|
}
|
|
|
|
|
2015-11-24 19:44:57 +03:00
|
|
|
void cmMakefile::PopSnapshot(bool reportError)
|
2008-03-01 23:20:35 +03:00
|
|
|
{
|
2015-11-24 19:44:57 +03:00
|
|
|
// cmState::Snapshot manages nested policy scopes within it.
|
|
|
|
// Since the scope corresponding to the snapshot is closing,
|
|
|
|
// reject any still-open nested policy scopes with an error.
|
2016-05-16 17:34:04 +03:00
|
|
|
while (!this->StateSnapshot.CanPopPolicyScope()) {
|
|
|
|
if (reportError) {
|
2009-01-22 18:57:16 +03:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR,
|
|
|
|
"cmake_policy PUSH without matching POP");
|
|
|
|
reportError = false;
|
2008-03-06 02:21:10 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->PopPolicy();
|
|
|
|
}
|
2009-01-22 18:57:16 +03:00
|
|
|
|
2015-07-26 14:04:09 +03:00
|
|
|
this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
|
|
|
|
assert(this->StateSnapshot.IsValid());
|
2008-03-01 23:20:35 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::SetPolicyVersion(const char* version)
|
2008-03-01 23:20:35 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return cmPolicies::ApplyPolicyVersion(this, version);
|
2008-03-01 23:20:35 +03:00
|
|
|
}
|
2009-01-22 21:16:47 +03:00
|
|
|
|
2015-10-20 20:13:52 +03:00
|
|
|
bool cmMakefile::HasCMP0054AlreadyBeenReported(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmListFileContext const& context) const
|
2014-09-04 22:21:28 +04:00
|
|
|
{
|
2015-10-20 20:13:52 +03:00
|
|
|
return !this->CMP0054ReportedIds.insert(context).second;
|
2014-09-04 22:21:28 +04:00
|
|
|
}
|
|
|
|
|
2009-01-22 21:16:47 +03:00
|
|
|
void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
|
|
|
|
{
|
|
|
|
/* Record the setting of every policy. */
|
|
|
|
typedef cmPolicies::PolicyID PolicyID;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
|
|
|
|
pid = PolicyID(pid + 1)) {
|
2015-05-03 11:12:28 +03:00
|
|
|
pm.Set(pid, this->GetPolicyStatus(pid));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-22 21:16:47 +03:00
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2015-05-08 22:41:08 +03:00
|
|
|
bool cmMakefile::IgnoreErrorsCMP0061() const
|
|
|
|
{
|
|
|
|
bool ignoreErrors = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatus(cmPolicies::CMP0061)) {
|
2015-05-08 22:41:08 +03:00
|
|
|
case cmPolicies::WARN:
|
2016-05-16 17:34:04 +03:00
|
|
|
// No warning for this policy!
|
2015-05-08 22:41:08 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
ignoreErrors = false;
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-08 22:41:08 +03:00
|
|
|
return ignoreErrors;
|
|
|
|
}
|
|
|
|
|
2014-04-02 17:57:15 +04:00
|
|
|
#define FEATURE_STRING(F) , #F
|
2016-06-27 23:44:16 +03:00
|
|
|
static const char* const C_FEATURES[] = { CM_NULLPTR FOR_EACH_C_FEATURE(
|
2016-05-16 17:34:04 +03:00
|
|
|
FEATURE_STRING) };
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
static const char* const CXX_FEATURES[] = { CM_NULLPTR FOR_EACH_CXX_FEATURE(
|
2016-05-16 17:34:04 +03:00
|
|
|
FEATURE_STRING) };
|
2014-05-10 15:11:50 +04:00
|
|
|
#undef FEATURE_STRING
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* const C_STANDARDS[] = { "90", "99", "11" };
|
|
|
|
static const char* const CXX_STANDARDS[] = { "98", "11", "14" };
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
|
|
|
|
const std::string& feature,
|
|
|
|
std::string* error) const
|
2014-04-02 17:57:15 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorExpression::Find(feature) != std::string::npos) {
|
2013-10-22 17:05:49 +04:00
|
|
|
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:33:20 +04:00
|
|
|
|
|
|
|
std::string lang;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CompileFeatureKnown(target, feature, lang, error)) {
|
2014-04-02 17:57:15 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2014-05-15 13:33:20 +04:00
|
|
|
const char* features = this->CompileFeaturesAvailable(lang, error);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!features) {
|
2014-04-15 20:09:21 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
|
|
|
|
std::vector<std::string> availableFeatures;
|
2014-05-15 13:33:20 +04:00
|
|
|
cmSystemTools::ExpandListArgument(features, availableFeatures);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (std::find(availableFeatures.begin(), availableFeatures.end(), feature) ==
|
|
|
|
availableFeatures.end()) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "The compiler feature \"" << feature << "\" is not known to " << lang
|
|
|
|
<< " compiler\n\""
|
2014-04-02 17:57:15 +04:00
|
|
|
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
|
|
|
|
<< "\"\nversion "
|
|
|
|
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
|
2016-01-29 00:10:27 +03:00
|
|
|
if (error) {
|
|
|
|
*error = e.str();
|
|
|
|
} else {
|
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
|
|
|
this->Backtrace);
|
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
|
|
|
|
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
|
|
|
|
|
2016-01-29 00:10:27 +03:00
|
|
|
return lang == "C"
|
|
|
|
? this->AddRequiredTargetCFeature(target, feature, error)
|
|
|
|
: this->AddRequiredTargetCxxFeature(target, feature, error);
|
2013-11-04 04:15:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::CompileFeatureKnown(cmTarget const* target,
|
|
|
|
const std::string& feature,
|
|
|
|
std::string& lang,
|
|
|
|
std::string* error) const
|
2014-05-15 13:33:20 +04:00
|
|
|
{
|
|
|
|
assert(cmGeneratorExpression::Find(feature) == std::string::npos);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool isCFeature =
|
|
|
|
std::find_if(cmArrayBegin(C_FEATURES) + 1, cmArrayEnd(C_FEATURES),
|
|
|
|
cmStrCmp(feature)) != cmArrayEnd(C_FEATURES);
|
|
|
|
if (isCFeature) {
|
2014-05-15 13:33:20 +04:00
|
|
|
lang = "C";
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
bool isCxxFeature =
|
|
|
|
std::find_if(cmArrayBegin(CXX_FEATURES) + 1, cmArrayEnd(CXX_FEATURES),
|
|
|
|
cmStrCmp(feature)) != cmArrayEnd(CXX_FEATURES);
|
|
|
|
if (isCxxFeature) {
|
2014-05-15 13:33:20 +04:00
|
|
|
lang = "CXX";
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (error) {
|
2014-05-15 13:33:20 +04:00
|
|
|
e << "specified";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-05-15 13:33:20 +04:00
|
|
|
e << "Specified";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:33:20 +04:00
|
|
|
e << " unknown feature \"" << feature << "\" for "
|
2016-05-16 17:34:04 +03:00
|
|
|
"target \""
|
|
|
|
<< target->GetName() << "\".";
|
|
|
|
if (error) {
|
2014-05-15 13:33:20 +04:00
|
|
|
*error = e.str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-01-29 00:10:27 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
|
|
|
this->Backtrace);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:33:20 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang,
|
|
|
|
std::string* error) const
|
2014-05-15 13:33:20 +04:00
|
|
|
{
|
|
|
|
const char* featuresKnown =
|
|
|
|
this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!featuresKnown || !*featuresKnown) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (error) {
|
2014-05-15 13:33:20 +04:00
|
|
|
e << "no";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-05-15 13:33:20 +04:00
|
|
|
e << "No";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:33:20 +04:00
|
|
|
e << " known features for " << lang << " compiler\n\""
|
|
|
|
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
|
|
|
|
<< "\"\nversion "
|
|
|
|
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (error) {
|
2014-05-15 13:33:20 +04:00
|
|
|
*error = e.str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-01-29 00:10:27 +03:00
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
|
|
|
this->Backtrace);
|
2014-05-15 13:33:20 +04:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:33:20 +04:00
|
|
|
return featuresKnown;
|
|
|
|
}
|
|
|
|
|
2015-01-11 19:43:44 +03:00
|
|
|
bool cmMakefile::HaveStandardAvailable(cmTarget const* target,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& lang,
|
|
|
|
const std::string& feature) const
|
2014-05-15 13:54:24 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return lang == "C" ? this->HaveCStandardAvailable(target, feature)
|
|
|
|
: this->HaveCxxStandardAvailable(target, feature);
|
2014-05-15 13:54:24 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::HaveCStandardAvailable(cmTarget const* target,
|
|
|
|
const std::string& feature) const
|
2014-05-15 13:54:24 +04:00
|
|
|
{
|
2015-01-27 00:42:36 +03:00
|
|
|
const char* defaultCStandard =
|
|
|
|
this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!defaultCStandard) {
|
2015-01-27 00:42:36 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "CMAKE_C_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
|
2016-05-16 17:34:04 +03:00
|
|
|
"not fully configured for this compiler.";
|
2015-01-27 00:42:36 +03:00
|
|
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
|
|
|
// Return true so the caller does not try to lookup the default standard.
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-27 00:42:36 +03:00
|
|
|
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStrCmp(defaultCStandard)) == cmArrayEnd(C_STANDARDS)) {
|
2015-01-27 00:42:36 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "The CMAKE_C_STANDARD_DEFAULT variable contains an "
|
2016-05-16 17:34:04 +03:00
|
|
|
"invalid value: \""
|
|
|
|
<< defaultCStandard << "\".";
|
2015-01-27 00:42:36 +03:00
|
|
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-27 00:42:36 +03:00
|
|
|
|
2014-05-15 13:54:24 +04:00
|
|
|
bool needC90 = false;
|
|
|
|
bool needC99 = false;
|
|
|
|
bool needC11 = false;
|
|
|
|
|
|
|
|
this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* existingCStandard = target->GetProperty("C_STANDARD");
|
|
|
|
if (!existingCStandard) {
|
2015-01-27 00:42:36 +03:00
|
|
|
existingCStandard = defaultCStandard;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:54:24 +04:00
|
|
|
|
|
|
|
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-05-15 13:54:24 +04:00
|
|
|
e << "The C_STANDARD property on target \"" << target->GetName()
|
|
|
|
<< "\" contained an invalid value: \"" << existingCStandard << "\".";
|
2014-10-15 16:54:05 +04:00
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2014-05-15 13:54:24 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:54:24 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* const* existingCIt = existingCStandard
|
|
|
|
? std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
|
|
|
cmStrCmp(existingCStandard))
|
|
|
|
: cmArrayEnd(C_STANDARDS);
|
2014-05-15 13:54:24 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (needC11 && existingCStandard &&
|
|
|
|
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
|
|
|
|
cmArrayEnd(C_STANDARDS), cmStrCmp("11"))) {
|
2014-05-15 13:54:24 +04:00
|
|
|
return false;
|
2016-08-18 21:36:29 +03:00
|
|
|
}
|
|
|
|
if (needC99 && existingCStandard &&
|
|
|
|
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
|
|
|
|
cmArrayEnd(C_STANDARDS), cmStrCmp("99"))) {
|
2014-05-15 13:54:24 +04:00
|
|
|
return false;
|
2016-08-18 21:36:29 +03:00
|
|
|
}
|
|
|
|
if (needC90 && existingCStandard &&
|
|
|
|
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
|
|
|
|
cmArrayEnd(C_STANDARDS), cmStrCmp("90"))) {
|
2014-05-15 13:54:24 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:54:24 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-15 13:32:30 +04:00
|
|
|
bool cmMakefile::IsLaterStandard(std::string const& lang,
|
|
|
|
std::string const& lhs,
|
|
|
|
std::string const& rhs)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (lang == "C") {
|
|
|
|
const char* const* rhsIt = std::find_if(
|
|
|
|
cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS), cmStrCmp(rhs));
|
2014-05-15 13:32:30 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
return std::find_if(rhsIt, cmArrayEnd(C_STANDARDS), cmStrCmp(lhs)) !=
|
|
|
|
cmArrayEnd(C_STANDARDS);
|
|
|
|
}
|
|
|
|
const char* const* rhsIt = std::find_if(
|
|
|
|
cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS), cmStrCmp(rhs));
|
2014-05-15 13:32:30 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
return std::find_if(rhsIt, cmArrayEnd(CXX_STANDARDS), cmStrCmp(lhs)) !=
|
|
|
|
cmArrayEnd(CXX_STANDARDS);
|
2014-05-15 13:32:30 +04:00
|
|
|
}
|
|
|
|
|
2015-01-11 19:43:44 +03:00
|
|
|
bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& feature) const
|
2014-05-15 13:54:24 +04:00
|
|
|
{
|
2015-01-27 00:42:36 +03:00
|
|
|
const char* defaultCxxStandard =
|
|
|
|
this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!defaultCxxStandard) {
|
2015-01-27 00:42:36 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "CMAKE_CXX_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
|
2016-05-16 17:34:04 +03:00
|
|
|
"not fully configured for this compiler.";
|
2015-01-27 00:42:36 +03:00
|
|
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
|
|
|
// Return true so the caller does not try to lookup the default standard.
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-27 00:42:36 +03:00
|
|
|
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStrCmp(defaultCxxStandard)) ==
|
|
|
|
cmArrayEnd(CXX_STANDARDS)) {
|
2015-01-27 00:42:36 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "The CMAKE_CXX_STANDARD_DEFAULT variable contains an "
|
2016-05-16 17:34:04 +03:00
|
|
|
"invalid value: \""
|
|
|
|
<< defaultCxxStandard << "\".";
|
2015-01-27 00:42:36 +03:00
|
|
|
this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-27 00:42:36 +03:00
|
|
|
|
2014-05-15 13:54:24 +04:00
|
|
|
bool needCxx98 = false;
|
|
|
|
bool needCxx11 = false;
|
2014-05-06 02:21:14 +04:00
|
|
|
bool needCxx14 = false;
|
|
|
|
this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14);
|
2014-05-15 13:54:24 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* existingCxxStandard = target->GetProperty("CXX_STANDARD");
|
|
|
|
if (!existingCxxStandard) {
|
2015-01-27 00:42:36 +03:00
|
|
|
existingCxxStandard = defaultCxxStandard;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:54:24 +04:00
|
|
|
|
|
|
|
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStrCmp(existingCxxStandard)) ==
|
|
|
|
cmArrayEnd(CXX_STANDARDS)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-05-15 13:54:24 +04:00
|
|
|
e << "The CXX_STANDARD property on target \"" << target->GetName()
|
|
|
|
<< "\" contained an invalid value: \"" << existingCxxStandard << "\".";
|
|
|
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:54:24 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* const* existingCxxIt = existingCxxStandard
|
|
|
|
? std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
|
|
|
cmStrCmp(existingCxxStandard))
|
|
|
|
: cmArrayEnd(CXX_STANDARDS);
|
2014-05-15 13:54:24 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (needCxx11 &&
|
|
|
|
existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
|
|
|
|
cmArrayEnd(CXX_STANDARDS),
|
|
|
|
cmStrCmp("11"))) {
|
2014-05-15 13:54:24 +04:00
|
|
|
return false;
|
2016-08-18 21:36:29 +03:00
|
|
|
}
|
|
|
|
if (needCxx98 &&
|
|
|
|
existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
|
|
|
|
cmArrayEnd(CXX_STANDARDS),
|
|
|
|
cmStrCmp("98"))) {
|
2014-05-15 13:54:24 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:54:24 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-15 13:49:02 +04:00
|
|
|
void cmMakefile::CheckNeededCxxLanguage(const std::string& feature,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool& needCxx98, bool& needCxx11,
|
2014-05-06 02:21:14 +04:00
|
|
|
bool& needCxx14) const
|
2013-11-04 04:15:43 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* propCxx98 =
|
|
|
|
this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES")) {
|
2014-04-06 13:40:11 +04:00
|
|
|
std::vector<std::string> props;
|
|
|
|
cmSystemTools::ExpandListArgument(propCxx98, props);
|
|
|
|
needCxx98 = std::find(props.begin(), props.end(), feature) != props.end();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (const char* propCxx11 =
|
|
|
|
this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES")) {
|
2014-04-02 17:57:15 +04:00
|
|
|
std::vector<std::string> props;
|
|
|
|
cmSystemTools::ExpandListArgument(propCxx11, props);
|
|
|
|
needCxx11 = std::find(props.begin(), props.end(), feature) != props.end();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (const char* propCxx14 =
|
|
|
|
this->GetDefinition("CMAKE_CXX14_COMPILE_FEATURES")) {
|
2014-05-06 02:21:14 +04:00
|
|
|
std::vector<std::string> props;
|
|
|
|
cmSystemTools::ExpandListArgument(propCxx14, props);
|
|
|
|
needCxx14 = std::find(props.begin(), props.end(), feature) != props.end();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:49:02 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target,
|
2016-01-29 00:10:27 +03:00
|
|
|
const std::string& feature,
|
|
|
|
std::string* error) const
|
2014-05-15 13:49:02 +04:00
|
|
|
{
|
|
|
|
bool needCxx98 = false;
|
|
|
|
bool needCxx11 = false;
|
2014-05-06 02:21:14 +04:00
|
|
|
bool needCxx14 = false;
|
2014-05-15 13:49:02 +04:00
|
|
|
|
2014-05-06 02:21:14 +04:00
|
|
|
this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14);
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* existingCxxStandard = target->GetProperty("CXX_STANDARD");
|
|
|
|
if (existingCxxStandard) {
|
2014-04-02 17:57:15 +04:00
|
|
|
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStrCmp(existingCxxStandard)) ==
|
|
|
|
cmArrayEnd(CXX_STANDARDS)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-04-02 17:57:15 +04:00
|
|
|
e << "The CXX_STANDARD property on target \"" << target->GetName()
|
|
|
|
<< "\" contained an invalid value: \"" << existingCxxStandard << "\".";
|
2016-01-29 00:10:27 +03:00
|
|
|
if (error) {
|
|
|
|
*error = e.str();
|
|
|
|
} else {
|
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
|
|
|
this->Backtrace);
|
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
const char* const* existingCxxIt = existingCxxStandard
|
|
|
|
? std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
|
|
|
|
cmStrCmp(existingCxxStandard))
|
|
|
|
: cmArrayEnd(CXX_STANDARDS);
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2014-04-06 13:40:11 +04:00
|
|
|
bool setCxx98 = needCxx98 && !existingCxxStandard;
|
2014-04-02 17:57:15 +04:00
|
|
|
bool setCxx11 = needCxx11 && !existingCxxStandard;
|
2014-05-06 02:21:14 +04:00
|
|
|
bool setCxx14 = needCxx14 && !existingCxxStandard;
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (needCxx14 && existingCxxStandard &&
|
|
|
|
existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
|
|
|
|
cmArrayEnd(CXX_STANDARDS),
|
|
|
|
cmStrCmp("14"))) {
|
2014-05-06 02:21:14 +04:00
|
|
|
setCxx14 = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (needCxx11 && existingCxxStandard &&
|
|
|
|
existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
|
|
|
|
cmArrayEnd(CXX_STANDARDS),
|
|
|
|
cmStrCmp("11"))) {
|
2014-04-02 17:57:15 +04:00
|
|
|
setCxx11 = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (needCxx98 && existingCxxStandard &&
|
|
|
|
existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
|
|
|
|
cmArrayEnd(CXX_STANDARDS),
|
|
|
|
cmStrCmp("98"))) {
|
2014-04-06 13:40:11 +04:00
|
|
|
setCxx98 = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setCxx14) {
|
2014-05-06 02:21:14 +04:00
|
|
|
target->SetProperty("CXX_STANDARD", "14");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (setCxx11) {
|
2014-04-02 17:57:15 +04:00
|
|
|
target->SetProperty("CXX_STANDARD", "11");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (setCxx98) {
|
2014-04-06 13:40:11 +04:00
|
|
|
target->SetProperty("CXX_STANDARD", "98");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-02 17:57:15 +04:00
|
|
|
return true;
|
|
|
|
}
|
2013-11-04 04:15:43 +04:00
|
|
|
|
2014-05-15 13:49:02 +04:00
|
|
|
void cmMakefile::CheckNeededCLanguage(const std::string& feature,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool& needC90, bool& needC99,
|
|
|
|
bool& needC11) const
|
2013-11-04 04:15:43 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* propC90 =
|
|
|
|
this->GetDefinition("CMAKE_C90_COMPILE_FEATURES")) {
|
2013-11-04 04:15:43 +04:00
|
|
|
std::vector<std::string> props;
|
|
|
|
cmSystemTools::ExpandListArgument(propC90, props);
|
|
|
|
needC90 = std::find(props.begin(), props.end(), feature) != props.end();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (const char* propC99 =
|
|
|
|
this->GetDefinition("CMAKE_C99_COMPILE_FEATURES")) {
|
2013-11-04 04:15:43 +04:00
|
|
|
std::vector<std::string> props;
|
|
|
|
cmSystemTools::ExpandListArgument(propC99, props);
|
|
|
|
needC99 = std::find(props.begin(), props.end(), feature) != props.end();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (const char* propC11 =
|
|
|
|
this->GetDefinition("CMAKE_C11_COMPILE_FEATURES")) {
|
2013-11-04 04:15:43 +04:00
|
|
|
std::vector<std::string> props;
|
|
|
|
cmSystemTools::ExpandListArgument(propC11, props);
|
|
|
|
needC11 = std::find(props.begin(), props.end(), feature) != props.end();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 13:49:02 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target,
|
2016-01-29 00:10:27 +03:00
|
|
|
const std::string& feature,
|
|
|
|
std::string* error) const
|
2014-05-15 13:49:02 +04:00
|
|
|
{
|
|
|
|
bool needC90 = false;
|
|
|
|
bool needC99 = false;
|
|
|
|
bool needC11 = false;
|
|
|
|
|
|
|
|
this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
|
2013-11-04 04:15:43 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* existingCStandard = target->GetProperty("C_STANDARD");
|
|
|
|
if (existingCStandard) {
|
2013-11-04 04:15:43 +04:00
|
|
|
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2013-11-04 04:15:43 +04:00
|
|
|
e << "The C_STANDARD property on target \"" << target->GetName()
|
|
|
|
<< "\" contained an invalid value: \"" << existingCStandard << "\".";
|
2016-01-29 00:10:27 +03:00
|
|
|
if (error) {
|
|
|
|
*error = e.str();
|
|
|
|
} else {
|
|
|
|
this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
|
|
|
this->Backtrace);
|
|
|
|
}
|
2013-11-04 04:15:43 +04:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
const char* const* existingCIt = existingCStandard
|
|
|
|
? std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
|
|
|
|
cmStrCmp(existingCStandard))
|
|
|
|
: cmArrayEnd(C_STANDARDS);
|
2013-11-04 04:15:43 +04:00
|
|
|
|
|
|
|
bool setC90 = needC90 && !existingCStandard;
|
|
|
|
bool setC99 = needC99 && !existingCStandard;
|
|
|
|
bool setC11 = needC11 && !existingCStandard;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (needC11 && existingCStandard &&
|
|
|
|
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
|
|
|
|
cmArrayEnd(C_STANDARDS), cmStrCmp("11"))) {
|
2013-11-04 04:15:43 +04:00
|
|
|
setC11 = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (needC99 && existingCStandard &&
|
|
|
|
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
|
|
|
|
cmArrayEnd(C_STANDARDS),
|
|
|
|
cmStrCmp("99"))) {
|
2013-11-04 04:15:43 +04:00
|
|
|
setC99 = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (needC90 && existingCStandard &&
|
|
|
|
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
|
|
|
|
cmArrayEnd(C_STANDARDS),
|
|
|
|
cmStrCmp("90"))) {
|
2013-11-04 04:15:43 +04:00
|
|
|
setC90 = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-04 04:15:43 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setC11) {
|
2013-11-04 04:15:43 +04:00
|
|
|
target->SetProperty("C_STANDARD", "11");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (setC99) {
|
2013-11-04 04:15:43 +04:00
|
|
|
target->SetProperty("C_STANDARD", "99");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (setC90) {
|
2013-11-04 04:15:43 +04:00
|
|
|
target->SetProperty("C_STANDARD", "90");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-04 04:15:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
2015-05-31 19:19:58 +03:00
|
|
|
|
|
|
|
cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf,
|
2015-05-31 20:37:08 +03:00
|
|
|
const std::string& fileName,
|
2015-05-31 19:19:58 +03:00
|
|
|
cmPolicies::PolicyMap const& pm)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Makefile(mf)
|
|
|
|
, ReportError(true)
|
2015-05-31 19:19:58 +03:00
|
|
|
{
|
2015-05-31 20:37:08 +03:00
|
|
|
this->Makefile->PushFunctionScope(fileName, pm);
|
2015-05-31 19:19:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmMakefile::FunctionPushPop::~FunctionPushPop()
|
|
|
|
{
|
|
|
|
this->Makefile->PopFunctionScope(this->ReportError);
|
|
|
|
}
|
2015-05-31 19:32:01 +03:00
|
|
|
|
|
|
|
cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf,
|
2015-05-31 20:37:08 +03:00
|
|
|
const std::string& fileName,
|
2015-05-31 19:32:01 +03:00
|
|
|
const cmPolicies::PolicyMap& pm)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Makefile(mf)
|
|
|
|
, ReportError(true)
|
2015-05-31 19:32:01 +03:00
|
|
|
{
|
2015-05-31 20:37:08 +03:00
|
|
|
this->Makefile->PushMacroScope(fileName, pm);
|
2015-05-31 19:32:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmMakefile::MacroPushPop::~MacroPushPop()
|
|
|
|
{
|
|
|
|
this->Makefile->PopMacroScope(this->ReportError);
|
|
|
|
}
|