/*=========================================================================
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.
=========================================================================*/
#include "cmGlobalCodeWarriorGenerator.h"
#include "cmLocalCodeWarriorGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
#include "cmSourceFile.h"
#include "cmCacheManager.h"
#include "cmake.h"
cmLocalCodeWarriorGenerator::cmLocalCodeWarriorGenerator()
{
}
cmLocalCodeWarriorGenerator::~cmLocalCodeWarriorGenerator()
{
}
void cmLocalCodeWarriorGenerator::Generate(bool /* fromTheTop */)
{
}
void cmLocalCodeWarriorGenerator::WriteTargets(std::ostream& fout)
{
// collect up the output names
// we do this here so any dependencies between targets will work,
// even if they are forward declared in the previous targets
cmTargets &tgts = m_Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
std::string targetOutputName = l->first;
switch (l->second.GetType())
{
case cmTarget::STATIC_LIBRARY:
targetOutputName += ".lib";
break;
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
targetOutputName += ".dylib";
break;
case cmTarget::EXECUTABLE:
case cmTarget::WIN32_EXECUTABLE:
targetOutputName += cmSystemTools::GetExecutableExtension();
break;
default:;
}
m_TargetOutputFiles[l->first] = targetOutputName;
}
// write out the individual targets
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
this->WriteTarget(fout,l->first.c_str(),&(l->second));
}
}
void cmLocalCodeWarriorGenerator::WriteTarget(std::ostream& fout,
const char *tgtName,
cmTarget const *l)
{
fout << "\n";
fout << "" << tgtName << "\n";
this->WriteSettingList(fout, tgtName,l);
this->WriteFileList(fout, tgtName,l);
this->WriteLinkOrder(fout, tgtName, l);
// this->WriteSubTargetList(fout,l);
fout << "\n";
}
void cmLocalCodeWarriorGenerator::AddFileMapping(std::ostream& fout,
const char *ftype,
const char *ext,
const char *comp,
const char *edit,
bool precomp,
bool launch,
bool res,
bool ignored)
{
fout << "\n";
if( strlen( ftype ) > 0 )
{
fout << "FileType" << ftype <<
"\n";
}
fout << "FileExtension" << ext <<
"\n";
fout << "Compiler" << comp <<
"\n";
fout << "EditLanguage" << edit <<
"\n";
fout << "Precompile"
<< (precomp ? "true" : "false") << "\n";
fout << "Launchable"
<< (launch ? "true" : "false") << "\n";
fout << "ResourceFile"
<< (res ? "true" : "false") << "\n";
fout << "IgnoredByMake"
<< (ignored ? "true" : "false") << "\n";
fout << "\n";
}
void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout,
const char *tgtName,
cmTarget const *l)
{
fout << "\n";
fout << "UserSourceTrees\n";
fout << "AlwaysSearchUserPathsfalse\n";
fout << "InterpretDOSAndUnixPathsfalse\n";
fout << "RequireFrameworkStyleIncludesfalse\n";
fout << "UserSearchPaths\n";
// project relative path
fout << "\n";
fout << "SearchPath\n";
fout << "Path:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootProject\n";
fout << "\n";
fout << "Recursivetrue\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
// list the include paths
/* std::vector& includes = l->GetIncludeDirectories();
std::vector::iterator i = includes.begin();
for(;i != includes.end(); ++i)
{
fout << "\n";
fout << "SearchPath\n";
fout << "Path" << i->c_str() << "\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
}*/
// library paths
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
for(; lib != libs.end(); ++lib)
{
// no frameworks!
if( isAframework.find( lib->first.c_str() ) ) continue;
// no environment variables!
if( isEnvironment.find( lib->first.c_str() ) ) continue;
std::string libPath = lib->first + "_CMAKE_PATH";
// is this lib part of this project? Look in the cache
const char* cacheValue
= GetGlobalGenerator()->GetCMakeInstance()
->GetCacheDefinition(libPath.c_str());
if( cacheValue )
{
// just tack it on
fout << "\n";
fout << "SearchPath\n";
fout << "Path" << cacheValue << "\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
}
}
const std::vector& links = l->GetLinkDirectories();
std::vector::const_iterator j = links.begin();
for(;j != links.end(); ++j)
{
fout << "\n";
fout << "SearchPath\n";
fout << "Path" << j->c_str() << "\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
}
fout << "\n";
// system include and library paths
fout << "SystemSearchPaths\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:MSL:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootCodeWarrior\n";
fout << "\n";
fout << "Recursivetrue\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:MacOS X Support:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootCodeWarrior\n";
fout << "\n";
fout << "Recursivetrue\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:usr:include:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootOS X Volume\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:usr:lib:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootOS X Volume\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:System:Library:Frameworks:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootOS X Volume\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathtrue\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:Library:Frameworks:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootOS X Volume\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathtrue\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "MWRuntimeSettings_WorkingDirectory\n";
fout << "MWRuntimeSettings_CommandLine\n";
fout << "MWRuntimeSettings_HostApplication\n";
fout << "Path\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "MWRuntimeSettings_EnvVars\n";
//
if( l->GetType() == cmTarget::SHARED_LIBRARY ||
l->GetType() == cmTarget::MODULE_LIBRARY )
{
fout << "LinkerMach-O PPC Linker\n";
}
else
{
fout << "LinkerMacOS X PPC Linker\n";
}
fout << "PreLinker\n";
fout << "PostLinker\n";
fout << "Targetname" << tgtName
<< "\n";
fout << "OutputDirectory\n";
fout << "Path\n";
fout << "PathFormatUnix\n";
fout << "PathRootProject\n";
fout << "\n";
fout << "SaveEntriesUsingRelativePathsfalse\n";
// add the cxx file type, and others
fout << "FileMappings\n";
if( l->GetType() == cmTarget::SHARED_LIBRARY ||
l->GetType() == cmTarget::MODULE_LIBRARY )
{
this->AddFileMapping(fout,"TEXT",".cxx","MW C/C++ MachPPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cpp","MW C/C++ MachPPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".c","MW C/C++ MachPPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cc","MW C/C++ MachPPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cp","MW C/C++ MachPPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cpp","MW C/C++ MachPPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".h","MW C/C++ MachPPC","C/C++",
false,false,false,true);
this->AddFileMapping(fout,"TEXT",".hpp","MW C/C++ MachPPC","C/C++",
false,false,false,true);
this->AddFileMapping(fout,"TEXT",".m","MW C/C++ MachPPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".mm","MW C/C++ MachPPC","C/C++",
false,false,false,false);
}
else
{
this->AddFileMapping(fout,"TEXT",".cxx","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cpp","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".c","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cc","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cp","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cpp","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".h","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,true);
this->AddFileMapping(fout,"TEXT",".hpp","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,true);
this->AddFileMapping(fout,"TEXT",".m","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".mm","MW C/C++ PPC Mac OS X","C/C++",
false,false,false,false);
}
this->AddFileMapping(fout,"",".lib","MachO Importer","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"",".dylib","MachO Importer","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"",".a","MachO Importer","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"",".o","MachO Importer","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"MDYL","","MachO Importer","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"MLIB","","MachO Importer","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"MMLB","","MachO Importer","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"MPLF","","MachO Importer","C/C++",
false,false,false,false);
fout << "\n";
//
fout << "CacheModDatestrue\n";
fout << "DumpBrowserInfofalse\n";
fout << "CacheSubprojectstrue\n";
fout << "UseThirdPartyDebuggerfalse\n";
fout << "BrowserGenerator1\n";
fout << "DebuggerAppPath\n";
fout << "Path\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "DebuggerCmdLineArgs\n";
fout << "DebuggerWorkingDir\n";
fout << "Path\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "CodeCompletionPrefixFileName"
<< "MacHeadersMach-O.c\n";
fout << "CodeCompletionMacroFileName"
<< "MacOSX_MSL_C++_Macros.h\n";
fout << "MWFrontEnd_C_prefixname"
<< "MSLCarbonPrefix.h";
//
fout << "MWLinker_MacOSX_linksym1\n";
fout << "MWLinker_MacOSX_symfullpath1\n";
fout << "MWLinker_MacOSX_nolinkwarnings0\n";
fout << "MWLinker_MacOSX_linkmap0\n";
fout << "MWLinker_MacOSX_dontdeadstripinitcode0\n";
fout << "MWLinker_MacOSX_permitmultdefs0\n";
fout << "MWLinker_MacOSX_use_objectivec_semantics1\n";
fout << "MWLinker_MacOSX_strip_debug_symbols0\n";
fout << "MWLinker_MacOSX_split_segs0\n";
fout << "MWLinker_MacOSX_report_msl_overloads0\n";
fout << "MWLinker_MacOSX_objects_follow_linkorder0\n";
fout << "MWLinker_MacOSX_linkmodeFast\n";
switch (l->GetType())
{
case cmTarget::STATIC_LIBRARY:
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
fout << "MWLinker_MacOSX_exportsAll\n";
break;
default:
fout << "MWLinker_MacOSX_exportsReferencedGlobals\n";
}
fout << "MWLinker_MacOSX_sortcodeNone\n";
fout << "MWLinker_MacOSX_mainnamestart\n";
//
fout << "MWProject_MacOSX_type";
std::string targetOutputType;
switch (l->GetType())
{
case cmTarget::STATIC_LIBRARY:
targetOutputType = "MMLB";
fout << "Library";
break;
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
targetOutputType = "MDYL";
fout << "SharedLibrary";
break;
case cmTarget::EXECUTABLE:
case cmTarget::WIN32_EXECUTABLE:
targetOutputType = "APPL";
fout << "ApplicationPackage";
break;
default:;
}
fout << "\n";
fout << "MWProject_MacOSX_outfile";
fout << m_TargetOutputFiles[std::string(tgtName)];
fout << "\n";
fout << "MWProject_MacOSX_filetype";
fout << targetOutputType << "\n";
fout << "MWProject_MacOSX_vmaddress0\n";
fout << "MWProject_MacOSX_usedefaultvmaddr1\n";
fout << "MWProject_MacOSX_flatrsrc1\n";
fout << "MWProject_MacOSX_flatrsrcfilename\n";
fout << "MWProject_MacOSX_flatrsrcoutputdir\n";
fout << "Path:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootProject\n";
fout << "\n";
fout << "MWProject_MacOSX_installpath./\n";
fout << "MWProject_MacOSX_dont_prebind0\n";
fout << "MWProject_MacOSX_flat_namespace0\n";
fout << "MWProject_MacOSX_frameworkversionA\n";
fout << "MWProject_MacOSX_currentversion0\n";
fout << "MWProject_MacOSX_flat_oldimpversion0\n";
//
fout << "MWLinker_MachO_exportsAll\n";
fout << "MWLinker_MachO_mainnamestart\n";
fout << "MWLinker_MachO_currentversion0\n";
fout << "MWLinker_MachO_compatibleversion0\n";
fout << "MWLinker_MachO_symfullpath0\n";
fout << "MWLinker_MachO_supresswarnings0\n";
fout << "MWLinker_MachO_multisymerror0\n";
fout << "MWLinker_MachO_prebind1\n";
fout << "MWLinker_MachO_deadstrip1\n";
fout << "MWLinker_MachO_objectivecsemantics0\n";
fout << "MWLinker_MachO_whichfileloaded0\n";
fout << "MWLinker_MachO_whyfileloaded0\n";
fout << "MWLinker_MachO_readonlyrelocsErrors\n";
fout << "MWLinker_MachO_undefinedsymbolsErrors\n";
fout << "MWLinker_MachO_twolevelnamespace1\n";
fout << "MWLinker_MachO_stripdebugsymbols0\n";
//
fout << "MWProject_MachO_type";
switch (l->GetType())
{
case cmTarget::STATIC_LIBRARY:
targetOutputType = "MMLB";
fout << "Library";
break;
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
targetOutputType = "MDYL";
fout << "SharedLibrary";
break;
case cmTarget::EXECUTABLE:
case cmTarget::WIN32_EXECUTABLE:
targetOutputType = "APPL";
fout << "ApplicationPackage";
break;
default:;
}
fout << "\n";
fout << "MWProject_MachO_outfile";
fout << m_TargetOutputFiles[std::string(tgtName)];
fout << "\n";
fout << "MWProject_MachO_filecreator????" << "\n";
fout << "MWProject_MachO_filetype";
fout << targetOutputType;
fout << "\n";
fout << "MWProject_MachO_vmaddress4096\n";
fout << "MWProject_MachO_flatrsrc0\n";
fout << "MWProject_MachO_flatrsrcfilename\n";
fout << "MWProject_MachO_flatrsrcoutputdir\n";
fout << "Path:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootProject\n";
fout << "\n";
fout << "MWProject_MachO_installpath./\n";
fout << "MWProject_MachO_frameworkversion\n";
fout << "\n";
}
void cmLocalCodeWarriorGenerator::WriteFileList(std::ostream& fout,
const char* /*tgtName*/,
cmTarget const *l)
{
fout << "\n";
// for each file
std::vector const& classes = l->GetSourceFiles();
for(std::vector::const_iterator i = classes.begin();
i != classes.end(); i++)
{
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
fout << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
//fout << "common\n";
fout << "" << source << "\n";
fout << "Generic\n";
fout << "Text\n";
fout << "Debug\n";
fout << "\n";
}
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
for(; lib != libs.end(); ++lib)
{
// no frameworks!
if( isAframework.find( lib->first.c_str() ) ) continue;
// no environment variables!
if( isEnvironment.find( lib->first.c_str() ) ) continue;
std::string libPath = lib->first + "_CMAKE_PATH";
// is this lib part of this project? Look in the cache
const char* cacheValue
= GetGlobalGenerator()->GetCMakeInstance()
->GetCacheDefinition(libPath.c_str());
if( cacheValue )
{
// just tack it on
fout << "\n";
fout << "RootRelative\n";
fout << "Project\n";
fout << "" << m_TargetOutputFiles[lib->first] << "\n";
fout << "Unix\n";
fout << "Library\n";
fout << "Debug, TargetOutputFile\n";
fout << "\n";
}
else if( lib->first.find('/') != std::string::npos )
{
// it's a path-based library, so we'll include it directly by path
fout << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
fout << "" << lib->first.c_str() << "\n";
fout << "Unix\n";
fout << "Text\n";
fout << "Debug\n";
fout << "\n";
}
else if( isUNIX.find( lib->first.c_str() ) )
{
// now we need to search the library directories for this
// library name, and if we don't find it, we have to search
// in the cache to see if there's a target defining that lib.
// for the first search, we have to check for
// [lib][.]
std::string libName = isUNIX.match(1);
}
else
{
// just tack it on
fout << "\n";
fout << "Name\n";
fout << "" << lib->first.c_str() << "\n";
fout << "Unix\n";
fout << "Library\n";
fout << "Debug\n";
fout << "\n";
}
}
// now add in the system libs (for an executable)
if (l->GetType() == cmTarget::EXECUTABLE)
{
fout << "\n";
fout << "Name\n";
fout << "crt1.o\n";
fout << "MacOS\n";
fout << "Library\n";
fout << "Debug\n";
fout << "\n";
fout << "\n";
fout << "Name\n";
fout << "MSL_All_Mach-O.lib\n";
fout << "Unix\n";
fout << "Library\n";
fout << "Debug\n";
fout << "\n";
fout << "\n";
fout << "Name\n";
fout << "console_OS_X.c\n";
fout << "Unix\n";
fout << "Text\n";
fout << "Debug\n";
fout << "\n";
}
// or a dynamic library
/* else if (l->GetType() == cmTarget::SHARED_LIBRARY ||
l->GetType() == cmTarget::MODULE_LIBRARY)
{
fout << "\n";
fout << "Name\n";
fout << "dylib1.o\n";
fout << "MacOS\n";
fout << "Library\n";
fout << "Debug\n";
fout << "\n";
}*/
fout << "\n";
}
void cmLocalCodeWarriorGenerator::WriteLinkOrder(std::ostream& fout,
const char* tgtName,
cmTarget const *l)
{
fout << "\n";
// for each file
std::vector const& classes = l->GetSourceFiles();
for(std::vector::const_iterator i = classes.begin();
i != classes.end(); i++)
{
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
fout << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
//fout << "common\n";
fout << "" << source << "\n";
fout << "Generic\n";
fout << "\n";
}
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
std::map referencedTargets;
for(; lib != libs.end(); ++lib)
{
// no frameworks!
if( isAframework.find( lib->first.c_str() ) ) continue;
// no environment variables!
if( isEnvironment.find( lib->first.c_str() ) ) continue;
std::string libPath = lib->first + "_CMAKE_PATH";
// is this lib part of this project? Look in the cache
const char* cacheValue
= GetGlobalGenerator()->GetCMakeInstance()
->GetCacheDefinition(libPath.c_str());
if( cacheValue )
{
// just tack it on
fout << "\n";
fout << "RootRelative\n";
fout << "Project\n";
fout << "" << m_TargetOutputFiles[lib->first] << "\n";
fout << "Unix\n";
fout << "\n";
referencedTargets[lib->first] = m_TargetOutputFiles[lib->first];
if( m_TargetReferencingList.count(m_TargetOutputFiles[lib->first]) == 0 )
{
m_TargetReferencingList[m_TargetOutputFiles[lib->first]] = std::string(tgtName);
}
}
else if( lib->first.find('/') != std::string::npos )
{
// it's a path-based library, so we'll include it directly by path
fout << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
fout << "" << lib->first.c_str() << "\n";
fout << "Unix\n";
fout << "\n";
}
else if( isUNIX.find( lib->first.c_str() ) )
{
// now we need to search the library directories for this
// library name, and if we don't find it, we have to search
// in the cache to see if there's a target defining that lib.
// for the first search, we have to check for
// [lib][.]
std::string libName = isUNIX.match(1);
}
else
{
// just tack it on
fout << "\n";
fout << "Name\n";
fout << "" << lib->first.c_str() << "\n";
fout << "Unix\n";
fout << "\n";
}
}
// now add in the system libs (for an executable)
if (l->GetType() == cmTarget::EXECUTABLE)
{
fout << "\n";
fout << "Name\n";
fout << "crt1.o\n";
fout << "MacOS\n";
fout << "\n";
fout << "\n";
fout << "Name\n";
fout << "MSL_All_Mach-O.lib\n";
fout << "Unix\n";
fout << "\n";
fout << "\n";
fout << "Name\n";
fout << "console_OS_X.c\n";
fout << "Unix\n";
fout << "\n";
}
// or a shared library
/* else if (l->GetType() == cmTarget::SHARED_LIBRARY ||
l->GetType() == cmTarget::MODULE_LIBRARY)
{
fout << "\n";
fout << "Name\n";
fout << "dylib1.o\n";
fout << "MacOS\n";
fout << "\n";
}*/
fout << "\n";
if( referencedTargets.size() )
{
fout << "\n";
// output subtarget list
std::map::const_iterator target = referencedTargets.begin();
for( ; target != referencedTargets.end(); target++ )
{
fout << "\n";
fout << "" << target->first << "\n";
fout << "LinkAgainst\n";
fout << "\nRootRelative\n"
<< "Project\n"
<< "" << target->second << "\n"
<< "Unix\n";
fout << "\n";
}
fout << "\n";
}
// we need at least one framework for the XML to be valid
// generate framework list
cmRegularExpression reg("[ \t]*\\-framework[ \t]+([^ \t]+)");
std::vector frameworks;
lib = libs.begin();
for(; lib != libs.end(); ++lib)
{
if( reg.find( lib->first.c_str() ) )
{
frameworks.push_back( reg.match(1) );
}
}
if( frameworks.size() > 0 || l->GetType() == cmTarget::EXECUTABLE )
{
fout << "\n";
std::vector::const_iterator framework = frameworks.begin();
for(; framework != frameworks.end(); ++framework)
{
fout << "\n";
fout << "\n";
fout << "Name\n";
fout << "" << framework->c_str() << ".framework\n";
fout << "MacOS\n";
fout << "\n";
// this isn't strictly always true, I believe, but Apple adheres to it
fout << "" << framework->c_str() << "\n";
fout << "\n";
}
// if it's an executable, it needs to link into System.framework
if (l->GetType() == cmTarget::EXECUTABLE)
{
fout << "\n";
fout << "\n";
fout << "Name\n";
fout << "System.framework\n";
fout << "MacOS\n";
fout << "\n";
fout << "System\n";
fout << "\n";
}
fout << "\n";
}
}
void cmLocalCodeWarriorGenerator::WriteGroups(std::ostream& fout)
{
bool hasExecutableTarget = false, hasDynamicLibTarget = false;
char *firstExecutableTarget = 0, *firstDynamicLibTarget = 0;
cmTargets &tgts = m_Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
this->WriteGroup(fout,l->first.c_str(),&(l->second));
if (l->second.GetType() == cmTarget::EXECUTABLE)
{
hasExecutableTarget = true;
if (firstExecutableTarget == 0)
{
firstExecutableTarget = const_cast(l->first.c_str());
}
}
else if (l->second.GetType() == cmTarget::SHARED_LIBRARY ||
l->second.GetType() == cmTarget::MODULE_LIBRARY)
{
hasDynamicLibTarget = true;
if (firstDynamicLibTarget == 0)
{
firstDynamicLibTarget = const_cast(l->first.c_str());
}
}
}
// write out the libraries groups
if( hasExecutableTarget )
{
fout << "" << "App Support" << "\n";
fout << "\n";
fout << "" << firstExecutableTarget << "\n";
fout << "Name\n";
fout << "crt1.o\n";
fout << "MacOS\n";
fout << "\n";
fout << "\n";
fout << "" << firstExecutableTarget << "\n";
fout << "Name\n";
fout << "MSL_All_Mach-O.lib\n";
fout << "Unix\n";
fout << "\n";
fout << "\n";
fout << "" << firstExecutableTarget << "\n";
fout << "Name\n";
fout << "console_OS_X.c\n";
fout << "Unix\n";
fout << "\n";
fout << "\n";
}
/* if (hasDynamicLibTarget)
{
fout << "" << "dylib Support" << "\n";
fout << "\n";
fout << "" << firstDynamicLibTarget << "\n";
fout << "Name\n";
fout << "dylib1.o\n";
fout << "MacOS\n";
fout << "\n";
fout << "\n";
}*/
// write out the referenced targets group
if( m_TargetReferencingList.size() > 0 )
{
fout << "Subtarget Files\n";
std::map::const_iterator subtarget = m_TargetReferencingList.begin();
for( ; subtarget != m_TargetReferencingList.end(); subtarget++ )
{
fout << "\n"
<< "" << subtarget->second << "\n";
fout << "RootRelative\nProject\n";
fout << "" << subtarget->first << "\n";
fout << "Unix\n";
fout << "";
}
fout << "";
}
}
void cmLocalCodeWarriorGenerator::WriteGroup(std::ostream& fout,
const char *tgtName,
cmTarget const *l)
{
fout << "" << tgtName << "\n";
// for each file
std::vector const& classes = l->GetSourceFiles();
for(std::vector::const_iterator i = classes.begin();
i != classes.end(); i++)
{
std::string source = (*i)->GetFullPath();
fout << "\n";
fout << "" << tgtName << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
fout << "" << source << "\n";
fout << "Generic\n";
fout << "\n";
}
// now add in the libraries we depend on
cmRegularExpression isAframework("[ \t]*\\-framework");
cmRegularExpression isEnvironment("\\${");
cmRegularExpression isUNIX("[ \t]*\\-l([^ \t]+)");
const cmTarget::LinkLibraries& libs = l->GetLinkLibraries();
cmTarget::LinkLibraries::const_iterator lib = libs.begin();
for(; lib != libs.end(); ++lib)
{
// no frameworks!
if( isAframework.find( lib->first.c_str() ) ) continue;
// no environment variables!
if( isEnvironment.find( lib->first.c_str() ) ) continue;
std::string libPath = lib->first + "_CMAKE_PATH";
// is this lib part of this project? Look in the cache
const char* cacheValue
= GetGlobalGenerator()->GetCMakeInstance()
->GetCacheDefinition(libPath.c_str());
if( cacheValue )
{
// this is a subtarget reference, it will be taken care of later
continue;
}
else if( lib->first.find('/') != std::string::npos )
{
// it's a path-based library, so we'll include it directly by path
fout << "\n";
fout << "" << tgtName << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
fout << "" << lib->first.c_str() << "\n";
fout << "Unix\n";
fout << "\n";
}
else if( isUNIX.find( lib->first.c_str() ) )
{
// now we need to search the library directories for this
// library name, and if we don't find it, we have to search
// in the cache to see if there's a target defining that lib.
// for the first search, we have to check for
// [lib][.]
std::string libName = isUNIX.match(1);
}
else
{
// just tack it on
fout << "\n";
fout << "" << tgtName << "\n";
fout << "Name\n";
fout << "" << lib->first.c_str() << "\n";
fout << "Unix\n";
fout << "\n";
}
}
fout << "\n";
}