MantisBT - CMake
View Issue Details
0013472CMakeCMakepublic2012-08-15 09:122013-01-09 14:05
Tobias Pape 
Brad King 
normalmajoralways
closedfixed 
i386OS X10.7
CMake 2.8.8 
CMake 2.8.10CMake 2.8.10 
0013472: Xcode: Assembly files do not get recognized correctly
On OS X using Xcode generator and enabled ASM language,
assembler files, such as *.s, *.S do not get compiled correctly.
A PRE_BUILD add_custom_command build step helps but is very cumbersome.

Here is a valid fix for cmake:
in cmGlobalXCodeGenerator.cxx there should be:


std::string
GetSourcecodeValueFromFileExtension(const std::string& _ext,
                                    const std::string& lang)
{
  std::string ext = cmSystemTools::LowerCase(_ext);
  std::string sourcecode = "sourcecode";

  if(ext == "o")
    {
    sourcecode = "compiled.mach-o.objfile";
    }
  else if(ext == "xib")
    {
    sourcecode = "file.xib";
    }
  else if(ext == "storyboard")
    {
    sourcecode = "file.storyboard";
    }
  else if(ext == "mm")
    {
    sourcecode += ".cpp.objcpp";
    }
  else if(ext == "m")
    {
    sourcecode += ".c.objc";
    }
  else if(ext == "xib")
    {
    sourcecode += ".file.xib";
    }
  else if(ext == "plist")
    {
    sourcecode += ".text.plist";
    }
  else if(ext == "h")
    {
    sourcecode += ".c.h";
    }
  else if(ext == "hxx" || ext == "hpp" || ext == "txx"
    || ext == "pch" || ext == "hh")
    {
    sourcecode += ".cpp.h";
    }
  else if(ext == "png" || ext == "gif" || ext == "jpg")
    {
    sourcecode = "image";
    }
  else if(ext == "txt")
    {
    sourcecode += ".text";
    }
  else if(lang == "CXX")
    {
    sourcecode += ".cpp.cpp";
    }
  else if(lang == "C")
    {
    sourcecode += ".c.c";
    }
  else if(lang == "ASM" || ext == "S" || ext == "s")
    {
    sourcecode += ".asm";
    }
  else if(lang == "Fortran")
    {
    sourcecode += ".fortran.f90";
    }
  //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.
  // }

  return sourcecode;
}
A different Fix would be to allow overriding the Source-code type via CMake code
akin to the XCODE_ATTRIBUTE_* properties that can be set on targets.

I would propose XCODE_ATTRIBUTE_FILE_TYPE.

Note that compiling assembly using the Makefile generator just works fine.
No tags attached.
Issue History
2012-08-15 09:12Tobias PapeNew Issue
2012-08-15 09:49Brad KingNote Added: 0030667
2012-08-15 09:51Brad KingSummaryAssembly files do not get recognized correctly => Xcode: Assembly files do not get recognized correctly
2012-08-15 09:52Tobias PapeNote Added: 0030669
2012-08-15 11:37Brad KingNote Added: 0030672
2012-08-15 11:37Brad KingAssigned To => Brad King
2012-08-15 11:37Brad KingStatusnew => resolved
2012-08-15 11:37Brad KingResolutionopen => fixed
2012-08-15 11:37Brad KingFixed in Version => CMake 2.8.10
2012-08-15 11:37Brad KingTarget Version => CMake 2.8.10
2013-01-09 14:05Robert MaynardNote Added: 0032068
2013-01-09 14:05Robert MaynardStatusresolved => closed

Notes
(0030667)
Brad King   
2012-08-15 09:49   
Is this enough without the extensions?
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index ae92a0a..e8ab38f 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -787,6 +787,10 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext,
     {
     sourcecode += ".fortran.f90";
     }
+  else if(lang == "ASM")
+    {
+    sourcecode += ".asm";
+    }
   //else
   //  {
   //  // Already specialized above or we leave sourcecode == "sourcecode"


The extensions listed here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeASMInformation.cmake;hb=v2.8.9#l53 [^]

should tell CMake to recognize the language and set it to ASM.
(0030669)
Tobias Pape   
2012-08-15 09:52   
Yes, this should suffice.
(0030672)
Brad King   
2012-08-15 11:37   
Applied, thanks:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f3477ed8 [^]
(0032068)
Robert Maynard   
2013-01-09 14:05   
Closing resolved issues that have not been updated in more than 4 months.