diff options
author | Brad King <brad.king@kitware.com> | 2009-03-16 18:30:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-03-16 18:30:24 (GMT) |
commit | 921f3a1ac233c121b8cf7cbf896bc4c88717c9a8 (patch) | |
tree | a4b5f4f972ce69a87d7433466562852d372b59b1 /Source | |
parent | 147d6f31015a64b3ec1b3799d4c0047942b27999 (diff) | |
download | CMake-921f3a1ac233c121b8cf7cbf896bc4c88717c9a8.zip CMake-921f3a1ac233c121b8cf7cbf896bc4c88717c9a8.tar.gz CMake-921f3a1ac233c121b8cf7cbf896bc4c88717c9a8.tar.bz2 |
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).
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCPluginAPI.cxx | 21 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmSourceFile.cxx | 19 |
4 files changed, 17 insertions, 37 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 04257cb..d94cf3e 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -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)) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index db1d78f..3fd14a9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -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 @@ -912,6 +912,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, const char* name2, diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 6e85a69..7a7bb00 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -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); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 6fe1024..8603d98 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -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()) { |