[CMake] working around gcc version bug in xocde generator

Simmons, Aaron asimmons at rosettastone.com
Mon Mar 29 16:12:18 EDT 2010


My project requires using gcc 4.0 when compiling on Mac OS X, as it has to support 10.4.  This works fine for the makefile generator, but it breaks with the XCode generator for Xcode 3.2 as the default gcc is v4.2.

Other posts on this list indicates that it's a bug in the Xcode generator.  I would like to workaround this issue somehow until a new version of cmake is released.

One poster suggested using gcc's -V option, which allows forcing the gcc version.  I've tried injecting this into the CMAKE_CXX_FLAGS like this:
        if (${CMAKE_GENERATOR} MATCHES "Xcode")
            set(CMAKE_CXX_FLAGS "-V 4.0 ${CMAKE_CXX_FLAGS}")
        endif(${CMAKE_GENERATOR} MATCHES "Xcode")

However, this creates a new error:
	'-V' must come at the start of the command line

It seems that the CMAKE_CXX_FLAGS are always appended to the constructed gcc command.  Is there some way that I can prepend flags (that is, put them at the very beginning of the command-line)?


Thanks,
aaron


More information about the CMake mailing list