Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1148 closed defect (fixed)

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 Patch:

Description (last modified by historic_bruno)

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 (4)

comment:1 by historic_bruno, 12 years ago

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 by ben, 12 years ago

Owner: set to ben
Resolution: fixed
Status: newclosed

In [11013]:

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

comment:3 by historic_bruno, 12 years ago

Milestone: BacklogAlpha 9

comment:4 by ben, 12 years ago

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.