BUG: Do not automatically set HEADER_FILE_ONLY

Long ago the native build system generators needed HEADER_FILE_ONLY to
be set on header files to stop them from building.  The modern
generators correctly handle headers without the help of this property.
This removes automatic setting of the property so that it can be used
reliably as an indicator of project author intention.  It fixes VS IDE
project files to show header files normally instead of excluded (broken
by the fix for issue #7845).
This commit is contained in:
Brad King 2009-03-16 14:30:24 -04:00
parent 147d6f3101
commit 921f3a1ac2
4 changed files with 17 additions and 37 deletions

View File

@ -706,10 +706,6 @@ void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
headerExts.push_back(headerExtensions[i]);
}
// Implement the old SetName method code here.
sf->Properties.SetProperty("HEADER_FILE_ONLY", "1",
cmProperty::SOURCE_FILE);
// Save the original name given.
sf->SourceName = name;
@ -742,13 +738,6 @@ void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
}
}
// See if the file is a header file
if(std::find( headerExts.begin(), headerExts.end(),
sf->SourceExtension ) == headerExts.end())
{
sf->Properties.SetProperty("HEADER_FILE_ONLY", "0",
cmProperty::SOURCE_FILE);
}
sf->FullPath = hname;
return;
}
@ -763,8 +752,6 @@ void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
if(cmSystemTools::FileExists(hname.c_str()))
{
sf->SourceExtension = *ext;
sf->Properties.SetProperty("HEADER_FILE_ONLY", "0",
cmProperty::SOURCE_FILE);
sf->FullPath = hname;
return;
}
@ -814,9 +801,11 @@ void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir,
}
// Implement the old SetName method code here.
sf->Properties.SetProperty("HEADER_FILE_ONLY",
headerFileOnly? "1" : "0",
cmProperty::SOURCE_FILE);
if(headerFileOnly)
{
sf->Properties.SetProperty("HEADER_FILE_ONLY", "1",
cmProperty::SOURCE_FILE);
}
sf->SourceName = name;
std::string fname = sf->SourceName;
if(ext && strlen(ext))

View File

@ -732,7 +732,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
{
externalObjFiles.push_back(xsf);
}
else if((*i)->GetPropertyAsBool("HEADER_FILE_ONLY") ||
else if(this->IsHeaderFile(*i) ||
(tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) ||
(tsFlags.Type == cmTarget::SourceFileTypePublicHeader))
{
@ -742,7 +742,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
{
resourceFiles.push_back(xsf);
}
else
else if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY"))
{
// Include this file in the build if it has a known language
// and has not been listed as an ignored extension for this
@ -911,6 +911,15 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
}
}
//----------------------------------------------------------------------------
bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
{
const std::vector<std::string>& hdrExts =
this->CurrentMakefile->GetHeaderExtensions();
return (std::find(hdrExts.begin(), hdrExts.end(), sf->GetExtension()) !=
hdrExts.end());
}
//----------------------------------------------------------------------------
cmXCodeObject*
cmGlobalXCodeGenerator::CreateBuildPhase(const char* name,

View File

@ -159,6 +159,7 @@ private:
cmTarget& cmtarget);
void CreateXCodeTargets(cmLocalGenerator* gen,
std::vector<cmXCodeObject*>&);
bool IsHeaderFile(cmSourceFile*);
void AddDependTarget(cmXCodeObject* target,
cmXCodeObject* dependTarget);
void CreateXCodeDependHackTarget(std::vector<cmXCodeObject*>& targets);

View File

@ -246,25 +246,6 @@ void cmSourceFile::CheckExtension()
this->SetProperty("EXTERNAL_OBJECT", "1");
}
// Look for header files.
cmMakefile* mf = this->Location.GetMakefile();
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
if(std::find(hdrExts.begin(), hdrExts.end(), this->Extension) ==
hdrExts.end())
{
// This is not a known header file extension. Mark it as not a
// header unless the user has already explicitly set the property.
if(!this->GetProperty("HEADER_FILE_ONLY"))
{
this->SetProperty("HEADER_FILE_ONLY", "0");
}
}
else
{
// This is a known header file extension. The source cannot be compiled.
this->SetProperty("HEADER_FILE_ONLY", "1");
}
// Try to identify the source file language from the extension.
if(this->Language.empty())
{