Ticket #1148 (closed defect: fixed)

Opened 16 months ago

Last modified 15 months ago

Problem building Objective-C/C++ with Premake

Reported by: historic_bruno Owned by: ben
Priority: Should Have Milestone: Alpha 9
Component: Build & Packages Keywords: osx,objectivec,pch
Cc: Yves

Description (last modified by historic_bruno) (diff)

While working on #1145, I noticed there are problems building Objective-C/C++ code, used for the Cocoa API on OS X. Until now this hasn't been a problem, but I do need to write some Obj-C to solve that ticket. Premake supports Obj-C source files (*.m, *.mm) and GCC is capable of compiling them, so I think the problem is how we're using Premake.

The first issue is *.m and *.mm files are not being picked up when Premake searches for files to include in the project. That doesn't seem too difficult to fix, I just modified one line of premake4.lua. The other problem is that the C++ precompiled headers are automatically getting included in the Objective-C source, which is bad, many of the libraries can't be compiled in Obj-C and we don't need them, so we shouldn't even try that. I don't think we'll have enough Obj-C code that we'll need precompiled headers just for them, so maybe we can leave PCH out entirely for Obj-C source files?

I manually edited the Makefile and removed the PCH bits for my one Obj-C source file, everything compiled and ran fine, so we're tantalizingly close to supporting this :)

Change History

comment:1 Changed 16 months ago by historic_bruno

  • Description modified (diff)

Oops, ignore the bit about PCH, I just renamed my .m file to .mm and it gets detected as Objective-C++ and compiles fine (also fixes the warnings about certain flags being C++ specific). So just the trivial change is left, I'll commit it soon :)

comment:2 Changed 16 months ago by ben

  • Owner set to ben
  • Status changed from new to closed
  • Resolution set to fixed

In [11013]:

Includes Objective-C++ (*.mm) files in Premake generated projects. Premake and GCC handle the rest. Fixes #1148.

comment:3 Changed 16 months ago by historic_bruno

  • Milestone changed from Backlog to Alpha 9

comment:4 Changed 15 months ago by ben

In 11259:

Removes Makefile PCH support for Obj-C/C++ source files. Apple's latest command line tools encountered an error because the source file was compiled with Obj-C++ but the PCH was compiled with C++. If we really needed PCH for Obj-C++ we could simply compile it separately for each language. Refs #1148.

Note: See TracTickets for help on using tickets.