So there are two easily surmountable issues to get a clean gtest build in XCode 4.6:
- Google no longer gives first rate support for the xcode and visual studio metadata files (preferring a tool called CMake instead)
- XCode doesn't like a particular compiler flag on one of its targets.
So, as before, we modify gtest/xcode/Config/General.xconfig to make it current-compatible:
I then recommend you open the xcode "project" from gtest/xcode/gtest.xcodeproj. Repeated attempts at Command-B, Command-Shift-K (build, clean, build, ...) will turn up errors and warnings that make you turn your SDKROOT to OS X 10.8 and your GCC_VERSION TO Default Compiler (Apple LLVM compiler 4.2) under Build Settings for the collection of targets. (You may of course choose just Apple LLVM compiler 4.2 for identical effect.)
There's a tricky hidden setting for the gtest_unittest-framework, gtest_unittest-static, sample1_unittest-framework, and sample1_unittest-static targets that should be set with LD_NO_PIE = Yes:
If you get an error including the words “lexical or preprocessor issue”, restart xcode. After I restarted, the issue went away, and then I was offered a dialog that would automagically perform a number of build settings changes, which I gladly chose to accept.
When all is said and done, you should get a similar output dialog if you run any of the targets:
FTM!
At Blue Pearl Software, we use CMake to generate the solution/project files for Visual Studio and the makefiles for Linux. Gtest fit right in to our existing CMake-based build system, with a few tweaks to the settings.
ReplyDeleteCMake has a (possibly user-supported) Xcode generator as well. Perhaps the best long-term solution for use with Xcode would be to transition to using CMake as your primary build source, and let it generate the necessary Xcode files? (Although there is a learning curve with CMake - not everything in it is well-documented, and it sometimes takes a bunch of looking at existing macro files to figure out the best way to do something).
I think I may give that a try as well. (It is recommended in the README after all.) Looks like there's a Jenkins plugin as well.
Delete