BUG: Fix issue #7046 - make sure extensionless headers and resource files work with the Xcode generator. Also fix incorrect mappings in the lastKnownFileType code. Add some extensionless files to the Framework test.

This commit is contained in:
David Cole 2008-09-05 15:51:19 -04:00
parent e3dda17db2
commit 58be1b005f
5 changed files with 44 additions and 20 deletions

View File

@ -526,11 +526,13 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
buildFile->AddAttribute("settings", settings); buildFile->AddAttribute("settings", settings);
fileRef->AddAttribute("fileEncoding", this->CreateString("4")); fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
const char* lang = const char* lang =
this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
std::string sourcecode = "sourcecode"; std::string sourcecode = "sourcecode";
std::string ext = sf->GetExtension(); std::string ext = sf->GetExtension();
ext = cmSystemTools::LowerCase(ext); ext = cmSystemTools::LowerCase(ext);
if(ext == "o") if(ext == "o")
{ {
sourcecode = "compiled.mach-o.objfile"; sourcecode = "compiled.mach-o.objfile";
@ -541,41 +543,50 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
} }
else if(ext == "m") else if(ext == "m")
{ {
sourcecode += ".cpp.objc"; sourcecode += ".c.objc";
} }
else if(ext == "plist") else if(ext == "plist")
{ {
sourcecode += ".text.plist"; sourcecode += ".text.plist";
} }
else if(!lang) else if(ext == "h" || ext == "hxx" || ext == "hpp")
{ {
sourcecode += ext; const char* linkLanguage = cmtarget.GetLinkerLanguage(this);
sourcecode += "."; if(linkLanguage && (std::string(linkLanguage) == "CXX"))
sourcecode += ext; {
sourcecode += ".cpp.h";
}
else
{
sourcecode += ".c.h";
}
} }
else if(strcmp(lang, "C") == 0) else if(lang && strcmp(lang, "CXX") == 0)
{
sourcecode += ".c.c";
}
else if(strcmp(lang, "CXX") == 0)
{ {
sourcecode += ".cpp.cpp"; sourcecode += ".cpp.cpp";
} }
else else if(lang && strcmp(lang, "C") == 0)
{ {
sourcecode += ext; sourcecode += ".c.c";
sourcecode += ".";
sourcecode += ext;
} }
//else
// {
// // Already specialized above or we leave sourcecode == "sourcecode"
// // which is probably the most correct choice. Extensionless headers,
// // for example... Or file types unknown to Xcode that do not map to a
// // valid lastKnownFileType value.
// }
fileRef->AddAttribute("lastKnownFileType", fileRef->AddAttribute("lastKnownFileType",
this->CreateString(sourcecode.c_str())); this->CreateString(sourcecode.c_str()));
std::string path =
std::string path =
this->ConvertToRelativeForXCode(sf->GetFullPath().c_str()); this->ConvertToRelativeForXCode(sf->GetFullPath().c_str());
std::string dir; std::string dir;
std::string file; std::string file;
cmSystemTools::SplitProgramPath(sf->GetFullPath().c_str(), cmSystemTools::SplitProgramPath(sf->GetFullPath().c_str(),
dir, file); dir, file);
fileRef->AddAttribute("name", this->CreateString(file.c_str())); fileRef->AddAttribute("name", this->CreateString(file.c_str()));
fileRef->AddAttribute("path", this->CreateString(path.c_str())); fileRef->AddAttribute("path", this->CreateString(path.c_str()));
if(this->XcodeVersion == 15) if(this->XcodeVersion == 15)
@ -590,6 +601,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
{ {
fileRef->AddAttribute("sourceTree", this->CreateString("<absolute>")); fileRef->AddAttribute("sourceTree", this->CreateString("<absolute>"));
} }
return buildFile; return buildFile;
} }
@ -693,7 +705,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
{ {
externalObjFiles.push_back(xsf); externalObjFiles.push_back(xsf);
} }
else if((*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) else if((*i)->GetPropertyAsBool("HEADER_FILE_ONLY") ||
(tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) ||
(tsFlags.Type == cmTarget::SourceFileTypePublicHeader))
{ {
headerFiles.push_back(xsf); headerFiles.push_back(xsf);
} }

View File

@ -5,8 +5,11 @@ add_library(foo SHARED
foo.cxx foo.cxx
foo.h foo.h
foo2.h foo2.h
fooExtensionlessResource
fooPublic.h fooPublic.h
fooPublicExtensionlessHeader
fooPrivate.h fooPrivate.h
fooPrivateExtensionlessHeader
fooNeither.h fooNeither.h
fooBoth.h fooBoth.h
test.lua test.lua
@ -20,9 +23,9 @@ set(foo_ver ver4)
set_target_properties(foo PROPERTIES set_target_properties(foo PROPERTIES
FRAMEWORK TRUE FRAMEWORK TRUE
FRAMEWORK_VERSION ${foo_ver} FRAMEWORK_VERSION ${foo_ver}
PRIVATE_HEADER "fooPrivate.h;fooBoth.h" PRIVATE_HEADER "fooPrivate.h;fooBoth.h;fooPrivateExtensionlessHeader"
PUBLIC_HEADER "foo.h;foo2.h;fooPublic.h;fooBoth.h" PUBLIC_HEADER "foo.h;foo2.h;fooPublic.h;fooBoth.h;fooPublicExtensionlessHeader"
RESOURCE "test.lua" RESOURCE "fooExtensionlessResource;test.lua"
INSTALL_NAME_DIR "@executable_path/../../../Library/Frameworks" INSTALL_NAME_DIR "@executable_path/../../../Library/Frameworks"
DEBUG_POSTFIX -d DEBUG_POSTFIX -d
) )
@ -57,11 +60,15 @@ add_library(fooStatic STATIC
foo.cxx foo.cxx
foo.h foo.h
foo2.h foo2.h
fooExtensionlessResource
fooPublic.h fooPublic.h
fooPublicExtensionlessHeader
fooPrivate.h fooPrivate.h
fooPrivateExtensionlessHeader
fooNeither.h fooNeither.h
fooBoth.h fooBoth.h
test.lua test.lua
fooDeepPublic.h
) )
set_target_properties(fooStatic PROPERTIES set_target_properties(fooStatic PROPERTIES
FRAMEWORK TRUE FRAMEWORK TRUE

View File

@ -0,0 +1 @@
fooExtensionlessResource

View File

@ -0,0 +1 @@
fooPrivateExtensionlessHeader

View File

@ -0,0 +1 @@
fooPublicExtensionlessHeader