summaryrefslogtreecommitdiffstats
path: root/Source/cmDSPWriter.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2001-04-26 20:22:53 (GMT)
committerKen Martin <ken.martin@kitware.com>2001-04-26 20:22:53 (GMT)
commit41e1270413b18272bc73a8b25150aad4c7913563 (patch)
tree97d507f6296c78e5aaf17e1858e610cf95c46ba7 /Source/cmDSPWriter.cxx
parent888e47ddb4215659e76673af4f18aba865ccc4b8 (diff)
downloadCMake-41e1270413b18272bc73a8b25150aad4c7913563.zip
CMake-41e1270413b18272bc73a8b25150aad4c7913563.tar.gz
CMake-41e1270413b18272bc73a8b25150aad4c7913563.tar.bz2
support for debug and opt libraries
Diffstat (limited to 'Source/cmDSPWriter.cxx')
-rw-r--r--Source/cmDSPWriter.cxx94
1 files changed, 58 insertions, 36 deletions
diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx
index 22dc798..1efbcc8 100644
--- a/Source/cmDSPWriter.cxx
+++ b/Source/cmDSPWriter.cxx
@@ -53,10 +53,8 @@ void cmDSPMakefile::OutputDSPFile()
}
// Create the DSP or set of DSP's for libraries and executables
- const char* cacheValue
- = cmCacheManager::GetInstance()->GetCacheValue("BUILD_SHARED_LIBS");
m_LibraryBuildType = STATIC_LIBRARY;
- if(cacheValue && strcmp(cacheValue,"0"))
+ if(cmCacheManager::GetInstance()->IsOn("BUILD_SHARED_LIBS"))
{
m_LibraryBuildType = DLL;
}
@@ -69,30 +67,6 @@ void cmDSPMakefile::OutputDSPFile()
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
- std::string libOptions;
- std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
- for(i = libdirs.begin(); i != libdirs.end(); ++i)
- {
- libOptions += " /LIBPATH:\"";
- libOptions += *i;
- libOptions += "/$(OUTDIR)\" ";
- libOptions += " /LIBPATH:\"";
- libOptions += *i;
- libOptions += "\" ";
- }
- std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
- for(i = libs.begin(); i != libs.end(); ++i)
- {
- // add libraries to executables and dlls (but never include
- // a library in a library, bad recursion)
- if (!l->second.IsALibrary() ||
- (m_LibraryBuildType == DLL && l->first.c_str() != *i))
- {
- libOptions += " ";
- libOptions += *i;
- libOptions += ".lib ";
- }
- }
if (l->second.IsALibrary())
{
this->SetBuildType(m_LibraryBuildType, l->first.c_str());
@@ -101,13 +75,11 @@ void cmDSPMakefile::OutputDSPFile()
{
this->SetBuildType(EXECUTABLE,l->first.c_str());
}
- libOptions += "/STACK:10000000 ";
- this->CreateSingleDSP(l->first.c_str(),l->second, libOptions);
+ this->CreateSingleDSP(l->first.c_str(),l->second);
}
}
-void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target,
- const std::string &libOptions)
+void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target)
{
std::string fname;
fname = m_Makefile->GetStartOutputDirectory();
@@ -121,7 +93,7 @@ void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target,
{
cmSystemTools::Error("Error Writing ", fname.c_str());
}
- this->WriteDSPFile(fout,lname,target, libOptions);
+ this->WriteDSPFile(fout,lname,target);
}
void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
@@ -189,11 +161,10 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
const char *libName,
- cmTarget &target,
- const std::string &libOptions)
+ cmTarget &target)
{
// Write the DSP file's header.
- this->WriteDSPHeader(fout, libName, libOptions);
+ this->WriteDSPHeader(fout, libName, target);
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
@@ -405,8 +376,55 @@ void cmDSPMakefile::SetBuildType(BuildType b, const char *libName)
}
void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName,
- const std::string &libOptions)
+ const cmTarget &target)
{
+ // determine the link directories
+ std::string libOptions;
+ std::string libDebugOptions;
+ std::string libOptimizedOptions;
+ std::vector<std::string>::iterator i;
+ std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
+ for(i = libdirs.begin(); i != libdirs.end(); ++i)
+ {
+ libOptions += " /LIBPATH:\"";
+ libOptions += *i;
+ libOptions += "/$(OUTDIR)\" ";
+ libOptions += " /LIBPATH:\"";
+ libOptions += *i;
+ libOptions += "\" ";
+ }
+ // find link libraries
+ cmMakefile::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
+ cmMakefile::LinkLibraries::const_iterator j;
+ for(j = libs.begin(); j != libs.end(); ++j)
+ {
+ // add libraries to executables and dlls (but never include
+ // a library in a library, bad recursion)
+ if (!target.IsALibrary() ||
+ (m_LibraryBuildType == DLL && libName != j->first))
+ {
+ if (j->second == cmMakefile::GENERAL)
+ {
+ libOptions += " ";
+ libOptions += j->first;
+ libOptions += ".lib ";
+ }
+ if (j->second == cmMakefile::DEBUG)
+ {
+ libDebugOptions += " ";
+ libDebugOptions += j->first;
+ libDebugOptions += ".lib ";
+ }
+ if (j->second == cmMakefile::OPTIMIZED)
+ {
+ libOptimizedOptions += " ";
+ libOptimizedOptions += j->first;
+ libOptimizedOptions += ".lib ";
+ }
+ }
+ }
+ libOptions += "/STACK:10000000 ";
+
std::ifstream fin(m_DSPHeaderTemplate.c_str());
if(!fin)
{
@@ -420,6 +438,10 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName,
std::string line = buffer;
cmSystemTools::ReplaceString(line, "CM_LIBRARIES",
libOptions.c_str());
+ cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES",
+ libDebugOptions.c_str());
+ cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES",
+ libOptimizedOptions.c_str());
cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
m_IncludeOptions.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);