From 99b3152a60d9049d261da1dc3e70916aae09fa45 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 16 Apr 2003 14:47:44 -0400 Subject: [PATCH] add COdeWarrior back in for testing --- Source/CMakeLists.txt | 9 + Source/cmLocalCodeWarriorGenerator.cxx | 859 +++++++++++++++++++++---- Source/cmLocalCodeWarriorGenerator.h | 7 +- Source/cmake.cxx | 11 + 4 files changed, 762 insertions(+), 124 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 03a4f0554..916093211 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -56,6 +56,15 @@ INCLUDE_DIRECTORIES(${CMake_SOURCE_DIR}/Source) # let cmake know it is supposed to use it ADD_DEFINITIONS(-DCMAKE_BUILD_WITH_CMAKE) +IF (APPLE) + SET(SRCS ${SRCS} + cmGlobalCodeWarriorGenerator.cxx + cmLocalCodeWarriorGenerator.cxx + cmGlobalCodeWarriorGenerator.h + cmLocalCodeWarriorGenerator.h + ) +ENDIF (APPLE) + IF (WIN32) IF(NOT UNIX) SET(SRCS ${SRCS} diff --git a/Source/cmLocalCodeWarriorGenerator.cxx b/Source/cmLocalCodeWarriorGenerator.cxx index f9b406d59..1b1fd740f 100644 --- a/Source/cmLocalCodeWarriorGenerator.cxx +++ b/Source/cmLocalCodeWarriorGenerator.cxx @@ -1,17 +1,17 @@ /*========================================================================= - Program: CMake - Cross-Platform Makefile Generator - Module: $RCSfile$ - Language: C++ - Date: $Date$ - Version: $Revision$ +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. +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. +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" @@ -20,6 +20,7 @@ #include "cmSystemTools.h" #include "cmSourceFile.h" #include "cmCacheManager.h" +#include "cmake.h" cmLocalCodeWarriorGenerator::cmLocalCodeWarriorGenerator() { @@ -37,7 +38,35 @@ 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++) { @@ -71,8 +100,11 @@ void cmLocalCodeWarriorGenerator::AddFileMapping(std::ostream& fout, bool ignored) { fout << "\n"; - fout << "FileType" << ftype << - "\n"; + if( strlen( ftype ) > 0 ) + { + fout << "FileType" << ftype << + "\n"; + } fout << "FileExtension" << ext << "\n"; fout << "Compiler" << comp << @@ -102,11 +134,24 @@ void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout, fout << "InterpretDOSAndUnixPathsfalse\n"; fout << "RequireFrameworkStyleIncludesfalse\n"; - // list the include paths fout << "UserSearchPaths\n"; - std::vector& includes = m_Makefile->GetIncludeDirectories(); - std::vector::iterator i = includes.begin(); - for(;i != includes.end(); ++i) + + // 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"; @@ -118,9 +163,64 @@ void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout, 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"; + } + } + + std::vector& links = l->GetLinkDirectories(); + std::vector::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"; @@ -134,7 +234,7 @@ void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout, fout << "\n"; fout << "\n"; fout << "SearchPath\n"; - fout << "Path:MacOS Support:\n"; + fout << "Path:MacOS X Support:\n"; fout << "PathFormatMacOS\n"; fout << "PathRootCodeWarrior\n"; fout << "\n"; @@ -142,6 +242,46 @@ void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout, 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"; @@ -154,107 +294,247 @@ void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout, fout << "MWRuntimeSettings_EnvVars\n"; // - fout << "LinkerMacOS PPC Linker\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 << "PathFormatMacOS\n"; + fout << "Path\n"; + fout << "PathFormatUnix\n"; fout << "PathRootProject\n"; fout << "\n"; fout << "SaveEntriesUsingRelativePathsfalse\n"; - // add the cxx file type + // add the cxx file type, and others fout << "FileMappings\n"; - this->AddFileMapping(fout,"TEXT",".cxx","MW C/C++ PPC","C/C++", + + 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,"TEXT",".cpp","MW C/C++ PPC","C/C++", + this->AddFileMapping(fout,"",".dylib","MachO Importer","C/C++", false,false,false,false); - this->AddFileMapping(fout,"TEXT",".c","MW C/C++ PPC","C/C++", + this->AddFileMapping(fout,"",".a","MachO Importer","C/C++", false,false,false,false); - this->AddFileMapping(fout,"TEXT",".cc","MW C/C++ PPC","C/C++", + this->AddFileMapping(fout,"",".o","MachO Importer","C/C++", false,false,false,false); - this->AddFileMapping(fout,"TEXT",".cp","MW C/C++ PPC","C/C++", + this->AddFileMapping(fout,"MDYL","","MachO Importer","C/C++", false,false,false,false); - this->AddFileMapping(fout,"TEXT",".cpp","MW C/C++ PPC","C/C++", + this->AddFileMapping(fout,"MLIB","","MachO Importer","C/C++", false,false,false,false); - this->AddFileMapping(fout,"TEXT",".h","MW C/C++ PPC","C/C++", - false,false,false,true); - this->AddFileMapping(fout,"TEXT",".hpp","MW C/C++ PPC","C/C++", - false,false,false,true); - this->AddFileMapping(fout,"TEXT",".m","MW C/C++ PPC","C/C++", + this->AddFileMapping(fout,"MMLB","","MachO Importer","C/C++", false,false,false,false); - this->AddFileMapping(fout,"TEXT",".mm","MW C/C++ PPC","C/C++", + this->AddFileMapping(fout,"MPLF","","MachO Importer","C/C++", false,false,false,false); fout << "\n"; - // - fout << "MWProject_PPC_type"; + // + 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: - fout << "Library" << "\n"; - fout << "MWProject_PPC_outfile"; - fout << tgtName << ".lib"; - fout << "\n"; + 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: - // m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); - fout << "Shared Library" << "\n"; - fout << "MWProject_PPC_outfile"; - fout << tgtName << ".dylib"; - fout << "\n"; + targetOutputType = "MDYL"; + fout << "SharedLibrary"; break; case cmTarget::EXECUTABLE: case cmTarget::WIN32_EXECUTABLE: - fout << "Application" << "\n"; - fout << "MWProject_PPC_outfile"; - fout << tgtName << cmSystemTools::GetExecutableExtension(); - fout << "\n"; + targetOutputType = "APPL"; + fout << "ApplicationPackage"; break; default:; } - - fout << "MWProject_PPC_filecreator????" << "\n"; - fout << "MWProject_PPC_filetypeAPPL\n"; - fout << "MWProject_PPC_size384\n"; - fout << "MWProject_PPC_minsize384\n"; - fout << "MWProject_PPC_stacksize64\n"; - fout << "MWProject_PPC_flags22720\n"; - fout << "MWProject_PPC_symfilename\n"; - fout << "MWProject_PPC_rsrcname\n"; - fout << "MWProject_PPC_rsrcheaderNative\n"; - fout << "MWProject_PPC_rsrctype????" << "\n"; - fout << "MWProject_PPC_rsrcid0\n"; - fout << "MWProject_PPC_rsrcflags0\n"; - fout << "MWProject_PPC_rsrcstore0\n"; - fout << "MWProject_PPC_rsrcmerge0\n"; - fout << "MWProject_PPC_flatrsrc0\n"; - fout << "MWProject_PPC_flatrsrcoutputdir\n"; - fout << "Path:\n"; - fout << "PathFormatMacOS\n"; - fout << "PathRootProject\n"; - fout << "\n"; - fout << "MWProject_PPC_flatrsrcfilename\n"; + fout << "\n"; + fout << "MWProject_MacOSX_outfile"; + fout << m_TargetOutputFiles[std::string(tgtName)]; + fout << "\n"; + fout << "MWProject_MacOSX_filetype"; + fout << targetOutputType << "\n"; - /* - fout << "MWMerge_MacOS_outputCreator????\n"; - fout << "MWMerge_MacOS_outputTypeAPPL\n"; - fout << "MWMerge_MacOS_suppressWarning0\n"; - fout << "MWMerge_MacOS_copyFragments1\n"; - fout << "MWMerge_MacOS_copyResources1\n"; - fout << "MWMerge_MacOS_flattenResource0\n"; - fout << "MWMerge_MacOS_flatFileNamea.rsrc\n"; - fout << "MWMerge_MacOS_flatFileOutputPath\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 << "MWMerge_MacOS_skipResources\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"; } @@ -284,26 +564,115 @@ void cmLocalCodeWarriorGenerator::WriteFileList(std::ostream& fout, } // 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 << "MSL RuntimePPC.Lib\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*/, + const char* tgtName, cmTarget const *l) { fout << "\n"; @@ -324,28 +693,256 @@ void cmLocalCodeWarriorGenerator::WriteLinkOrder(std::ostream& fout, 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 << "MSL RuntimePPC.Lib\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, @@ -369,46 +966,62 @@ void cmLocalCodeWarriorGenerator::WriteGroup(std::ostream& fout, fout << "\n"; } - // write out the libraries groups -/* - - Classic Release - Name - console.stubs.c - MacOS - -*/ - - if (l->GetType() == cmTarget::EXECUTABLE) + // 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) { - fout << "\n"; - fout << "" << tgtName << "\n"; - fout << "Name\n"; - fout << "MSL RuntimePPC.Lib\n"; - fout << "MacOS\n"; - fout << "\n"; + // 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"; + } } - -/* - - Classic Release - Name - MSL C++.PPC.Lib - MacOS - - - Classic Release - Name - MSL C.PPC.Lib - MacOS - - - Carbon Debug - Name - MSL C.CARBON.Lib - MacOS - -*/ fout << "\n"; } diff --git a/Source/cmLocalCodeWarriorGenerator.h b/Source/cmLocalCodeWarriorGenerator.h index cad68dfce..c415bc4ca 100644 --- a/Source/cmLocalCodeWarriorGenerator.h +++ b/Source/cmLocalCodeWarriorGenerator.h @@ -70,7 +70,12 @@ private: const char *ext, const char *comp, const char *edit, bool precomp, bool launch, bool res, bool ignored); - + +private: + // lists the names of the output files of the various targets + std::map m_TargetOutputFiles; + // lists which target first references another target's output + std::map m_TargetReferencingList; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a12ab83b6..4f6eb78a8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -40,6 +40,7 @@ #include #include #include +#include "cmGlobalCodeWarriorGenerator.h" #endif @@ -652,6 +653,9 @@ void cmake::GetRegisteredGenerators(std::vector& names) names.push_back(cmGlobalBorlandMakefileGenerator::GetActualName()); names.push_back(cmGlobalNMakeMakefileGenerator::GetActualName()); #else +#ifdef __APPLE__ + names.push_back(cmGlobalCodeWarriorGenerator::GetActualName()); +#endif names.push_back(cmGlobalUnixMakefileGenerator::GetActualName()); #endif } @@ -681,6 +685,13 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) ret->SetCMakeInstance(this); } #else +#ifdef __APPLE__ + if (!strcmp(name,cmGlobalCodeWarriorGenerator::GetActualName())) + { + ret = new cmGlobalCodeWarriorGenerator; + ret->SetCMakeInstance(this); + } +#endif if (!strcmp(name,cmGlobalUnixMakefileGenerator::GetActualName())) { ret = new cmGlobalUnixMakefileGenerator;