2008-01-22 17:13:04 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#ifndef cmComputeLinkInformation_h
|
|
|
|
#define cmComputeLinkInformation_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
|
|
|
|
#include <cmsys/RegularExpression.hxx>
|
|
|
|
|
2008-02-04 23:22:10 +03:00
|
|
|
class cmake;
|
2008-01-22 17:13:04 +03:00
|
|
|
class cmGlobalGenerator;
|
|
|
|
class cmLocalGenerator;
|
|
|
|
class cmMakefile;
|
|
|
|
class cmTarget;
|
2008-02-21 19:41:11 +03:00
|
|
|
class cmOrderDirectories;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
/** \class cmComputeLinkInformation
|
|
|
|
* \brief Compute link information for a target in one configuration.
|
|
|
|
*/
|
|
|
|
class cmComputeLinkInformation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmComputeLinkInformation(cmTarget* target, const char* config);
|
2008-02-01 16:56:00 +03:00
|
|
|
~cmComputeLinkInformation();
|
2008-01-22 17:13:04 +03:00
|
|
|
bool Compute();
|
|
|
|
|
|
|
|
struct Item
|
|
|
|
{
|
|
|
|
Item(): Value(), IsPath(true) {}
|
|
|
|
Item(Item const& item): Value(item.Value), IsPath(item.IsPath) {}
|
|
|
|
Item(std::string const& v, bool p): Value(v), IsPath(p) {}
|
|
|
|
std::string Value;
|
|
|
|
bool IsPath;
|
|
|
|
};
|
|
|
|
typedef std::vector<Item> ItemVector;
|
|
|
|
ItemVector const& GetItems();
|
|
|
|
std::vector<std::string> const& GetDirectories();
|
|
|
|
std::vector<std::string> const& GetDepends();
|
|
|
|
std::vector<std::string> const& GetFrameworkPaths();
|
|
|
|
const char* GetLinkLanguage() const { return this->LinkLanguage; }
|
|
|
|
std::vector<std::string> const& GetRuntimeSearchPath();
|
2008-01-29 23:07:33 +03:00
|
|
|
std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
|
|
|
|
std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
|
|
|
|
void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
|
|
|
|
std::string GetRPathString(bool for_install);
|
|
|
|
std::string GetChrpathString();
|
2008-01-29 23:47:18 +03:00
|
|
|
std::set<cmTarget*> const& GetSharedLibrariesLinked();
|
2008-02-01 16:56:00 +03:00
|
|
|
|
|
|
|
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
|
|
|
|
std::string GetRPathLinkString();
|
2008-01-22 17:13:04 +03:00
|
|
|
private:
|
2008-02-01 16:56:00 +03:00
|
|
|
void AddItem(std::string const& item, cmTarget* tgt);
|
|
|
|
void AddSharedDepItem(std::string const& item, cmTarget* tgt);
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Output information.
|
|
|
|
ItemVector Items;
|
|
|
|
std::vector<std::string> Directories;
|
|
|
|
std::vector<std::string> Depends;
|
|
|
|
std::vector<std::string> FrameworkPaths;
|
|
|
|
std::vector<std::string> RuntimeSearchPath;
|
2008-01-29 23:47:18 +03:00
|
|
|
std::set<cmTarget*> SharedLibrariesLinked;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Context information.
|
|
|
|
cmTarget* Target;
|
|
|
|
cmMakefile* Makefile;
|
|
|
|
cmLocalGenerator* LocalGenerator;
|
|
|
|
cmGlobalGenerator* GlobalGenerator;
|
2008-02-04 23:22:10 +03:00
|
|
|
cmake* CMakeInstance;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Configuration information.
|
|
|
|
const char* Config;
|
|
|
|
const char* LinkLanguage;
|
|
|
|
|
2008-01-31 23:45:31 +03:00
|
|
|
// Modes for dealing with dependent shared libraries.
|
|
|
|
enum SharedDepMode
|
|
|
|
{
|
2008-02-21 19:41:11 +03:00
|
|
|
SharedDepModeNone, // Drop
|
|
|
|
SharedDepModeDir, // List dir in -rpath-link flag
|
|
|
|
SharedDepModeLibDir, // List dir in linker search path
|
|
|
|
SharedDepModeLink // List file on link line
|
2008-01-31 23:45:31 +03:00
|
|
|
};
|
|
|
|
|
2008-01-22 17:13:04 +03:00
|
|
|
// System info.
|
|
|
|
bool UseImportLibrary;
|
|
|
|
const char* LoaderFlag;
|
|
|
|
std::string LibLinkFlag;
|
2008-01-23 21:30:55 +03:00
|
|
|
std::string LibLinkFileFlag;
|
2008-01-22 17:13:04 +03:00
|
|
|
std::string LibLinkSuffix;
|
2008-01-29 23:07:33 +03:00
|
|
|
std::string RuntimeFlag;
|
|
|
|
std::string RuntimeSep;
|
|
|
|
std::string RuntimeAlways;
|
|
|
|
bool RuntimeUseChrpath;
|
2008-02-21 19:41:11 +03:00
|
|
|
bool NoSONameUsesPath;
|
|
|
|
bool LinkWithRuntimePath;
|
2008-02-01 16:56:00 +03:00
|
|
|
std::string RPathLinkFlag;
|
2008-01-31 23:45:31 +03:00
|
|
|
SharedDepMode SharedDependencyMode;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Link type adjustment.
|
|
|
|
void ComputeLinkTypeInfo();
|
|
|
|
enum LinkType { LinkUnknown, LinkStatic, LinkShared };
|
|
|
|
LinkType StartLinkType;
|
|
|
|
LinkType CurrentLinkType;
|
|
|
|
std::string StaticLinkTypeFlag;
|
|
|
|
std::string SharedLinkTypeFlag;
|
|
|
|
bool LinkTypeEnabled;
|
|
|
|
void SetCurrentLinkType(LinkType lt);
|
2008-02-04 23:22:10 +03:00
|
|
|
bool ArchivesMayBeShared;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Link item parsing.
|
|
|
|
void ComputeItemParserInfo();
|
|
|
|
std::vector<std::string> StaticLinkExtensions;
|
|
|
|
std::vector<std::string> SharedLinkExtensions;
|
|
|
|
std::vector<std::string> LinkExtensions;
|
|
|
|
std::set<cmStdString> LinkPrefixes;
|
|
|
|
cmsys::RegularExpression ExtractStaticLibraryName;
|
|
|
|
cmsys::RegularExpression ExtractSharedLibraryName;
|
|
|
|
cmsys::RegularExpression ExtractAnyLibraryName;
|
|
|
|
void AddLinkPrefix(const char* p);
|
|
|
|
void AddLinkExtension(const char* e, LinkType type);
|
|
|
|
std::string CreateExtensionRegex(std::vector<std::string> const& exts);
|
|
|
|
std::string NoCaseExpression(const char* str);
|
|
|
|
|
2008-02-21 19:41:11 +03:00
|
|
|
// Handling of link items.
|
2008-01-22 18:05:27 +03:00
|
|
|
void AddTargetItem(std::string const& item, cmTarget* target);
|
|
|
|
void AddFullItem(std::string const& item);
|
2008-01-31 15:50:40 +03:00
|
|
|
bool CheckImplicitDirItem(std::string const& item);
|
2008-01-22 17:13:04 +03:00
|
|
|
void AddUserItem(std::string const& item);
|
|
|
|
void AddDirectoryItem(std::string const& item);
|
|
|
|
void AddFrameworkItem(std::string const& item);
|
|
|
|
void DropDirectoryItem(std::string const& item);
|
2008-02-21 19:41:11 +03:00
|
|
|
bool CheckSharedLibNoSOName(std::string const& item);
|
|
|
|
void AddSharedLibNoSOName(std::string const& item);
|
2008-01-22 17:13:04 +03:00
|
|
|
|
|
|
|
// Framework info.
|
|
|
|
void ComputeFrameworkInfo();
|
|
|
|
void AddFrameworkPath(std::string const& p);
|
|
|
|
std::set<cmStdString> FrameworkPathsEmmitted;
|
|
|
|
cmsys::RegularExpression SplitFramework;
|
|
|
|
|
|
|
|
// Linker search path computation.
|
2008-02-21 19:41:11 +03:00
|
|
|
cmOrderDirectories* OrderLinkerSearchPath;
|
|
|
|
void FinishLinkerSearchDirectories();
|
2008-01-31 15:50:40 +03:00
|
|
|
std::set<cmStdString> ImplicitLinkDirs;
|
2008-01-22 17:13:04 +03:00
|
|
|
|
2008-01-23 23:22:38 +03:00
|
|
|
// Linker search path compatibility mode.
|
2008-02-21 19:41:11 +03:00
|
|
|
std::vector<std::string> OldLinkDirItems;
|
2008-01-23 23:22:38 +03:00
|
|
|
bool OldLinkDirMode;
|
|
|
|
bool HaveUserFlagItem;
|
|
|
|
|
2008-01-22 17:13:04 +03:00
|
|
|
// Runtime path computation.
|
2008-02-21 19:41:11 +03:00
|
|
|
cmOrderDirectories* OrderRuntimeSearchPath;
|
2008-01-22 17:13:04 +03:00
|
|
|
void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target);
|
2008-02-06 21:34:44 +03:00
|
|
|
void AddLibraryRuntimeInfo(std::string const& fullPath);
|
2008-02-01 16:56:00 +03:00
|
|
|
|
|
|
|
// Dependent library path computation.
|
2008-02-21 19:41:11 +03:00
|
|
|
cmOrderDirectories* OrderDependentRPath;
|
2008-01-22 17:13:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|