added TARGET_LINK_LIBRARY command and support for debug and release libraries to link against
This commit is contained in:
parent
13143f51d2
commit
2da0c57d46
|
@ -14,6 +14,7 @@
|
|||
#include "cmIncludeDirectoryCommand.cxx"
|
||||
#include "cmLinkDirectoriesCommand.cxx"
|
||||
#include "cmLinkLibrariesCommand.cxx"
|
||||
#include "cmTargetLinkLibrariesCommand.cxx"
|
||||
#include "cmProjectCommand.cxx"
|
||||
#include "cmSourceFilesCommand.cxx"
|
||||
#include "cmSourceFilesRequireCommand.cxx"
|
||||
|
@ -24,6 +25,7 @@
|
|||
#include "cmWin32DefinesCommand.cxx"
|
||||
#include "cmWin32LibrariesCommand.cxx"
|
||||
#include "cmWin32IncludeDirectoryCommand.cxx"
|
||||
#include "cmConfigureFile.cxx"
|
||||
#include "cmConfigureFileNoAutoconf.cxx"
|
||||
#include "cmCableCommand.cxx"
|
||||
#include "cmCableData.cxx"
|
||||
|
@ -64,6 +66,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
|||
commands.push_back(new cmIncludeDirectoryCommand);
|
||||
commands.push_back(new cmLinkDirectoriesCommand);
|
||||
commands.push_back(new cmLinkLibrariesCommand);
|
||||
commands.push_back(new cmTargetLinkLibrariesCommand);
|
||||
commands.push_back(new cmProjectCommand);
|
||||
commands.push_back(new cmSourceFilesCommand);
|
||||
commands.push_back(new cmSourceFilesRequireCommand);
|
||||
|
@ -74,6 +77,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
|||
commands.push_back(new cmWin32DefinesCommand);
|
||||
commands.push_back(new cmWin32LibrariesCommand);
|
||||
commands.push_back(new cmWin32IncludeDirectoryCommand);
|
||||
commands.push_back(new cmConfigureFile);
|
||||
commands.push_back(new cmConfigureFileNoAutoconf);
|
||||
commands.push_back(new cmCableDefineSetCommand);
|
||||
commands.push_back(new cmCableOpenNamespaceCommand);
|
||||
|
|
|
@ -415,8 +415,8 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName,
|
|||
libOptions += "\" ";
|
||||
}
|
||||
// find link libraries
|
||||
cmMakefile::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
|
||||
cmMakefile::LinkLibraries::const_iterator j;
|
||||
const cmTarget::LinkLibraries& libs = target.GetLinkLibraries();
|
||||
cmTarget::LinkLibraries::const_iterator j;
|
||||
for(j = libs.begin(); j != libs.end(); ++j)
|
||||
{
|
||||
// add libraries to executables and dlls (but never include
|
||||
|
@ -424,19 +424,19 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName,
|
|||
if (!target.IsALibrary() ||
|
||||
(m_LibraryBuildType == DLL && libName != j->first))
|
||||
{
|
||||
if (j->second == cmMakefile::GENERAL)
|
||||
if (j->second == cmTarget::GENERAL)
|
||||
{
|
||||
libOptions += " ";
|
||||
libOptions += j->first;
|
||||
libOptions += ".lib ";
|
||||
}
|
||||
if (j->second == cmMakefile::DEBUG)
|
||||
if (j->second == cmTarget::DEBUG)
|
||||
{
|
||||
libDebugOptions += " ";
|
||||
libDebugOptions += j->first;
|
||||
libDebugOptions += ".lib ";
|
||||
}
|
||||
if (j->second == cmMakefile::OPTIMIZED)
|
||||
if (j->second == cmTarget::OPTIMIZED)
|
||||
{
|
||||
libOptimizedOptions += " ";
|
||||
libOptimizedOptions += j->first;
|
||||
|
|
|
@ -415,8 +415,8 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName,
|
|||
libOptions += "\" ";
|
||||
}
|
||||
// find link libraries
|
||||
cmMakefile::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
|
||||
cmMakefile::LinkLibraries::const_iterator j;
|
||||
const cmTarget::LinkLibraries& libs = target.GetLinkLibraries();
|
||||
cmTarget::LinkLibraries::const_iterator j;
|
||||
for(j = libs.begin(); j != libs.end(); ++j)
|
||||
{
|
||||
// add libraries to executables and dlls (but never include
|
||||
|
@ -424,19 +424,19 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName,
|
|||
if (!target.IsALibrary() ||
|
||||
(m_LibraryBuildType == DLL && libName != j->first))
|
||||
{
|
||||
if (j->second == cmMakefile::GENERAL)
|
||||
if (j->second == cmTarget::GENERAL)
|
||||
{
|
||||
libOptions += " ";
|
||||
libOptions += j->first;
|
||||
libOptions += ".lib ";
|
||||
}
|
||||
if (j->second == cmMakefile::DEBUG)
|
||||
if (j->second == cmTarget::DEBUG)
|
||||
{
|
||||
libDebugOptions += " ";
|
||||
libDebugOptions += j->first;
|
||||
libDebugOptions += ".lib ";
|
||||
}
|
||||
if (j->second == cmMakefile::OPTIMIZED)
|
||||
if (j->second == cmTarget::OPTIMIZED)
|
||||
{
|
||||
libOptimizedOptions += " ";
|
||||
libOptimizedOptions += j->first;
|
||||
|
|
|
@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "cmSystemTools.h"
|
||||
#include "cmDSPMakefile.h"
|
||||
#include "cmMSProjectGenerator.h"
|
||||
#include "cmCacheManager.h"
|
||||
|
||||
|
||||
cmDSWMakefile::cmDSWMakefile(cmMakefile* m)
|
||||
|
@ -151,9 +152,9 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
|
|||
fout << "{{{\n";
|
||||
|
||||
// insert Begin Project Dependency Project_Dep_Name project stuff here
|
||||
cmMakefile::LinkLibraries::const_iterator j, jend;
|
||||
j = project->GetMakefile()->GetLinkLibraries().begin();
|
||||
jend = project->GetMakefile()->GetLinkLibraries().end();
|
||||
cmTarget::LinkLibraries::const_iterator j, jend;
|
||||
j = l.GetLinkLibraries().begin();
|
||||
jend = l.GetLinkLibraries().end();
|
||||
for(;j!= jend; ++j)
|
||||
{
|
||||
if(j->first != dspname)
|
||||
|
@ -161,9 +162,15 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
|
|||
if (!l.IsALibrary() ||
|
||||
project->GetLibraryBuildType() == cmDSPMakefile::DLL)
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << j->first << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
// is the library part of this DSW ? If so add dependency
|
||||
const char* cacheValue
|
||||
= cmCacheManager::GetInstance()->GetCacheValue(j->first.c_str());
|
||||
if(cacheValue)
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << j->first << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "cmSystemTools.h"
|
||||
#include "cmDSPMakefile.h"
|
||||
#include "cmMSProjectGenerator.h"
|
||||
#include "cmCacheManager.h"
|
||||
|
||||
|
||||
cmDSWMakefile::cmDSWMakefile(cmMakefile* m)
|
||||
|
@ -151,9 +152,9 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
|
|||
fout << "{{{\n";
|
||||
|
||||
// insert Begin Project Dependency Project_Dep_Name project stuff here
|
||||
cmMakefile::LinkLibraries::const_iterator j, jend;
|
||||
j = project->GetMakefile()->GetLinkLibraries().begin();
|
||||
jend = project->GetMakefile()->GetLinkLibraries().end();
|
||||
cmTarget::LinkLibraries::const_iterator j, jend;
|
||||
j = l.GetLinkLibraries().begin();
|
||||
jend = l.GetLinkLibraries().end();
|
||||
for(;j!= jend; ++j)
|
||||
{
|
||||
if(j->first != dspname)
|
||||
|
@ -161,9 +162,15 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
|
|||
if (!l.IsALibrary() ||
|
||||
project->GetLibraryBuildType() == cmDSPMakefile::DLL)
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << j->first << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
// is the library part of this DSW ? If so add dependency
|
||||
const char* cacheValue
|
||||
= cmCacheManager::GetInstance()->GetCacheValue(j->first.c_str());
|
||||
if(cacheValue)
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << j->first << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,11 +44,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// cmFindIncludeCommand
|
||||
bool cmFindIncludeCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if(args.size() < 2 )
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
this->SetError("This has been deprecated, please use FIND_PATH command instead ");
|
||||
return false;
|
||||
|
||||
|
||||
// Now check and see if the value has been stored in the cache
|
||||
// already, if so use that value and don't look for the program
|
||||
const char* cacheValue
|
||||
|
|
|
@ -132,6 +132,6 @@ bool cmFindLibraryCommand::Invoke(std::vector<std::string>& args)
|
|||
"NOTFOUND",
|
||||
helpString.c_str(),
|
||||
cmCacheManager::PATH);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,13 +57,13 @@ bool cmLinkLibrariesCommand::Invoke(std::vector<std::string>& args)
|
|||
{
|
||||
++i;
|
||||
m_Makefile->AddLinkLibrary(i->c_str(),
|
||||
cmMakefile::DEBUG);
|
||||
cmTarget::DEBUG);
|
||||
}
|
||||
else if (*i == "optimized")
|
||||
{
|
||||
++i;
|
||||
m_Makefile->AddLinkLibrary(i->c_str(),
|
||||
cmMakefile::OPTIMIZED);
|
||||
cmTarget::OPTIMIZED);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -98,8 +98,7 @@ public:
|
|||
"LINK_LIBRARIES(library1 <debug | optimized> library2 ...)\n"
|
||||
"Specify a list of libraries to be linked into\n"
|
||||
"executables or shared objects. This command is passed\n"
|
||||
"down to all other commands. The library name should be\n"
|
||||
"the same as the name used in the LIBRARY(library) command.\n"
|
||||
"down to all other commands. \n"
|
||||
"The debug and optimized strings may be used to indicate that\n"
|
||||
"the next library listed is to be used only for that specific\n"
|
||||
"type of build";
|
||||
|
|
|
@ -83,8 +83,39 @@ void cmMakefile::AddDefaultCommands()
|
|||
#if defined(__CYGWIN__)
|
||||
this->AddDefinition("UNIX", "1");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void cmMakefile::ReadSystemConfiguration(const char *fname)
|
||||
{
|
||||
std::ifstream fin(fname);
|
||||
if(!fin)
|
||||
{
|
||||
cmSystemTools::Error("error can not open file ", fname);
|
||||
return;
|
||||
}
|
||||
|
||||
cmRegularExpression aDef("^Define[ \t]*([A-Za-z_0-9]*)[ \t]*([A-Za-z_0-9]*)[ \t]*$");
|
||||
const int BUFFER_SIZE = 4096;
|
||||
char inbuffer[BUFFER_SIZE];
|
||||
while (fin)
|
||||
{
|
||||
if(fin.getline(inbuffer, BUFFER_SIZE ) )
|
||||
{
|
||||
if(aDef.find(inbuffer))
|
||||
{
|
||||
// the arguments are the second match
|
||||
std::string def = aDef.match(1);
|
||||
std::string val = aDef.match(2);
|
||||
// add the definition if true
|
||||
if (cmSystemTools::IsOn(val.c_str()))
|
||||
{
|
||||
this->AddDefinition(def.c_str(),val.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmMakefile::~cmMakefile()
|
||||
{
|
||||
|
@ -309,6 +340,12 @@ void cmMakefile::GenerateMakefile()
|
|||
{
|
||||
(*i)->FinalPass();
|
||||
}
|
||||
// merge libraries
|
||||
for (cmTargets::iterator l = m_Targets.begin();
|
||||
l != m_Targets.end(); l++)
|
||||
{
|
||||
l->second.MergeLibraries(m_LinkLibraries);
|
||||
}
|
||||
// now do the generation
|
||||
m_MakefileGenerator->GenerateMakefile();
|
||||
}
|
||||
|
@ -359,15 +396,27 @@ void cmMakefile::AddUtilityDirectory(const char* dir)
|
|||
m_UtilityDirectories.push_back(dir);
|
||||
}
|
||||
|
||||
void cmMakefile::AddLinkLibrary(const char* lib, LinkLibraryType llt)
|
||||
void cmMakefile::AddLinkLibrary(const char* lib, cmTarget::LinkLibraryType llt)
|
||||
{
|
||||
m_LinkLibraries.push_back(
|
||||
std::pair<std::string, LinkLibraryType>(lib,llt));
|
||||
std::pair<std::string, cmTarget::LinkLibraryType>(lib,llt));
|
||||
}
|
||||
|
||||
void cmMakefile::AddLinkLibraryForTarget(const char *target,
|
||||
const char* lib,
|
||||
cmTarget::LinkLibraryType llt)
|
||||
{
|
||||
if (m_Targets.find(target) != m_Targets.end())
|
||||
{
|
||||
m_Targets[target].GetLinkLibraries().
|
||||
push_back(
|
||||
std::pair<std::string, cmTarget::LinkLibraryType>(lib,llt));
|
||||
}
|
||||
}
|
||||
|
||||
void cmMakefile::AddLinkLibrary(const char* lib)
|
||||
{
|
||||
this->AddLinkLibrary(lib,GENERAL);
|
||||
this->AddLinkLibrary(lib,cmTarget::GENERAL);
|
||||
}
|
||||
|
||||
void cmMakefile::AddLinkDirectory(const char* dir)
|
||||
|
@ -513,7 +562,7 @@ void cmMakefile::ExpandVariables()
|
|||
{
|
||||
this->ExpandVariablesInString(*j);
|
||||
}
|
||||
LinkLibraries::iterator j2, end2;
|
||||
cmTarget::LinkLibraries::iterator j2, end2;
|
||||
j2 = m_LinkLibraries.begin();
|
||||
end2 = m_LinkLibraries.end();
|
||||
for(; j2 != end2; ++j2)
|
||||
|
@ -581,6 +630,19 @@ void cmMakefile::ExpandVariablesInString(std::string& source) const
|
|||
}
|
||||
}
|
||||
|
||||
void cmMakefile::RemoveVariablesInString(std::string& source) const
|
||||
{
|
||||
cmRegularExpression var("(\\${[A-Za-z_0-9]*})");
|
||||
cmRegularExpression var2("(@[A-Za-z_0-9]*@)");
|
||||
while (var.find(source))
|
||||
{
|
||||
source.erase(var.start(),var.end());
|
||||
}
|
||||
while (var2.find(source))
|
||||
{
|
||||
source.erase(var2.start(),var2.end());
|
||||
}
|
||||
}
|
||||
|
||||
// recursive function to create a vector of cmMakefile objects
|
||||
// This is done by reading the sub directory CMakeLists.txt files,
|
||||
|
@ -774,3 +836,27 @@ void cmMakefile::RemoveFunctionBlocker(const char *name,
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
void cmMakefile::SetHomeDirectory(const char* dir)
|
||||
{
|
||||
m_cmHomeDirectory = dir;
|
||||
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
|
||||
this->AddDefinition("CMAKE_SOURCE_DIR", this->GetHomeDirectory());
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
std::string fpath = dir;
|
||||
fpath += "/CMake/CMakeWindowsSystemConfig.txt";
|
||||
this->ReadSystemConfiguration(fpath.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void cmMakefile::SetHomeOutputDirectory(const char* lib)
|
||||
{
|
||||
m_HomeOutputDirectory = lib;
|
||||
cmSystemTools::ConvertToUnixSlashes(m_HomeOutputDirectory);
|
||||
this->AddDefinition("CMAKE_BINARY_DIR", this->GetHomeOutputDirectory());
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
std::string fpath = lib;
|
||||
fpath += "/CMakeSystemConfig.txt";
|
||||
this->ReadSystemConfiguration(fpath.c_str());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -146,9 +146,7 @@ public:
|
|||
/**
|
||||
* Get a list of link libraries in the build.
|
||||
*/
|
||||
enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
|
||||
typedef std::vector<std::pair<std::string,LinkLibraryType> > LinkLibraries;
|
||||
LinkLibraries& GetLinkLibraries()
|
||||
cmTarget::LinkLibraries& GetLinkLibraries()
|
||||
{
|
||||
return m_LinkLibraries;
|
||||
}
|
||||
|
@ -157,7 +155,9 @@ public:
|
|||
* Add a link library to the build.
|
||||
*/
|
||||
void AddLinkLibrary(const char*);
|
||||
void AddLinkLibrary(const char*, LinkLibraryType type);
|
||||
void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
|
||||
void AddLinkLibraryForTarget(const char *tgt, const char*,
|
||||
cmTarget::LinkLibraryType type);
|
||||
|
||||
/**
|
||||
* Add a link directory to the build.
|
||||
|
@ -236,22 +236,12 @@ public:
|
|||
* CMakeLists files by recursing up the tree starting at the StartDirectory
|
||||
* and going up until it reaches the HomeDirectory.
|
||||
*/
|
||||
void SetHomeDirectory(const char* dir)
|
||||
{
|
||||
m_cmHomeDirectory = dir;
|
||||
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
|
||||
this->AddDefinition("CMAKE_SOURCE_DIR", this->GetHomeDirectory());
|
||||
}
|
||||
void SetHomeDirectory(const char* dir);
|
||||
const char* GetHomeDirectory() const
|
||||
{
|
||||
return m_cmHomeDirectory.c_str();
|
||||
}
|
||||
void SetHomeOutputDirectory(const char* lib)
|
||||
{
|
||||
m_HomeOutputDirectory = lib;
|
||||
cmSystemTools::ConvertToUnixSlashes(m_HomeOutputDirectory);
|
||||
this->AddDefinition("CMAKE_BINARY_DIR", this->GetHomeOutputDirectory());
|
||||
}
|
||||
void SetHomeOutputDirectory(const char* lib);
|
||||
const char* GetHomeOutputDirectory() const
|
||||
{
|
||||
return m_HomeOutputDirectory.c_str();
|
||||
|
@ -426,6 +416,12 @@ public:
|
|||
*/
|
||||
void ExpandVariablesInString(std::string& source) const;
|
||||
|
||||
/**
|
||||
* Remove any remaining variables in the string. Anything with ${var} or
|
||||
* @var@ will be removed.
|
||||
*/
|
||||
void RemoveVariablesInString(std::string& source) const;
|
||||
|
||||
/**
|
||||
* Expand variables in the makefiles ivars such as link directories etc
|
||||
*/
|
||||
|
@ -445,6 +441,11 @@ public:
|
|||
*/
|
||||
void GenerateCacheOnly();
|
||||
|
||||
/**
|
||||
* find what source group this source is in
|
||||
*/
|
||||
void ReadSystemConfiguration(const char *fname);
|
||||
|
||||
/**
|
||||
* find what source group this source is in
|
||||
*/
|
||||
|
@ -474,7 +475,7 @@ protected:
|
|||
std::vector<std::string> m_LinkDirectories;
|
||||
std::vector<std::string> m_Utilities;
|
||||
std::vector<std::string> m_UtilityDirectories;
|
||||
LinkLibraries m_LinkLibraries;
|
||||
cmTarget::LinkLibraries m_LinkLibraries;
|
||||
std::string m_IncludeFileRegularExpression;
|
||||
std::string m_DefineFlags;
|
||||
std::vector<cmSourceGroup> m_SourceGroups;
|
||||
|
|
|
@ -67,3 +67,18 @@ void cmTarget::GenerateSourceFilesFromSourceLists(const cmMakefile &mf)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmTarget::MergeLibraries(const LinkLibraries &ll)
|
||||
{
|
||||
typedef std::vector<std::pair<std::string,LinkLibraryType> > LinkLibraries;
|
||||
|
||||
LinkLibraries::const_iterator p = ll.begin();
|
||||
for (;p != ll.end(); ++p)
|
||||
{
|
||||
if (std::find(m_LinkLibraries.begin(),m_LinkLibraries.end(),*p) == m_LinkLibraries.end())
|
||||
{
|
||||
m_LinkLibraries.push_back(*p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,19 @@ public:
|
|||
{return m_SourceFiles;}
|
||||
std::vector<cmSourceFile> &GetSourceFiles() {return m_SourceFiles;}
|
||||
|
||||
/**
|
||||
* Get the list of the source files used by this target
|
||||
*/
|
||||
enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
|
||||
typedef std::vector<std::pair<std::string,LinkLibraryType> > LinkLibraries;
|
||||
const LinkLibraries &GetLinkLibraries() const {return m_LinkLibraries;}
|
||||
LinkLibraries &GetLinkLibraries() {return m_LinkLibraries;}
|
||||
|
||||
/**
|
||||
* Merge Link LIbraries into this targets current list
|
||||
*/
|
||||
void MergeLibraries(const LinkLibraries &ll);
|
||||
|
||||
/**
|
||||
* Generate the SourceFilesList from the SourceLists. This should only be
|
||||
* done once to be safe.
|
||||
|
@ -92,6 +105,7 @@ private:
|
|||
std::vector<std::string> m_SourceLists;
|
||||
bool m_IsALibrary;
|
||||
std::vector<cmSourceFile> m_SourceFiles;
|
||||
LinkLibraries m_LinkLibraries;
|
||||
};
|
||||
|
||||
typedef std::map<std::string,cmTarget> cmTargets;
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/*=========================================================================
|
||||
|
||||
Program: Insight Segmentation & Registration Toolkit
|
||||
Module: $RCSfile$
|
||||
Language: C++
|
||||
Date: $Date$
|
||||
Version: $Revision$
|
||||
|
||||
Copyright (c) 2001 Insight Consortium
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The name of the Insight Consortium, nor the names of any consortium members,
|
||||
nor of any contributors, may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
* Modified source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=========================================================================*/
|
||||
#include "cmTargetLinkLibrariesCommand.h"
|
||||
|
||||
// cmTargetLinkLibrariesCommand
|
||||
bool cmTargetLinkLibrariesCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if(args.size() < 2)
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
// add libraries, nothe that there is an optional prefix
|
||||
// of debug and optimized than can be used
|
||||
for(std::vector<std::string>::iterator i = args.begin();
|
||||
i != args.end(); ++i)
|
||||
{
|
||||
if (*i == "debug")
|
||||
{
|
||||
++i;
|
||||
m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
|
||||
cmTarget::DEBUG);
|
||||
}
|
||||
else if (*i == "optimized")
|
||||
{
|
||||
++i;
|
||||
m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
|
||||
cmTarget::OPTIMIZED);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
|
||||
cmTarget::GENERAL);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/*=========================================================================
|
||||
|
||||
Program: Insight Segmentation & Registration Toolkit
|
||||
Module: $RCSfile$
|
||||
Language: C++
|
||||
Date: $Date$
|
||||
Version: $Revision$
|
||||
|
||||
Copyright (c) 2001 Insight Consortium
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The name of the Insight Consortium, nor the names of any consortium members,
|
||||
nor of any contributors, may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
* Modified source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=========================================================================*/
|
||||
#ifndef cmTargetLinkLibrariesCommand_h
|
||||
#define cmTargetLinkLibrariesCommand_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmCommand.h"
|
||||
|
||||
/** \class cmTargetLinkLibrariesCommand
|
||||
* \brief Specify a list of libraries to link into executables.
|
||||
*
|
||||
* cmTargetLinkLibrariesCommand is used to specify a list of libraries to link
|
||||
* into executable(s) or shared objects. The names of the libraries
|
||||
* should be those defined by the LIBRARY(library) command(s).
|
||||
*/
|
||||
class cmTargetLinkLibrariesCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
virtual cmCommand* Clone()
|
||||
{
|
||||
return new cmTargetLinkLibrariesCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when the command is first encountered in
|
||||
* the CMakeLists.txt file.
|
||||
*/
|
||||
virtual bool Invoke(std::vector<std::string>& args);
|
||||
|
||||
/**
|
||||
* The name of the command as specified in CMakeList.txt.
|
||||
*/
|
||||
virtual const char* GetName() { return "TARGET_LINK_LIBRARIES";}
|
||||
|
||||
/**
|
||||
* Succinct documentation.
|
||||
*/
|
||||
virtual const char* GetTerseDocumentation()
|
||||
{
|
||||
return
|
||||
"Specify a list of libraries to be linked into\n"
|
||||
"executables or shared objects.";
|
||||
}
|
||||
|
||||
/**
|
||||
* More documentation.
|
||||
*/
|
||||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"TARGET_LINK_LIBRARIES(target library1 <debug | optimized> library2 ...)\n"
|
||||
"Specify a list of libraries to be linked into the specified target\n"
|
||||
"The debug and optimized strings may be used to indicate that\n"
|
||||
"the next library listed is to be used only for that specific\n"
|
||||
"type of build";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -140,7 +140,8 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
|||
* to the name of the library. This will not link a library against itself.
|
||||
*/
|
||||
void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
|
||||
const char* targetLibrary)
|
||||
const char* targetLibrary,
|
||||
const cmTarget &tgt)
|
||||
{
|
||||
// collect all the flags needed for linking libraries
|
||||
std::string linkLibs;
|
||||
|
@ -158,14 +159,14 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
|
|||
linkLibs += " ";
|
||||
}
|
||||
std::string librariesLinked;
|
||||
cmMakefile::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
|
||||
cmMakefile::LinkLibraries::const_iterator j2;
|
||||
const cmTarget::LinkLibraries& libs = tgt.GetLinkLibraries();
|
||||
cmTarget::LinkLibraries::const_iterator j2;
|
||||
for(j2 = libs.begin(); j2 != libs.end(); ++j2)
|
||||
{
|
||||
// Don't link the library against itself!
|
||||
if(targetLibrary && (j2->first == targetLibrary)) continue;
|
||||
// don't look at debug libraries
|
||||
if (j2->second == cmMakefile::DEBUG) continue;
|
||||
if (j2->second == cmTarget::DEBUG) continue;
|
||||
std::string::size_type pos = j2->first.find("-l");
|
||||
if((pos == std::string::npos || pos > 0)
|
||||
&& j2->first.find("${") == std::string::npos)
|
||||
|
@ -213,7 +214,7 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
|
|||
fout << "\t lib" << l->first << "$(SHLIB_SUFFIX) \\\n";
|
||||
fout << "\t ${KIT_OBJ} ${" << l->first <<
|
||||
"_SRC_OBJS} ";
|
||||
this->OutputLinkLibraries(fout, l->first.c_str());
|
||||
this->OutputLinkLibraries(fout, l->first.c_str(), l->second);
|
||||
fout << "\n\n";
|
||||
}
|
||||
else
|
||||
|
@ -222,7 +223,7 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
|
|||
l->first << "_SRC_OBJS} ${CMAKE_DEPEND_LIBS}\n";
|
||||
fout << "\t${CXX} ${CXX_FLAGS} ${" <<
|
||||
l->first << "_SRC_OBJS} ";
|
||||
this->OutputLinkLibraries(fout, NULL);
|
||||
this->OutputLinkLibraries(fout, NULL,l->second);
|
||||
fout << " -o " << l->first << "\n\n";
|
||||
}
|
||||
}
|
||||
|
@ -234,8 +235,8 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
|
|||
void cmUnixMakefileGenerator::OutputDependencies(std::ostream& fout)
|
||||
{
|
||||
fout << "CMAKE_DEPEND_LIBS = ";
|
||||
cmMakefile::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
|
||||
cmMakefile::LinkLibraries::const_iterator lib2;
|
||||
cmTarget::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
|
||||
cmTarget::LinkLibraries::const_iterator lib2;
|
||||
// Search the list of libraries that will be linked into
|
||||
// the executable
|
||||
for(lib2 = libs.begin(); lib2 != libs.end(); ++lib2)
|
||||
|
|
|
@ -70,7 +70,7 @@ protected:
|
|||
void OutputMakeFlags(std::ostream&);
|
||||
void OutputVerbatim(std::ostream&);
|
||||
void OutputTargetRules(std::ostream& fout);
|
||||
void OutputLinkLibraries(std::ostream&, const char*);
|
||||
void OutputLinkLibraries(std::ostream&, const char*, const cmTarget &);
|
||||
void OutputTargets(std::ostream&);
|
||||
void OutputSubDirectoryRules(std::ostream&);
|
||||
void OutputDependInformation(std::ostream&);
|
||||
|
|
Loading…
Reference in New Issue