[Cmake-commits] [cmake-commits] king committed cmSourceFile.cxx 1.50 1.51 cmSourceFile.h 1.25 1.26
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Apr 29 14:17:44 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv26757/Source
Modified Files:
cmSourceFile.cxx cmSourceFile.h
Log Message:
ENH: In cmSourceFile::GetLanguage use the file extension (if not ambiguous) to determine the language without requiring the source file to exist.
Index: cmSourceFile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.cxx,v
retrieving revision 1.50
retrieving revision 1.51
diff -C 2 -d -r1.50 -r1.51
*** cmSourceFile.cxx 29 Apr 2008 18:17:35 -0000 1.50
--- cmSourceFile.cxx 29 Apr 2008 18:17:42 -0000 1.51
***************
*** 47,54 ****
const char* cmSourceFile::GetLanguage()
{
! // Compute the final location of the file if necessary.
! if(this->FullPath.empty())
{
! this->GetFullPath();
}
--- 47,72 ----
const char* cmSourceFile::GetLanguage()
{
! // If the language was set explicitly by the user then use it.
! if(const char* lang = this->GetProperty("LANGUAGE"))
{
! return lang;
! }
!
! // Perform computation needed to get the language if necessary.
! if(this->FullPath.empty() && this->Language.empty())
! {
! if(this->Location.ExtensionIsAmbiguous())
! {
! // Finalize the file location to get the extension and set the
! // language.
! this->GetFullPath();
! }
! else
! {
! // Use the known extension to get the language if possible.
! std::string ext =
! cmSystemTools::GetFilenameLastExtension(this->Location.GetName());
! this->CheckLanguage(ext);
! }
}
***************
*** 253,258 ****
// Try to identify the source file language from the extension.
cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
! if(const char* l = gg->GetLanguageFromExtension(this->Extension.c_str()))
{
this->Language = l;
--- 271,287 ----
// Try to identify the source file language from the extension.
+ if(this->Language.empty())
+ {
+ this->CheckLanguage(this->Extension);
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ void cmSourceFile::CheckLanguage(std::string const& ext)
+ {
+ // Try to identify the source file language from the extension.
+ cmMakefile* mf = this->Location.GetMakefile();
cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
! if(const char* l = gg->GetLanguageFromExtension(ext.c_str()))
{
this->Language = l;
Index: cmSourceFile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -C 2 -d -r1.25 -r1.26
*** cmSourceFile.h 30 Jan 2008 16:21:54 -0000 1.25
--- cmSourceFile.h 29 Apr 2008 18:17:42 -0000 1.26
***************
*** 117,120 ****
--- 117,121 ----
bool TryFullPath(const char* tryPath, const char* ext);
void CheckExtension();
+ void CheckLanguage(std::string const& ext);
std::vector<std::string> Depends;
More information about the Cmake-commits
mailing list