2012-03-07 20:44:48 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
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.
|
|
|
|
============================================================================*/
|
|
|
|
#include "cmGeneratorTarget.h"
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2014-01-01 18:49:05 +04:00
|
|
|
#include "cmComputeLinkInformation.h"
|
2014-03-07 20:20:10 +04:00
|
|
|
#include "cmCustomCommandGenerator.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGeneratorExpression.h"
|
|
|
|
#include "cmGeneratorExpressionDAGChecker.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSourceFile.h"
|
|
|
|
#include "cmTarget.h"
|
2012-03-07 20:44:48 +04:00
|
|
|
|
2012-10-11 02:57:11 +04:00
|
|
|
#include <queue>
|
|
|
|
|
2014-01-01 18:49:05 +04:00
|
|
|
#include "assert.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <errno.h>
|
2014-01-01 18:49:05 +04:00
|
|
|
|
2016-06-23 01:29:47 +03:00
|
|
|
#if defined(CMake_HAVE_CXX_UNORDERED_SET)
|
|
|
|
#include <unordered_set>
|
|
|
|
#define UNORDERED_SET std::unordered_set
|
|
|
|
#elif defined(CMAKE_BUILD_WITH_CMAKE)
|
2015-08-04 20:19:49 +03:00
|
|
|
#include <cmsys/hash_set.hxx>
|
|
|
|
#define UNORDERED_SET cmsys::hash_set
|
|
|
|
#else
|
|
|
|
#define UNORDERED_SET std::set
|
|
|
|
#endif
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmGeneratorTarget::TargetPropertyEntry
|
|
|
|
{
|
2015-08-05 00:14:53 +03:00
|
|
|
static cmLinkImplItem NoLinkImplItem;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2015-08-05 00:14:53 +03:00
|
|
|
public:
|
2016-06-28 17:17:52 +03:00
|
|
|
TargetPropertyEntry(CM_AUTO_PTR<cmCompiledGeneratorExpression> cge,
|
2015-08-05 00:14:53 +03:00
|
|
|
cmLinkImplItem const& item = NoLinkImplItem)
|
2016-05-16 17:34:04 +03:00
|
|
|
: ge(cge)
|
|
|
|
, LinkImplItem(item)
|
|
|
|
{
|
|
|
|
}
|
2016-06-28 17:17:52 +03:00
|
|
|
const CM_AUTO_PTR<cmCompiledGeneratorExpression> ge;
|
2015-08-05 00:14:53 +03:00
|
|
|
cmLinkImplItem const& LinkImplItem;
|
|
|
|
};
|
|
|
|
cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
|
|
|
|
|
2014-02-14 00:07:31 +04:00
|
|
|
void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget const* target, cmake* cm)
|
2014-02-14 00:07:31 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!badObjLib.empty()) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-02-14 00:07:31 +04:00
|
|
|
e << "OBJECT library \"" << target->GetName() << "\" contains:\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
|
|
|
|
i != badObjLib.end(); ++i) {
|
2014-02-14 00:07:31 +04:00
|
|
|
e << " " << (*i)->GetLocation().GetName() << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-07-02 23:38:10 +04:00
|
|
|
e << "but may contain only sources that compile, header files, and "
|
|
|
|
"other files that would not affect linking of a normal library.";
|
2016-05-16 17:34:04 +03:00
|
|
|
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), target->GetBacktrace());
|
|
|
|
}
|
2014-02-14 00:07:31 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
struct ObjectSourcesTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct CustomCommandsTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct ExtraSourcesTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct HeaderSourcesTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct ExternalObjectsTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct IDLSourcesTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct ResxTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct ModuleDefinitionFileTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct AppManifestTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct ManifestsTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct CertificatesTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct XamlTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Tag, typename OtherTag>
|
2014-02-14 00:07:31 +04:00
|
|
|
struct IsSameTag
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
enum
|
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
Result = false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename Tag>
|
2014-02-14 00:07:31 +04:00
|
|
|
struct IsSameTag<Tag, Tag>
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
enum
|
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
Result = true
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <bool>
|
2014-02-14 00:07:31 +04:00
|
|
|
struct DoAccept
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename T>
|
|
|
|
static void Do(T&, cmSourceFile*)
|
|
|
|
{
|
|
|
|
}
|
2014-02-14 00:07:31 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
2014-02-14 00:07:31 +04:00
|
|
|
struct DoAccept<true>
|
|
|
|
{
|
2014-03-13 02:06:05 +04:00
|
|
|
static void Do(std::vector<cmSourceFile const*>& files, cmSourceFile* f)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
files.push_back(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-14 00:07:31 +04:00
|
|
|
static void Do(cmGeneratorTarget::ResxData& data, cmSourceFile* f)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
// Build and save the name of the corresponding .h file
|
|
|
|
// This relationship will be used later when building the project files.
|
|
|
|
// Both names would have been auto generated from Visual Studio
|
|
|
|
// where the user supplied the file name and Visual Studio
|
|
|
|
// appended the suffix.
|
|
|
|
std::string resx = f->GetFullPath();
|
2016-05-24 22:24:10 +03:00
|
|
|
std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h";
|
2014-02-14 00:07:31 +04:00
|
|
|
data.ExpectedResxHeaders.insert(hFileName);
|
|
|
|
data.ResxSources.push_back(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-03-31 23:49:39 +03:00
|
|
|
static void Do(cmGeneratorTarget::XamlData& data, cmSourceFile* f)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2015-03-31 23:49:39 +03:00
|
|
|
// Build and save the name of the corresponding .h and .cpp file
|
|
|
|
// This relationship will be used later when building the project files.
|
|
|
|
// Both names would have been auto generated from Visual Studio
|
|
|
|
// where the user supplied the file name and Visual Studio
|
|
|
|
// appended the suffix.
|
|
|
|
std::string xaml = f->GetFullPath();
|
|
|
|
std::string hFileName = xaml + ".h";
|
|
|
|
std::string cppFileName = xaml + ".cpp";
|
|
|
|
data.ExpectedXamlHeaders.insert(hFileName);
|
|
|
|
data.ExpectedXamlSources.insert(cppFileName);
|
|
|
|
data.XamlSources.push_back(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-14 00:07:31 +04:00
|
|
|
static void Do(std::string& data, cmSourceFile* f)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
data = f->GetFullPath();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-14 00:07:31 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename Tag, typename DataType = std::vector<cmSourceFile const*> >
|
2014-02-14 00:07:31 +04:00
|
|
|
struct TagVisitor
|
|
|
|
{
|
|
|
|
DataType& Data;
|
|
|
|
std::vector<cmSourceFile*> BadObjLibFiles;
|
2015-08-02 20:44:31 +03:00
|
|
|
cmGeneratorTarget const* Target;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGlobalGenerator* GlobalGenerator;
|
2014-02-14 00:07:31 +04:00
|
|
|
cmsys::RegularExpression Header;
|
|
|
|
bool IsObjLib;
|
|
|
|
|
2015-08-02 20:44:31 +03:00
|
|
|
TagVisitor(cmGeneratorTarget const* target, DataType& data)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Data(data)
|
|
|
|
, Target(target)
|
|
|
|
, GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator())
|
|
|
|
, Header(CM_HEADER_REGEX)
|
|
|
|
, IsObjLib(target->GetType() == cmState::OBJECT_LIBRARY)
|
2014-02-14 00:07:31 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~TagVisitor()
|
|
|
|
{
|
|
|
|
reportBadObjLib(this->BadObjLibFiles, this->Target,
|
|
|
|
this->GlobalGenerator->GetCMakeInstance());
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void Accept(cmSourceFile* sf)
|
2014-02-14 00:07:31 +04:00
|
|
|
{
|
|
|
|
std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sf->GetCustomCommand()) {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->Target->GetType() == cmState::UTILITY) {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, ExternalObjectsTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsObjLib) {
|
2014-02-14 00:07:31 +04:00
|
|
|
this->BadObjLibFiles.push_back(sf);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (!sf->GetLanguage().empty()) {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == "def") {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, ModuleDefinitionFileTag>::Result>::Do(this->Data,
|
|
|
|
sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsObjLib) {
|
2014-02-14 00:07:31 +04:00
|
|
|
this->BadObjLibFiles.push_back(sf);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == "idl") {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, IDLSourcesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsObjLib) {
|
2014-02-14 00:07:31 +04:00
|
|
|
this->BadObjLibFiles.push_back(sf);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == "resx") {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, ResxTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == "appxmanifest") {
|
2014-08-11 22:08:49 +04:00
|
|
|
DoAccept<IsSameTag<Tag, AppManifestTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == "manifest") {
|
2015-09-16 17:24:16 +03:00
|
|
|
DoAccept<IsSameTag<Tag, ManifestsTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == "pfx") {
|
2014-08-11 22:17:12 +04:00
|
|
|
DoAccept<IsSameTag<Tag, CertificatesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (ext == "xaml") {
|
2015-03-31 23:49:39 +03:00
|
|
|
DoAccept<IsSameTag<Tag, XamlTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->Header.find(sf->GetFullPath().c_str())) {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str())) {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-14 00:07:31 +04:00
|
|
|
DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-14 00:07:31 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-08-05 00:14:53 +03:00
|
|
|
void CreatePropertyGeneratorExpressions(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStringRange const& entries, cmBacktraceRange const& backtraces,
|
|
|
|
std::vector<cmGeneratorTarget::TargetPropertyEntry*>& items,
|
|
|
|
bool evaluateForBuildsystem = false)
|
2015-08-05 00:14:53 +03:00
|
|
|
{
|
|
|
|
std::vector<cmListFileBacktrace>::const_iterator btIt = backtraces.begin();
|
|
|
|
for (std::vector<std::string>::const_iterator it = entries.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != entries.end(); ++it, ++btIt) {
|
2015-08-05 00:14:53 +03:00
|
|
|
cmGeneratorExpression ge(*btIt);
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
|
2015-08-05 00:14:53 +03:00
|
|
|
cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
|
|
|
|
items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
}
|
|
|
|
|
2015-06-06 14:14:04 +03:00
|
|
|
cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Target(t)
|
2016-06-10 17:58:36 +03:00
|
|
|
, FortranModuleDirectoryCreated(false)
|
2016-05-16 17:34:04 +03:00
|
|
|
, SourceFileFlagsConstructed(false)
|
|
|
|
, PolicyWarnedCMP0022(false)
|
|
|
|
, DebugIncludesDone(false)
|
|
|
|
, DebugCompileOptionsDone(false)
|
|
|
|
, DebugCompileFeaturesDone(false)
|
|
|
|
, DebugCompileDefinitionsDone(false)
|
|
|
|
, DebugSourcesDone(false)
|
|
|
|
, LinkImplementationLanguageIsContextDependent(true)
|
|
|
|
, UtilityItemsDone(false)
|
2012-03-07 20:44:48 +04:00
|
|
|
{
|
|
|
|
this->Makefile = this->Target->GetMakefile();
|
2015-06-06 14:14:04 +03:00
|
|
|
this->LocalGenerator = lg;
|
2015-08-02 20:42:31 +03:00
|
|
|
this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
|
2015-08-05 00:14:53 +03:00
|
|
|
|
cmGlobalGenerator: Initialize generator targets on construction (#15729)
The Ninja generator and Visual Studio generators are special-cased for the
QtAutogen feature. In order to reduce the number of custom targets, the Visual
Studio generators prefer to create custom commands instead, and in order to
create appropriate Ninja files, generated rcc files are listed as byproducts.
This requires the use of the GetConfigCommonSourceFiles API of the
cmGeneratorTarget for those generators when initializing the autogen target.
The initializer method is called from Compute() after the cmGeneratorTarget
objects are created, however the initialization of the object directory occurs
later in the InitGeneratorTargets method. That means that the resulting object
locations are computed incorrectly and cached before the object directory is
determined, so the generated buildsystem can not find the object files.
The initialization of the object directory was split from the creation of
cmGeneratorTarget instances in commit 0e0258c8 (cmGlobalGenerator: Split
creation of generator object from initialization., 2015-07-25). The motivation
for the split was to do only what is essential to do early in cases where
cmGeneratorTargets need to be created at configure-time. That is required for
the purpose of implementing policies CMP0024 and CMP0026, and for
try_compile(LINK_LIBRARIES). However, the split was not really necessary.
Compute the object directory in the cmGeneratorTarget constructor instead.
The QtAutogen unit test already tests the use of TARGET_OBJECTS with AUTOMOC,
and that test already passes on Ninja. The reason it already passes is that
the QtAutogen target also uses the AUTORCC feature, and specifies several qrc
files in its SOURCES. Later in the Compute algorithm (after the
InitGeneratorTargets call), the rcc files are determined and target->AddSource
is called. The AddSource call clears the previously mentioned cache of source
files, causing it to be regenerated when next queried, this time taking account
of the object directory.
Extend the test suite with a new target which does not make use of AUTORCC with
qrc files so that the test added alone would break without the fix in this
commit.
2015-09-26 20:48:50 +03:00
|
|
|
this->GlobalGenerator->ComputeTargetObjectDirectory(this);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
CreatePropertyGeneratorExpressions(t->GetIncludeDirectoriesEntries(),
|
|
|
|
t->GetIncludeDirectoriesBacktraces(),
|
|
|
|
this->IncludeDirectoriesEntries);
|
2015-08-05 00:43:56 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
CreatePropertyGeneratorExpressions(t->GetCompileOptionsEntries(),
|
|
|
|
t->GetCompileOptionsBacktraces(),
|
|
|
|
this->CompileOptionsEntries);
|
2015-08-05 00:48:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
CreatePropertyGeneratorExpressions(t->GetCompileFeaturesEntries(),
|
|
|
|
t->GetCompileFeaturesBacktraces(),
|
|
|
|
this->CompileFeaturesEntries);
|
2015-08-05 01:00:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
CreatePropertyGeneratorExpressions(t->GetCompileDefinitionsEntries(),
|
|
|
|
t->GetCompileDefinitionsBacktraces(),
|
|
|
|
this->CompileDefinitionsEntries);
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
CreatePropertyGeneratorExpressions(t->GetSourceEntries(),
|
|
|
|
t->GetSourceBacktraces(),
|
|
|
|
this->SourceEntries, true);
|
2015-10-20 01:44:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DLLPlatform =
|
|
|
|
(this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
|
|
|
|
this->Makefile->IsOn("MINGW"));
|
2015-10-20 02:05:42 +03:00
|
|
|
|
|
|
|
this->PolicyMap = t->PolicyMap;
|
2012-03-07 20:44:48 +04:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:42 +03:00
|
|
|
cmGeneratorTarget::~cmGeneratorTarget()
|
|
|
|
{
|
2015-08-05 00:14:53 +03:00
|
|
|
cmDeleteAll(this->IncludeDirectoriesEntries);
|
2015-08-05 00:43:56 +03:00
|
|
|
cmDeleteAll(this->CompileOptionsEntries);
|
2015-08-05 00:48:58 +03:00
|
|
|
cmDeleteAll(this->CompileFeaturesEntries);
|
2015-08-05 01:00:53 +03:00
|
|
|
cmDeleteAll(this->CompileDefinitionsEntries);
|
2015-09-13 11:18:15 +03:00
|
|
|
cmDeleteAll(this->SourceEntries);
|
2015-08-04 20:19:42 +03:00
|
|
|
cmDeleteAll(this->LinkInformation);
|
|
|
|
this->LinkInformation.clear();
|
|
|
|
}
|
|
|
|
|
2015-06-06 13:59:25 +03:00
|
|
|
cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const
|
|
|
|
{
|
|
|
|
return this->LocalGenerator;
|
|
|
|
}
|
|
|
|
|
2015-10-08 01:23:34 +03:00
|
|
|
cmState::TargetType cmGeneratorTarget::GetType() const
|
2012-09-17 14:02:24 +04:00
|
|
|
{
|
|
|
|
return this->Target->GetType();
|
|
|
|
}
|
|
|
|
|
2016-01-15 16:06:45 +03:00
|
|
|
const std::string& cmGeneratorTarget::GetName() const
|
2012-09-17 14:02:24 +04:00
|
|
|
{
|
|
|
|
return this->Target->GetName();
|
|
|
|
}
|
|
|
|
|
2015-10-17 16:08:13 +03:00
|
|
|
std::string cmGeneratorTarget::GetExportName() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* exportName = this->GetProperty("EXPORT_NAME");
|
2015-10-17 16:08:13 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (exportName && *exportName) {
|
|
|
|
if (!cmGeneratorExpression::IsValidTargetName(exportName)) {
|
2015-10-17 16:08:13 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "EXPORT_NAME property \"" << exportName << "\" for \""
|
|
|
|
<< this->GetName() << "\": is not valid.";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return "";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return exportName;
|
|
|
|
}
|
2015-10-17 16:08:13 +03:00
|
|
|
return this->GetName();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
|
2012-09-17 14:02:24 +04:00
|
|
|
{
|
|
|
|
return this->Target->GetProperty(prop);
|
|
|
|
}
|
|
|
|
|
2015-08-05 20:11:48 +03:00
|
|
|
const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetType()) {
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::SHARED_LIBRARY:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsDLLPlatform()) {
|
|
|
|
if (implib) {
|
2015-08-05 20:11:48 +03:00
|
|
|
// A DLL import library is treated as an archive target.
|
|
|
|
return "ARCHIVE";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 20:11:48 +03:00
|
|
|
// A DLL shared library is treated as a runtime target.
|
|
|
|
return "RUNTIME";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 20:11:48 +03:00
|
|
|
// For non-DLL platforms shared libraries are treated as
|
|
|
|
// library targets.
|
|
|
|
return "LIBRARY";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::STATIC_LIBRARY:
|
2015-08-05 20:11:48 +03:00
|
|
|
// Static libraries are always treated as archive targets.
|
|
|
|
return "ARCHIVE";
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::MODULE_LIBRARY:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (implib) {
|
2015-08-05 20:11:48 +03:00
|
|
|
// Module libraries are always treated as library targets.
|
|
|
|
return "ARCHIVE";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 20:11:48 +03:00
|
|
|
// Module import libraries are treated as archive targets.
|
|
|
|
return "LIBRARY";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::EXECUTABLE:
|
2016-05-16 17:34:04 +03:00
|
|
|
if (implib) {
|
2015-08-05 20:11:48 +03:00
|
|
|
// Executable import libraries are treated as archive targets.
|
|
|
|
return "ARCHIVE";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 20:11:48 +03:00
|
|
|
// Executables are always treated as runtime targets.
|
|
|
|
return "RUNTIME";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:11:48 +03:00
|
|
|
default:
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:11:48 +03:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:50 +03:00
|
|
|
std::string cmGeneratorTarget::GetOutputName(const std::string& config,
|
|
|
|
bool implib) const
|
|
|
|
{
|
2015-08-14 23:35:58 +03:00
|
|
|
// Lookup/compute/cache the output name for this configuration.
|
|
|
|
OutputNameKey key(config, implib);
|
|
|
|
cmGeneratorTarget::OutputNameMapType::iterator i =
|
|
|
|
this->OutputNameMap.find(key);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == this->OutputNameMap.end()) {
|
2015-08-14 23:35:58 +03:00
|
|
|
// Add empty name in map to detect potential recursion.
|
|
|
|
OutputNameMapType::value_type entry(key, "");
|
|
|
|
i = this->OutputNameMap.insert(entry).first;
|
2015-08-04 20:19:50 +03:00
|
|
|
|
2015-08-14 23:35:58 +03:00
|
|
|
// Compute output name.
|
|
|
|
std::vector<std::string> props;
|
2015-08-05 20:11:48 +03:00
|
|
|
std::string type = this->GetOutputTargetType(implib);
|
2015-08-14 23:35:58 +03:00
|
|
|
std::string configUpper = cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!type.empty() && !configUpper.empty()) {
|
2015-08-14 23:35:58 +03:00
|
|
|
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
|
|
|
|
props.push_back(type + "_OUTPUT_NAME_" + configUpper);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!type.empty()) {
|
2015-08-14 23:35:58 +03:00
|
|
|
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME
|
|
|
|
props.push_back(type + "_OUTPUT_NAME");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!configUpper.empty()) {
|
2015-08-14 23:35:58 +03:00
|
|
|
// OUTPUT_NAME_<CONFIG>
|
|
|
|
props.push_back("OUTPUT_NAME_" + configUpper);
|
|
|
|
// <CONFIG>_OUTPUT_NAME
|
|
|
|
props.push_back(configUpper + "_OUTPUT_NAME");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-14 23:35:58 +03:00
|
|
|
// OUTPUT_NAME
|
|
|
|
props.push_back("OUTPUT_NAME");
|
2015-08-04 20:19:50 +03:00
|
|
|
|
2015-08-14 23:35:58 +03:00
|
|
|
std::string outName;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator it = props.begin();
|
|
|
|
it != props.end(); ++it) {
|
|
|
|
if (const char* outNameProp = this->GetProperty(*it)) {
|
2015-08-14 23:35:58 +03:00
|
|
|
outName = outNameProp;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-14 23:35:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (outName.empty()) {
|
2015-08-14 23:35:58 +03:00
|
|
|
outName = this->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-14 23:35:58 +03:00
|
|
|
|
|
|
|
// Now evaluate genex and update the previously-prepared map entry.
|
|
|
|
cmGeneratorExpression ge;
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
|
2015-07-25 17:56:52 +03:00
|
|
|
i->second = cge->Evaluate(this->LocalGenerator, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (i->second.empty()) {
|
2015-08-14 23:35:58 +03:00
|
|
|
// An empty map entry indicates we have been called recursively
|
|
|
|
// from the above block.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
|
2015-08-14 23:35:58 +03:00
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.",
|
2015-10-19 23:39:08 +03:00
|
|
|
this->GetBacktrace());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-14 23:35:58 +03:00
|
|
|
return i->second;
|
2015-08-04 20:19:50 +03:00
|
|
|
}
|
|
|
|
|
2015-08-29 19:10:19 +03:00
|
|
|
void cmGeneratorTarget::AddSource(const std::string& src)
|
|
|
|
{
|
2015-09-13 11:18:15 +03:00
|
|
|
this->Target->AddSource(src);
|
|
|
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
|
|
|
cmGeneratorExpression ge(lfbt);
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src);
|
2015-09-13 11:18:15 +03:00
|
|
|
cge->SetEvaluateForBuildsystem(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SourceEntries.push_back(new TargetPropertyEntry(cge));
|
2015-09-13 11:18:15 +03:00
|
|
|
this->SourceFilesMap.clear();
|
|
|
|
this->LinkImplementationLanguageIsContextDependent = true;
|
2015-08-29 19:10:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs)
|
|
|
|
{
|
|
|
|
this->Target->AddTracedSources(srcs);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!srcs.empty()) {
|
2015-09-13 11:18:15 +03:00
|
|
|
std::string srcFiles = cmJoin(srcs, ";");
|
|
|
|
this->SourceFilesMap.clear();
|
|
|
|
this->LinkImplementationLanguageIsContextDependent = true;
|
|
|
|
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
|
|
|
|
cmGeneratorExpression ge(lfbt);
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
|
2015-09-13 11:18:15 +03:00
|
|
|
cge->SetEvaluateForBuildsystem(true);
|
|
|
|
this->SourceEntries.push_back(
|
2016-05-16 17:34:04 +03:00
|
|
|
new cmGeneratorTarget::TargetPropertyEntry(cge));
|
|
|
|
}
|
2015-08-29 19:10:19 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
|
|
|
|
cmSourceFile const* sf) const
|
2012-10-11 02:57:11 +04:00
|
|
|
{
|
2015-08-29 19:47:14 +03:00
|
|
|
SourceEntriesType::const_iterator i = this->SourceDepends.find(sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != this->SourceDepends.end()) {
|
2012-10-11 02:57:11 +04:00
|
|
|
return &i->second.Depends;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void handleSystemIncludesDep(
|
|
|
|
cmLocalGenerator* lg, cmGeneratorTarget const* depTgt,
|
|
|
|
const std::string& config, cmGeneratorTarget const* headTarget,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker,
|
|
|
|
std::vector<std::string>& result, bool excludeImported)
|
2014-01-01 18:49:05 +04:00
|
|
|
{
|
|
|
|
if (const char* dirs =
|
2016-05-16 17:34:04 +03:00
|
|
|
depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
|
2014-05-23 22:59:11 +04:00
|
|
|
cmGeneratorExpression ge;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt,
|
|
|
|
dagChecker),
|
|
|
|
result);
|
|
|
|
}
|
|
|
|
if (!depTgt->IsImported() || excludeImported) {
|
2014-01-01 18:49:05 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-01 18:49:05 +04:00
|
|
|
|
|
|
|
if (const char* dirs =
|
2016-05-16 17:34:04 +03:00
|
|
|
depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
|
2014-05-23 22:59:11 +04:00
|
|
|
cmGeneratorExpression ge;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt,
|
|
|
|
dagChecker),
|
|
|
|
result);
|
|
|
|
}
|
2014-01-01 18:49:05 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 21:44:13 +03:00
|
|
|
/* clang-format off */
|
|
|
|
#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \
|
|
|
|
{ \
|
|
|
|
std::vector<cmSourceFile*> sourceFiles; \
|
|
|
|
this->GetSourceFiles(sourceFiles, config); \
|
|
|
|
TagVisitor< DATA##Tag DATATYPE > visitor(this, data); \
|
|
|
|
for (std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \
|
|
|
|
si != sourceFiles.end(); ++si) { \
|
|
|
|
visitor.Accept(*si); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
/* clang-format on */
|
2014-02-14 00:07:31 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define IMPLEMENT_VISIT(DATA) IMPLEMENT_VISIT_IMPL(DATA, EMPTY)
|
2014-02-14 00:07:31 +04:00
|
|
|
|
|
|
|
#define EMPTY
|
|
|
|
#define COMMA ,
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetObjectSources(
|
|
|
|
std::vector<cmSourceFile const*>& data, const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
IMPLEMENT_VISIT(ObjectSources);
|
2014-03-14 16:21:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Objects.empty()) {
|
2014-03-14 16:21:26 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-14 16:21:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile const*>::const_iterator it = data.begin();
|
|
|
|
it != data.end(); ++it) {
|
2014-03-14 16:21:26 +04:00
|
|
|
this->Objects[*it];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-14 16:21:26 +04:00
|
|
|
|
|
|
|
this->LocalGenerator->ComputeObjectFilenames(this->Objects, this);
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2014-03-14 16:21:26 +04:00
|
|
|
void cmGeneratorTarget::ComputeObjectMapping()
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Objects.empty()) {
|
2014-03-14 16:21:26 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-13 20:25:00 +04:00
|
|
|
|
|
|
|
std::vector<std::string> configs;
|
|
|
|
this->Makefile->GetConfigurations(configs);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configs.empty()) {
|
2014-02-13 20:25:00 +04:00
|
|
|
configs.push_back("");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator ci = configs.begin();
|
|
|
|
ci != configs.end(); ++ci) {
|
2014-02-13 20:25:00 +04:00
|
|
|
std::vector<cmSourceFile const*> sourceFiles;
|
|
|
|
this->GetObjectSources(sourceFiles, *ci);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2015-06-06 16:40:26 +03:00
|
|
|
const char* cmGeneratorTarget::GetFeature(const std::string& feature,
|
|
|
|
const std::string& config) const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-06-06 16:40:26 +03:00
|
|
|
std::string featureConfig = feature;
|
|
|
|
featureConfig += "_";
|
|
|
|
featureConfig += cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* value = this->GetProperty(featureConfig)) {
|
2015-06-06 16:40:26 +03:00
|
|
|
return value;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (const char* value = this->GetProperty(feature)) {
|
2015-06-06 16:40:26 +03:00
|
|
|
return value;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-06 16:42:31 +03:00
|
|
|
return this->LocalGenerator->GetFeature(feature, config);
|
2015-06-06 16:40:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::GetFeatureAsBool(const std::string& feature,
|
|
|
|
const std::string& config) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::IsOn(this->GetFeature(feature, config));
|
|
|
|
}
|
|
|
|
|
2014-03-14 16:21:26 +04:00
|
|
|
const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-03-14 16:21:26 +04:00
|
|
|
this->ComputeObjectMapping();
|
|
|
|
return this->Objects[file];
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2014-03-13 15:28:32 +04:00
|
|
|
void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf)
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
|
|
|
this->ExplicitObjectName.insert(sf);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
|
|
|
|
{
|
2014-03-14 16:21:26 +04:00
|
|
|
const_cast<cmGeneratorTarget*>(this)->ComputeObjectMapping();
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set<cmSourceFile const*>::const_iterator it =
|
|
|
|
this->ExplicitObjectName.find(file);
|
2013-11-10 14:22:44 +04:00
|
|
|
return it != this->ExplicitObjectName.end();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile const*>& data,
|
|
|
|
const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
IMPLEMENT_VISIT(IDLSources);
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetHeaderSources(
|
|
|
|
std::vector<cmSourceFile const*>& data, const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
IMPLEMENT_VISIT(HeaderSources);
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile const*>& data,
|
|
|
|
const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
IMPLEMENT_VISIT(ExtraSources);
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetCustomCommands(
|
|
|
|
std::vector<cmSourceFile const*>& data, const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
IMPLEMENT_VISIT(CustomCommands);
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetExternalObjects(
|
|
|
|
std::vector<cmSourceFile const*>& data, const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
IMPLEMENT_VISIT(ExternalObjects);
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
|
|
|
|
const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
ResxData data;
|
|
|
|
IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
|
|
|
|
srcs = data.ExpectedResxHeaders;
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile const*>& srcs,
|
|
|
|
const std::string& config) const
|
2013-11-10 14:22:44 +04:00
|
|
|
{
|
2014-02-14 00:07:31 +04:00
|
|
|
ResxData data;
|
|
|
|
IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
|
|
|
|
srcs = data.ResxSources;
|
2013-11-10 14:22:44 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetAppManifest(std::vector<cmSourceFile const*>& data,
|
|
|
|
const std::string& config) const
|
2014-08-11 22:08:49 +04:00
|
|
|
{
|
|
|
|
IMPLEMENT_VISIT(AppManifest);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetManifests(std::vector<cmSourceFile const*>& data,
|
|
|
|
const std::string& config) const
|
2015-09-16 17:24:16 +03:00
|
|
|
{
|
|
|
|
IMPLEMENT_VISIT(Manifests);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetCertificates(std::vector<cmSourceFile const*>& data,
|
|
|
|
const std::string& config) const
|
2014-08-11 22:17:12 +04:00
|
|
|
{
|
|
|
|
IMPLEMENT_VISIT(Certificates);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetExpectedXamlHeaders(std::set<std::string>& headers,
|
|
|
|
const std::string& config) const
|
2015-03-31 23:49:39 +03:00
|
|
|
{
|
|
|
|
XamlData data;
|
|
|
|
IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
|
|
|
|
headers = data.ExpectedXamlHeaders;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs,
|
|
|
|
const std::string& config) const
|
2015-03-31 23:49:39 +03:00
|
|
|
{
|
|
|
|
XamlData data;
|
|
|
|
IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
|
2016-05-16 17:34:04 +03:00
|
|
|
srcs = data.ExpectedXamlSources;
|
2015-10-08 02:01:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->UtilityItemsDone) {
|
2015-10-08 02:01:38 +03:00
|
|
|
this->UtilityItemsDone = true;
|
2015-10-23 02:01:46 +03:00
|
|
|
std::set<std::string> const& utilities = this->GetUtilities();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<std::string>::const_iterator i = utilities.begin();
|
|
|
|
i != utilities.end(); ++i) {
|
2015-10-16 20:19:49 +03:00
|
|
|
cmGeneratorTarget* gt =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->FindGeneratorTargetToUse(*i);
|
2015-10-08 02:18:42 +03:00
|
|
|
this->UtilityItems.insert(cmLinkItem(*i, gt));
|
2015-10-08 02:01:38 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-08 02:01:38 +03:00
|
|
|
return this->UtilityItems;
|
2015-03-31 23:49:39 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetXamlSources(std::vector<cmSourceFile const*>& srcs,
|
|
|
|
const std::string& config) const
|
2015-03-31 23:49:39 +03:00
|
|
|
{
|
|
|
|
XamlData data;
|
|
|
|
IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
|
|
|
|
srcs = data.XamlSources;
|
|
|
|
}
|
|
|
|
|
2013-10-28 22:47:46 +04:00
|
|
|
const char* cmGeneratorTarget::GetLocation(const std::string& config) const
|
|
|
|
{
|
|
|
|
static std::string location;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2013-10-28 22:47:46 +04:00
|
|
|
location = this->Target->ImportedGetFullPath(config, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-10-06 20:30:43 +04:00
|
|
|
location = this->GetFullPath(config, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-10-28 22:47:46 +04:00
|
|
|
return location.c_str();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPreBuildCommands()
|
|
|
|
const
|
2015-10-23 01:42:58 +03:00
|
|
|
{
|
|
|
|
return this->Target->GetPreBuildCommands();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPreLinkCommands()
|
|
|
|
const
|
2015-10-23 01:42:58 +03:00
|
|
|
{
|
|
|
|
return this->Target->GetPreLinkCommands();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPostBuildCommands()
|
|
|
|
const
|
2015-10-23 01:42:58 +03:00
|
|
|
{
|
|
|
|
return this->Target->GetPostBuildCommands();
|
|
|
|
}
|
|
|
|
|
2013-10-28 22:47:46 +04:00
|
|
|
bool cmGeneratorTarget::IsImported() const
|
|
|
|
{
|
|
|
|
return this->Target->IsImported();
|
|
|
|
}
|
|
|
|
|
2015-10-25 15:06:37 +03:00
|
|
|
bool cmGeneratorTarget::IsImportedGloballyVisible() const
|
|
|
|
{
|
|
|
|
return this->Target->IsImportedGloballyVisible();
|
|
|
|
}
|
|
|
|
|
2014-03-10 19:57:02 +04:00
|
|
|
const char* cmGeneratorTarget::GetLocationForBuild() const
|
|
|
|
{
|
|
|
|
static std::string location;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2014-03-10 19:57:02 +04:00
|
|
|
location = this->Target->ImportedGetFullPath("", false);
|
|
|
|
return location.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-10 19:57:02 +04:00
|
|
|
|
|
|
|
// Now handle the deprecated build-time configuration location.
|
2014-10-20 22:31:47 +04:00
|
|
|
location = this->GetDirectory();
|
2014-03-10 19:57:02 +04:00
|
|
|
const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cfgid && strcmp(cfgid, ".") != 0) {
|
2014-03-10 19:57:02 +04:00
|
|
|
location += "/";
|
|
|
|
location += cfgid;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-10 19:57:02 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsAppBundleOnApple()) {
|
|
|
|
std::string macdir = this->BuildMacContentDirectory("", "", false);
|
|
|
|
if (!macdir.empty()) {
|
2014-03-10 19:57:02 +04:00
|
|
|
location += "/";
|
|
|
|
location += macdir;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-10 19:57:02 +04:00
|
|
|
location += "/";
|
2015-08-04 20:19:48 +03:00
|
|
|
location += this->GetFullName("", false);
|
2014-03-10 19:57:02 +04:00
|
|
|
return location.c_str();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmGeneratorTarget::IsSystemIncludeDirectory(
|
|
|
|
const std::string& dir, const std::string& config) const
|
2013-07-02 00:28:26 +04:00
|
|
|
{
|
2015-10-08 01:21:51 +03:00
|
|
|
assert(this->GetType() != cmState::INTERFACE_LIBRARY);
|
2013-07-02 16:30:10 +04:00
|
|
|
std::string config_upper;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2013-07-02 16:30:10 +04:00
|
|
|
config_upper = cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-07-02 16:30:10 +04:00
|
|
|
|
|
|
|
typedef std::map<std::string, std::vector<std::string> > IncludeCacheType;
|
2013-11-03 17:10:12 +04:00
|
|
|
IncludeCacheType::const_iterator iter =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SystemIncludesCache.find(config_upper);
|
2013-07-02 00:55:25 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (iter == this->SystemIncludesCache.end()) {
|
2014-05-23 22:59:11 +04:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(
|
2016-06-27 23:44:16 +03:00
|
|
|
this->GetName(), "SYSTEM_INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR);
|
2014-01-01 18:49:05 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
|
2014-01-08 03:38:54 +04:00
|
|
|
|
2013-07-02 16:30:10 +04:00
|
|
|
std::vector<std::string> result;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<std::string>::const_iterator it =
|
|
|
|
this->Target->GetSystemIncludeDirectories().begin();
|
|
|
|
it != this->Target->GetSystemIncludeDirectories().end(); ++it) {
|
2014-05-23 22:59:11 +04:00
|
|
|
cmGeneratorExpression ge;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
ge.Parse(*it)->Evaluate(this->LocalGenerator, config, false, this,
|
|
|
|
&dagChecker),
|
|
|
|
result);
|
|
|
|
}
|
2014-01-01 18:49:05 +04:00
|
|
|
|
2015-10-08 02:45:44 +03:00
|
|
|
std::vector<cmGeneratorTarget const*> const& deps =
|
2015-08-04 20:19:44 +03:00
|
|
|
this->GetLinkImplementationClosure(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget const *>::const_iterator
|
|
|
|
li = deps.begin(),
|
|
|
|
le = deps.end();
|
|
|
|
li != le; ++li) {
|
2015-09-16 05:38:52 +03:00
|
|
|
handleSystemIncludesDep(this->LocalGenerator, *li, config, this,
|
2014-07-15 19:39:36 +04:00
|
|
|
&dagChecker, result, excludeImported);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-07-15 19:39:36 +04:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> unique;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator li = result.begin();
|
|
|
|
li != result.end(); ++li) {
|
2013-08-29 12:28:52 +04:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(*li);
|
2014-01-01 18:49:05 +04:00
|
|
|
unique.insert(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-01 18:49:05 +04:00
|
|
|
result.clear();
|
2014-11-22 13:00:45 +03:00
|
|
|
result.insert(result.end(), unique.begin(), unique.end());
|
2013-08-29 12:28:52 +04:00
|
|
|
|
2013-07-02 16:30:10 +04:00
|
|
|
IncludeCacheType::value_type entry(config_upper, result);
|
|
|
|
iter = this->SystemIncludesCache.insert(entry).first;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-07-02 16:30:10 +04:00
|
|
|
|
2014-08-06 17:20:24 +04:00
|
|
|
return std::binary_search(iter->second.begin(), iter->second.end(), dir);
|
2013-07-02 00:28:26 +04:00
|
|
|
}
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
|
2012-09-17 14:02:24 +04:00
|
|
|
{
|
|
|
|
return this->Target->GetPropertyAsBool(prop);
|
|
|
|
}
|
|
|
|
|
2015-09-13 10:45:41 +03:00
|
|
|
static void AddInterfaceEntries(
|
|
|
|
cmGeneratorTarget const* thisTarget, std::string const& config,
|
|
|
|
std::string const& prop,
|
|
|
|
std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmLinkImplementationLibraries const* impl =
|
|
|
|
thisTarget->GetLinkImplementationLibraries(config)) {
|
2015-09-13 10:45:41 +03:00
|
|
|
for (std::vector<cmLinkImplItem>::const_iterator
|
2016-05-16 17:34:04 +03:00
|
|
|
it = impl->Libraries.begin(),
|
|
|
|
end = impl->Libraries.end();
|
|
|
|
it != end; ++it) {
|
|
|
|
if (it->Target) {
|
|
|
|
std::string genex = "$<TARGET_PROPERTY:" + *it + "," + prop + ">";
|
2015-09-13 10:45:41 +03:00
|
|
|
cmGeneratorExpression ge(it->Backtrace);
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
|
2015-09-13 10:45:41 +03:00
|
|
|
cge->SetEvaluateForBuildsystem(true);
|
|
|
|
entries.push_back(
|
|
|
|
new cmGeneratorTarget::TargetPropertyEntry(cge, *it));
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-13 10:45:41 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static bool processSources(
|
|
|
|
cmGeneratorTarget const* tgt,
|
|
|
|
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
|
|
|
|
std::vector<std::string>& srcs, UNORDERED_SET<std::string>& uniqueSrcs,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config,
|
|
|
|
bool debugSources)
|
2015-09-13 11:18:15 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakefile* mf = tgt->Target->GetMakefile();
|
2015-09-13 11:18:15 +03:00
|
|
|
|
|
|
|
bool contextDependent = false;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
|
|
|
|
it = entries.begin(),
|
|
|
|
end = entries.end();
|
|
|
|
it != end; ++it) {
|
2015-09-13 11:18:15 +03:00
|
|
|
cmLinkImplItem const& item = (*it)->LinkImplItem;
|
|
|
|
std::string const& targetName = item;
|
|
|
|
std::vector<std::string> entrySources;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
(*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt, tgt,
|
|
|
|
dagChecker),
|
|
|
|
entrySources);
|
|
|
|
|
|
|
|
if ((*it)->ge->GetHadContextSensitiveCondition()) {
|
2015-09-13 11:18:15 +03:00
|
|
|
contextDependent = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator i = entrySources.begin();
|
|
|
|
i != entrySources.end(); ++i) {
|
2015-09-13 11:18:15 +03:00
|
|
|
std::string& src = *i;
|
|
|
|
cmSourceFile* sf = mf->GetOrCreateSource(src);
|
|
|
|
std::string e;
|
|
|
|
std::string fullPath = sf->GetFullPath(&e);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fullPath.empty()) {
|
|
|
|
if (!e.empty()) {
|
2015-10-16 20:19:49 +03:00
|
|
|
cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance();
|
2016-05-16 17:34:04 +03:00
|
|
|
cm->IssueMessage(cmake::FATAL_ERROR, e, tgt->GetBacktrace());
|
2015-09-13 11:18:15 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return contextDependent;
|
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) {
|
2015-09-13 11:18:15 +03:00
|
|
|
std::ostringstream err;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!targetName.empty()) {
|
|
|
|
err << "Target \"" << targetName
|
|
|
|
<< "\" contains relative "
|
|
|
|
"path in its INTERFACE_SOURCES:\n"
|
|
|
|
" \""
|
|
|
|
<< src << "\"";
|
|
|
|
} else {
|
2015-09-13 11:18:15 +03:00
|
|
|
err << "Found relative path while evaluating sources of "
|
2016-05-16 17:34:04 +03:00
|
|
|
"\""
|
|
|
|
<< tgt->GetName() << "\":\n \"" << src << "\"\n";
|
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
tgt->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, err.str());
|
|
|
|
return contextDependent;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
src = fullPath;
|
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
std::string usedSources;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator li = entrySources.begin();
|
|
|
|
li != entrySources.end(); ++li) {
|
2015-09-13 11:18:15 +03:00
|
|
|
std::string src = *li;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (uniqueSrcs.insert(src).second) {
|
2015-09-13 11:18:15 +03:00
|
|
|
srcs.push_back(src);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (debugSources) {
|
2015-09-13 11:18:15 +03:00
|
|
|
usedSources += " * " + src + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!usedSources.empty()) {
|
|
|
|
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
|
|
|
|
cmake::LOG, std::string("Used sources for target ") + tgt->GetName() +
|
|
|
|
":\n" + usedSources,
|
|
|
|
(*it)->ge->GetBacktrace());
|
|
|
|
}
|
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
return contextDependent;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
|
|
|
|
const std::string& config) const
|
2015-09-13 11:18:15 +03:00
|
|
|
{
|
2015-10-08 01:21:51 +03:00
|
|
|
assert(this->GetType() != cmState::INTERFACE_LIBRARY);
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
|
2015-09-13 11:18:15 +03:00
|
|
|
// At configure-time, this method can be called as part of getting the
|
|
|
|
// LOCATION property or to export() a file to be include()d. However
|
|
|
|
// there is no cmGeneratorTarget at configure-time, so search the SOURCES
|
|
|
|
// for TARGET_OBJECTS instead for backwards compatibility with OLD
|
|
|
|
// behavior of CMP0024 and CMP0026 only.
|
|
|
|
|
|
|
|
cmStringRange sourceEntries = this->Target->GetSourceEntries();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmStringRange::const_iterator i = sourceEntries.begin();
|
|
|
|
i != sourceEntries.end(); ++i) {
|
2015-09-13 11:18:15 +03:00
|
|
|
std::string const& entry = *i;
|
|
|
|
|
|
|
|
std::vector<std::string> items;
|
|
|
|
cmSystemTools::ExpandListArgument(entry, items);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator li = items.begin();
|
|
|
|
li != items.end(); ++li) {
|
|
|
|
if (cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
|
|
|
|
(*li)[li->size() - 1] == '>') {
|
2015-09-13 11:18:15 +03:00
|
|
|
continue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
files.push_back(*li);
|
2015-09-13 11:18:15 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
|
|
|
|
std::vector<std::string> debugProperties;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* debugProp =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
|
|
|
|
if (debugProp) {
|
2015-09-13 11:18:15 +03:00
|
|
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool debugSources = !this->DebugSourcesDone &&
|
|
|
|
std::find(debugProperties.begin(), debugProperties.end(), "SOURCES") !=
|
|
|
|
debugProperties.end();
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
|
2015-09-13 11:18:15 +03:00
|
|
|
this->DebugSourcesDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES",
|
|
|
|
CM_NULLPTR, CM_NULLPTR);
|
2015-09-13 11:18:15 +03:00
|
|
|
|
|
|
|
UNORDERED_SET<std::string> uniqueSrcs;
|
2016-05-16 17:34:04 +03:00
|
|
|
bool contextDependentDirectSources =
|
|
|
|
processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker,
|
|
|
|
config, debugSources);
|
2015-09-13 11:18:15 +03:00
|
|
|
|
|
|
|
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
|
|
|
|
linkInterfaceSourcesEntries;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
AddInterfaceEntries(this, config, "INTERFACE_SOURCES",
|
|
|
|
linkInterfaceSourcesEntries);
|
2015-09-13 11:18:15 +03:00
|
|
|
|
|
|
|
std::vector<std::string>::size_type numFilesBefore = files.size();
|
2016-05-16 17:34:04 +03:00
|
|
|
bool contextDependentInterfaceSources =
|
|
|
|
processSources(this, linkInterfaceSourcesEntries, files, uniqueSrcs,
|
|
|
|
&dagChecker, config, debugSources);
|
|
|
|
|
|
|
|
if (!contextDependentDirectSources &&
|
|
|
|
!(contextDependentInterfaceSources && numFilesBefore < files.size())) {
|
2015-09-13 11:18:15 +03:00
|
|
|
this->LinkImplementationLanguageIsContextDependent = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-13 11:18:15 +03:00
|
|
|
|
|
|
|
cmDeleteAll(linkInterfaceSourcesEntries);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files,
|
2014-02-13 20:25:00 +04:00
|
|
|
const std::string& config) const
|
2012-09-17 14:02:24 +04:00
|
|
|
{
|
2015-09-13 11:18:15 +03:00
|
|
|
|
2015-09-13 10:57:43 +03:00
|
|
|
// Lookup any existing link implementation for this configuration.
|
|
|
|
std::string key = cmSystemTools::UpperCase(config);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->LinkImplementationLanguageIsContextDependent) {
|
2015-09-13 11:18:15 +03:00
|
|
|
files = this->SourceFilesMap.begin()->second;
|
2015-09-13 10:57:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-13 10:57:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
SourceFilesMapType::iterator it = this->SourceFilesMap.find(key);
|
|
|
|
if (it != this->SourceFilesMap.end()) {
|
2015-09-13 10:57:43 +03:00
|
|
|
files = it->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-09-13 10:57:43 +03:00
|
|
|
std::vector<std::string> srcs;
|
2015-09-13 11:18:15 +03:00
|
|
|
this->GetSourceFiles(srcs, config);
|
2015-09-13 10:57:43 +03:00
|
|
|
|
|
|
|
std::set<cmSourceFile*> emitted;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = srcs.begin();
|
|
|
|
i != srcs.end(); ++i) {
|
2015-09-13 10:57:43 +03:00
|
|
|
cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emitted.insert(sf).second) {
|
2015-09-13 10:57:43 +03:00
|
|
|
files.push_back(sf);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SourceFilesMap[key] = files;
|
|
|
|
}
|
2012-09-17 14:02:24 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetCompilePDBName(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:45 +03:00
|
|
|
{
|
|
|
|
std::string prefix;
|
|
|
|
std::string base;
|
|
|
|
std::string suffix;
|
2015-08-04 20:19:48 +03:00
|
|
|
this->GetFullNameInternal(config, false, prefix, base, suffix);
|
2015-08-04 20:19:45 +03:00
|
|
|
|
|
|
|
// Check for a per-configuration output directory target property.
|
|
|
|
std::string configUpper = cmSystemTools::UpperCase(config);
|
|
|
|
std::string configProp = "COMPILE_PDB_NAME_";
|
|
|
|
configProp += configUpper;
|
2015-10-07 22:50:29 +03:00
|
|
|
const char* config_name = this->GetProperty(configProp);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (config_name && *config_name) {
|
2015-08-04 20:19:45 +03:00
|
|
|
return prefix + config_name + ".pdb";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:45 +03:00
|
|
|
|
2015-10-07 22:50:29 +03:00
|
|
|
const char* name = this->GetProperty("COMPILE_PDB_NAME");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name && *name) {
|
2015-08-04 20:19:45 +03:00
|
|
|
return prefix + name + ".pdb";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:45 +03:00
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetCompilePDBPath(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:45 +03:00
|
|
|
{
|
2015-08-04 20:19:51 +03:00
|
|
|
std::string dir = this->GetCompilePDBDirectory(config);
|
2015-08-04 20:19:45 +03:00
|
|
|
std::string name = this->GetCompilePDBName(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dir.empty() && !name.empty()) {
|
2015-08-05 19:39:17 +03:00
|
|
|
dir = this->GetPDBDirectory(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!dir.empty()) {
|
2015-08-04 20:19:45 +03:00
|
|
|
dir += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:45 +03:00
|
|
|
return dir + name;
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:45 +03:00
|
|
|
bool cmGeneratorTarget::HasSOName(const std::string& config) const
|
|
|
|
{
|
|
|
|
// soname is supported only for shared libraries and modules,
|
|
|
|
// and then only when the platform supports an soname flag.
|
2015-10-08 01:21:51 +03:00
|
|
|
return ((this->GetType() == cmState::SHARED_LIBRARY) &&
|
2015-08-04 20:19:45 +03:00
|
|
|
!this->GetPropertyAsBool("NO_SONAME") &&
|
2015-08-04 20:19:49 +03:00
|
|
|
this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config)));
|
2015-08-04 20:19:45 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmGeneratorTarget::NeedRelinkBeforeInstall(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:46 +03:00
|
|
|
{
|
|
|
|
// Only executables and shared libraries can have an rpath and may
|
|
|
|
// need relinking.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() != cmState::EXECUTABLE &&
|
|
|
|
this->GetType() != cmState::SHARED_LIBRARY &&
|
|
|
|
this->GetType() != cmState::MODULE_LIBRARY) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// If there is no install location this target will not be installed
|
|
|
|
// and therefore does not need relinking.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Target->GetHaveInstallRule()) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// If skipping all rpaths completely then no relinking is needed.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_SKIP_RPATH")) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// If building with the install-tree rpath no relinking is needed.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// If chrpath is going to be used no relinking is needed.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsChrpathUsed(config)) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// Check for rpath support on this platform.
|
2015-08-04 20:19:49 +03:00
|
|
|
std::string ll = this->GetLinkerLanguage(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ll.empty()) {
|
2015-08-04 20:19:46 +03:00
|
|
|
std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
|
|
|
flagVar += ll;
|
|
|
|
flagVar += "_FLAG";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->IsSet(flagVar)) {
|
2015-08-04 20:19:46 +03:00
|
|
|
// There is no rpath support on this platform so nothing needs
|
|
|
|
// relinking.
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:46 +03:00
|
|
|
// No linker language is known. This error will be reported by
|
|
|
|
// other code.
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// If either a build or install tree rpath is set then the rpath
|
|
|
|
// will likely change between the build tree and install tree and
|
|
|
|
// this target must be relinked.
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH();
|
2015-08-04 20:19:46 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:46 +03:00
|
|
|
bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
|
|
|
|
{
|
|
|
|
// Only certain target types have an rpath.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!(this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::MODULE_LIBRARY ||
|
|
|
|
this->GetType() == cmState::EXECUTABLE)) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// If the target will not be installed we do not need to change its
|
|
|
|
// rpath.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Target->GetHaveInstallRule()) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// Skip chrpath if skipping rpath altogether.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_SKIP_RPATH")) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// Skip chrpath if it does not need to be changed at install time.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// Allow the user to disable builtin chrpath explicitly.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
#if defined(CMAKE_USE_ELF_PARSER)
|
|
|
|
// Enable if the rpath flag uses a separator and the target uses ELF
|
|
|
|
// binaries.
|
2015-08-04 20:19:49 +03:00
|
|
|
std::string ll = this->GetLinkerLanguage(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ll.empty()) {
|
2015-08-04 20:19:46 +03:00
|
|
|
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
|
|
|
|
sepVar += ll;
|
|
|
|
sepVar += "_FLAG_SEP";
|
|
|
|
const char* sep = this->Makefile->GetDefinition(sepVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sep && *sep) {
|
2015-08-04 20:19:46 +03:00
|
|
|
// TODO: Add ELF check to ABI detection and get rid of
|
|
|
|
// CMAKE_EXECUTABLE_FORMAT.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* fmt =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) {
|
2015-08-04 20:19:46 +03:00
|
|
|
return strcmp(fmt, "ELF") == 0;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
#endif
|
|
|
|
static_cast<void>(config);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-05 20:19:50 +03:00
|
|
|
bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-05 20:19:50 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY) {
|
|
|
|
if (cmGeneratorTarget::ImportInfo const* info =
|
|
|
|
this->GetImportInfo(config)) {
|
2015-08-05 20:19:50 +03:00
|
|
|
return info->NoSOName;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:19:50 +03:00
|
|
|
return false;
|
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
2015-08-05 20:07:03 +03:00
|
|
|
bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-05 20:07:03 +03:00
|
|
|
{
|
|
|
|
bool install_name_is_rpath = false;
|
|
|
|
bool macosx_rpath = false;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->IsImported()) {
|
|
|
|
if (this->GetType() != cmState::SHARED_LIBRARY) {
|
2015-08-05 20:07:03 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
|
|
|
|
bool use_install_name =
|
|
|
|
this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (install_name && use_install_name &&
|
|
|
|
std::string(install_name) == "@rpath") {
|
2015-08-05 20:07:03 +03:00
|
|
|
install_name_is_rpath = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (install_name && use_install_name) {
|
2015-08-05 20:07:03 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!install_name_is_rpath) {
|
2015-08-05 20:07:03 +03:00
|
|
|
macosx_rpath = this->MacOSXRpathInstallNameDirDefault();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 20:07:03 +03:00
|
|
|
// Lookup the imported soname.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorTarget::ImportInfo const* info =
|
|
|
|
this->GetImportInfo(config)) {
|
|
|
|
if (!info->NoSOName && !info->SOName.empty()) {
|
|
|
|
if (info->SOName.find("@rpath/") == 0) {
|
2015-08-05 20:07:03 +03:00
|
|
|
install_name_is_rpath = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 20:07:03 +03:00
|
|
|
std::string install_name;
|
|
|
|
cmSystemTools::GuessLibraryInstallName(info->Location, install_name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (install_name.find("@rpath") != std::string::npos) {
|
2015-08-05 20:07:03 +03:00
|
|
|
install_name_is_rpath = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!install_name_is_rpath && !macosx_rpath) {
|
2015-08-05 20:07:03 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) {
|
2015-08-05 20:07:03 +03:00
|
|
|
std::ostringstream w;
|
|
|
|
w << "Attempting to use";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (macosx_rpath) {
|
2015-08-05 20:07:03 +03:00
|
|
|
w << " MACOSX_RPATH";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 20:07:03 +03:00
|
|
|
w << " @rpath";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set.";
|
|
|
|
w << " This could be because you are using a Mac OS X version";
|
|
|
|
w << " less than 10.5 or because CMake's platform configuration is";
|
|
|
|
w << " corrupt.";
|
2015-10-16 20:19:49 +03:00
|
|
|
cmake* cm = this->LocalGenerator->GetCMakeInstance();
|
2016-05-16 17:34:04 +03:00
|
|
|
cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace());
|
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
|
|
|
|
{
|
|
|
|
// we can't do rpaths when unsupported
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) {
|
2015-08-05 20:07:03 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
|
|
|
|
const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (macosx_rpath_str) {
|
2015-08-05 20:07:03 +03:00
|
|
|
return this->GetPropertyAsBool("MACOSX_RPATH");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
|
2015-10-20 02:12:37 +03:00
|
|
|
cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042();
|
2015-08-05 20:07:03 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmp0042 == cmPolicies::WARN) {
|
|
|
|
this->LocalGenerator->GetGlobalGenerator()->AddCMP0042WarnTarget(
|
|
|
|
this->GetName());
|
|
|
|
}
|
2015-08-05 20:07:03 +03:00
|
|
|
|
2016-06-02 00:29:53 +03:00
|
|
|
return cmp0042 == cmPolicies::NEW;
|
2015-08-05 20:07:03 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
2015-08-04 20:19:41 +03:00
|
|
|
std::string cmGeneratorTarget::GetSOName(const std::string& config) const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2015-08-04 20:19:41 +03:00
|
|
|
// Lookup the imported soname.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorTarget::ImportInfo const* info =
|
|
|
|
this->GetImportInfo(config)) {
|
|
|
|
if (info->NoSOName) {
|
2015-08-04 20:19:41 +03:00
|
|
|
// The imported library has no builtin soname so the name
|
|
|
|
// searched at runtime will be just the filename.
|
|
|
|
return cmSystemTools::GetFilenameName(info->Location);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:41 +03:00
|
|
|
// Use the soname given if any.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (info->SOName.find("@rpath/") == 0) {
|
2015-08-04 20:19:41 +03:00
|
|
|
return info->SOName.substr(6);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return info->SOName;
|
2015-08-04 20:19:41 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:41 +03:00
|
|
|
return "";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:41 +03:00
|
|
|
// Compute the soname that will be built.
|
|
|
|
std::string name;
|
|
|
|
std::string soName;
|
|
|
|
std::string realName;
|
|
|
|
std::string impName;
|
|
|
|
std::string pdbName;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
|
2015-08-04 20:19:41 +03:00
|
|
|
return soName;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:41 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
|
|
|
|
bool contentOnly) const
|
2015-08-04 20:19:48 +03:00
|
|
|
{
|
2015-08-04 20:19:48 +03:00
|
|
|
std::string fpath = this->GetFullName(config, false);
|
2016-06-19 21:30:00 +03:00
|
|
|
fpath += ".";
|
|
|
|
const char* ext = this->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (!ext) {
|
|
|
|
ext = "app";
|
|
|
|
}
|
|
|
|
fpath += ext;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->PlatformIsAppleIos()) {
|
2015-08-18 22:30:54 +03:00
|
|
|
fpath += "/Contents";
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!contentOnly) {
|
2015-08-18 22:30:54 +03:00
|
|
|
fpath += "/MacOS";
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
return fpath;
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:49 +03:00
|
|
|
bool cmGeneratorTarget::IsBundleOnApple() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() ||
|
|
|
|
this->IsCFBundleOnApple();
|
2015-08-04 20:19:49 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:48 +03:00
|
|
|
std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config,
|
|
|
|
bool contentOnly) const
|
|
|
|
{
|
|
|
|
std::string fpath;
|
2015-08-04 20:19:50 +03:00
|
|
|
fpath += this->GetOutputName(config, false);
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += ".";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* ext = this->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (!ext) {
|
|
|
|
if (this->IsXCTestOnApple()) {
|
2015-08-04 20:19:48 +03:00
|
|
|
ext = "xctest";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:48 +03:00
|
|
|
ext = "bundle";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += ext;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->PlatformIsAppleIos()) {
|
2015-08-18 22:30:54 +03:00
|
|
|
fpath += "/Contents";
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!contentOnly) {
|
2015-08-18 22:30:54 +03:00
|
|
|
fpath += "/MacOS";
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2015-08-18 22:30:54 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
return fpath;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
|
|
|
|
bool rootDir) const
|
2015-08-04 20:19:48 +03:00
|
|
|
{
|
|
|
|
std::string fpath;
|
2015-08-04 20:19:50 +03:00
|
|
|
fpath += this->GetOutputName(config, false);
|
2016-06-19 22:26:40 +03:00
|
|
|
fpath += ".";
|
|
|
|
const char* ext = this->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (!ext) {
|
|
|
|
ext = "framework";
|
|
|
|
}
|
|
|
|
fpath += ext;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!rootDir && !this->Makefile->PlatformIsAppleIos()) {
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += "/Versions/";
|
2015-10-23 01:47:31 +03:00
|
|
|
fpath += this->GetFrameworkVersion();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
return fpath;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetFullName(const std::string& config,
|
|
|
|
bool implib) const
|
2015-08-04 20:19:48 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2015-10-16 20:19:50 +03:00
|
|
|
return this->GetFullNameImported(config, implib);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:48 +03:00
|
|
|
return this->GetFullNameInternal(config, implib);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:47 +03:00
|
|
|
{
|
|
|
|
// If building directly for installation then the build tree install_name
|
|
|
|
// is the same as the install tree.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
|
2015-08-04 20:19:47 +03:00
|
|
|
return this->GetInstallNameDirForInstallTree();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:47 +03:00
|
|
|
|
|
|
|
// Use the build tree directory for the target.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") &&
|
|
|
|
!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
|
|
|
|
!this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
|
2015-08-04 20:19:47 +03:00
|
|
|
std::string dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->MacOSXRpathInstallNameDirDefault()) {
|
2015-08-04 20:19:47 +03:00
|
|
|
dir = "@rpath";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-10-20 22:31:47 +04:00
|
|
|
dir = this->GetDirectory(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:47 +03:00
|
|
|
dir += "/";
|
|
|
|
return dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:47 +03:00
|
|
|
return "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
2015-08-04 20:19:47 +03:00
|
|
|
std::string dir;
|
|
|
|
const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
|
|
|
|
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) {
|
|
|
|
if (install_name_dir && *install_name_dir) {
|
2015-08-04 20:19:47 +03:00
|
|
|
dir = install_name_dir;
|
|
|
|
dir += "/";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!install_name_dir) {
|
|
|
|
if (this->MacOSXRpathInstallNameDirDefault()) {
|
2015-08-04 20:19:47 +03:00
|
|
|
dir = "@rpath/";
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return dir;
|
|
|
|
} else {
|
2015-08-04 20:19:47 +03:00
|
|
|
return "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:47 +03:00
|
|
|
}
|
|
|
|
|
2015-10-19 23:39:08 +03:00
|
|
|
cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
|
|
|
|
{
|
|
|
|
return this->Target->GetBacktrace();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::vector<std::string>& cmGeneratorTarget::GetLinkDirectories() const
|
2015-10-23 01:49:58 +03:00
|
|
|
{
|
|
|
|
return this->Target->GetLinkDirectories();
|
|
|
|
}
|
|
|
|
|
2015-10-23 02:01:46 +03:00
|
|
|
const std::set<std::string>& cmGeneratorTarget::GetUtilities() const
|
|
|
|
{
|
|
|
|
return this->Target->GetUtilities();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const cmListFileBacktrace* cmGeneratorTarget::GetUtilityBacktrace(
|
|
|
|
const std::string& u) const
|
2015-10-23 02:04:07 +03:00
|
|
|
{
|
|
|
|
return this->Target->GetUtilityBacktrace(u);
|
|
|
|
}
|
|
|
|
|
2015-10-20 01:42:01 +03:00
|
|
|
bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->GetType() == cmState::STATIC_LIBRARY ||
|
2015-10-20 01:42:01 +03:00
|
|
|
this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::MODULE_LIBRARY ||
|
|
|
|
this->GetType() == cmState::EXECUTABLE;
|
|
|
|
}
|
|
|
|
|
2015-10-19 23:42:01 +03:00
|
|
|
const char* cmGeneratorTarget::GetExportMacro() const
|
|
|
|
{
|
|
|
|
// Define the symbol for targets that export symbols.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::MODULE_LIBRARY ||
|
|
|
|
this->IsExecutableWithExports()) {
|
|
|
|
if (const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
|
2015-10-19 23:42:01 +03:00
|
|
|
this->ExportMacro = custom_export_name;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-10-19 23:42:01 +03:00
|
|
|
std::string in = this->GetName();
|
|
|
|
in += "_EXPORTS";
|
|
|
|
this->ExportMacro = cmSystemTools::MakeCidentifier(in);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->ExportMacro.c_str();
|
|
|
|
} else {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-19 23:42:01 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:49 +03:00
|
|
|
class cmTargetCollectLinkLanguages
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmTargetCollectLinkLanguages(cmGeneratorTarget const* target,
|
|
|
|
const std::string& config,
|
|
|
|
UNORDERED_SET<std::string>& languages,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget const* head)
|
|
|
|
: Config(config)
|
|
|
|
, Languages(languages)
|
|
|
|
, HeadTarget(head)
|
|
|
|
, Target(target)
|
|
|
|
{
|
|
|
|
this->Visited.insert(target);
|
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
|
|
|
void Visit(cmLinkItem const& item)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
if (!item.Target) {
|
|
|
|
if (item.find("::") != std::string::npos) {
|
2015-08-04 20:19:49 +03:00
|
|
|
bool noMessage = false;
|
|
|
|
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
2016-06-14 23:37:36 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->Target->GetLocalGenerator()->GetPolicyStatus(
|
|
|
|
cmPolicies::CMP0028)) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-08-04 20:19:49 +03:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n";
|
|
|
|
messageType = cmake::AUTHOR_WARNING;
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2015-08-04 20:19:49 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
noMessage = true;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// Issue the fatal message.
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!noMessage) {
|
2015-08-04 20:19:49 +03:00
|
|
|
e << "Target \"" << this->Target->GetName()
|
|
|
|
<< "\" links to target \"" << item
|
|
|
|
<< "\" but the target was not found. Perhaps a find_package() "
|
2016-05-16 17:34:04 +03:00
|
|
|
"call is missing for an IMPORTED target, or an ALIAS target is "
|
|
|
|
"missing?";
|
2015-10-09 00:28:46 +03:00
|
|
|
this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
|
2015-10-19 23:39:08 +03:00
|
|
|
messageType, e.str(), this->Target->GetBacktrace());
|
2015-08-04 20:19:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->Visited.insert(item.Target).second) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-26 20:35:45 +03:00
|
|
|
cmLinkInterface const* iface =
|
2015-10-08 02:18:42 +03:00
|
|
|
item.Target->GetLinkInterface(this->Config, this->HeadTarget);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!iface) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator li =
|
|
|
|
iface->Languages.begin();
|
|
|
|
li != iface->Languages.end(); ++li) {
|
2015-08-04 20:19:49 +03:00
|
|
|
this->Languages.insert(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLinkItem>::const_iterator li = iface->Libraries.begin();
|
|
|
|
li != iface->Libraries.end(); ++li) {
|
2015-08-04 20:19:49 +03:00
|
|
|
this->Visit(*li);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:49 +03:00
|
|
|
private:
|
|
|
|
std::string Config;
|
|
|
|
UNORDERED_SET<std::string>& Languages;
|
2015-09-16 05:46:15 +03:00
|
|
|
cmGeneratorTarget const* HeadTarget;
|
2015-08-04 20:19:49 +03:00
|
|
|
const cmGeneratorTarget* Target;
|
2015-10-16 20:19:48 +03:00
|
|
|
std::set<cmGeneratorTarget const*> Visited;
|
2015-08-04 20:19:49 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget::LinkClosure const* cmGeneratorTarget::GetLinkClosure(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:49 +03:00
|
|
|
{
|
|
|
|
std::string key(cmSystemTools::UpperCase(config));
|
2016-05-16 17:34:04 +03:00
|
|
|
LinkClosureMapType::iterator i = this->LinkClosureMap.find(key);
|
|
|
|
if (i == this->LinkClosureMap.end()) {
|
2015-08-04 20:19:49 +03:00
|
|
|
LinkClosure lc;
|
|
|
|
this->ComputeLinkClosure(config, lc);
|
|
|
|
LinkClosureMapType::value_type entry(key, lc);
|
|
|
|
i = this->LinkClosureMap.insert(entry).first;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
return &i->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
class cmTargetSelectLinker
|
|
|
|
{
|
|
|
|
int Preference;
|
|
|
|
cmGeneratorTarget const* Target;
|
|
|
|
cmGlobalGenerator* GG;
|
|
|
|
std::set<std::string> Preferred;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2015-08-04 20:19:49 +03:00
|
|
|
public:
|
|
|
|
cmTargetSelectLinker(cmGeneratorTarget const* target)
|
2016-05-16 17:34:04 +03:00
|
|
|
: Preference(0)
|
|
|
|
, Target(target)
|
|
|
|
{
|
2015-08-25 23:55:11 +03:00
|
|
|
this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
void Consider(const char* lang)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2015-08-04 20:19:49 +03:00
|
|
|
int preference = this->GG->GetLinkerPreference(lang);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (preference > this->Preference) {
|
2015-08-04 20:19:49 +03:00
|
|
|
this->Preference = preference;
|
|
|
|
this->Preferred.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (preference == this->Preference) {
|
2015-08-04 20:19:49 +03:00
|
|
|
this->Preferred.insert(lang);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
std::string Choose()
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
if (this->Preferred.empty()) {
|
2015-08-04 20:19:49 +03:00
|
|
|
return "";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->Preferred.size() > 1) {
|
2016-06-14 23:37:36 +03:00
|
|
|
std::ostringstream e;
|
2015-08-04 20:19:49 +03:00
|
|
|
e << "Target " << this->Target->GetName()
|
|
|
|
<< " contains multiple languages with the highest linker preference"
|
|
|
|
<< " (" << this->Preference << "):\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<std::string>::const_iterator li = this->Preferred.begin();
|
|
|
|
li != this->Preferred.end(); ++li) {
|
2015-08-04 20:19:49 +03:00
|
|
|
e << " " << *li << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
e << "Set the LINKER_LANGUAGE property for this target.";
|
2015-10-16 20:19:49 +03:00
|
|
|
cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance();
|
2015-08-04 20:19:49 +03:00
|
|
|
cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
2015-10-19 23:39:08 +03:00
|
|
|
this->Target->GetBacktrace());
|
2015-08-04 20:19:49 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return *this->Preferred.begin();
|
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
|
|
|
|
LinkClosure& lc) const
|
|
|
|
{
|
|
|
|
// Get languages built in this target.
|
|
|
|
UNORDERED_SET<std::string> languages;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
|
2015-08-03 22:28:41 +03:00
|
|
|
assert(impl);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
|
|
|
|
li != impl->Languages.end(); ++li) {
|
2015-08-04 20:19:49 +03:00
|
|
|
languages.insert(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
|
|
|
// Add interface languages from linked targets.
|
2015-09-16 05:46:15 +03:00
|
|
|
cmTargetCollectLinkLanguages cll(this, config, languages, this);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLinkImplItem>::const_iterator li =
|
|
|
|
impl->Libraries.begin();
|
|
|
|
li != impl->Libraries.end(); ++li) {
|
2015-08-04 20:19:49 +03:00
|
|
|
cll.Visit(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
|
|
|
// Store the transitive closure of languages.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (UNORDERED_SET<std::string>::const_iterator li = languages.begin();
|
|
|
|
li != languages.end(); ++li) {
|
2015-08-04 20:19:49 +03:00
|
|
|
lc.Languages.push_back(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
|
|
|
// Choose the language whose linker should be used.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetProperty("HAS_CXX")) {
|
2015-08-04 20:19:49 +03:00
|
|
|
lc.LinkerLanguage = "CXX";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) {
|
2015-08-04 20:19:49 +03:00
|
|
|
lc.LinkerLanguage = linkerLang;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:49 +03:00
|
|
|
// Find the language with the highest preference value.
|
|
|
|
cmTargetSelectLinker tsl(this);
|
|
|
|
|
|
|
|
// First select from the languages compiled directly in this target.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
|
|
|
|
li != impl->Languages.end(); ++li) {
|
2015-08-04 20:19:49 +03:00
|
|
|
tsl.Consider(li->c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
|
|
|
// Now consider languages that propagate from linked targets.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (UNORDERED_SET<std::string>::const_iterator sit = languages.begin();
|
|
|
|
sit != languages.end(); ++sit) {
|
|
|
|
std::string propagates =
|
|
|
|
"CMAKE_" + *sit + "_LINKER_PREFERENCE_PROPAGATES";
|
|
|
|
if (this->Makefile->IsOn(propagates)) {
|
2015-08-04 20:19:49 +03:00
|
|
|
tsl.Consider(sit->c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
|
|
|
|
lc.LinkerLanguage = tsl.Choose();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:49 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:47 +03:00
|
|
|
void cmGeneratorTarget::GetFullNameComponents(std::string& prefix,
|
|
|
|
std::string& base,
|
|
|
|
std::string& suffix,
|
|
|
|
const std::string& config,
|
|
|
|
bool implib) const
|
|
|
|
{
|
2015-08-04 20:19:48 +03:00
|
|
|
this->GetFullNameInternal(config, implib, prefix, base, suffix);
|
2015-08-04 20:19:47 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::BuildMacContentDirectory(
|
|
|
|
const std::string& base, const std::string& config, bool contentOnly) const
|
2015-08-04 20:19:47 +03:00
|
|
|
{
|
|
|
|
std::string fpath = base;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsAppBundleOnApple()) {
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += this->GetAppBundleDirectory(config, contentOnly);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->IsFrameworkOnApple()) {
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += this->GetFrameworkDirectory(config, contentOnly);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->IsCFBundleOnApple()) {
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += this->GetCFBundleDirectory(config, contentOnly);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:47 +03:00
|
|
|
return fpath;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetMacContentDirectory(
|
|
|
|
const std::string& config, bool implib) const
|
2015-08-04 20:19:47 +03:00
|
|
|
{
|
|
|
|
// Start with the output directory for the target.
|
2014-10-20 22:31:47 +04:00
|
|
|
std::string fpath = this->GetDirectory(config, implib);
|
2015-08-04 20:19:47 +03:00
|
|
|
fpath += "/";
|
|
|
|
bool contentOnly = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsFrameworkOnApple()) {
|
2015-08-04 20:19:47 +03:00
|
|
|
// additional files with a framework go into the version specific
|
|
|
|
// directory
|
|
|
|
contentOnly = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:47 +03:00
|
|
|
fpath = this->BuildMacContentDirectory(fpath, config, contentOnly);
|
|
|
|
return fpath;
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:51 +03:00
|
|
|
cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-04 20:19:51 +03:00
|
|
|
{
|
|
|
|
// There is no compile information for imported targets.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:51 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() > cmState::OBJECT_LIBRARY) {
|
2015-08-04 20:19:51 +03:00
|
|
|
std::string msg = "cmTarget::GetCompileInfo called for ";
|
|
|
|
msg += this->GetName();
|
|
|
|
msg += " which has type ";
|
2015-10-08 01:26:50 +03:00
|
|
|
msg += cmState::GetTargetTypeName(this->GetType());
|
2015-08-25 23:18:39 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:51 +03:00
|
|
|
|
|
|
|
// Lookup/compute/cache the compile information for this configuration.
|
|
|
|
std::string config_upper;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-08-04 20:19:51 +03:00
|
|
|
config_upper = cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:51 +03:00
|
|
|
CompileInfoMapType::const_iterator i =
|
|
|
|
this->CompileInfoMap.find(config_upper);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == this->CompileInfoMap.end()) {
|
2015-08-04 20:19:51 +03:00
|
|
|
CompileInfo info;
|
2015-08-05 20:01:23 +03:00
|
|
|
this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir);
|
2015-08-04 20:19:51 +03:00
|
|
|
CompileInfoMapType::value_type entry(config_upper, info);
|
|
|
|
i = this->CompileInfoMap.insert(entry).first;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:51 +03:00
|
|
|
return &i->second;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSourceFile const* cmGeneratorTarget::GetModuleDefinitionFile(
|
|
|
|
const std::string& config) const
|
2014-02-14 13:23:23 +04:00
|
|
|
{
|
2015-11-02 17:24:25 +03:00
|
|
|
std::vector<cmSourceFile const*> data;
|
|
|
|
IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile,
|
|
|
|
COMMA std::vector<cmSourceFile const*>)
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!data.empty()) {
|
2015-11-02 17:24:25 +03:00
|
|
|
return data.front();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-02 17:24:25 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2014-02-14 13:23:23 +04:00
|
|
|
}
|
|
|
|
|
2015-10-20 01:44:15 +03:00
|
|
|
bool cmGeneratorTarget::IsDLLPlatform() const
|
|
|
|
{
|
|
|
|
return this->DLLPlatform;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs,
|
|
|
|
const std::string& config) const
|
2012-03-12 22:40:58 +04:00
|
|
|
{
|
2014-03-18 20:07:56 +04:00
|
|
|
std::vector<cmSourceFile const*> objectFiles;
|
2014-02-13 20:25:00 +04:00
|
|
|
this->GetExternalObjects(objectFiles, config);
|
2015-10-16 20:19:48 +03:00
|
|
|
std::vector<cmGeneratorTarget*> objectLibraries;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile const*>::const_iterator it =
|
|
|
|
objectFiles.begin();
|
|
|
|
it != objectFiles.end(); ++it) {
|
2014-03-18 20:07:56 +04:00
|
|
|
std::string objLib = (*it)->GetObjectLibrary();
|
2015-10-16 20:19:48 +03:00
|
|
|
if (cmGeneratorTarget* tgt =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->FindGeneratorTargetToUse(objLib)) {
|
2015-02-18 23:58:07 +03:00
|
|
|
objectLibraries.push_back(tgt);
|
2014-03-18 20:07:56 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-18 20:07:56 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmGeneratorTarget*>::const_iterator end =
|
|
|
|
cmRemoveDuplicates(objectLibraries);
|
2015-02-18 23:58:07 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::const_iterator ti =
|
|
|
|
objectLibraries.begin();
|
|
|
|
ti != end; ++ti) {
|
2015-10-16 20:19:48 +03:00
|
|
|
cmGeneratorTarget* ogt = *ti;
|
2014-03-14 14:02:47 +04:00
|
|
|
std::vector<cmSourceFile const*> objectSources;
|
2014-02-13 20:25:00 +04:00
|
|
|
ogt->GetObjectSources(objectSources, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile const*>::const_iterator si =
|
|
|
|
objectSources.begin();
|
|
|
|
si != objectSources.end(); ++si) {
|
2012-03-12 22:40:58 +04:00
|
|
|
std::string obj = ogt->ObjectDirectory;
|
|
|
|
obj += ogt->Objects[*si];
|
|
|
|
objs.push_back(obj);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-03-12 22:40:58 +04:00
|
|
|
}
|
2012-09-14 21:04:25 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:41 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* prop =
|
|
|
|
this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config);
|
|
|
|
if (!prop) {
|
2015-08-04 20:19:41 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:41 +03:00
|
|
|
cmGeneratorExpression ge;
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(
|
|
|
|
this->GetName(), "AUTOUIC_OPTIONS", CM_NULLPTR, CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false, this,
|
|
|
|
&dagChecker),
|
|
|
|
result);
|
2015-08-04 20:19:41 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:44 +03:00
|
|
|
void processILibs(const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget const* headTarget, cmLinkItem const& item,
|
2015-08-26 20:38:37 +03:00
|
|
|
cmGlobalGenerator* gg,
|
2015-10-08 02:45:44 +03:00
|
|
|
std::vector<cmGeneratorTarget const*>& tgts,
|
2015-10-08 02:47:37 +03:00
|
|
|
std::set<cmGeneratorTarget const*>& emitted)
|
2015-08-04 20:19:44 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (item.Target && emitted.insert(item.Target).second) {
|
2015-10-08 02:45:44 +03:00
|
|
|
tgts.push_back(item.Target);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmLinkInterfaceLibraries const* iface =
|
|
|
|
item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) {
|
|
|
|
for (std::vector<cmLinkItem>::const_iterator it =
|
|
|
|
iface->Libraries.begin();
|
|
|
|
it != iface->Libraries.end(); ++it) {
|
2015-08-26 20:38:37 +03:00
|
|
|
processILibs(config, headTarget, *it, gg, tgts, emitted);
|
2015-08-04 20:19:44 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
}
|
|
|
|
|
2015-10-08 02:45:44 +03:00
|
|
|
const std::vector<const cmGeneratorTarget*>&
|
2015-08-04 20:19:44 +03:00
|
|
|
cmGeneratorTarget::GetLinkImplementationClosure(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-04 20:19:44 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
LinkImplClosure& tgts = this->LinkImplClosureMap[config];
|
|
|
|
if (!tgts.Done) {
|
2015-08-04 20:19:44 +03:00
|
|
|
tgts.Done = true;
|
2015-10-08 02:47:37 +03:00
|
|
|
std::set<cmGeneratorTarget const*> emitted;
|
2015-08-04 20:19:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkImplementationLibraries const* impl =
|
|
|
|
this->GetLinkImplementationLibraries(config);
|
2015-08-04 20:19:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLinkImplItem>::const_iterator it =
|
|
|
|
impl->Libraries.begin();
|
|
|
|
it != impl->Libraries.end(); ++it) {
|
2015-09-16 05:40:14 +03:00
|
|
|
processILibs(config, this, *it,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->GetGlobalGenerator(), tgts, emitted);
|
2015-08-04 20:19:44 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
return tgts;
|
|
|
|
}
|
|
|
|
|
2012-10-11 02:57:11 +04:00
|
|
|
class cmTargetTraceDependencies
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmTargetTraceDependencies(cmGeneratorTarget* target);
|
|
|
|
void Trace();
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2012-10-11 02:57:11 +04:00
|
|
|
private:
|
|
|
|
cmGeneratorTarget* GeneratorTarget;
|
|
|
|
cmMakefile* Makefile;
|
2015-10-16 20:19:48 +03:00
|
|
|
cmLocalGenerator* LocalGenerator;
|
2014-01-10 16:19:15 +04:00
|
|
|
cmGlobalGenerator const* GlobalGenerator;
|
2012-10-11 02:57:11 +04:00
|
|
|
typedef cmGeneratorTarget::SourceEntry SourceEntry;
|
|
|
|
SourceEntry* CurrentEntry;
|
2014-04-05 13:41:58 +04:00
|
|
|
std::queue<cmSourceFile*> SourceQueue;
|
|
|
|
std::set<cmSourceFile*> SourcesQueued;
|
2014-02-10 09:21:34 +04:00
|
|
|
typedef std::map<std::string, cmSourceFile*> NameMapType;
|
2012-10-11 02:57:11 +04:00
|
|
|
NameMapType NameMap;
|
2014-04-09 03:32:14 +04:00
|
|
|
std::vector<std::string> NewSources;
|
2012-10-11 02:57:11 +04:00
|
|
|
|
2014-04-05 13:41:58 +04:00
|
|
|
void QueueSource(cmSourceFile* sf);
|
2012-10-11 02:57:11 +04:00
|
|
|
void FollowName(std::string const& name);
|
|
|
|
void FollowNames(std::vector<std::string> const& names);
|
|
|
|
bool IsUtility(std::string const& dep);
|
|
|
|
void CheckCustomCommand(cmCustomCommand const& cc);
|
|
|
|
void CheckCustomCommands(const std::vector<cmCustomCommand>& commands);
|
2014-03-07 20:20:10 +04:00
|
|
|
void FollowCommandDepends(cmCustomCommand const& cc,
|
|
|
|
const std::string& config,
|
|
|
|
std::set<std::string>& emitted);
|
2012-10-11 02:57:11 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
|
|
|
|
: GeneratorTarget(target)
|
2012-10-11 02:57:11 +04:00
|
|
|
{
|
|
|
|
// Convenience.
|
2015-10-16 20:19:48 +03:00
|
|
|
this->Makefile = target->Target->GetMakefile();
|
|
|
|
this->LocalGenerator = target->GetLocalGenerator();
|
|
|
|
this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CurrentEntry = CM_NULLPTR;
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Queue all the source files already specified for the target.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (target->GetType() != cmState::INTERFACE_LIBRARY) {
|
2014-02-13 20:25:00 +04:00
|
|
|
std::vector<std::string> configs;
|
|
|
|
this->Makefile->GetConfigurations(configs);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configs.empty()) {
|
2014-02-13 20:25:00 +04:00
|
|
|
configs.push_back("");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-05 13:41:58 +04:00
|
|
|
std::set<cmSourceFile*> emitted;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator ci = configs.begin();
|
|
|
|
ci != configs.end(); ++ci) {
|
2014-04-05 13:41:58 +04:00
|
|
|
std::vector<cmSourceFile*> sources;
|
2015-08-29 18:51:15 +03:00
|
|
|
this->GeneratorTarget->GetSourceFiles(sources, *ci);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
|
|
|
|
si != sources.end(); ++si) {
|
2014-04-05 13:41:58 +04:00
|
|
|
cmSourceFile* sf = *si;
|
2015-10-10 19:41:51 +03:00
|
|
|
const std::set<cmGeneratorTarget const*> tgts =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GlobalGenerator->GetFilenameTargetDepends(sf);
|
|
|
|
if (tgts.find(this->GeneratorTarget) != tgts.end()) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-11-05 01:24:54 +03:00
|
|
|
e << "Evaluation output file\n \"" << sf->GetFullPath()
|
|
|
|
<< "\"\ndepends on the sources of a target it is used in. This "
|
2016-05-16 17:34:04 +03:00
|
|
|
"is a dependency loop and is not allowed.";
|
|
|
|
this->GeneratorTarget->LocalGenerator->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR, e.str());
|
2014-11-05 01:24:54 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (emitted.insert(sf).second &&
|
|
|
|
this->SourcesQueued.insert(sf).second) {
|
2014-04-05 13:41:58 +04:00
|
|
|
this->SourceQueue.push(sf);
|
2014-03-27 20:06:34 +04:00
|
|
|
}
|
2014-02-14 16:43:40 +04:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Queue pre-build, pre-link, and post-build rule dependencies.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CheckCustomCommands(this->GeneratorTarget->GetPreBuildCommands());
|
|
|
|
this->CheckCustomCommands(this->GeneratorTarget->GetPreLinkCommands());
|
|
|
|
this->CheckCustomCommands(this->GeneratorTarget->GetPostBuildCommands());
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmTargetTraceDependencies::Trace()
|
|
|
|
{
|
|
|
|
// Process one dependency at a time until the queue is empty.
|
2016-05-16 17:34:04 +03:00
|
|
|
while (!this->SourceQueue.empty()) {
|
2012-10-11 02:57:11 +04:00
|
|
|
// Get the next source from the queue.
|
2014-04-05 13:41:58 +04:00
|
|
|
cmSourceFile* sf = this->SourceQueue.front();
|
2012-10-11 02:57:11 +04:00
|
|
|
this->SourceQueue.pop();
|
2015-08-29 19:47:14 +03:00
|
|
|
this->CurrentEntry = &this->GeneratorTarget->SourceDepends[sf];
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Queue dependencies added explicitly by the user.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) {
|
2012-10-11 02:57:11 +04:00
|
|
|
std::vector<std::string> objDeps;
|
|
|
|
cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator odi = objDeps.begin();
|
|
|
|
odi != objDeps.end(); ++odi) {
|
|
|
|
if (cmSystemTools::FileIsFullPath(*odi)) {
|
2015-01-27 18:57:17 +03:00
|
|
|
*odi = cmSystemTools::CollapseFullPath(*odi);
|
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->FollowNames(objDeps);
|
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Queue the source needed to generate this file, if any.
|
|
|
|
this->FollowName(sf->GetFullPath());
|
|
|
|
|
|
|
|
// Queue dependencies added programatically by commands.
|
|
|
|
this->FollowNames(sf->GetDepends());
|
|
|
|
|
|
|
|
// Queue custom command dependencies.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmCustomCommand const* cc = sf->GetCustomCommand()) {
|
2012-10-11 02:57:11 +04:00
|
|
|
this->CheckCustomCommand(*cc);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CurrentEntry = CM_NULLPTR;
|
2014-04-09 03:32:14 +04:00
|
|
|
|
2015-08-29 19:10:19 +03:00
|
|
|
this->GeneratorTarget->AddTracedSources(this->NewSources);
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
2014-04-05 13:41:58 +04:00
|
|
|
void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
|
2012-10-11 02:57:11 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SourcesQueued.insert(sf).second) {
|
2014-04-05 13:41:58 +04:00
|
|
|
this->SourceQueue.push(sf);
|
2012-10-11 02:57:11 +04:00
|
|
|
|
2014-04-09 03:32:14 +04:00
|
|
|
// Make sure this file is in the target at the end.
|
|
|
|
this->NewSources.push_back(sf->GetFullPath());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmTargetTraceDependencies::FollowName(std::string const& name)
|
|
|
|
{
|
|
|
|
NameMapType::iterator i = this->NameMap.find(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == this->NameMap.end()) {
|
2012-10-11 02:57:11 +04:00
|
|
|
// Check if we know how to generate this file.
|
2014-03-11 03:04:11 +04:00
|
|
|
cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name);
|
2012-10-11 02:57:11 +04:00
|
|
|
NameMapType::value_type entry(name, sf);
|
|
|
|
i = this->NameMap.insert(entry).first;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSourceFile* sf = i->second) {
|
2012-10-11 02:57:11 +04:00
|
|
|
// Record the dependency we just followed.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CurrentEntry) {
|
2012-10-11 02:57:11 +04:00
|
|
|
this->CurrentEntry->Depends.push_back(sf);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->QueueSource(sf);
|
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmTargetTraceDependencies::FollowNames(
|
|
|
|
std::vector<std::string> const& names)
|
2012-10-11 02:57:11 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = names.begin();
|
|
|
|
i != names.end(); ++i) {
|
2012-10-11 02:57:11 +04:00
|
|
|
this->FollowName(*i);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
|
|
|
|
{
|
|
|
|
// Dependencies on targets (utilities) are supposed to be named by
|
|
|
|
// just the target name. However for compatibility we support
|
|
|
|
// naming the output file generated by the target (assuming there is
|
|
|
|
// no output-name property which old code would not have set). In
|
|
|
|
// that case the target name will be the file basename of the
|
|
|
|
// dependency.
|
|
|
|
std::string util = cmSystemTools::GetFilenameName(dep);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetFilenameLastExtension(util) == ".exe") {
|
2012-10-11 02:57:11 +04:00
|
|
|
util = cmSystemTools::GetFilenameWithoutLastExtension(util);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Check for a target with this name.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorTarget* t =
|
|
|
|
this->GeneratorTarget->GetLocalGenerator()->FindGeneratorTargetToUse(
|
|
|
|
util)) {
|
2012-10-11 02:57:11 +04:00
|
|
|
// If we find the target and the dep was given as a full path,
|
|
|
|
// then make sure it was not a full path to something else, and
|
|
|
|
// the fact that the name matched a target was just a coincidence.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsFullPath(dep.c_str())) {
|
|
|
|
if (t->GetType() >= cmState::EXECUTABLE &&
|
|
|
|
t->GetType() <= cmState::MODULE_LIBRARY) {
|
2012-10-11 02:57:11 +04:00
|
|
|
// This is really only for compatibility so we do not need to
|
|
|
|
// worry about configuration names and output names.
|
2014-03-10 19:57:02 +04:00
|
|
|
std::string tLocation = t->GetLocationForBuild();
|
2012-10-11 02:57:11 +04:00
|
|
|
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
|
|
|
std::string depLocation = cmSystemTools::GetFilenamePath(dep);
|
2014-10-15 16:54:05 +04:00
|
|
|
depLocation = cmSystemTools::CollapseFullPath(depLocation);
|
|
|
|
tLocation = cmSystemTools::CollapseFullPath(tLocation);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (depLocation == tLocation) {
|
2015-10-16 20:19:48 +03:00
|
|
|
this->GeneratorTarget->Target->AddUtility(util);
|
2012-10-11 02:57:11 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-10-11 02:57:11 +04:00
|
|
|
// The original name of the dependency was not a full path. It
|
|
|
|
// must name a target, so add the target-level dependency.
|
2015-10-16 20:19:48 +03:00
|
|
|
this->GeneratorTarget->Target->AddUtility(util);
|
2012-10-11 02:57:11 +04:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// The dependency does not name a target built in this project.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
|
2012-10-11 02:57:11 +04:00
|
|
|
{
|
|
|
|
// Transform command names that reference targets built in this
|
|
|
|
// project to corresponding target-level dependencies.
|
2015-07-09 00:52:51 +03:00
|
|
|
cmGeneratorExpression ge(cc.GetBacktrace());
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Add target-level dependencies referenced by generator expressions.
|
2015-10-10 19:41:51 +03:00
|
|
|
std::set<cmGeneratorTarget*> targets;
|
2012-10-11 02:57:11 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
|
|
|
|
cit != cc.GetCommandLines().end(); ++cit) {
|
2012-10-11 02:57:11 +04:00
|
|
|
std::string const& command = *cit->begin();
|
|
|
|
// Check for a target with this name.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmGeneratorTarget* t =
|
|
|
|
this->LocalGenerator->FindGeneratorTargetToUse(command)) {
|
|
|
|
if (t->GetType() == cmState::EXECUTABLE) {
|
2012-10-11 02:57:11 +04:00
|
|
|
// The command refers to an executable target built in
|
|
|
|
// this project. Add the target-level dependency to make
|
|
|
|
// sure the executable is up to date before this custom
|
|
|
|
// command possibly runs.
|
2015-10-16 20:19:48 +03:00
|
|
|
this->GeneratorTarget->Target->AddUtility(command);
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Check for target references in generator expressions.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmCustomCommandLine::const_iterator cli = cit->begin();
|
|
|
|
cli != cit->end(); ++cli) {
|
2016-06-28 17:17:52 +03:00
|
|
|
const CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*cli);
|
2015-07-25 17:56:52 +03:00
|
|
|
cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true);
|
2015-10-10 19:41:51 +03:00
|
|
|
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
|
2014-11-25 18:33:00 +03:00
|
|
|
targets.insert(geTargets.begin(), geTargets.end());
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<cmGeneratorTarget*>::iterator ti = targets.begin();
|
|
|
|
ti != targets.end(); ++ti) {
|
2015-10-16 20:19:48 +03:00
|
|
|
this->GeneratorTarget->Target->AddUtility((*ti)->GetName());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Queue the custom command dependencies.
|
2014-03-07 20:20:10 +04:00
|
|
|
std::vector<std::string> configs;
|
|
|
|
std::set<std::string> emitted;
|
|
|
|
this->Makefile->GetConfigurations(configs);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configs.empty()) {
|
2014-03-07 20:20:10 +04:00
|
|
|
configs.push_back("");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator ci = configs.begin();
|
|
|
|
ci != configs.end(); ++ci) {
|
2014-03-07 20:20:10 +04:00
|
|
|
this->FollowCommandDepends(cc, *ci, emitted);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-07 20:20:10 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmTargetTraceDependencies::FollowCommandDepends(
|
|
|
|
cmCustomCommand const& cc, const std::string& config,
|
|
|
|
std::set<std::string>& emitted)
|
2014-03-07 20:20:10 +04:00
|
|
|
{
|
2015-07-25 18:52:10 +03:00
|
|
|
cmCustomCommandGenerator ccg(cc, config,
|
|
|
|
this->GeneratorTarget->LocalGenerator);
|
2014-03-07 20:20:10 +04:00
|
|
|
|
|
|
|
const std::vector<std::string>& depends = ccg.GetDepends();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator di = depends.begin();
|
|
|
|
di != depends.end(); ++di) {
|
2012-10-11 02:57:11 +04:00
|
|
|
std::string const& dep = *di;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emitted.insert(dep).second) {
|
|
|
|
if (!this->IsUtility(dep)) {
|
2014-03-07 20:20:10 +04:00
|
|
|
// The dependency does not name a target and may be a file we
|
|
|
|
// know how to generate. Queue it.
|
|
|
|
this->FollowName(dep);
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmTargetTraceDependencies::CheckCustomCommands(
|
|
|
|
const std::vector<cmCustomCommand>& commands)
|
2012-10-11 02:57:11 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
|
|
|
|
cli != commands.end(); ++cli) {
|
2012-10-11 02:57:11 +04:00
|
|
|
this->CheckCustomCommand(*cli);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmGeneratorTarget::TraceDependencies()
|
|
|
|
{
|
|
|
|
// CMake-generated targets have no dependencies to trace. Normally tracing
|
|
|
|
// would find nothing anyway, but when building CMake itself the "install"
|
|
|
|
// target command ends up referencing the "cmake" target but we do not
|
|
|
|
// really want the dependency because "install" depend on "all" anyway.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::GLOBAL_TARGET) {
|
2012-10-11 02:57:11 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-11 02:57:11 +04:00
|
|
|
|
|
|
|
// Use a helper object to trace the dependencies.
|
|
|
|
cmTargetTraceDependencies tracer(this);
|
|
|
|
tracer.Trace();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetCompilePDBDirectory(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:51 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (CompileInfo const* info = this->GetCompileInfo(config)) {
|
2015-08-04 20:19:51 +03:00
|
|
|
return info->CompilePdbDir;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:51 +03:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2014-02-10 07:48:34 +04:00
|
|
|
void cmGeneratorTarget::GetAppleArchs(const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>& archVec) const
|
2012-09-16 03:16:43 +04:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* archs = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2012-09-16 03:16:43 +04:00
|
|
|
std::string defVarName = "OSX_ARCHITECTURES_";
|
|
|
|
defVarName += cmSystemTools::UpperCase(config);
|
2015-10-07 22:50:29 +03:00
|
|
|
archs = this->GetProperty(defVarName);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!archs) {
|
2015-10-07 22:50:29 +03:00
|
|
|
archs = this->GetProperty("OSX_ARCHITECTURES");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (archs) {
|
2012-09-16 03:16:43 +04:00
|
|
|
cmSystemTools::ExpandListArgument(std::string(archs), archVec);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-09-16 03:16:43 +04:00
|
|
|
}
|
2012-09-16 03:19:54 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetCreateRuleVariable(
|
|
|
|
std::string const& lang, std::string const& config) const
|
2012-09-16 03:19:54 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetType()) {
|
|
|
|
case cmState::STATIC_LIBRARY: {
|
2014-05-21 17:40:30 +04:00
|
|
|
std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION", config)) {
|
2014-05-21 17:40:30 +04:00
|
|
|
std::string varIPO = var + "_IPO";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->GetDefinition(varIPO)) {
|
2014-05-21 17:40:30 +04:00
|
|
|
return varIPO;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return var;
|
|
|
|
}
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::SHARED_LIBRARY:
|
2014-05-21 17:38:24 +04:00
|
|
|
return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY";
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::MODULE_LIBRARY:
|
2014-05-21 17:38:24 +04:00
|
|
|
return "CMAKE_" + lang + "_CREATE_SHARED_MODULE";
|
2015-10-08 01:21:51 +03:00
|
|
|
case cmState::EXECUTABLE:
|
2014-05-21 17:38:24 +04:00
|
|
|
return "CMAKE_" + lang + "_LINK_EXECUTABLE";
|
2012-09-16 03:19:54 +04:00
|
|
|
default:
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-09-16 03:19:54 +04:00
|
|
|
return "";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
static void processIncludeDirectories(
|
|
|
|
cmGeneratorTarget const* tgt,
|
|
|
|
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
|
|
|
|
std::vector<std::string>& includes,
|
|
|
|
UNORDERED_SET<std::string>& uniqueIncludes,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
|
|
|
|
bool debugIncludes, const std::string& language)
|
|
|
|
{
|
|
|
|
for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
|
|
|
|
it = entries.begin(),
|
|
|
|
end = entries.end();
|
|
|
|
it != end; ++it) {
|
2015-08-05 00:14:53 +03:00
|
|
|
cmLinkImplItem const& item = (*it)->LinkImplItem;
|
|
|
|
std::string const& targetName = item;
|
|
|
|
bool const fromImported = item.Target && item.Target->IsImported();
|
|
|
|
bool const checkCMP0027 = item.FromGenex;
|
|
|
|
std::vector<std::string> entryIncludes;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
(*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
|
|
|
|
dagChecker, language),
|
|
|
|
entryIncludes);
|
2015-08-05 00:14:53 +03:00
|
|
|
|
|
|
|
std::string usedIncludes;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator li = entryIncludes.begin();
|
|
|
|
li != entryIncludes.end(); ++li) {
|
|
|
|
if (fromImported && !cmSystemTools::FileExists(li->c_str())) {
|
2015-08-05 00:14:53 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (checkCMP0027) {
|
|
|
|
switch (tgt->GetPolicyStatusCMP0027()) {
|
2015-08-05 00:14:53 +03:00
|
|
|
case cmPolicies::WARN:
|
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n";
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
messageType = cmake::AUTHOR_WARNING;
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-08-05 00:14:53 +03:00
|
|
|
e << "Imported target \"" << targetName << "\" includes "
|
|
|
|
"non-existent path\n \"" << *li << "\"\nin its "
|
|
|
|
"INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
|
|
|
|
"* The path was deleted, renamed, or moved to another "
|
|
|
|
"location.\n"
|
|
|
|
"* An install or uninstall procedure did not complete "
|
|
|
|
"successfully.\n"
|
|
|
|
"* The installation package was faulty and references files it "
|
|
|
|
"does not provide.\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2015-08-05 00:14:53 +03:00
|
|
|
tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsFullPath(li->c_str())) {
|
2015-08-05 00:14:53 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
bool noMessage = false;
|
|
|
|
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!targetName.empty()) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-08-05 00:14:53 +03:00
|
|
|
e << "Target \"" << targetName << "\" contains relative "
|
|
|
|
"path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
|
|
|
|
" \"" << *li << "\"";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
switch (tgt->GetPolicyStatusCMP0021()) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-08-05 00:14:53 +03:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n";
|
|
|
|
messageType = cmake::AUTHOR_WARNING;
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2015-08-05 00:14:53 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
noMessage = true;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// Issue the fatal message.
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Found relative path while evaluating include directories of "
|
|
|
|
"\""
|
|
|
|
<< tgt->GetName() << "\":\n \"" << *li << "\"\n";
|
|
|
|
}
|
|
|
|
if (!noMessage) {
|
2015-08-05 00:14:53 +03:00
|
|
|
tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (messageType == cmake::FATAL_ERROR) {
|
2015-08-05 00:14:53 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::IsOff(li->c_str())) {
|
2015-08-05 00:14:53 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
std::string inc = *li;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (uniqueIncludes.insert(inc).second) {
|
2015-08-05 00:14:53 +03:00
|
|
|
includes.push_back(inc);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (debugIncludes) {
|
2015-08-05 00:14:53 +03:00
|
|
|
usedIncludes += " * " + inc + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!usedIncludes.empty()) {
|
|
|
|
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
|
|
|
|
cmake::LOG, std::string("Used includes for target ") + tgt->GetName() +
|
|
|
|
":\n" + usedIncludes,
|
|
|
|
(*it)->ge->GetBacktrace());
|
|
|
|
}
|
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
|
|
|
|
const std::string& config, const std::string& lang) const
|
2012-09-16 12:03:42 +04:00
|
|
|
{
|
2015-08-05 00:14:53 +03:00
|
|
|
std::vector<std::string> includes;
|
|
|
|
UNORDERED_SET<std::string> uniqueIncludes;
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(
|
|
|
|
this->GetName(), "INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR);
|
2015-08-05 00:14:53 +03:00
|
|
|
|
|
|
|
std::vector<std::string> debugProperties;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* debugProp =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
|
|
|
|
if (debugProp) {
|
2015-08-05 00:14:53 +03:00
|
|
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool debugIncludes = !this->DebugIncludesDone &&
|
|
|
|
std::find(debugProperties.begin(), debugProperties.end(),
|
|
|
|
"INCLUDE_DIRECTORIES") != debugProperties.end();
|
2015-08-05 00:14:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
|
2015-08-05 00:14:53 +03:00
|
|
|
this->DebugIncludesDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
processIncludeDirectories(this, this->IncludeDirectoriesEntries, includes,
|
|
|
|
uniqueIncludes, &dagChecker, config, debugIncludes,
|
2015-08-05 00:14:53 +03:00
|
|
|
lang);
|
|
|
|
|
|
|
|
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
|
|
|
|
linkInterfaceIncludeDirectoriesEntries;
|
2016-05-16 17:34:04 +03:00
|
|
|
AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES",
|
|
|
|
linkInterfaceIncludeDirectoriesEntries);
|
2015-08-05 00:14:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("APPLE")) {
|
2015-08-05 00:14:53 +03:00
|
|
|
cmLinkImplementationLibraries const* impl =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetLinkImplementationLibraries(config);
|
|
|
|
for (std::vector<cmLinkImplItem>::const_iterator it =
|
|
|
|
impl->Libraries.begin();
|
|
|
|
it != impl->Libraries.end(); ++it) {
|
2015-08-05 00:14:53 +03:00
|
|
|
std::string libDir = cmSystemTools::CollapseFullPath(*it);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static cmsys::RegularExpression frameworkCheck(
|
|
|
|
"(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
|
|
|
|
if (!frameworkCheck.find(libDir)) {
|
2015-08-05 00:14:53 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
|
|
|
|
libDir = frameworkCheck.match(1);
|
|
|
|
|
|
|
|
cmGeneratorExpression ge;
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
|
2016-05-16 17:34:04 +03:00
|
|
|
ge.Parse(libDir.c_str());
|
|
|
|
linkInterfaceIncludeDirectoriesEntries.push_back(
|
|
|
|
new cmGeneratorTarget::TargetPropertyEntry(cge));
|
2015-08-05 00:14:53 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:14:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
processIncludeDirectories(this, linkInterfaceIncludeDirectoriesEntries,
|
|
|
|
includes, uniqueIncludes, &dagChecker, config,
|
|
|
|
debugIncludes, lang);
|
2015-08-05 00:14:53 +03:00
|
|
|
|
|
|
|
cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
|
|
|
|
|
2016-05-24 18:39:25 +03:00
|
|
|
// Add standard include directories for this language.
|
|
|
|
std::string const standardIncludesVar =
|
|
|
|
"CMAKE_" + lang + "_STANDARD_INCLUDE_DIRECTORIES";
|
|
|
|
std::string const standardIncludes =
|
|
|
|
this->Makefile->GetSafeDefinition(standardIncludesVar);
|
|
|
|
std::vector<std::string>::size_type const before = includes.size();
|
|
|
|
cmSystemTools::ExpandListArgument(standardIncludes, includes);
|
|
|
|
for (std::vector<std::string>::iterator i = includes.begin() + before;
|
|
|
|
i != includes.end(); ++i) {
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(*i);
|
|
|
|
}
|
|
|
|
|
2015-08-05 00:14:53 +03:00
|
|
|
return includes;
|
2012-09-16 12:03:42 +04:00
|
|
|
}
|
2012-09-14 21:04:25 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void processCompileOptionsInternal(
|
|
|
|
cmGeneratorTarget const* tgt,
|
|
|
|
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
|
|
|
|
std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
|
|
|
|
bool debugOptions, const char* logName, std::string const& language)
|
2015-08-05 00:43:56 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
|
|
|
|
it = entries.begin(),
|
|
|
|
end = entries.end();
|
|
|
|
it != end; ++it) {
|
2015-08-05 00:43:56 +03:00
|
|
|
std::vector<std::string> entryOptions;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(
|
|
|
|
(*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
|
|
|
|
dagChecker, language),
|
|
|
|
entryOptions);
|
2015-08-05 00:43:56 +03:00
|
|
|
std::string usedOptions;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator li = entryOptions.begin();
|
|
|
|
li != entryOptions.end(); ++li) {
|
2015-08-05 00:43:56 +03:00
|
|
|
std::string const& opt = *li;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (uniqueOptions.insert(opt).second) {
|
2015-08-05 00:43:56 +03:00
|
|
|
options.push_back(opt);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (debugOptions) {
|
2015-08-05 00:43:56 +03:00
|
|
|
usedOptions += " * " + opt + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!usedOptions.empty()) {
|
|
|
|
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
|
|
|
|
cmake::LOG, std::string("Used compile ") + logName +
|
|
|
|
std::string(" for target ") + tgt->GetName() + ":\n" + usedOptions,
|
|
|
|
(*it)->ge->GetBacktrace());
|
|
|
|
}
|
|
|
|
}
|
2015-08-05 00:43:56 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void processCompileOptions(
|
|
|
|
cmGeneratorTarget const* tgt,
|
|
|
|
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
|
|
|
|
std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
|
|
|
|
bool debugOptions, std::string const& language)
|
2015-08-05 00:43:56 +03:00
|
|
|
{
|
|
|
|
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
|
|
|
|
dagChecker, config, debugOptions, "options",
|
|
|
|
language);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
|
|
|
|
const std::string& config,
|
|
|
|
const std::string& language) const
|
2015-08-05 00:43:56 +03:00
|
|
|
{
|
|
|
|
UNORDERED_SET<std::string> uniqueOptions;
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(
|
|
|
|
this->GetName(), "COMPILE_OPTIONS", CM_NULLPTR, CM_NULLPTR);
|
2015-08-05 00:43:56 +03:00
|
|
|
|
|
|
|
std::vector<std::string> debugProperties;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* debugProp =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
|
|
|
|
if (debugProp) {
|
2015-08-05 00:43:56 +03:00
|
|
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:43:56 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool debugOptions = !this->DebugCompileOptionsDone &&
|
|
|
|
std::find(debugProperties.begin(), debugProperties.end(),
|
|
|
|
"COMPILE_OPTIONS") != debugProperties.end();
|
2015-08-05 00:43:56 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
|
2015-08-05 00:43:56 +03:00
|
|
|
this->DebugCompileOptionsDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:43:56 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
processCompileOptions(this, this->CompileOptionsEntries, result,
|
|
|
|
uniqueOptions, &dagChecker, config, debugOptions,
|
|
|
|
language);
|
2015-08-05 00:43:56 +03:00
|
|
|
|
|
|
|
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
|
|
|
|
linkInterfaceCompileOptionsEntries;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS",
|
|
|
|
linkInterfaceCompileOptionsEntries);
|
|
|
|
|
|
|
|
processCompileOptions(this, linkInterfaceCompileOptionsEntries, result,
|
|
|
|
uniqueOptions, &dagChecker, config, debugOptions,
|
|
|
|
language);
|
2015-08-05 00:43:56 +03:00
|
|
|
|
|
|
|
cmDeleteAll(linkInterfaceCompileOptionsEntries);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void processCompileFeatures(
|
|
|
|
cmGeneratorTarget const* tgt,
|
|
|
|
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
|
|
|
|
std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
|
|
|
|
bool debugOptions)
|
2015-08-05 00:48:58 +03:00
|
|
|
{
|
|
|
|
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
|
|
|
|
dagChecker, config, debugOptions, "features",
|
|
|
|
std::string());
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
|
|
|
|
const std::string& config) const
|
2015-08-05 00:48:58 +03:00
|
|
|
{
|
|
|
|
UNORDERED_SET<std::string> uniqueFeatures;
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(
|
|
|
|
this->GetName(), "COMPILE_FEATURES", CM_NULLPTR, CM_NULLPTR);
|
2015-08-05 00:48:58 +03:00
|
|
|
|
|
|
|
std::vector<std::string> debugProperties;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* debugProp =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
|
|
|
|
if (debugProp) {
|
2015-08-05 00:48:58 +03:00
|
|
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:48:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool debugFeatures = !this->DebugCompileFeaturesDone &&
|
|
|
|
std::find(debugProperties.begin(), debugProperties.end(),
|
|
|
|
"COMPILE_FEATURES") != debugProperties.end();
|
2015-08-05 00:48:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
|
2015-08-05 00:48:58 +03:00
|
|
|
this->DebugCompileFeaturesDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 00:48:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
processCompileFeatures(this, this->CompileFeaturesEntries, result,
|
|
|
|
uniqueFeatures, &dagChecker, config, debugFeatures);
|
2015-08-05 00:48:58 +03:00
|
|
|
|
|
|
|
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
|
|
|
|
linkInterfaceCompileFeaturesEntries;
|
2016-05-16 17:34:04 +03:00
|
|
|
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_FEATURES",
|
|
|
|
linkInterfaceCompileFeaturesEntries);
|
|
|
|
|
|
|
|
processCompileFeatures(this, linkInterfaceCompileFeaturesEntries, result,
|
|
|
|
uniqueFeatures, &dagChecker, config, debugFeatures);
|
2015-08-05 00:48:58 +03:00
|
|
|
|
|
|
|
cmDeleteAll(linkInterfaceCompileFeaturesEntries);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void processCompileDefinitions(
|
|
|
|
cmGeneratorTarget const* tgt,
|
|
|
|
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
|
|
|
|
std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
|
|
|
|
bool debugOptions, std::string const& language)
|
2015-08-05 01:00:53 +03:00
|
|
|
{
|
|
|
|
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
|
|
|
|
dagChecker, config, debugOptions,
|
|
|
|
"definitions", language);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetCompileDefinitions(
|
|
|
|
std::vector<std::string>& list, const std::string& config,
|
|
|
|
const std::string& language) const
|
2015-08-05 01:00:53 +03:00
|
|
|
{
|
|
|
|
UNORDERED_SET<std::string> uniqueOptions;
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(
|
|
|
|
this->GetName(), "COMPILE_DEFINITIONS", CM_NULLPTR, CM_NULLPTR);
|
2015-08-05 01:00:53 +03:00
|
|
|
|
|
|
|
std::vector<std::string> debugProperties;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* debugProp =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
|
|
|
|
if (debugProp) {
|
2015-08-05 01:00:53 +03:00
|
|
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 01:00:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool debugDefines = !this->DebugCompileDefinitionsDone &&
|
|
|
|
std::find(debugProperties.begin(), debugProperties.end(),
|
|
|
|
"COMPILE_DEFINITIONS") != debugProperties.end();
|
2015-08-05 01:00:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
|
2015-08-05 01:00:53 +03:00
|
|
|
this->DebugCompileDefinitionsDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 01:00:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
processCompileDefinitions(this, this->CompileDefinitionsEntries, list,
|
|
|
|
uniqueOptions, &dagChecker, config, debugDefines,
|
2015-08-05 01:00:53 +03:00
|
|
|
language);
|
|
|
|
|
|
|
|
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
|
|
|
|
linkInterfaceCompileDefinitionsEntries;
|
2016-05-16 17:34:04 +03:00
|
|
|
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS",
|
|
|
|
linkInterfaceCompileDefinitionsEntries);
|
|
|
|
if (!config.empty()) {
|
|
|
|
std::string configPropName =
|
|
|
|
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
|
|
|
|
const char* configProp = this->GetProperty(configPropName);
|
|
|
|
if (configProp) {
|
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-08-05 01:00:53 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, e.str());
|
|
|
|
}
|
|
|
|
case cmPolicies::OLD: {
|
2015-08-05 01:00:53 +03:00
|
|
|
cmGeneratorExpression ge;
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
|
2016-05-16 17:34:04 +03:00
|
|
|
ge.Parse(configProp);
|
|
|
|
linkInterfaceCompileDefinitionsEntries.push_back(
|
|
|
|
new cmGeneratorTarget::TargetPropertyEntry(cge));
|
|
|
|
} break;
|
2015-08-05 01:00:53 +03:00
|
|
|
case cmPolicies::NEW:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 01:00:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
processCompileDefinitions(this, linkInterfaceCompileDefinitionsEntries, list,
|
|
|
|
uniqueOptions, &dagChecker, config, debugDefines,
|
2015-08-05 01:00:53 +03:00
|
|
|
language);
|
|
|
|
|
|
|
|
cmDeleteAll(linkInterfaceCompileDefinitionsEntries);
|
2012-09-16 12:03:42 +04:00
|
|
|
}
|
2012-09-14 21:04:25 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
|
2012-09-14 21:04:25 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2012-09-14 21:04:25 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-02 20:42:31 +03:00
|
|
|
cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
|
2012-09-14 21:04:25 +04:00
|
|
|
|
|
|
|
// Get the names.
|
|
|
|
std::string name;
|
|
|
|
std::string soName;
|
|
|
|
std::string realName;
|
|
|
|
std::string impName;
|
|
|
|
std::string pdbName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::EXECUTABLE) {
|
2015-08-04 20:19:44 +03:00
|
|
|
this->GetExecutableNames(name, realName, impName, pdbName, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GetType() == cmState::STATIC_LIBRARY ||
|
|
|
|
this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::MODULE_LIBRARY) {
|
|
|
|
this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
|
|
|
|
} else {
|
2012-09-14 21:04:25 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-09-14 21:04:25 +04:00
|
|
|
|
|
|
|
// Get the directory.
|
2014-10-20 22:31:47 +04:00
|
|
|
std::string dir = this->GetDirectory(config, false);
|
2012-09-14 21:04:25 +04:00
|
|
|
|
|
|
|
// Add each name.
|
|
|
|
std::string f;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!name.empty()) {
|
2012-09-14 21:04:25 +04:00
|
|
|
f = dir;
|
|
|
|
f += "/";
|
|
|
|
f += name;
|
2015-07-25 20:10:44 +03:00
|
|
|
gg->AddToManifest(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!soName.empty()) {
|
2012-09-14 21:04:25 +04:00
|
|
|
f = dir;
|
|
|
|
f += "/";
|
|
|
|
f += soName;
|
2015-07-25 20:10:44 +03:00
|
|
|
gg->AddToManifest(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!realName.empty()) {
|
2012-09-14 21:04:25 +04:00
|
|
|
f = dir;
|
|
|
|
f += "/";
|
|
|
|
f += realName;
|
2015-07-25 20:10:44 +03:00
|
|
|
gg->AddToManifest(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!pdbName.empty()) {
|
2012-09-14 21:04:25 +04:00
|
|
|
f = dir;
|
|
|
|
f += "/";
|
|
|
|
f += pdbName;
|
2015-07-25 20:10:44 +03:00
|
|
|
gg->AddToManifest(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!impName.empty()) {
|
2014-10-20 22:31:47 +04:00
|
|
|
f = this->GetDirectory(config, true);
|
2012-09-14 21:04:25 +04:00
|
|
|
f += "/";
|
|
|
|
f += impName;
|
2015-07-25 20:10:44 +03:00
|
|
|
gg->AddToManifest(f);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-09-14 21:04:25 +04:00
|
|
|
}
|
2013-11-20 19:58:01 +04:00
|
|
|
|
2012-10-06 20:30:43 +04:00
|
|
|
std::string cmGeneratorTarget::GetFullPath(const std::string& config,
|
|
|
|
bool implib, bool realname) const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2012-10-06 20:30:43 +04:00
|
|
|
return this->Target->ImportedGetFullPath(config, implib);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-10-06 20:30:43 +04:00
|
|
|
return this->NormalGetFullPath(config, implib, realname);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-06 20:30:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
|
|
|
|
bool implib,
|
|
|
|
bool realname) const
|
|
|
|
{
|
2014-10-20 22:31:47 +04:00
|
|
|
std::string fpath = this->GetDirectory(config, implib);
|
2012-10-06 20:30:43 +04:00
|
|
|
fpath += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsAppBundleOnApple()) {
|
2015-08-04 20:19:47 +03:00
|
|
|
fpath = this->BuildMacContentDirectory(fpath, config, false);
|
2012-10-06 20:30:43 +04:00
|
|
|
fpath += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-06 20:30:43 +04:00
|
|
|
|
|
|
|
// Add the full name of the target.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (implib) {
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += this->GetFullName(config, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (realname) {
|
2012-10-06 20:30:43 +04:00
|
|
|
fpath += this->NormalGetRealName(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:48 +03:00
|
|
|
fpath += this->GetFullName(config, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-06 20:30:43 +04:00
|
|
|
return fpath;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::NormalGetRealName(
|
|
|
|
const std::string& config) const
|
2012-10-06 20:30:43 +04:00
|
|
|
{
|
|
|
|
// This should not be called for imported targets.
|
|
|
|
// TODO: Split cmTarget into a class hierarchy to get compile-time
|
|
|
|
// enforcement of the limited imported target API.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
|
|
|
std::string msg = "NormalGetRealName called on imported target: ";
|
2012-10-06 20:30:43 +04:00
|
|
|
msg += this->GetName();
|
2015-08-25 23:18:39 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-06 20:30:43 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::EXECUTABLE) {
|
2012-10-06 20:30:43 +04:00
|
|
|
// Compute the real name that will be built.
|
|
|
|
std::string name;
|
|
|
|
std::string realName;
|
|
|
|
std::string impName;
|
|
|
|
std::string pdbName;
|
2015-08-04 20:19:44 +03:00
|
|
|
this->GetExecutableNames(name, realName, impName, pdbName, config);
|
2012-10-06 20:30:43 +04:00
|
|
|
return realName;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-10-06 20:30:43 +04:00
|
|
|
// Compute the real name that will be built.
|
|
|
|
std::string name;
|
|
|
|
std::string soName;
|
|
|
|
std::string realName;
|
|
|
|
std::string impName;
|
|
|
|
std::string pdbName;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
|
2012-10-06 20:30:43 +04:00
|
|
|
return realName;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-10-06 20:30:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
|
|
|
|
std::string& realName,
|
|
|
|
std::string& impName,
|
|
|
|
std::string& pdbName,
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:45 +03:00
|
|
|
{
|
|
|
|
// This should not be called for imported targets.
|
|
|
|
// TODO: Split cmTarget into a class hierarchy to get compile-time
|
|
|
|
// enforcement of the limited imported target API.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
|
|
|
std::string msg = "GetLibraryNames called on imported target: ";
|
2015-08-04 20:19:45 +03:00
|
|
|
msg += this->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
|
2015-08-04 20:19:45 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:45 +03:00
|
|
|
|
|
|
|
// Check for library version properties.
|
|
|
|
const char* version = this->GetProperty("VERSION");
|
|
|
|
const char* soversion = this->GetProperty("SOVERSION");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->HasSOName(config) ||
|
|
|
|
this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") ||
|
|
|
|
this->IsFrameworkOnApple()) {
|
2015-08-04 20:19:45 +03:00
|
|
|
// Versioning is supported only for shared libraries and modules,
|
|
|
|
// and then only when the platform supports an soname flag.
|
2016-06-27 23:44:16 +03:00
|
|
|
version = CM_NULLPTR;
|
|
|
|
soversion = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (version && !soversion) {
|
2015-08-04 20:19:45 +03:00
|
|
|
// The soversion must be set if the library version is set. Use
|
|
|
|
// the library version as the soversion.
|
|
|
|
soversion = version;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!version && soversion) {
|
2015-08-04 20:19:45 +03:00
|
|
|
// Use the soversion as the library version.
|
|
|
|
version = soversion;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:45 +03:00
|
|
|
|
|
|
|
// Get the components of the library name.
|
|
|
|
std::string prefix;
|
|
|
|
std::string base;
|
|
|
|
std::string suffix;
|
2015-08-04 20:19:48 +03:00
|
|
|
this->GetFullNameInternal(config, false, prefix, base, suffix);
|
2015-08-04 20:19:45 +03:00
|
|
|
|
|
|
|
// The library name.
|
2016-05-16 17:34:04 +03:00
|
|
|
name = prefix + base + suffix;
|
2015-08-04 20:19:45 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsFrameworkOnApple()) {
|
2015-08-04 20:19:45 +03:00
|
|
|
realName = prefix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->PlatformIsAppleIos()) {
|
2015-08-18 22:30:54 +03:00
|
|
|
realName += "Versions/";
|
2015-10-23 01:47:31 +03:00
|
|
|
realName += this->GetFrameworkVersion();
|
2015-08-18 22:30:54 +03:00
|
|
|
realName += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:45 +03:00
|
|
|
realName += base;
|
|
|
|
soName = realName;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:45 +03:00
|
|
|
// The library's soname.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ComputeVersionedName(soName, prefix, base, suffix, name, soversion);
|
2015-08-04 20:19:45 +03:00
|
|
|
|
|
|
|
// The library's real name on disk.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ComputeVersionedName(realName, prefix, base, suffix, name, version);
|
2015-08-04 20:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// The import library name.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::MODULE_LIBRARY) {
|
2015-08-04 20:19:48 +03:00
|
|
|
impName = this->GetFullNameInternal(config, true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:45 +03:00
|
|
|
impName = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:45 +03:00
|
|
|
|
|
|
|
// The program database file name.
|
2015-08-04 20:19:46 +03:00
|
|
|
pdbName = this->GetPDBName(config);
|
2015-08-04 20:19:45 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:44 +03:00
|
|
|
void cmGeneratorTarget::GetExecutableNames(std::string& name,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string& realName,
|
|
|
|
std::string& impName,
|
|
|
|
std::string& pdbName,
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:44 +03:00
|
|
|
{
|
|
|
|
// This should not be called for imported targets.
|
|
|
|
// TODO: Split cmTarget into a class hierarchy to get compile-time
|
|
|
|
// enforcement of the limited imported target API.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
|
|
|
std::string msg = "GetExecutableNames called on imported target: ";
|
2015-08-04 20:19:44 +03:00
|
|
|
msg += this->GetName();
|
|
|
|
this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// This versioning is supported only for executables and then only
|
|
|
|
// when the platform supports symbolic links.
|
2015-08-04 20:19:44 +03:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
|
|
const char* version = 0;
|
|
|
|
#else
|
|
|
|
// Check for executable version properties.
|
|
|
|
const char* version = this->GetProperty("VERSION");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() != cmState::EXECUTABLE ||
|
|
|
|
this->Makefile->IsOn("XCODE")) {
|
2016-06-27 23:44:16 +03:00
|
|
|
version = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Get the components of the executable name.
|
|
|
|
std::string prefix;
|
|
|
|
std::string base;
|
|
|
|
std::string suffix;
|
2015-08-04 20:19:48 +03:00
|
|
|
this->GetFullNameInternal(config, false, prefix, base, suffix);
|
2015-08-04 20:19:44 +03:00
|
|
|
|
|
|
|
// The executable name.
|
2016-05-16 17:34:04 +03:00
|
|
|
name = prefix + base + suffix;
|
2015-08-04 20:19:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// The executable's real name on disk.
|
2015-08-04 20:19:44 +03:00
|
|
|
#if defined(__CYGWIN__)
|
2016-05-16 17:34:04 +03:00
|
|
|
realName = prefix + base;
|
2015-08-04 20:19:44 +03:00
|
|
|
#else
|
|
|
|
realName = name;
|
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
if (version) {
|
2015-08-04 20:19:44 +03:00
|
|
|
realName += "-";
|
|
|
|
realName += version;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
#if defined(__CYGWIN__)
|
|
|
|
realName += suffix;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// The import library name.
|
2015-08-04 20:19:48 +03:00
|
|
|
impName = this->GetFullNameInternal(config, true);
|
2015-08-04 20:19:44 +03:00
|
|
|
|
|
|
|
// The program database file name.
|
2015-08-04 20:19:46 +03:00
|
|
|
pdbName = this->GetPDBName(config);
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:48 +03:00
|
|
|
std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config,
|
|
|
|
bool implib) const
|
|
|
|
{
|
|
|
|
std::string prefix;
|
|
|
|
std::string base;
|
|
|
|
std::string suffix;
|
|
|
|
this->GetFullNameInternal(config, implib, prefix, base, suffix);
|
2016-05-16 17:34:04 +03:00
|
|
|
return prefix + base + suffix;
|
2015-08-04 20:19:48 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmGeneratorTarget::ImportedGetLocation(
|
|
|
|
const std::string& config) const
|
2015-10-16 20:19:50 +03:00
|
|
|
{
|
|
|
|
static std::string location;
|
|
|
|
assert(this->IsImported());
|
|
|
|
location = this->Target->ImportedGetFullPath(config, false);
|
|
|
|
return location.c_str();
|
|
|
|
}
|
|
|
|
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string cmGeneratorTarget::GetFullNameImported(const std::string& config,
|
|
|
|
bool implib) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::GetFilenameName(
|
|
|
|
this->Target->ImportedGetFullPath(config, implib));
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:48 +03:00
|
|
|
void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
|
|
|
|
bool implib,
|
|
|
|
std::string& outPrefix,
|
|
|
|
std::string& outBase,
|
|
|
|
std::string& outSuffix) const
|
|
|
|
{
|
|
|
|
// Use just the target name for non-main target types.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() != cmState::STATIC_LIBRARY &&
|
|
|
|
this->GetType() != cmState::SHARED_LIBRARY &&
|
|
|
|
this->GetType() != cmState::MODULE_LIBRARY &&
|
|
|
|
this->GetType() != cmState::EXECUTABLE) {
|
2015-08-04 20:19:48 +03:00
|
|
|
outPrefix = "";
|
|
|
|
outBase = this->GetName();
|
|
|
|
outSuffix = "";
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// Return an empty name for the import library if this platform
|
|
|
|
// does not support import libraries.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (implib &&
|
|
|
|
!this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
|
2015-08-04 20:19:48 +03:00
|
|
|
outPrefix = "";
|
|
|
|
outBase = "";
|
|
|
|
outSuffix = "";
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// The implib option is only allowed for shared libraries, module
|
|
|
|
// libraries, and executables.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() != cmState::SHARED_LIBRARY &&
|
|
|
|
this->GetType() != cmState::MODULE_LIBRARY &&
|
|
|
|
this->GetType() != cmState::EXECUTABLE) {
|
2015-08-04 20:19:48 +03:00
|
|
|
implib = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// Compute the full name for main target types.
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* targetPrefix = (implib ? this->GetProperty("IMPORT_PREFIX")
|
|
|
|
: this->GetProperty("PREFIX"));
|
|
|
|
const char* targetSuffix = (implib ? this->GetProperty("IMPORT_SUFFIX")
|
|
|
|
: this->GetProperty("SUFFIX"));
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* configPostfix = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-08-04 20:19:48 +03:00
|
|
|
std::string configProp = cmSystemTools::UpperCase(config);
|
|
|
|
configProp += "_POSTFIX";
|
|
|
|
configPostfix = this->GetProperty(configProp);
|
|
|
|
// Mac application bundles and frameworks have no postfix.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configPostfix &&
|
|
|
|
(this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) {
|
2016-06-27 23:44:16 +03:00
|
|
|
configPostfix = CM_NULLPTR;
|
2015-08-04 20:19:48 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
const char* prefixVar = this->Target->GetPrefixVariableInternal(implib);
|
|
|
|
const char* suffixVar = this->Target->GetSuffixVariableInternal(implib);
|
|
|
|
|
|
|
|
// Check for language-specific default prefix and suffix.
|
2015-08-04 20:19:49 +03:00
|
|
|
std::string ll = this->GetLinkerLanguage(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ll.empty()) {
|
|
|
|
if (!targetSuffix && suffixVar && *suffixVar) {
|
2015-08-04 20:19:48 +03:00
|
|
|
std::string langSuff = suffixVar + std::string("_") + ll;
|
|
|
|
targetSuffix = this->Makefile->GetDefinition(langSuff);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!targetPrefix && prefixVar && *prefixVar) {
|
2015-08-04 20:19:48 +03:00
|
|
|
std::string langPrefix = prefixVar + std::string("_") + ll;
|
|
|
|
targetPrefix = this->Makefile->GetDefinition(langPrefix);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// if there is no prefix on the target use the cmake definition
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!targetPrefix && prefixVar) {
|
2015-08-04 20:19:48 +03:00
|
|
|
targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
// if there is no suffix on the target use the cmake definition
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!targetSuffix && suffixVar) {
|
2015-08-04 20:19:48 +03:00
|
|
|
targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// frameworks have directory prefix but no suffix
|
|
|
|
std::string fw_prefix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsFrameworkOnApple()) {
|
2015-08-04 20:19:50 +03:00
|
|
|
fw_prefix = this->GetOutputName(config, false);
|
2016-06-19 22:26:40 +03:00
|
|
|
fw_prefix += ".";
|
|
|
|
const char* ext = this->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (!ext) {
|
|
|
|
ext = "framework";
|
|
|
|
}
|
|
|
|
fw_prefix += ext;
|
|
|
|
fw_prefix += "/";
|
2015-08-04 20:19:48 +03:00
|
|
|
targetPrefix = fw_prefix.c_str();
|
2016-06-27 23:44:16 +03:00
|
|
|
targetSuffix = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsCFBundleOnApple()) {
|
2015-08-04 20:19:48 +03:00
|
|
|
fw_prefix = this->GetCFBundleDirectory(config, false);
|
2015-08-04 20:19:48 +03:00
|
|
|
fw_prefix += "/";
|
|
|
|
targetPrefix = fw_prefix.c_str();
|
2016-06-27 23:44:16 +03:00
|
|
|
targetSuffix = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// Begin the final name with the prefix.
|
2016-05-16 17:34:04 +03:00
|
|
|
outPrefix = targetPrefix ? targetPrefix : "";
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// Append the target name or property-specified name.
|
2015-08-04 20:19:50 +03:00
|
|
|
outBase += this->GetOutputName(config, implib);
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// Append the per-configuration postfix.
|
2016-05-16 17:34:04 +03:00
|
|
|
outBase += configPostfix ? configPostfix : "";
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// Name shared libraries with their version number on some platforms.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* soversion = this->GetProperty("SOVERSION")) {
|
|
|
|
if (this->GetType() == cmState::SHARED_LIBRARY && !implib &&
|
|
|
|
this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) {
|
2015-08-04 20:19:48 +03:00
|
|
|
outBase += "-";
|
|
|
|
outBase += soversion;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:48 +03:00
|
|
|
|
|
|
|
// Append the suffix.
|
2016-05-16 17:34:04 +03:00
|
|
|
outSuffix = targetSuffix ? targetSuffix : "";
|
2015-08-04 20:19:48 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetLinkerLanguage(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:49 +03:00
|
|
|
{
|
2015-08-04 20:19:49 +03:00
|
|
|
return this->GetLinkClosure(config)->LinkerLanguage;
|
2015-08-04 20:19:49 +03:00
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:46 +03:00
|
|
|
std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
|
|
|
|
{
|
|
|
|
std::string prefix;
|
|
|
|
std::string base;
|
|
|
|
std::string suffix;
|
2015-08-04 20:19:48 +03:00
|
|
|
this->GetFullNameInternal(config, false, prefix, base, suffix);
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
std::vector<std::string> props;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string configUpper = cmSystemTools::UpperCase(config);
|
|
|
|
if (!configUpper.empty()) {
|
2015-08-04 20:19:46 +03:00
|
|
|
// PDB_NAME_<CONFIG>
|
|
|
|
props.push_back("PDB_NAME_" + configUpper);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:46 +03:00
|
|
|
|
|
|
|
// PDB_NAME
|
|
|
|
props.push_back("PDB_NAME");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = props.begin();
|
|
|
|
i != props.end(); ++i) {
|
|
|
|
if (const char* outName = this->GetProperty(*i)) {
|
2015-08-04 20:19:46 +03:00
|
|
|
base = outName;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
return prefix + base + ".pdb";
|
2015-08-04 20:19:44 +03:00
|
|
|
}
|
|
|
|
|
2015-10-21 20:51:50 +03:00
|
|
|
bool cmGeneratorTarget::StrictTargetComparison::operator()(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget const* t1, cmGeneratorTarget const* t2) const
|
2015-10-21 20:51:50 +03:00
|
|
|
{
|
|
|
|
int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nameResult == 0) {
|
2015-10-21 20:51:50 +03:00
|
|
|
return strcmp(t1->GetLocalGenerator()->GetCurrentBinaryDirectory(),
|
|
|
|
t2->GetLocalGenerator()->GetCurrentBinaryDirectory()) < 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-21 20:51:50 +03:00
|
|
|
return nameResult < 0;
|
|
|
|
}
|
|
|
|
|
2014-02-06 14:24:37 +04:00
|
|
|
struct cmGeneratorTarget::SourceFileFlags
|
|
|
|
cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
|
|
|
|
{
|
|
|
|
struct SourceFileFlags flags;
|
|
|
|
this->ConstructSourceFileFlags();
|
|
|
|
std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
|
|
|
|
this->SourceFlagsMap.find(sf);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (si != this->SourceFlagsMap.end()) {
|
2014-02-06 14:24:37 +04:00
|
|
|
flags = si->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-14 15:24:13 +04:00
|
|
|
// Handle the MACOSX_PACKAGE_LOCATION property on source files that
|
|
|
|
// were not listed in one of the other lists.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) {
|
2014-02-14 15:24:13 +04:00
|
|
|
flags.MacFolder = location;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (strcmp(location, "Resources") == 0) {
|
2014-02-14 15:24:13 +04:00
|
|
|
flags.Type = cmGeneratorTarget::SourceFileTypeResource;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-02-14 15:24:13 +04:00
|
|
|
flags.Type = cmGeneratorTarget::SourceFileTypeMacContent;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-06 14:24:37 +04:00
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGeneratorTarget::ConstructSourceFileFlags() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SourceFileFlagsConstructed) {
|
2014-02-06 14:24:37 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-06 14:24:37 +04:00
|
|
|
this->SourceFileFlagsConstructed = true;
|
|
|
|
|
|
|
|
// Process public headers to mark the source files.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* files = this->GetProperty("PUBLIC_HEADER")) {
|
2014-02-06 14:24:37 +04:00
|
|
|
std::vector<std::string> relFiles;
|
|
|
|
cmSystemTools::ExpandListArgument(files, relFiles);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator it = relFiles.begin();
|
|
|
|
it != relFiles.end(); ++it) {
|
|
|
|
if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
|
2014-02-06 14:24:37 +04:00
|
|
|
SourceFileFlags& flags = this->SourceFlagsMap[sf];
|
|
|
|
flags.MacFolder = "Headers";
|
|
|
|
flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-06 14:24:37 +04:00
|
|
|
|
|
|
|
// Process private headers after public headers so that they take
|
|
|
|
// precedence if a file is listed in both.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* files = this->GetProperty("PRIVATE_HEADER")) {
|
2014-02-06 14:24:37 +04:00
|
|
|
std::vector<std::string> relFiles;
|
|
|
|
cmSystemTools::ExpandListArgument(files, relFiles);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator it = relFiles.begin();
|
|
|
|
it != relFiles.end(); ++it) {
|
|
|
|
if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
|
2014-02-06 14:24:37 +04:00
|
|
|
SourceFileFlags& flags = this->SourceFlagsMap[sf];
|
|
|
|
flags.MacFolder = "PrivateHeaders";
|
|
|
|
flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-06 14:24:37 +04:00
|
|
|
|
|
|
|
// Mark sources listed as resources.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* files = this->GetProperty("RESOURCE")) {
|
2014-02-06 14:24:37 +04:00
|
|
|
std::vector<std::string> relFiles;
|
|
|
|
cmSystemTools::ExpandListArgument(files, relFiles);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator it = relFiles.begin();
|
|
|
|
it != relFiles.end(); ++it) {
|
|
|
|
if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
|
2014-02-06 14:24:37 +04:00
|
|
|
SourceFileFlags& flags = this->SourceFlagsMap[sf];
|
2015-12-03 00:34:25 +03:00
|
|
|
flags.MacFolder = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile->PlatformIsAppleIos()) {
|
2015-12-03 00:34:25 +03:00
|
|
|
flags.MacFolder = "Resources";
|
2014-02-06 14:24:37 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
flags.Type = cmGeneratorTarget::SourceFileTypeResource;
|
2014-02-06 14:24:37 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-06 14:24:37 +04:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
|
|
|
|
const cmGeneratorTarget::CompatibleInterfacesBase&
|
|
|
|
cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
|
|
|
|
{
|
|
|
|
cmGeneratorTarget::CompatibleInterfaces& compat =
|
|
|
|
this->CompatibleInterfacesMap[config];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!compat.Done) {
|
2015-08-04 20:19:42 +03:00
|
|
|
compat.Done = true;
|
|
|
|
compat.PropsBool.insert("POSITION_INDEPENDENT_CODE");
|
|
|
|
compat.PropsString.insert("AUTOUIC_OPTIONS");
|
2015-10-08 02:45:44 +03:00
|
|
|
std::vector<cmGeneratorTarget const*> const& deps =
|
2015-08-04 20:19:44 +03:00
|
|
|
this->GetLinkImplementationClosure(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget const*>::const_iterator li =
|
|
|
|
deps.begin();
|
|
|
|
li != deps.end(); ++li) {
|
|
|
|
#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
|
|
|
|
if (const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
|
|
|
|
std::vector<std::string> props; \
|
|
|
|
cmSystemTools::ExpandListArgument(prop, props); \
|
|
|
|
compat.Props##x.insert(props.begin(), props.end()); \
|
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
|
|
|
|
CM_READ_COMPATIBLE_INTERFACE(STRING, String)
|
|
|
|
CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin)
|
|
|
|
CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax)
|
|
|
|
#undef CM_READ_COMPATIBLE_INTERFACE
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
return compat;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:42 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::OBJECT_LIBRARY ||
|
|
|
|
this->GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-08-04 20:19:42 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:42 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::OBJECT_LIBRARY ||
|
|
|
|
this->GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-08-04 20:19:42 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:42 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::OBJECT_LIBRARY ||
|
|
|
|
this->GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-08-04 20:19:42 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:42 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::OBJECT_LIBRARY ||
|
|
|
|
this->GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-08-04 20:19:42 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0;
|
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
|
2015-08-04 20:19:43 +03:00
|
|
|
enum CompatibleType
|
|
|
|
{
|
|
|
|
BoolType,
|
|
|
|
StringType,
|
|
|
|
NumberMinType,
|
|
|
|
NumberMaxType
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename PropertyType>
|
2015-08-04 20:19:43 +03:00
|
|
|
PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
|
2015-08-04 20:19:43 +03:00
|
|
|
const std::string& prop,
|
|
|
|
const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
CompatibleType, PropertyType*);
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
2015-08-04 20:19:43 +03:00
|
|
|
bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
|
2015-08-04 20:19:43 +03:00
|
|
|
const std::string& prop,
|
|
|
|
const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
CompatibleType, bool*)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2015-08-04 20:19:43 +03:00
|
|
|
return tgt->GetLinkInterfaceDependentBoolProperty(prop, config);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
|
|
|
const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
|
|
|
|
const std::string& prop,
|
|
|
|
const std::string& config,
|
|
|
|
CompatibleType t, const char**)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (t) {
|
|
|
|
case BoolType:
|
|
|
|
assert(0 && "String compatibility check function called for boolean");
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
case StringType:
|
|
|
|
return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
|
|
|
|
case NumberMinType:
|
|
|
|
return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config);
|
|
|
|
case NumberMaxType:
|
|
|
|
return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
assert(0 && "Unreachable!");
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename PropertyType>
|
2015-08-04 20:19:43 +03:00
|
|
|
void checkPropertyConsistency(cmGeneratorTarget const* depender,
|
2015-10-08 01:49:38 +03:00
|
|
|
cmGeneratorTarget const* dependee,
|
2015-08-04 20:19:43 +03:00
|
|
|
const std::string& propName,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set<std::string>& emitted,
|
|
|
|
const std::string& config, CompatibleType t,
|
|
|
|
PropertyType*)
|
|
|
|
{
|
|
|
|
const char* prop = dependee->GetProperty(propName);
|
|
|
|
if (!prop) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
|
|
|
std::vector<std::string> props;
|
|
|
|
cmSystemTools::ExpandListArgument(prop, props);
|
2016-03-14 17:38:19 +03:00
|
|
|
std::string pdir = cmSystemTools::GetCMakeRoot();
|
2015-08-04 20:19:43 +03:00
|
|
|
pdir += "/Help/prop_tgt/";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator pi = props.begin();
|
|
|
|
pi != props.end(); ++pi) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::string pname = cmSystemTools::HelpFileName(*pi);
|
|
|
|
std::string pfile = pdir + pname + ".rst";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(pfile.c_str(), true)) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Target \"" << dependee->GetName() << "\" has property \"" << *pi
|
|
|
|
<< "\" listed in its " << propName
|
|
|
|
<< " property. "
|
|
|
|
"This is not allowed. Only user-defined properties may appear "
|
|
|
|
"listed in the "
|
|
|
|
<< propName << " property.";
|
2015-08-04 20:19:43 +03:00
|
|
|
depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2015-08-04 20:19:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (emitted.insert(*pi).second) {
|
|
|
|
getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config, t,
|
2016-06-27 23:44:16 +03:00
|
|
|
CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static std::string intersect(const std::set<std::string>& s1,
|
|
|
|
const std::set<std::string>& s2)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
|
|
|
std::set<std::string> intersect;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
|
|
|
|
std::inserter(intersect, intersect.begin()));
|
|
|
|
if (!intersect.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return *intersect.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static std::string intersect(const std::set<std::string>& s1,
|
|
|
|
const std::set<std::string>& s2,
|
|
|
|
const std::set<std::string>& s3)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
result = intersect(s1, s2);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!result.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return result;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
result = intersect(s1, s3);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!result.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return result;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
return intersect(s2, s3);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static std::string intersect(const std::set<std::string>& s1,
|
|
|
|
const std::set<std::string>& s2,
|
|
|
|
const std::set<std::string>& s3,
|
|
|
|
const std::set<std::string>& s4)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
result = intersect(s1, s2);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!result.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return result;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
result = intersect(s1, s3);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!result.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return result;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
result = intersect(s1, s4);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!result.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return result;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
return intersect(s2, s3, s4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGeneratorTarget::CheckPropertyCompatibility(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmComputeLinkInformation* info, const std::string& config) const
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
|
2015-08-04 20:19:43 +03:00
|
|
|
|
|
|
|
std::set<std::string> emittedBools;
|
|
|
|
static std::string strBool = "COMPATIBLE_INTERFACE_BOOL";
|
|
|
|
std::set<std::string> emittedStrings;
|
|
|
|
static std::string strString = "COMPATIBLE_INTERFACE_STRING";
|
|
|
|
std::set<std::string> emittedMinNumbers;
|
|
|
|
static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN";
|
|
|
|
std::set<std::string> emittedMaxNumbers;
|
|
|
|
static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
|
|
|
|
li != deps.end(); ++li) {
|
|
|
|
if (!li->Target) {
|
2015-08-04 20:19:43 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
checkPropertyConsistency<bool>(this, li->Target, strBool, emittedBools,
|
2016-06-27 23:44:16 +03:00
|
|
|
config, BoolType, CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
checkPropertyConsistency<const char*>(this, li->Target, strString,
|
|
|
|
emittedStrings, config, StringType,
|
|
|
|
CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
checkPropertyConsistency<const char*>(this, li->Target, strNumMin,
|
|
|
|
emittedMinNumbers, config,
|
2016-06-27 23:44:16 +03:00
|
|
|
NumberMinType, CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
checkPropertyConsistency<const char*>(this, li->Target, strNumMax,
|
|
|
|
emittedMaxNumbers, config,
|
2016-06-27 23:44:16 +03:00
|
|
|
NumberMaxType, CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string prop = intersect(emittedBools, emittedStrings, emittedMinNumbers,
|
2015-08-04 20:19:43 +03:00
|
|
|
emittedMaxNumbers);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!prop.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
// Use a sorted std::vector to keep the error message sorted.
|
|
|
|
std::vector<std::string> props;
|
|
|
|
std::set<std::string>::const_iterator i = emittedBools.find(prop);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != emittedBools.end()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
props.push_back(strBool);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
i = emittedStrings.find(prop);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != emittedStrings.end()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
props.push_back(strString);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
i = emittedMinNumbers.find(prop);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != emittedMinNumbers.end()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
props.push_back(strNumMin);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
i = emittedMaxNumbers.find(prop);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != emittedMaxNumbers.end()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
props.push_back(strNumMax);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
std::sort(props.begin(), props.end());
|
|
|
|
|
|
|
|
std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", ");
|
|
|
|
propsString += " and the " + props.back();
|
|
|
|
|
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Property \"" << prop << "\" appears in both the " << propsString
|
|
|
|
<< " property in the dependencies of target \"" << this->GetName()
|
|
|
|
<< "\". This is not allowed. A property may only require compatibility "
|
|
|
|
"in a boolean interpretation, a numeric minimum, a numeric maximum "
|
|
|
|
"or a "
|
|
|
|
"string interpretation, but not a mixture.";
|
2015-08-04 20:19:43 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
|
2015-08-04 20:19:43 +03:00
|
|
|
std::string compatibilityType(CompatibleType t)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (t) {
|
2015-08-04 20:19:43 +03:00
|
|
|
case BoolType:
|
2015-08-04 20:19:43 +03:00
|
|
|
return "Boolean compatibility";
|
2015-08-04 20:19:43 +03:00
|
|
|
case StringType:
|
2015-08-04 20:19:43 +03:00
|
|
|
return "String compatibility";
|
2015-08-04 20:19:43 +03:00
|
|
|
case NumberMaxType:
|
2015-08-04 20:19:43 +03:00
|
|
|
return "Numeric maximum compatibility";
|
2015-08-04 20:19:43 +03:00
|
|
|
case NumberMinType:
|
2015-08-04 20:19:43 +03:00
|
|
|
return "Numeric minimum compatibility";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
assert(0 && "Unreachable!");
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-08-04 20:19:43 +03:00
|
|
|
std::string compatibilityAgree(CompatibleType t, bool dominant)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (t) {
|
2015-08-04 20:19:43 +03:00
|
|
|
case BoolType:
|
|
|
|
case StringType:
|
2015-08-04 20:19:43 +03:00
|
|
|
return dominant ? "(Disagree)\n" : "(Agree)\n";
|
2015-08-04 20:19:43 +03:00
|
|
|
case NumberMaxType:
|
|
|
|
case NumberMinType:
|
2015-08-04 20:19:43 +03:00
|
|
|
return dominant ? "(Dominant)\n" : "(Ignored)\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
assert(0 && "Unreachable!");
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename PropertyType>
|
2015-10-08 02:47:02 +03:00
|
|
|
PropertyType getTypedProperty(cmGeneratorTarget const* tgt,
|
|
|
|
const std::string& prop);
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
2015-10-08 02:47:02 +03:00
|
|
|
bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
|
|
|
|
const std::string& prop)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
|
|
|
return tgt->GetPropertyAsBool(prop);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
|
|
|
const char* getTypedProperty<const char*>(cmGeneratorTarget const* tgt,
|
|
|
|
const std::string& prop)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
|
|
|
return tgt->GetProperty(prop);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename PropertyType>
|
2015-08-04 20:19:43 +03:00
|
|
|
std::string valueAsString(PropertyType);
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
2015-08-04 20:19:43 +03:00
|
|
|
std::string valueAsString<bool>(bool value)
|
|
|
|
{
|
|
|
|
return value ? "TRUE" : "FALSE";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
2015-08-04 20:19:43 +03:00
|
|
|
std::string valueAsString<const char*>(const char* value)
|
|
|
|
{
|
|
|
|
return value ? value : "(unset)";
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename PropertyType>
|
2015-08-04 20:19:43 +03:00
|
|
|
PropertyType impliedValue(PropertyType);
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
2015-08-04 20:19:43 +03:00
|
|
|
bool impliedValue<bool>(bool)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
2015-08-04 20:19:43 +03:00
|
|
|
const char* impliedValue<const char*>(const char*)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename PropertyType>
|
2015-08-04 20:19:43 +03:00
|
|
|
std::pair<bool, PropertyType> consistentProperty(PropertyType lhs,
|
|
|
|
PropertyType rhs,
|
2015-08-04 20:19:43 +03:00
|
|
|
CompatibleType t);
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
|
|
|
std::pair<bool, bool> consistentProperty(bool lhs, bool rhs, CompatibleType)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
|
|
|
return std::make_pair(lhs == rhs, lhs);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::pair<bool, const char*> consistentStringProperty(const char* lhs,
|
|
|
|
const char* rhs)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
|
|
|
const bool b = strcmp(lhs, rhs) == 0;
|
2016-06-27 23:44:16 +03:00
|
|
|
return std::make_pair(b, b ? lhs : CM_NULLPTR);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
|
|
|
|
const char* rhs,
|
|
|
|
CompatibleType t)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
char* pEnd;
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* const null_ptr = CM_NULLPTR;
|
2015-08-04 20:19:43 +03:00
|
|
|
|
|
|
|
long lnum = strtol(lhs, &pEnd, 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return std::pair<bool, const char*>(false, null_ptr);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
|
|
|
long rnum = strtol(rhs, &pEnd, 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return std::pair<bool, const char*>(false, null_ptr);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t == NumberMaxType) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <>
|
|
|
|
std::pair<bool, const char*> consistentProperty(const char* lhs,
|
|
|
|
const char* rhs,
|
2015-08-04 20:19:43 +03:00
|
|
|
CompatibleType t)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!lhs && !rhs) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return std::make_pair(true, lhs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!lhs) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return std::make_pair(true, rhs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!rhs) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return std::make_pair(true, lhs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* const null_ptr = CM_NULLPTR;
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (t) {
|
|
|
|
case BoolType:
|
|
|
|
assert(0 && "consistentProperty for strings called with BoolType");
|
|
|
|
return std::pair<bool, const char*>(false, null_ptr);
|
|
|
|
case StringType:
|
|
|
|
return consistentStringProperty(lhs, rhs);
|
|
|
|
case NumberMinType:
|
|
|
|
case NumberMaxType:
|
|
|
|
return consistentNumberProperty(lhs, rhs, t);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
assert(0 && "Unreachable!");
|
|
|
|
return std::pair<bool, const char*>(false, null_ptr);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename PropertyType>
|
2015-08-04 20:19:44 +03:00
|
|
|
PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& p,
|
|
|
|
const std::string& config,
|
|
|
|
const char* defaultValue,
|
|
|
|
CompatibleType t,
|
|
|
|
PropertyType*)
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2015-10-08 02:47:02 +03:00
|
|
|
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
|
2015-10-25 12:35:36 +03:00
|
|
|
std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
|
|
|
|
const bool explicitlySet =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::find(headPropKeys.begin(), headPropKeys.end(), p) !=
|
|
|
|
headPropKeys.end();
|
2015-10-25 12:35:36 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const bool impliedByUse = tgt->IsNullImpliedByLinkLibraries(p);
|
|
|
|
assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet));
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2015-10-08 02:45:44 +03:00
|
|
|
std::vector<cmGeneratorTarget const*> const& deps =
|
2015-08-04 20:19:44 +03:00
|
|
|
tgt->GetLinkImplementationClosure(config);
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (deps.empty()) {
|
2015-08-04 20:19:43 +03:00
|
|
|
return propContent;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
bool propInitialized = explicitlySet;
|
|
|
|
|
|
|
|
std::string report = " * Target \"";
|
|
|
|
report += tgt->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (explicitlySet) {
|
2015-08-04 20:19:43 +03:00
|
|
|
report += "\" has property content \"";
|
|
|
|
report += valueAsString<PropertyType>(propContent);
|
|
|
|
report += "\"\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (impliedByUse) {
|
2015-08-04 20:19:43 +03:00
|
|
|
report += "\" property is implied by use.\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
report += "\" property not set.\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
|
|
|
std::string interfaceProperty = "INTERFACE_" + p;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget const*>::const_iterator li = deps.begin();
|
|
|
|
li != deps.end(); ++li) {
|
2015-08-04 20:19:43 +03:00
|
|
|
// An error should be reported if one dependency
|
|
|
|
// has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other
|
|
|
|
// has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the
|
|
|
|
// target itself has a POSITION_INDEPENDENT_CODE which disagrees
|
|
|
|
// with a dependency.
|
|
|
|
|
2015-10-08 02:45:44 +03:00
|
|
|
cmGeneratorTarget const* theTarget = *li;
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2015-10-25 12:35:36 +03:00
|
|
|
std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const bool ifaceIsSet = std::find(propKeys.begin(), propKeys.end(),
|
|
|
|
interfaceProperty) != propKeys.end();
|
2015-08-04 20:19:43 +03:00
|
|
|
PropertyType ifacePropContent =
|
2016-05-16 17:34:04 +03:00
|
|
|
getTypedProperty<PropertyType>(theTarget, interfaceProperty);
|
2015-08-04 20:19:43 +03:00
|
|
|
|
|
|
|
std::string reportEntry;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ifaceIsSet) {
|
2015-08-04 20:19:43 +03:00
|
|
|
reportEntry += " * Target \"";
|
|
|
|
reportEntry += theTarget->GetName();
|
|
|
|
reportEntry += "\" property value \"";
|
|
|
|
reportEntry += valueAsString<PropertyType>(ifacePropContent);
|
|
|
|
reportEntry += "\" ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (explicitlySet) {
|
|
|
|
if (ifaceIsSet) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::pair<bool, PropertyType> consistent =
|
2016-05-16 17:34:04 +03:00
|
|
|
consistentProperty(propContent, ifacePropContent, t);
|
2015-08-04 20:19:43 +03:00
|
|
|
report += reportEntry;
|
|
|
|
report += compatibilityAgree(t, propContent != consistent.second);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!consistent.first) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Property " << p << " on target \"" << tgt->GetName()
|
|
|
|
<< "\" does\nnot match the "
|
|
|
|
"INTERFACE_"
|
|
|
|
<< p << " property requirement\nof "
|
|
|
|
"dependency \""
|
|
|
|
<< theTarget->GetName() << "\".\n";
|
2015-08-04 20:19:43 +03:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
propContent = consistent.second;
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
// Explicitly set on target and not set in iface. Can't disagree.
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (impliedByUse) {
|
2015-08-04 20:19:43 +03:00
|
|
|
propContent = impliedValue<PropertyType>(propContent);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ifaceIsSet) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::pair<bool, PropertyType> consistent =
|
2016-05-16 17:34:04 +03:00
|
|
|
consistentProperty(propContent, ifacePropContent, t);
|
2015-08-04 20:19:43 +03:00
|
|
|
report += reportEntry;
|
|
|
|
report += compatibilityAgree(t, propContent != consistent.second);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!consistent.first) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Property " << p << " on target \"" << tgt->GetName()
|
|
|
|
<< "\" is\nimplied to be " << defaultValue
|
2015-08-04 20:19:43 +03:00
|
|
|
<< " because it was used to determine the link libraries\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
"already. The INTERFACE_"
|
|
|
|
<< p << " property on\ndependency \"" << theTarget->GetName()
|
|
|
|
<< "\" is in conflict.\n";
|
2015-08-04 20:19:43 +03:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
propContent = consistent.second;
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
// Implicitly set on target and not set in iface. Can't disagree.
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (ifaceIsSet) {
|
|
|
|
if (propInitialized) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::pair<bool, PropertyType> consistent =
|
2016-05-16 17:34:04 +03:00
|
|
|
consistentProperty(propContent, ifacePropContent, t);
|
2015-08-04 20:19:43 +03:00
|
|
|
report += reportEntry;
|
|
|
|
report += compatibilityAgree(t, propContent != consistent.second);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!consistent.first) {
|
2015-08-04 20:19:43 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "The INTERFACE_" << p << " property of \""
|
|
|
|
<< theTarget->GetName() << "\" does\nnot agree with the value "
|
2016-05-16 17:34:04 +03:00
|
|
|
"of "
|
|
|
|
<< p << " already determined\nfor \"" << tgt->GetName()
|
|
|
|
<< "\".\n";
|
2015-08-04 20:19:43 +03:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
propContent = consistent.second;
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
report += reportEntry + "(Interface set)\n";
|
|
|
|
propContent = ifacePropContent;
|
|
|
|
propInitialized = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-04 20:19:43 +03:00
|
|
|
// Not set. Nothing to agree on.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:43 +03:00
|
|
|
|
|
|
|
tgt->ReportPropertyOrigin(p, valueAsString<PropertyType>(propContent),
|
|
|
|
report, compatibilityType(t));
|
|
|
|
return propContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
|
2016-06-27 23:44:16 +03:00
|
|
|
BoolType, CM_NULLPTR);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return checkInterfacePropertyCompatibility<const char*>(
|
2016-06-27 23:44:16 +03:00
|
|
|
this, p, config, "empty", StringType, CM_NULLPTR);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty(
|
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return checkInterfacePropertyCompatibility<const char*>(
|
2016-06-27 23:44:16 +03:00
|
|
|
this, p, config, "empty", NumberMinType, CM_NULLPTR);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty(
|
|
|
|
const std::string& p, const std::string& config) const
|
2015-08-04 20:19:43 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return checkInterfacePropertyCompatibility<const char*>(
|
2016-06-27 23:44:16 +03:00
|
|
|
this, p, config, "empty", NumberMaxType, CM_NULLPTR);
|
2015-08-04 20:19:43 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(
|
|
|
|
const std::string& config) const
|
2015-08-04 20:19:42 +03:00
|
|
|
{
|
|
|
|
// Lookup any existing information for this configuration.
|
|
|
|
std::string key(cmSystemTools::UpperCase(config));
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTargetLinkInformationMap::iterator i = this->LinkInformation.find(key);
|
|
|
|
if (i == this->LinkInformation.end()) {
|
2015-08-04 20:19:42 +03:00
|
|
|
// Compute information for this configuration.
|
|
|
|
cmComputeLinkInformation* info =
|
2015-08-04 20:19:50 +03:00
|
|
|
new cmComputeLinkInformation(this, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!info || !info->Compute()) {
|
2015-08-04 20:19:42 +03:00
|
|
|
delete info;
|
2016-06-27 23:44:16 +03:00
|
|
|
info = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
|
|
|
|
// Store the information for this configuration.
|
|
|
|
cmTargetLinkInformationMap::value_type entry(key, info);
|
|
|
|
i = this->LinkInformation.insert(entry).first;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (info) {
|
2015-08-04 20:19:43 +03:00
|
|
|
this->CheckPropertyCompatibility(info, config);
|
2015-08-04 20:19:42 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:42 +03:00
|
|
|
return i->second;
|
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
|
2015-10-16 20:19:51 +03:00
|
|
|
void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const
|
|
|
|
{
|
|
|
|
int patch;
|
|
|
|
this->GetTargetVersion(false, major, minor, patch);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major,
|
|
|
|
int& minor, int& patch) const
|
2015-10-16 20:19:51 +03:00
|
|
|
{
|
|
|
|
// Set the default values.
|
|
|
|
major = 0;
|
|
|
|
minor = 0;
|
|
|
|
patch = 0;
|
|
|
|
|
|
|
|
assert(this->GetType() != cmState::INTERFACE_LIBRARY);
|
|
|
|
|
|
|
|
// Look for a VERSION or SOVERSION property.
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* prop = soversion ? "SOVERSION" : "VERSION";
|
|
|
|
if (const char* version = this->GetProperty(prop)) {
|
2015-10-16 20:19:51 +03:00
|
|
|
// Try to parse the version number and store the results that were
|
|
|
|
// successfully parsed.
|
|
|
|
int parsed_major;
|
|
|
|
int parsed_minor;
|
|
|
|
int parsed_patch;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (sscanf(version, "%d.%d.%d", &parsed_major, &parsed_minor,
|
|
|
|
&parsed_patch)) {
|
|
|
|
case 3:
|
|
|
|
patch = parsed_patch; // no break!
|
|
|
|
case 2:
|
|
|
|
minor = parsed_minor; // no break!
|
|
|
|
case 1:
|
|
|
|
major = parsed_major; // no break!
|
|
|
|
default:
|
|
|
|
break;
|
2015-10-16 20:19:51 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:51 +03:00
|
|
|
}
|
|
|
|
|
2016-06-10 17:58:36 +03:00
|
|
|
std::string cmGeneratorTarget::GetFortranModuleDirectory() const
|
|
|
|
{
|
|
|
|
if (!this->FortranModuleDirectoryCreated) {
|
|
|
|
this->FortranModuleDirectory = true;
|
|
|
|
this->FortranModuleDirectory = this->CreateFortranModuleDirectory();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->FortranModuleDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmGeneratorTarget::CreateFortranModuleDirectory() const
|
|
|
|
{
|
2016-06-21 20:37:06 +03:00
|
|
|
std::string mod_dir;
|
2016-06-10 17:58:36 +03:00
|
|
|
const char* target_mod_dir = this->GetProperty("Fortran_MODULE_DIRECTORY");
|
|
|
|
const char* moddir_flag =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
|
|
|
|
if (target_mod_dir && moddir_flag) {
|
|
|
|
// Compute the full path to the module directory.
|
|
|
|
if (cmSystemTools::FileIsFullPath(target_mod_dir)) {
|
|
|
|
// Already a full path.
|
|
|
|
mod_dir = target_mod_dir;
|
|
|
|
} else {
|
|
|
|
// Interpret relative to the current output directory.
|
|
|
|
mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
|
|
|
|
mod_dir += "/";
|
|
|
|
mod_dir += target_mod_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the module output directory exists.
|
|
|
|
cmSystemTools::MakeDirectory(mod_dir);
|
|
|
|
}
|
|
|
|
return mod_dir;
|
|
|
|
}
|
|
|
|
|
2015-10-23 01:47:31 +03:00
|
|
|
std::string cmGeneratorTarget::GetFrameworkVersion() const
|
|
|
|
{
|
|
|
|
assert(this->GetType() != cmState::INTERFACE_LIBRARY);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) {
|
2015-10-23 01:47:31 +03:00
|
|
|
return fversion;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* tversion = this->GetProperty("VERSION")) {
|
2015-10-23 01:47:31 +03:00
|
|
|
return tversion;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-10-23 01:47:31 +03:00
|
|
|
return "A";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-23 01:47:31 +03:00
|
|
|
}
|
|
|
|
|
2015-10-16 20:19:51 +03:00
|
|
|
void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& prefix,
|
|
|
|
std::string const& base,
|
|
|
|
std::string const& suffix,
|
|
|
|
std::string const& name,
|
|
|
|
const char* version) const
|
|
|
|
{
|
|
|
|
vName = this->Makefile->IsOn("APPLE") ? (prefix + base) : name;
|
|
|
|
if (version) {
|
2015-10-16 20:19:51 +03:00
|
|
|
vName += ".";
|
|
|
|
vName += version;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:51 +03:00
|
|
|
vName += this->Makefile->IsOn("APPLE") ? suffix : std::string();
|
|
|
|
}
|
|
|
|
|
2015-10-25 12:35:36 +03:00
|
|
|
std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
|
|
|
|
{
|
|
|
|
cmPropertyMap propsObject = this->Target->GetProperties();
|
|
|
|
std::vector<std::string> props;
|
|
|
|
props.reserve(propsObject.size());
|
|
|
|
for (cmPropertyMap::const_iterator it = propsObject.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != propsObject.end(); ++it) {
|
2015-10-25 12:35:36 +03:00
|
|
|
props.push_back(it->first);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-25 12:35:36 +03:00
|
|
|
return props;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::ReportPropertyOrigin(
|
|
|
|
const std::string& p, const std::string& result, const std::string& report,
|
|
|
|
const std::string& compatibilityType) const
|
2015-08-04 20:19:44 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string> debugProperties;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* debugProp = this->Target->GetMakefile()->GetDefinition(
|
|
|
|
"CMAKE_DEBUG_TARGET_PROPERTIES");
|
|
|
|
if (debugProp) {
|
2015-08-04 20:19:44 +03:00
|
|
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] &&
|
|
|
|
std::find(debugProperties.begin(), debugProperties.end(), p) !=
|
|
|
|
debugProperties.end();
|
2015-08-04 20:19:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
|
2015-08-04 20:19:44 +03:00
|
|
|
this->DebugCompatiblePropertiesDone[p] = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!debugOrigin) {
|
2015-08-04 20:19:44 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:19:44 +03:00
|
|
|
|
|
|
|
std::string areport = compatibilityType;
|
|
|
|
areport += std::string(" of property \"") + p + "\" for target \"";
|
|
|
|
areport += std::string(this->GetName());
|
|
|
|
areport += "\" (result: \"";
|
|
|
|
areport += result;
|
|
|
|
areport += "\"):\n" + report;
|
|
|
|
|
2015-10-09 00:28:46 +03:00
|
|
|
this->LocalGenerator->GetCMakeInstance()->IssueMessage(cmake::LOG, areport);
|
2015-08-04 20:19:44 +03:00
|
|
|
}
|
2015-08-26 20:37:45 +03:00
|
|
|
|
2015-08-04 20:22:30 +03:00
|
|
|
void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmLinkItem>& items) const
|
2015-08-04 20:22:30 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = names.begin();
|
|
|
|
i != names.end(); ++i) {
|
2015-10-16 20:19:51 +03:00
|
|
|
std::string name = this->CheckCMP0004(*i);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == this->GetName() || name.empty()) {
|
2015-08-04 20:22:30 +03:00
|
|
|
continue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
items.push_back(cmLinkItem(name, this->FindTargetToLink(name)));
|
|
|
|
}
|
2015-08-04 20:22:30 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::ExpandLinkItems(
|
|
|
|
std::string const& prop, std::string const& value, std::string const& config,
|
|
|
|
cmGeneratorTarget const* headTarget, bool usage_requirements_only,
|
|
|
|
std::vector<cmLinkItem>& items, bool& hadHeadSensitiveCondition) const
|
2015-08-04 20:22:30 +03:00
|
|
|
{
|
|
|
|
cmGeneratorExpression ge;
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, CM_NULLPTR,
|
|
|
|
CM_NULLPTR);
|
2015-08-04 20:22:30 +03:00
|
|
|
// The $<LINK_ONLY> expression may be in a link interface to specify private
|
|
|
|
// link dependencies that are otherwise excluded from usage requirements.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (usage_requirements_only) {
|
2015-08-04 20:22:30 +03:00
|
|
|
dagChecker.SetTransitivePropertiesOnly();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-04 20:22:30 +03:00
|
|
|
std::vector<std::string> libs;
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, config,
|
|
|
|
false, headTarget, this,
|
|
|
|
&dagChecker),
|
|
|
|
libs);
|
2015-08-04 20:22:30 +03:00
|
|
|
this->LookupLinkItems(libs, items);
|
|
|
|
hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
|
|
|
|
const std::string& config, cmGeneratorTarget const* head) const
|
2015-08-26 20:37:45 +03:00
|
|
|
{
|
|
|
|
// Imported targets have their own link interface.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2015-08-26 20:39:17 +03:00
|
|
|
return this->GetImportLinkInterface(config, head, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:37:45 +03:00
|
|
|
|
|
|
|
// Link interfaces are not supported for executables that do not
|
|
|
|
// export symbols.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::EXECUTABLE &&
|
|
|
|
!this->IsExecutableWithExports()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:37:45 +03:00
|
|
|
|
|
|
|
// Lookup any existing link interface for this configuration.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmHeadToLinkInterfaceMap& hm = this->GetHeadToLinkInterfaceMap(config);
|
2015-08-26 20:37:45 +03:00
|
|
|
|
|
|
|
// If the link interface does not depend on the head target
|
|
|
|
// then return the one we computed first.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
|
2015-08-26 20:37:45 +03:00
|
|
|
return &hm.begin()->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:37:45 +03:00
|
|
|
|
2015-10-08 02:05:41 +03:00
|
|
|
cmOptionalLinkInterface& iface = hm[head];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!iface.LibrariesDone) {
|
2015-08-26 20:37:45 +03:00
|
|
|
iface.LibrariesDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ComputeLinkInterfaceLibraries(config, iface, head, false);
|
|
|
|
}
|
|
|
|
if (!iface.AllDone) {
|
2015-08-26 20:37:45 +03:00
|
|
|
iface.AllDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (iface.Exists) {
|
2015-08-26 20:38:14 +03:00
|
|
|
this->ComputeLinkInterface(config, iface, head);
|
2015-08-26 20:37:45 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:37:45 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
return iface.Exists ? &iface : CM_NULLPTR;
|
2015-08-26 20:37:45 +03:00
|
|
|
}
|
2015-08-26 20:38:14 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::ComputeLinkInterface(
|
|
|
|
const std::string& config, cmOptionalLinkInterface& iface,
|
|
|
|
cmGeneratorTarget const* headTarget) const
|
2015-08-26 20:38:14 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (iface.ExplicitLibraries) {
|
|
|
|
if (this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::STATIC_LIBRARY ||
|
|
|
|
this->GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-08-26 20:38:14 +03:00
|
|
|
// Shared libraries may have runtime implementation dependencies
|
|
|
|
// on other shared libraries that are not in the interface.
|
|
|
|
UNORDERED_SET<std::string> emitted;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLinkItem>::const_iterator li =
|
|
|
|
iface.Libraries.begin();
|
|
|
|
li != iface.Libraries.end(); ++li) {
|
2015-08-26 20:38:14 +03:00
|
|
|
emitted.insert(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->GetType() != cmState::INTERFACE_LIBRARY) {
|
|
|
|
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
|
|
|
|
for (std::vector<cmLinkImplItem>::const_iterator li =
|
|
|
|
impl->Libraries.begin();
|
|
|
|
li != impl->Libraries.end(); ++li) {
|
|
|
|
if (emitted.insert(*li).second) {
|
|
|
|
if (li->Target) {
|
2015-08-26 20:38:14 +03:00
|
|
|
// This is a runtime dependency on another shared library.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (li->Target->GetType() == cmState::SHARED_LIBRARY) {
|
2015-08-26 20:38:14 +03:00
|
|
|
iface.SharedDeps.push_back(*li);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-26 20:38:14 +03:00
|
|
|
// TODO: Recognize shared library file names. Perhaps this
|
|
|
|
// should be moved to cmComputeLinkInformation, but that creates
|
|
|
|
// a chicken-and-egg problem since this list is needed for its
|
|
|
|
// construction.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN ||
|
|
|
|
this->GetPolicyStatusCMP0022() == cmPolicies::OLD) {
|
2015-08-26 20:38:14 +03:00
|
|
|
// The link implementation is the default link interface.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkImplementationLibraries const* impl =
|
|
|
|
this->GetLinkImplementationLibrariesInternal(config, headTarget);
|
2015-08-26 20:38:14 +03:00
|
|
|
iface.ImplementationIsInterface = true;
|
|
|
|
iface.WrongConfigLibraries = impl->WrongConfigLibraries;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:14 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->LinkLanguagePropagatesToDependents()) {
|
2015-08-26 20:38:14 +03:00
|
|
|
// Targets using this archive need its language runtime libraries.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmLinkImplementation const* impl =
|
|
|
|
this->GetLinkImplementation(config)) {
|
2015-08-26 20:38:14 +03:00
|
|
|
iface.Languages = impl->Languages;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:14 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::STATIC_LIBRARY) {
|
2015-08-26 20:38:14 +03:00
|
|
|
// Construct the property name suffix for this configuration.
|
|
|
|
std::string suffix = "_";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-08-26 20:38:14 +03:00
|
|
|
suffix += cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-26 20:38:14 +03:00
|
|
|
suffix += "NOCONFIG";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:14 +03:00
|
|
|
|
|
|
|
// How many repetitions are needed if this library has cyclic
|
|
|
|
// dependencies?
|
|
|
|
std::string propName = "LINK_INTERFACE_MULTIPLICITY";
|
|
|
|
propName += suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_reps = this->GetProperty(propName)) {
|
2015-08-26 20:38:14 +03:00
|
|
|
sscanf(config_reps, "%u", &iface.Multiplicity);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* reps =
|
|
|
|
this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) {
|
2015-08-26 20:38:14 +03:00
|
|
|
sscanf(reps, "%u", &iface.Multiplicity);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:14 +03:00
|
|
|
}
|
2015-08-26 20:38:37 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
|
|
|
|
const std::string& config, cmGeneratorTarget const* head,
|
|
|
|
bool usage_requirements_only) const
|
2015-08-26 20:38:37 +03:00
|
|
|
{
|
|
|
|
// Imported targets have their own link interface.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
|
|
|
return this->GetImportLinkInterface(config, head, usage_requirements_only);
|
|
|
|
}
|
2015-08-26 20:38:37 +03:00
|
|
|
|
|
|
|
// Link interfaces are not supported for executables that do not
|
|
|
|
// export symbols.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::EXECUTABLE &&
|
|
|
|
!this->IsExecutableWithExports()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:37 +03:00
|
|
|
|
|
|
|
// Lookup any existing link interface for this configuration.
|
|
|
|
std::string CONFIG = cmSystemTools::UpperCase(config);
|
|
|
|
cmHeadToLinkInterfaceMap& hm =
|
2016-05-16 17:34:04 +03:00
|
|
|
(usage_requirements_only
|
|
|
|
? this->GetHeadToLinkInterfaceUsageRequirementsMap(config)
|
|
|
|
: this->GetHeadToLinkInterfaceMap(config));
|
2015-08-26 20:38:37 +03:00
|
|
|
|
|
|
|
// If the link interface does not depend on the head target
|
|
|
|
// then return the one we computed first.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
|
2015-08-26 20:38:37 +03:00
|
|
|
return &hm.begin()->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:37 +03:00
|
|
|
|
2015-10-08 02:05:41 +03:00
|
|
|
cmOptionalLinkInterface& iface = hm[head];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!iface.LibrariesDone) {
|
2015-08-26 20:38:37 +03:00
|
|
|
iface.LibrariesDone = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ComputeLinkInterfaceLibraries(config, iface, head,
|
|
|
|
usage_requirements_only);
|
|
|
|
}
|
2015-08-26 20:38:37 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
return iface.Exists ? &iface : CM_NULLPTR;
|
2015-08-26 20:38:37 +03:00
|
|
|
}
|
2015-08-26 20:38:57 +03:00
|
|
|
|
2014-10-20 22:31:47 +04:00
|
|
|
std::string cmGeneratorTarget::GetDirectory(const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool implib) const
|
2014-10-20 22:31:47 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2014-10-20 22:31:47 +04:00
|
|
|
// Return the directory from which the target is imported.
|
2016-05-16 17:34:04 +03:00
|
|
|
return cmSystemTools::GetFilenamePath(
|
2014-10-20 22:31:47 +04:00
|
|
|
this->Target->ImportedGetFullPath(config, implib));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (OutputInfo const* info = this->GetOutputInfo(config)) {
|
2014-10-20 22:31:47 +04:00
|
|
|
// Return the directory in which the target will be built.
|
2016-05-16 17:34:04 +03:00
|
|
|
return implib ? info->ImpDir : info->OutDir;
|
|
|
|
}
|
2014-10-20 22:31:47 +04:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-08-05 19:47:35 +03:00
|
|
|
bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool implib) const
|
2015-08-05 19:47:35 +03:00
|
|
|
{
|
|
|
|
std::string dir;
|
2015-08-05 19:55:14 +03:00
|
|
|
return this->ComputeOutputDir(config, implib, dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-05 19:55:14 +03:00
|
|
|
{
|
|
|
|
// There is no output information for imported targets.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Only libraries and executables have well-defined output files.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->HaveWellDefinedOutputFiles()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
std::string msg = "cmGeneratorTarget::GetOutputInfo called for ";
|
|
|
|
msg += this->GetName();
|
|
|
|
msg += " which has type ";
|
2015-10-08 01:26:50 +03:00
|
|
|
msg += cmState::GetTargetTypeName(this->GetType());
|
2015-08-05 19:55:14 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Lookup/compute/cache the output information for this configuration.
|
|
|
|
std::string config_upper;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
config_upper = cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
OutputInfoMapType::iterator i = this->OutputInfoMap.find(config_upper);
|
|
|
|
if (i == this->OutputInfoMap.end()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
// Add empty info in map to detect potential recursion.
|
|
|
|
OutputInfo info;
|
|
|
|
OutputInfoMapType::value_type entry(config_upper, info);
|
|
|
|
i = this->OutputInfoMap.insert(entry).first;
|
|
|
|
|
|
|
|
// Compute output directories.
|
|
|
|
this->ComputeOutputDir(config, false, info.OutDir);
|
|
|
|
this->ComputeOutputDir(config, true, info.ImpDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) {
|
2015-08-05 19:55:14 +03:00
|
|
|
info.PdbDir = info.OutDir;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Now update the previously-prepared map entry.
|
|
|
|
i->second = info;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (i->second.empty()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
// An empty map entry indicates we have been called recursively
|
|
|
|
// from the above block.
|
|
|
|
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.",
|
2015-10-19 23:39:08 +03:00
|
|
|
this->GetBacktrace());
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
return &i->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool implib, std::string& out) const
|
2015-08-05 19:55:14 +03:00
|
|
|
{
|
|
|
|
bool usesDefaultOutputDir = false;
|
|
|
|
std::string conf = config;
|
|
|
|
|
|
|
|
// Look for a target property defining the target output directory
|
|
|
|
// based on the target type.
|
2015-08-05 20:11:48 +03:00
|
|
|
std::string targetTypeName = this->GetOutputTargetType(implib);
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* propertyName = CM_NULLPTR;
|
2015-08-05 19:55:14 +03:00
|
|
|
std::string propertyNameStr = targetTypeName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!propertyNameStr.empty()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
propertyNameStr += "_OUTPUT_DIRECTORY";
|
|
|
|
propertyName = propertyNameStr.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Check for a per-configuration output directory target property.
|
|
|
|
std::string configUpper = cmSystemTools::UpperCase(conf);
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* configProp = CM_NULLPTR;
|
2015-08-05 19:55:14 +03:00
|
|
|
std::string configPropStr = targetTypeName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!configPropStr.empty()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
configPropStr += "_OUTPUT_DIRECTORY_";
|
|
|
|
configPropStr += configUpper;
|
|
|
|
configProp = configPropStr.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Select an output directory.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_outdir = this->GetProperty(configProp)) {
|
2015-08-05 19:55:14 +03:00
|
|
|
// Use the user-specified per-configuration output directory.
|
|
|
|
cmGeneratorExpression ge;
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(config_outdir);
|
2015-07-25 17:56:52 +03:00
|
|
|
out = cge->Evaluate(this->LocalGenerator, config);
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Skip per-configuration subdirectory.
|
|
|
|
conf = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* outdir = this->GetProperty(propertyName)) {
|
2015-08-05 19:55:14 +03:00
|
|
|
// Use the user-specified output directory.
|
|
|
|
cmGeneratorExpression ge;
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outdir);
|
2015-07-25 17:56:52 +03:00
|
|
|
out = cge->Evaluate(this->LocalGenerator, config);
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Skip per-configuration subdirectory if the value contained a
|
|
|
|
// generator expression.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (out != outdir) {
|
2015-08-05 19:55:14 +03:00
|
|
|
conf = "";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GetType() == cmState::EXECUTABLE) {
|
2015-08-05 19:55:14 +03:00
|
|
|
// Lookup the output path for executables.
|
|
|
|
out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GetType() == cmState::STATIC_LIBRARY ||
|
|
|
|
this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::MODULE_LIBRARY) {
|
2015-08-05 19:55:14 +03:00
|
|
|
// Lookup the output path for libraries.
|
|
|
|
out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (out.empty()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
// Default to the current output directory.
|
|
|
|
usesDefaultOutputDir = true;
|
|
|
|
out = ".";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// Convert the output path to a full path in case it is
|
|
|
|
// specified as a relative path. Treat a relative path as
|
|
|
|
// relative to the current output directory for this makefile.
|
2016-05-16 17:34:04 +03:00
|
|
|
out = (cmSystemTools::CollapseFullPath(
|
|
|
|
out, this->LocalGenerator->GetCurrentBinaryDirectory()));
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
// The generator may add the configuration's subdirectory.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!conf.empty()) {
|
2015-08-05 19:55:14 +03:00
|
|
|
bool iosPlatform = this->Makefile->PlatformIsAppleIos();
|
|
|
|
std::string suffix =
|
|
|
|
usesDefaultOutputDir && iosPlatform ? "${EFFECTIVE_PLATFORM_NAME}" : "";
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->GetGlobalGenerator()->AppendDirectoryForConfig(
|
|
|
|
"/", conf, suffix, out);
|
|
|
|
}
|
2015-08-05 19:55:14 +03:00
|
|
|
|
|
|
|
return usesDefaultOutputDir;
|
2015-08-05 19:47:35 +03:00
|
|
|
}
|
|
|
|
|
2015-08-05 20:01:23 +03:00
|
|
|
bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config,
|
|
|
|
std::string& out) const
|
2015-08-05 20:01:23 +03:00
|
|
|
{
|
|
|
|
// Look for a target property defining the target output directory
|
|
|
|
// based on the target type.
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* propertyName = CM_NULLPTR;
|
2015-08-05 20:01:23 +03:00
|
|
|
std::string propertyNameStr = kind;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!propertyNameStr.empty()) {
|
2015-08-05 20:01:23 +03:00
|
|
|
propertyNameStr += "_OUTPUT_DIRECTORY";
|
|
|
|
propertyName = propertyNameStr.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:01:23 +03:00
|
|
|
std::string conf = config;
|
|
|
|
|
|
|
|
// Check for a per-configuration output directory target property.
|
|
|
|
std::string configUpper = cmSystemTools::UpperCase(conf);
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* configProp = CM_NULLPTR;
|
2015-08-05 20:01:23 +03:00
|
|
|
std::string configPropStr = kind;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!configPropStr.empty()) {
|
2015-08-05 20:01:23 +03:00
|
|
|
configPropStr += "_OUTPUT_DIRECTORY_";
|
|
|
|
configPropStr += configUpper;
|
|
|
|
configProp = configPropStr.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:01:23 +03:00
|
|
|
|
|
|
|
// Select an output directory.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_outdir = this->GetProperty(configProp)) {
|
2015-08-05 20:01:23 +03:00
|
|
|
// Use the user-specified per-configuration output directory.
|
|
|
|
out = config_outdir;
|
|
|
|
|
|
|
|
// Skip per-configuration subdirectory.
|
|
|
|
conf = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* outdir = this->GetProperty(propertyName)) {
|
2015-08-05 20:01:23 +03:00
|
|
|
// Use the user-specified output directory.
|
|
|
|
out = outdir;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (out.empty()) {
|
2015-08-05 20:01:23 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 20:01:23 +03:00
|
|
|
|
|
|
|
// Convert the output path to a full path in case it is
|
|
|
|
// specified as a relative path. Treat a relative path as
|
|
|
|
// relative to the current output directory for this makefile.
|
2016-05-16 17:34:04 +03:00
|
|
|
out = (cmSystemTools::CollapseFullPath(
|
|
|
|
out, this->LocalGenerator->GetCurrentBinaryDirectory()));
|
2015-08-05 20:01:23 +03:00
|
|
|
|
|
|
|
// The generator may add the configuration's subdirectory.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!conf.empty()) {
|
|
|
|
this->LocalGenerator->GetGlobalGenerator()->AppendDirectoryForConfig(
|
|
|
|
"/", conf, "", out);
|
|
|
|
}
|
2015-08-05 20:01:23 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-05 20:02:45 +03:00
|
|
|
bool cmGeneratorTarget::HaveInstallTreeRPATH() const
|
|
|
|
{
|
|
|
|
const char* install_rpath = this->GetProperty("INSTALL_RPATH");
|
|
|
|
return (install_rpath && *install_rpath) &&
|
2016-05-16 17:34:04 +03:00
|
|
|
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
|
2015-08-05 20:02:45 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
|
|
|
|
const std::string& config, cmOptionalLinkInterface& iface,
|
|
|
|
cmGeneratorTarget const* headTarget, bool usage_requirements_only) const
|
2015-08-26 20:38:57 +03:00
|
|
|
{
|
|
|
|
// Construct the property name suffix for this configuration.
|
|
|
|
std::string suffix = "_";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-08-26 20:38:57 +03:00
|
|
|
suffix += cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-26 20:38:57 +03:00
|
|
|
suffix += "NOCONFIG";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:57 +03:00
|
|
|
|
|
|
|
// An explicit list of interface libraries may be set for shared
|
|
|
|
// libraries and executables that export symbols.
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* explicitLibraries = CM_NULLPTR;
|
2015-08-26 20:38:57 +03:00
|
|
|
std::string linkIfaceProp;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
|
|
|
|
this->GetPolicyStatusCMP0022() != cmPolicies::WARN) {
|
2015-08-26 20:38:57 +03:00
|
|
|
// CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
|
|
|
|
linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
|
|
|
|
explicitLibraries = this->GetProperty(linkIfaceProp);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->IsExecutableWithExports()) {
|
2015-08-26 20:38:57 +03:00
|
|
|
// CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a
|
|
|
|
// shared lib or executable.
|
|
|
|
|
|
|
|
// Lookup the per-configuration property.
|
|
|
|
linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
|
|
|
|
linkIfaceProp += suffix;
|
|
|
|
explicitLibraries = this->GetProperty(linkIfaceProp);
|
|
|
|
|
|
|
|
// If not set, try the generic property.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!explicitLibraries) {
|
2015-08-26 20:38:57 +03:00
|
|
|
linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
|
|
|
|
explicitLibraries = this->GetProperty(linkIfaceProp);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:57 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (explicitLibraries &&
|
|
|
|
this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
|
|
|
|
!this->PolicyWarnedCMP0022) {
|
2015-08-26 20:38:57 +03:00
|
|
|
// Compare the explicitly set old link interface properties to the
|
|
|
|
// preferred new link interface property one and warn if different.
|
|
|
|
const char* newExplicitLibraries =
|
|
|
|
this->GetProperty("INTERFACE_LINK_LIBRARIES");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (newExplicitLibraries &&
|
|
|
|
strcmp(newExplicitLibraries, explicitLibraries) != 0) {
|
2015-08-26 20:38:57 +03:00
|
|
|
std::ostringstream w;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-08-26 20:38:57 +03:00
|
|
|
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
|
|
|
|
"Target \"" << this->GetName() << "\" has an "
|
|
|
|
"INTERFACE_LINK_LIBRARIES property which differs from its " <<
|
|
|
|
linkIfaceProp << " properties."
|
|
|
|
"\n"
|
|
|
|
"INTERFACE_LINK_LIBRARIES:\n"
|
|
|
|
" " << newExplicitLibraries << "\n" <<
|
|
|
|
linkIfaceProp << ":\n"
|
|
|
|
" " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2015-08-26 20:38:57 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
|
|
|
this->PolicyWarnedCMP0022 = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:57 +03:00
|
|
|
|
|
|
|
// There is no implicit link interface for executables or modules
|
|
|
|
// so if none was explicitly set then there is no link interface.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!explicitLibraries && (this->GetType() == cmState::EXECUTABLE ||
|
|
|
|
(this->GetType() == cmState::MODULE_LIBRARY))) {
|
2015-08-26 20:38:57 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:57 +03:00
|
|
|
iface.Exists = true;
|
|
|
|
iface.ExplicitLibraries = explicitLibraries;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (explicitLibraries) {
|
2015-08-26 20:38:57 +03:00
|
|
|
// The interface libraries have been explicitly set.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget,
|
|
|
|
usage_requirements_only, iface.Libraries,
|
|
|
|
iface.HadHeadSensitiveCondition);
|
|
|
|
} else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN ||
|
|
|
|
this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
|
|
|
|
// If CMP0022 is NEW then the plain tll signature sets the
|
|
|
|
// INTERFACE_LINK_LIBRARIES, so if we get here then the project
|
|
|
|
// cleared the property explicitly and we should not fall back
|
|
|
|
// to the link implementation.
|
|
|
|
{
|
2015-08-26 20:38:57 +03:00
|
|
|
// The link implementation is the default link interface.
|
|
|
|
cmLinkImplementationLibraries const* impl =
|
2015-09-16 05:56:37 +03:00
|
|
|
this->GetLinkImplementationLibrariesInternal(config, headTarget);
|
2016-05-16 17:34:04 +03:00
|
|
|
iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(),
|
|
|
|
impl->Libraries.end());
|
|
|
|
if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
|
|
|
|
!this->PolicyWarnedCMP0022 && !usage_requirements_only) {
|
2015-08-26 20:38:57 +03:00
|
|
|
// Compare the link implementation fallback link interface to the
|
|
|
|
// preferred new link interface property and warn if different.
|
|
|
|
std::vector<cmLinkItem> ifaceLibs;
|
|
|
|
static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* newExplicitLibraries = this->GetProperty(newProp)) {
|
2015-08-26 20:38:57 +03:00
|
|
|
bool hadHeadSensitiveConditionDummy = false;
|
2015-08-04 20:22:30 +03:00
|
|
|
this->ExpandLinkItems(newProp, newExplicitLibraries, config,
|
2016-05-16 17:34:04 +03:00
|
|
|
headTarget, usage_requirements_only, ifaceLibs,
|
|
|
|
hadHeadSensitiveConditionDummy);
|
|
|
|
}
|
|
|
|
if (ifaceLibs != iface.Libraries) {
|
2015-08-26 20:38:57 +03:00
|
|
|
std::string oldLibraries = cmJoin(impl->Libraries, ";");
|
|
|
|
std::string newLibraries = cmJoin(ifaceLibs, ";");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (oldLibraries.empty()) {
|
|
|
|
oldLibraries = "(empty)";
|
|
|
|
}
|
|
|
|
if (newLibraries.empty()) {
|
|
|
|
newLibraries = "(empty)";
|
|
|
|
}
|
2015-08-26 20:38:57 +03:00
|
|
|
|
|
|
|
std::ostringstream w;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-08-26 20:38:57 +03:00
|
|
|
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
|
|
|
|
"Target \"" << this->GetName() << "\" has an "
|
|
|
|
"INTERFACE_LINK_LIBRARIES property. "
|
|
|
|
"This should be preferred as the source of the link interface "
|
|
|
|
"for this library but because CMP0022 is not set CMake is "
|
|
|
|
"ignoring the property and using the link implementation "
|
|
|
|
"as the link interface instead."
|
|
|
|
"\n"
|
|
|
|
"INTERFACE_LINK_LIBRARIES:\n"
|
|
|
|
" " << newLibraries << "\n"
|
|
|
|
"Link implementation:\n"
|
|
|
|
" " << oldLibraries << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2015-08-26 20:38:57 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
|
|
|
this->PolicyWarnedCMP0022 = true;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:38:57 +03:00
|
|
|
}
|
2015-08-26 20:39:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
|
|
|
|
const std::string& config, cmGeneratorTarget const* headTarget,
|
|
|
|
bool usage_requirements_only) const
|
2015-08-26 20:39:17 +03:00
|
|
|
{
|
2015-10-16 20:19:50 +03:00
|
|
|
cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!info) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:39:17 +03:00
|
|
|
|
|
|
|
std::string CONFIG = cmSystemTools::UpperCase(config);
|
|
|
|
cmHeadToLinkInterfaceMap& hm =
|
2016-05-16 17:34:04 +03:00
|
|
|
(usage_requirements_only
|
|
|
|
? this->GetHeadToLinkInterfaceUsageRequirementsMap(config)
|
|
|
|
: this->GetHeadToLinkInterfaceMap(config));
|
2015-08-26 20:39:17 +03:00
|
|
|
|
|
|
|
// If the link interface does not depend on the head target
|
|
|
|
// then return the one we computed first.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
|
2015-08-26 20:39:17 +03:00
|
|
|
return &hm.begin()->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:39:17 +03:00
|
|
|
|
2015-10-08 02:05:41 +03:00
|
|
|
cmOptionalLinkInterface& iface = hm[headTarget];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!iface.AllDone) {
|
2015-08-26 20:39:17 +03:00
|
|
|
iface.AllDone = true;
|
|
|
|
iface.Multiplicity = info->Multiplicity;
|
|
|
|
cmSystemTools::ExpandListArgument(info->Languages, iface.Languages);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config,
|
|
|
|
headTarget, usage_requirements_only, iface.Libraries,
|
2015-08-26 20:39:17 +03:00
|
|
|
iface.HadHeadSensitiveCondition);
|
|
|
|
std::vector<std::string> deps;
|
|
|
|
cmSystemTools::ExpandListArgument(info->SharedDeps, deps);
|
2015-08-04 20:22:30 +03:00
|
|
|
this->LookupLinkItems(deps, iface.SharedDeps);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-26 20:39:17 +03:00
|
|
|
|
|
|
|
return &iface;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo(
|
|
|
|
const std::string& config) const
|
2015-10-16 20:19:50 +03:00
|
|
|
{
|
|
|
|
// There is no imported information for non-imported targets.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->IsImported()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Lookup/compute/cache the import information for this
|
|
|
|
// configuration.
|
|
|
|
std::string config_upper;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!config.empty()) {
|
2015-10-16 20:19:50 +03:00
|
|
|
config_upper = cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-10-16 20:19:50 +03:00
|
|
|
config_upper = "NOCONFIG";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
ImportInfoMapType::const_iterator i = this->ImportInfoMap.find(config_upper);
|
|
|
|
if (i == this->ImportInfoMap.end()) {
|
2015-10-16 20:19:50 +03:00
|
|
|
ImportInfo info;
|
|
|
|
this->ComputeImportInfo(config_upper, info);
|
|
|
|
ImportInfoMapType::value_type entry(config_upper, info);
|
|
|
|
i = this->ImportInfoMap.insert(entry).first;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-10-16 20:19:50 +03:00
|
|
|
return &i->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
// If the location is empty then the target is not available for
|
|
|
|
// this configuration.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i->second.Location.empty() && i->second.ImportLibrary.empty()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Return the import information.
|
|
|
|
return &i->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
|
2016-05-16 17:34:04 +03:00
|
|
|
ImportInfo& info) const
|
2015-10-16 20:19:50 +03:00
|
|
|
{
|
|
|
|
// This method finds information about an imported target from its
|
|
|
|
// properties. The "IMPORTED_" namespace is reserved for properties
|
|
|
|
// defined by the project exporting the target.
|
|
|
|
|
|
|
|
// Initialize members.
|
|
|
|
info.NoSOName = false;
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* loc = CM_NULLPTR;
|
|
|
|
const char* imp = CM_NULLPTR;
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix)) {
|
2015-10-16 20:19:50 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Get the link interface.
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string linkProp = "INTERFACE_LINK_LIBRARIES";
|
|
|
|
const char* propertyLibs = this->GetProperty(linkProp);
|
|
|
|
|
|
|
|
if (this->GetType() != cmState::INTERFACE_LIBRARY) {
|
|
|
|
if (!propertyLibs) {
|
|
|
|
linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
|
|
|
|
linkProp += suffix;
|
|
|
|
propertyLibs = this->GetProperty(linkProp);
|
2015-10-16 20:19:50 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!propertyLibs) {
|
|
|
|
linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
|
|
|
|
propertyLibs = this->GetProperty(linkProp);
|
2015-10-16 20:19:50 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (propertyLibs) {
|
|
|
|
info.LibrariesProp = linkProp;
|
|
|
|
info.Libraries = propertyLibs;
|
2015-10-16 20:19:50 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::INTERFACE_LIBRARY) {
|
2015-10-16 20:19:50 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// A provided configuration has been chosen. Load the
|
|
|
|
// configuration's properties.
|
|
|
|
|
|
|
|
// Get the location.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (loc) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.Location = loc;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string impProp = "IMPORTED_LOCATION";
|
|
|
|
impProp += suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_location = this->GetProperty(impProp)) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.Location = config_location;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* location = this->GetProperty("IMPORTED_LOCATION")) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.Location = location;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Get the soname.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::SHARED_LIBRARY) {
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string soProp = "IMPORTED_SONAME";
|
|
|
|
soProp += suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_soname = this->GetProperty(soProp)) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.SOName = config_soname;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* soname = this->GetProperty("IMPORTED_SONAME")) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.SOName = soname;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Get the "no-soname" mark.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::SHARED_LIBRARY) {
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string soProp = "IMPORTED_NO_SONAME";
|
|
|
|
soProp += suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_no_soname = this->GetProperty(soProp)) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.NoSOName = cmSystemTools::IsOn(config_no_soname);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* no_soname =
|
|
|
|
this->GetProperty("IMPORTED_NO_SONAME")) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.NoSOName = cmSystemTools::IsOn(no_soname);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Get the import library.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (imp) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.ImportLibrary = imp;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->IsExecutableWithExports()) {
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string impProp = "IMPORTED_IMPLIB";
|
|
|
|
impProp += suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_implib = this->GetProperty(impProp)) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.ImportLibrary = config_implib;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.ImportLibrary = implib;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Get the link dependencies.
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES";
|
|
|
|
linkProp += suffix;
|
|
|
|
if (const char* config_libs = this->GetProperty(linkProp)) {
|
|
|
|
info.SharedDeps = config_libs;
|
|
|
|
} else if (const char* libs =
|
|
|
|
this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) {
|
|
|
|
info.SharedDeps = libs;
|
2015-10-16 20:19:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the link languages.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->LinkLanguagePropagatesToDependents()) {
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
|
|
|
|
linkProp += suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_libs = this->GetProperty(linkProp)) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.Languages = config_libs;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* libs =
|
|
|
|
this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) {
|
2015-10-16 20:19:50 +03:00
|
|
|
info.Languages = libs;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
|
|
|
|
// Get the cyclic repetition count.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetType() == cmState::STATIC_LIBRARY) {
|
2015-10-16 20:19:50 +03:00
|
|
|
std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
|
|
|
|
linkProp += suffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_reps = this->GetProperty(linkProp)) {
|
2015-10-16 20:19:50 +03:00
|
|
|
sscanf(config_reps, "%u", &info.Multiplicity);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* reps =
|
|
|
|
this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) {
|
2015-10-16 20:19:50 +03:00
|
|
|
sscanf(reps, "%u", &info.Multiplicity);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:50 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmHeadToLinkInterfaceMap& cmGeneratorTarget::GetHeadToLinkInterfaceMap(
|
|
|
|
const std::string& config) const
|
2015-08-26 20:39:17 +03:00
|
|
|
{
|
|
|
|
std::string CONFIG = cmSystemTools::UpperCase(config);
|
|
|
|
return this->LinkInterfaceMap[CONFIG];
|
|
|
|
}
|
|
|
|
|
|
|
|
cmHeadToLinkInterfaceMap&
|
|
|
|
cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-26 20:39:17 +03:00
|
|
|
{
|
|
|
|
std::string CONFIG = cmSystemTools::UpperCase(config);
|
|
|
|
return this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG];
|
|
|
|
}
|
2015-08-05 18:37:49 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
|
|
|
|
const std::string& config) const
|
2015-08-05 18:37:49 +03:00
|
|
|
{
|
|
|
|
// There is no link implementation for imported targets.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:49 +03:00
|
|
|
|
2015-08-05 19:17:55 +03:00
|
|
|
std::string CONFIG = cmSystemTools::UpperCase(config);
|
2015-10-25 13:37:34 +03:00
|
|
|
cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!impl.LibrariesDone) {
|
2015-08-05 18:37:49 +03:00
|
|
|
impl.LibrariesDone = true;
|
2015-09-16 06:04:51 +03:00
|
|
|
this->ComputeLinkImplementationLibraries(config, impl, this);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!impl.LanguagesDone) {
|
2015-08-05 18:37:49 +03:00
|
|
|
impl.LanguagesDone = true;
|
2015-08-05 18:37:50 +03:00
|
|
|
this->ComputeLinkImplementationLanguages(config, impl);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:49 +03:00
|
|
|
return &impl;
|
|
|
|
}
|
2015-08-05 18:37:49 +03:00
|
|
|
|
2015-08-05 18:37:50 +03:00
|
|
|
bool cmGeneratorTarget::GetConfigCommonSourceFiles(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmSourceFile*>& files) const
|
2015-08-05 18:37:50 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string> configs;
|
|
|
|
this->Makefile->GetConfigurations(configs);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configs.empty()) {
|
2015-08-05 18:37:50 +03:00
|
|
|
configs.push_back("");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:50 +03:00
|
|
|
|
|
|
|
std::vector<std::string>::const_iterator it = configs.begin();
|
|
|
|
const std::string& firstConfig = *it;
|
2015-08-29 18:51:15 +03:00
|
|
|
this->GetSourceFiles(files, firstConfig);
|
2015-08-05 18:37:50 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; it != configs.end(); ++it) {
|
2015-08-05 18:37:50 +03:00
|
|
|
std::vector<cmSourceFile*> configFiles;
|
2015-08-29 18:51:15 +03:00
|
|
|
this->GetSourceFiles(configFiles, *it);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configFiles != files) {
|
2015-08-05 18:37:50 +03:00
|
|
|
std::string firstConfigFiles;
|
|
|
|
const char* sep = "";
|
|
|
|
for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
fi != files.end(); ++fi) {
|
2015-08-05 18:37:50 +03:00
|
|
|
firstConfigFiles += sep;
|
|
|
|
firstConfigFiles += (*fi)->GetFullPath();
|
|
|
|
sep = "\n ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:50 +03:00
|
|
|
|
|
|
|
std::string thisConfigFiles;
|
|
|
|
sep = "";
|
|
|
|
for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
fi != configFiles.end(); ++fi) {
|
2015-08-05 18:37:50 +03:00
|
|
|
thisConfigFiles += sep;
|
|
|
|
thisConfigFiles += (*fi)->GetFullPath();
|
|
|
|
sep = "\n ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:50 +03:00
|
|
|
std::ostringstream e;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2015-08-05 18:37:50 +03:00
|
|
|
e << "Target \"" << this->GetName()
|
|
|
|
<< "\" has source files which vary by "
|
|
|
|
"configuration. This is not supported by the \""
|
|
|
|
<< this->GlobalGenerator->GetName()
|
|
|
|
<< "\" generator.\n"
|
|
|
|
"Config \"" << firstConfig << "\":\n"
|
|
|
|
" " << firstConfigFiles << "\n"
|
|
|
|
"Config \"" << *it << "\":\n"
|
|
|
|
" " << thisConfigFiles << "\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2015-08-05 18:37:50 +03:00
|
|
|
this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:50 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-16 20:19:48 +03:00
|
|
|
void cmGeneratorTarget::GetObjectLibrariesCMP0026(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmGeneratorTarget*>& objlibs) const
|
2015-10-16 20:19:48 +03:00
|
|
|
{
|
|
|
|
// At configure-time, this method can be called as part of getting the
|
|
|
|
// LOCATION property or to export() a file to be include()d. However
|
|
|
|
// there is no cmGeneratorTarget at configure-time, so search the SOURCES
|
|
|
|
// for TARGET_OBJECTS instead for backwards compatibility with OLD
|
|
|
|
// behavior of CMP0024 and CMP0026 only.
|
|
|
|
cmStringRange rng = this->Target->GetSourceEntries();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = rng.begin();
|
|
|
|
i != rng.end(); ++i) {
|
2015-10-16 20:19:48 +03:00
|
|
|
std::string const& entry = *i;
|
|
|
|
|
|
|
|
std::vector<std::string> files;
|
|
|
|
cmSystemTools::ExpandListArgument(entry, files);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator li = files.begin();
|
|
|
|
li != files.end(); ++li) {
|
|
|
|
if (cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
|
|
|
|
(*li)[li->size() - 1] == '>') {
|
|
|
|
std::string objLibName = li->substr(17, li->size() - 18);
|
|
|
|
|
|
|
|
if (cmGeneratorExpression::Find(objLibName) != std::string::npos) {
|
2015-10-16 20:19:48 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmGeneratorTarget* objLib =
|
|
|
|
this->LocalGenerator->FindGeneratorTargetToUse(objLibName);
|
|
|
|
if (objLib) {
|
2015-10-16 20:19:48 +03:00
|
|
|
objlibs.push_back(objLib);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:48 +03:00
|
|
|
}
|
|
|
|
|
2015-10-16 20:19:51 +03:00
|
|
|
std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
|
|
|
|
{
|
|
|
|
// Strip whitespace off the library names because we used to do this
|
|
|
|
// in case variables were expanded at generate time. We no longer
|
|
|
|
// do the expansion but users link to libraries like " ${VAR} ".
|
|
|
|
std::string lib = item;
|
|
|
|
std::string::size_type pos = lib.find_first_not_of(" \t\r\n");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != lib.npos) {
|
2015-10-16 20:19:51 +03:00
|
|
|
lib = lib.substr(pos, lib.npos);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:51 +03:00
|
|
|
pos = lib.find_last_not_of(" \t\r\n");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != lib.npos) {
|
|
|
|
lib = lib.substr(0, pos + 1);
|
|
|
|
}
|
|
|
|
if (lib != item) {
|
2015-10-16 20:19:51 +03:00
|
|
|
cmake* cm = this->LocalGenerator->GetCMakeInstance();
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatusCMP0004()) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-10-16 20:19:51 +03:00
|
|
|
std::ostringstream w;
|
|
|
|
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "Target \"" << this->GetName() << "\" links to item \"" << item
|
|
|
|
<< "\" which has leading or trailing whitespace.";
|
|
|
|
cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), this->GetBacktrace());
|
|
|
|
}
|
2015-10-16 20:19:51 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
case cmPolicies::NEW: {
|
2015-10-16 20:19:51 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Target \"" << this->GetName() << "\" links to item \"" << item
|
|
|
|
<< "\" which has leading or trailing whitespace. "
|
2015-10-16 20:19:51 +03:00
|
|
|
<< "This is now an error according to policy CMP0004.";
|
2016-05-16 17:34:04 +03:00
|
|
|
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
|
|
|
|
} break;
|
2015-10-16 20:19:51 +03:00
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
2016-05-16 17:34:04 +03:00
|
|
|
case cmPolicies::REQUIRED_ALWAYS: {
|
2015-10-16 20:19:51 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "Target \"" << this->GetName() << "\" links to item \"" << item
|
|
|
|
<< "\" which has leading or trailing whitespace.";
|
|
|
|
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
|
|
|
|
} break;
|
2015-10-16 20:19:51 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-16 20:19:51 +03:00
|
|
|
return lib;
|
|
|
|
}
|
|
|
|
|
2015-08-05 18:37:50 +03:00
|
|
|
void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-05 18:37:50 +03:00
|
|
|
{
|
|
|
|
std::vector<cmSourceFile*> sourceFiles;
|
2015-08-05 18:37:50 +03:00
|
|
|
this->GetSourceFiles(sourceFiles, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin();
|
|
|
|
i != sourceFiles.end(); ++i) {
|
2015-08-05 18:37:50 +03:00
|
|
|
const std::string& lang = (*i)->GetLanguage();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!lang.empty()) {
|
2015-08-05 18:37:50 +03:00
|
|
|
languages.insert(lang);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:50 +03:00
|
|
|
|
|
|
|
std::vector<cmGeneratorTarget*> objectLibraries;
|
|
|
|
std::vector<cmSourceFile const*> externalObjects;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) {
|
2015-10-16 20:19:48 +03:00
|
|
|
std::vector<cmGeneratorTarget*> objectTargets;
|
|
|
|
this->GetObjectLibrariesCMP0026(objectTargets);
|
2015-08-05 18:37:50 +03:00
|
|
|
objectLibraries.reserve(objectTargets.size());
|
2015-10-16 20:19:48 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::const_iterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
objectTargets.begin();
|
|
|
|
it != objectTargets.end(); ++it) {
|
2015-10-16 20:19:48 +03:00
|
|
|
objectLibraries.push_back(*it);
|
2015-08-05 18:37:50 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-08-05 18:37:50 +03:00
|
|
|
this->GetExternalObjects(externalObjects, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmSourceFile const*>::const_iterator i =
|
|
|
|
externalObjects.begin();
|
|
|
|
i != externalObjects.end(); ++i) {
|
2015-08-05 18:37:50 +03:00
|
|
|
std::string objLib = (*i)->GetObjectLibrary();
|
2015-10-16 20:19:49 +03:00
|
|
|
if (cmGeneratorTarget* tgt =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->FindGeneratorTargetToUse(objLib)) {
|
2015-10-16 20:19:49 +03:00
|
|
|
objectLibraries.push_back(tgt);
|
2015-08-05 18:37:50 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<cmGeneratorTarget*>::const_iterator i =
|
|
|
|
objectLibraries.begin();
|
|
|
|
i != objectLibraries.end(); ++i) {
|
2015-08-05 18:37:50 +03:00
|
|
|
(*i)->GetLanguages(languages, config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:50 +03:00
|
|
|
}
|
|
|
|
|
2015-08-05 18:37:50 +03:00
|
|
|
void cmGeneratorTarget::ComputeLinkImplementationLanguages(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config, cmOptionalLinkImplementation& impl) const
|
2015-08-05 18:37:50 +03:00
|
|
|
{
|
|
|
|
// This target needs runtime libraries for its source languages.
|
|
|
|
std::set<std::string> languages;
|
|
|
|
// Get languages used in our source files.
|
2015-08-05 18:37:50 +03:00
|
|
|
this->GetLanguages(languages, config);
|
2015-08-05 18:37:50 +03:00
|
|
|
// Copy the set of langauges to the link implementation.
|
2016-05-16 17:34:04 +03:00
|
|
|
impl.Languages.insert(impl.Languages.begin(), languages.begin(),
|
|
|
|
languages.end());
|
2015-08-05 18:37:50 +03:00
|
|
|
}
|
|
|
|
|
2015-08-05 18:37:49 +03:00
|
|
|
bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
|
2015-08-05 18:37:49 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmLinkImplementationLibraries const* impl =
|
|
|
|
this->GetLinkImplementationLibraries(config)) {
|
2015-08-05 18:37:49 +03:00
|
|
|
return !impl->Libraries.empty();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 18:37:49 +03:00
|
|
|
return false;
|
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
|
|
|
cmLinkImplementationLibraries const*
|
|
|
|
cmGeneratorTarget::GetLinkImplementationLibraries(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config) const
|
2015-08-05 19:17:55 +03:00
|
|
|
{
|
2015-09-16 05:56:37 +03:00
|
|
|
return this->GetLinkImplementationLibrariesInternal(config, this);
|
2015-08-05 19:17:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmLinkImplementationLibraries const*
|
|
|
|
cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config, cmGeneratorTarget const* head) const
|
2015-08-05 19:17:55 +03:00
|
|
|
{
|
|
|
|
// There is no link implementation for imported targets.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsImported()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
|
|
|
// Populate the link implementation libraries for this configuration.
|
|
|
|
std::string CONFIG = cmSystemTools::UpperCase(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
HeadToLinkImplementationMap& hm = this->LinkImplMap[CONFIG];
|
2015-08-05 19:17:55 +03:00
|
|
|
|
|
|
|
// If the link implementation does not depend on the head target
|
|
|
|
// then return the one we computed first.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
|
2015-08-05 19:17:55 +03:00
|
|
|
return &hm.begin()->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
2015-10-25 13:37:34 +03:00
|
|
|
cmOptionalLinkImplementation& impl = hm[head];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!impl.LibrariesDone) {
|
2015-08-05 19:17:55 +03:00
|
|
|
impl.LibrariesDone = true;
|
2015-09-16 06:04:51 +03:00
|
|
|
this->ComputeLinkImplementationLibraries(config, impl, head);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
return &impl;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmGeneratorTarget::IsNullImpliedByLinkLibraries(
|
|
|
|
const std::string& p) const
|
2015-08-05 19:41:53 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->LinkImplicitNullProperties.find(p) !=
|
|
|
|
this->LinkImplicitNullProperties.end();
|
2015-08-05 19:41:53 +03:00
|
|
|
}
|
|
|
|
|
2015-08-05 19:17:55 +03:00
|
|
|
void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& config, cmOptionalLinkImplementation& impl,
|
2015-09-16 06:04:51 +03:00
|
|
|
cmGeneratorTarget const* head) const
|
2015-08-05 19:17:55 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStringRange entryRange = this->Target->GetLinkImplementationEntries();
|
|
|
|
cmBacktraceRange btRange = this->Target->GetLinkImplementationBacktraces();
|
2015-08-05 19:17:55 +03:00
|
|
|
cmBacktraceRange::const_iterator btIt = btRange.begin();
|
|
|
|
// Collect libraries directly linked in this configuration.
|
|
|
|
for (cmStringRange::const_iterator le = entryRange.begin(),
|
2016-05-16 17:34:04 +03:00
|
|
|
end = entryRange.end();
|
|
|
|
le != end; ++le, ++btIt) {
|
2015-08-05 19:17:55 +03:00
|
|
|
std::vector<std::string> llibs;
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(
|
|
|
|
this->GetName(), "LINK_LIBRARIES", CM_NULLPTR, CM_NULLPTR);
|
2015-08-05 19:17:55 +03:00
|
|
|
cmGeneratorExpression ge(*btIt);
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
|
2015-08-05 19:17:55 +03:00
|
|
|
std::string const evaluated =
|
2015-09-16 05:38:52 +03:00
|
|
|
cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
|
2015-08-05 19:17:55 +03:00
|
|
|
cmSystemTools::ExpandListArgument(evaluated, llibs);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cge->GetHadHeadSensitiveCondition()) {
|
2015-08-05 19:17:55 +03:00
|
|
|
impl.HadHeadSensitiveCondition = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator li = llibs.begin();
|
|
|
|
li != llibs.end(); ++li) {
|
2015-08-05 19:17:55 +03:00
|
|
|
// Skip entries that resolve to the target itself or are empty.
|
2015-10-16 20:19:51 +03:00
|
|
|
std::string name = this->CheckCMP0004(*li);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == this->GetName() || name.empty()) {
|
|
|
|
if (name == this->GetName()) {
|
2015-08-05 19:17:55 +03:00
|
|
|
bool noMessage = false;
|
|
|
|
cmake::MessageType messageType = cmake::FATAL_ERROR;
|
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->GetPolicyStatusCMP0038()) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-08-05 19:17:55 +03:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n";
|
|
|
|
messageType = cmake::AUTHOR_WARNING;
|
2016-05-16 17:34:04 +03:00
|
|
|
} break;
|
2015-08-05 19:17:55 +03:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
noMessage = true;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
// Issue the fatal message.
|
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!noMessage) {
|
2015-08-05 19:17:55 +03:00
|
|
|
e << "Target \"" << this->GetName() << "\" links to itself.";
|
|
|
|
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
|
2015-10-19 23:39:08 +03:00
|
|
|
messageType, e.str(), this->GetBacktrace());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (messageType == cmake::FATAL_ERROR) {
|
2015-08-05 19:17:55 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
continue;
|
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
|
|
|
// The entry is meant for this configuration.
|
2016-05-16 17:34:04 +03:00
|
|
|
impl.Libraries.push_back(cmLinkImplItem(
|
|
|
|
name, this->FindTargetToLink(name), *btIt, evaluated != *le));
|
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
|
|
|
std::set<std::string> const& seenProps = cge->GetSeenTargetProperties();
|
|
|
|
for (std::set<std::string>::const_iterator it = seenProps.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != seenProps.end(); ++it) {
|
|
|
|
if (!this->GetProperty(*it)) {
|
2015-08-05 19:41:53 +03:00
|
|
|
this->LinkImplicitNullProperties.insert(*it);
|
2015-08-05 19:17:55 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
|
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
|
2015-10-20 01:57:35 +03:00
|
|
|
// Get the list of configurations considered to be DEBUG.
|
|
|
|
std::vector<std::string> debugConfigs =
|
|
|
|
this->Makefile->GetCMakeInstance()->GetDebugConfigs();
|
|
|
|
|
|
|
|
cmTargetLinkLibraryType linkType =
|
2016-05-16 17:34:04 +03:00
|
|
|
CMP0003_ComputeLinkType(config, debugConfigs);
|
2015-08-05 19:17:55 +03:00
|
|
|
cmTarget::LinkLibraryVectorType const& oldllibs =
|
|
|
|
this->Target->GetOriginalLinkLibraries();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
|
|
|
|
li != oldllibs.end(); ++li) {
|
|
|
|
if (li->second != GENERAL_LibraryType && li->second != linkType) {
|
2015-10-16 20:19:51 +03:00
|
|
|
std::string name = this->CheckCMP0004(li->first);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == this->GetName() || name.empty()) {
|
2015-08-05 19:17:55 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
// Support OLD behavior for CMP0003.
|
|
|
|
impl.WrongConfigLibraries.push_back(
|
2015-10-10 13:23:19 +03:00
|
|
|
cmLinkItem(name, this->FindTargetToLink(name)));
|
2015-08-05 19:17:55 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:17:55 +03:00
|
|
|
}
|
2015-08-05 19:39:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink(
|
|
|
|
std::string const& name) const
|
2015-10-10 13:23:19 +03:00
|
|
|
{
|
2015-10-16 20:19:49 +03:00
|
|
|
cmGeneratorTarget* tgt =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LocalGenerator->FindGeneratorTargetToUse(name);
|
2015-10-10 13:23:19 +03:00
|
|
|
|
|
|
|
// Skip targets that will not really be linked. This is probably a
|
|
|
|
// name conflict between an external library and an executable
|
|
|
|
// within the project.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (tgt && tgt->GetType() == cmState::EXECUTABLE &&
|
|
|
|
!tgt->IsExecutableWithExports()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
tgt = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 13:23:19 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (tgt && tgt->GetType() == cmState::OBJECT_LIBRARY) {
|
2015-10-10 13:23:19 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "Target \"" << this->GetName() << "\" links to "
|
2016-05-16 17:34:04 +03:00
|
|
|
"OBJECT library \""
|
|
|
|
<< tgt->GetName()
|
|
|
|
<< "\" but this is not "
|
|
|
|
"allowed. "
|
|
|
|
"One may link only to STATIC or SHARED libraries, or to executables "
|
|
|
|
"with the ENABLE_EXPORTS property set.";
|
2015-10-16 20:19:49 +03:00
|
|
|
cmake* cm = this->LocalGenerator->GetCMakeInstance();
|
2016-05-16 17:34:04 +03:00
|
|
|
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
|
2016-06-27 23:44:16 +03:00
|
|
|
tgt = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 13:23:19 +03:00
|
|
|
|
2015-10-16 20:19:49 +03:00
|
|
|
return tgt;
|
2015-10-10 13:23:19 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
|
2015-08-05 19:39:17 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (OutputInfo const* info = this->GetOutputInfo(config)) {
|
2015-08-05 19:39:17 +03:00
|
|
|
// Return the directory in which the target will be built.
|
|
|
|
return info->PdbDir;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-05 19:39:17 +03:00
|
|
|
return "";
|
|
|
|
}
|
2015-10-10 00:50:36 +03:00
|
|
|
|
|
|
|
bool cmGeneratorTarget::HasImplibGNUtoMS() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
|
2015-10-10 00:50:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string& out,
|
|
|
|
const char* newExt) const
|
2015-10-10 00:50:36 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->HasImplibGNUtoMS() && gnuName.size() > 6 &&
|
|
|
|
gnuName.substr(gnuName.size() - 6) == ".dll.a") {
|
|
|
|
out = gnuName.substr(0, gnuName.size() - 6);
|
|
|
|
out += newExt ? newExt : ".lib";
|
2015-10-10 00:50:36 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 00:50:36 +03:00
|
|
|
return false;
|
|
|
|
}
|
2015-10-10 00:45:55 +03:00
|
|
|
|
2015-10-19 01:34:23 +03:00
|
|
|
bool cmGeneratorTarget::IsExecutableWithExports() const
|
|
|
|
{
|
|
|
|
return (this->GetType() == cmState::EXECUTABLE &&
|
|
|
|
this->GetPropertyAsBool("ENABLE_EXPORTS"));
|
|
|
|
}
|
|
|
|
|
2015-10-10 00:45:55 +03:00
|
|
|
bool cmGeneratorTarget::HasImportLibrary() const
|
|
|
|
{
|
2015-10-20 01:44:15 +03:00
|
|
|
return (this->IsDLLPlatform() &&
|
2015-10-08 01:21:51 +03:00
|
|
|
(this->GetType() == cmState::SHARED_LIBRARY ||
|
2015-10-19 01:34:23 +03:00
|
|
|
this->IsExecutableWithExports()));
|
2015-10-10 00:45:55 +03:00
|
|
|
}
|
2015-10-10 01:29:47 +03:00
|
|
|
|
|
|
|
std::string cmGeneratorTarget::GetSupportDirectory() const
|
|
|
|
{
|
2015-10-16 20:19:49 +03:00
|
|
|
std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory();
|
2015-10-10 01:29:47 +03:00
|
|
|
dir += cmake::GetCMakeFilesDirectory();
|
|
|
|
dir += "/";
|
|
|
|
dir += this->GetName();
|
|
|
|
#if defined(__VMS)
|
|
|
|
dir += "_dir";
|
|
|
|
#else
|
|
|
|
dir += ".dir";
|
|
|
|
#endif
|
|
|
|
return dir;
|
|
|
|
}
|
2015-10-10 00:44:11 +03:00
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsLinkable() const
|
|
|
|
{
|
|
|
|
return (this->GetType() == cmState::STATIC_LIBRARY ||
|
|
|
|
this->GetType() == cmState::SHARED_LIBRARY ||
|
|
|
|
this->GetType() == cmState::MODULE_LIBRARY ||
|
|
|
|
this->GetType() == cmState::UNKNOWN_LIBRARY ||
|
|
|
|
this->GetType() == cmState::INTERFACE_LIBRARY ||
|
2015-10-19 01:34:23 +03:00
|
|
|
this->IsExecutableWithExports());
|
2015-10-10 00:44:11 +03:00
|
|
|
}
|
2015-10-10 00:57:17 +03:00
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsFrameworkOnApple() const
|
|
|
|
{
|
|
|
|
return (this->GetType() == cmState::SHARED_LIBRARY &&
|
|
|
|
this->Makefile->IsOn("APPLE") &&
|
|
|
|
this->GetPropertyAsBool("FRAMEWORK"));
|
|
|
|
}
|
2015-10-10 00:58:19 +03:00
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsAppBundleOnApple() const
|
|
|
|
{
|
|
|
|
return (this->GetType() == cmState::EXECUTABLE &&
|
|
|
|
this->Makefile->IsOn("APPLE") &&
|
|
|
|
this->GetPropertyAsBool("MACOSX_BUNDLE"));
|
|
|
|
}
|
2015-10-10 01:15:38 +03:00
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsXCTestOnApple() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return (this->IsCFBundleOnApple() && this->GetPropertyAsBool("XCTEST"));
|
2015-10-10 01:15:38 +03:00
|
|
|
}
|
2015-10-10 00:59:10 +03:00
|
|
|
|
|
|
|
bool cmGeneratorTarget::IsCFBundleOnApple() const
|
|
|
|
{
|
|
|
|
return (this->GetType() == cmState::MODULE_LIBRARY &&
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("BUNDLE"));
|
2015-10-10 00:59:10 +03:00
|
|
|
}
|