tags:

views:

175

answers:

2

Hello people!

First of all, I've never developed with Xcode. I have a project that has been developed by me under a certain environment (Linux and emacs) and now some colleagues that use a different environment will work with me. This is a C++ project that uses CMake.

Long story short:

  • I use Linux/emacs. Other developers use mac/Xcode.
  • I use the GNU Makefiles generator. They use Xcode generator.
  • Everything seemed to work ok.

The problem

Xcode developers will use the executable that appears under the Executables list of the Group & Files window of Xcode. They will configure it by double-clicking and add their tweaks (configuring debugging directories, setting environment variables, but more importantly, setting the arguments of the executable).

When a developer (me) changes the CMakeLists.txt (namely to add a new source file), the XCode developers are forced to re-generate their project and they lose all the configuration mentioned above.

Question: Is there a way to avoid this?

If each Xcode developer constantly loses that configuration I would certainly be the only one using CMake. :(

Thanks for your help!

+2  A: 

You can add a target which runs the program by add_custom_target(foobar COMMAND foo --bar DEPENDS foo). You can also call a script instead of the program, where it is easy to set environment variables (I use this setup under Win32 to tweak paths in VC). This script could also be a template in the VCS, so each developer has an own version of the script with the actual command line parameters.

Rudi
I guess this is a valid solution, but in my case not very practical at all :/
YuppieNetworking
+2  A: 

Hi,

I think you are going to lose this one. Xcode stores all the project definitions in a file called Foo.xcodeproj/project.pbxproj. When one of your Mac developers changes a flag or setting, it's recorded in the project.pbxproj file. When you change your CMakeLists.txt file, CMake triggers a rebuild of project.pbxproj, wiping out all the Mac developer's changes. Xcode was not designed with CMake in mind, and they two work only so well together.

One possible solution (which isn't the greatest for the Mac developers) is to use CMake to generate makefiles. They would need to write a few custom commands in Xcode which invoke CMake/Make to build the executables, but they would be able to pass arguments into CMake to control the build process. The executables would be defined separately to Xcode, and CMake would only wipe out the Makefiles. This might be a way to keep everyone happy.

The CMake folks have not given Xcode the attention it deserves, IMHO. But this limitation is inherent in Xcode's architecture, and will be a tough nut.

Hope this helps,
-dan

Edit:

Your Xcode developers have some limited ability to use "User-Defined Settings". I don't know to how to use these (I'm an emacs/make-sort of guy), but perhaps they could use these to override CMake's settings.

Daniel Blezek
i'll try these user-defined settings and get back to you
YuppieNetworking
I've checked but these settings are very limited. I can't even define arguments for the executables :S
YuppieNetworking