[cmake-developers] Specifying VS target platform

Patrick Gansterer paroga at paroga.com
Fri Sep 14 17:59:40 EDT 2012


Am 14.09.2012 um 14:11 schrieb Brad King:
> On 9/14/2012 6:47 AM, Patrick Gansterer wrote:
>> I've pushed a new version to the ce branch again. Maybe you find time 
>> to give me some feedback. I'll test it in the meantime.
> 
> Great start!
> 
> Good catch on the duplicated local generator implementations.  IIRC
> the methods were originally different but became the same after
> some recent refactoring.  I'm glad to see that enabled even more
> cleanup.

Maybe you can merge the first patch already.

> The idea of a "generator platform" is not generic among all generators.
> Rather than the general CMAKE_GENERATOR_PLATFORM infrastructure I'd
> generator-specific handling.  The value of -GP should be passed to the
> global generator created from -G.  If the generator does not support
> platform specification in this way then -GP should be an error (all
> generators except VS >= 8).  If the generator does support -GP then it
> should do its own thing to save the value.  For VS save it in a cache
> entry like "CMAKE_VS_PLATFORM" (we have "CMAKE_VS_PLATFORM_TOOLSET"
> already for the VS 10 toolchain in some cases).

I'm not a big fan of your ideas: What about the parts where we pass the generator platform to other parts? Do we want to add branches for every generator type to get get correct value for the -GP parameter (e.g. if (CMAKE_GENERATOR == "Visual Studio ...") "-GP ${CMAKE_VS_PLATFORM}")? IMHO that's not a good idea. Also handling for making sure that generator platform isn't changed by the user (like we do for -G already) in a second run of CMake must be duplicated later if we add -GP to more than one generator. (and so on...)

> I realized that existing projects may test ${CMAKE_GENERATOR} to look
> for things like "Win64".  For compatibility we need to make sure that
> 
> -G "Visual Studio 10" -GP x64
> 
> results in CMAKE_GENERATOR being set to
> 
> -G "Visual Studio 10 Win64"
> 
> while processing CMake code even if it is not used that way
> internally.  Of course for future VS versions the generator names
> will not need to work this way, only the existing ones.

Since we need to support -G "Visual Studio 10 Win64" anyway, I don't see much problem if such cases will work with -G "Visual Studio 10 Win64", but not with -G "Visual Studio 10" -GP x64.

> In the compiler id sources, you add this:
> 
> +#ifdef ADD_MAINCRTSTARTUP
> +void mainCRTStartup() {}
> +#endif
> 
> It should be compiled with the actual compiler for the platform.  Is
> there a predefined macro that could be used instead?  Does it have
> to be conditional?  I do not think they would hurt anything on other
> platforms (just use "(void)" instead of "()" in the declaration).

It will work for other platforms, but when compiling with MSVC the linker usually searches for mainCRTStartup(). For the desktop platforms the function is defined in the C runtime, which is linked by default and would result in a duplicated symbol.

> In the "Remove TargetMachine for linker" change does that work for
> VS 10 too?  Currently the change only affects VS 7-9.

Didn't try, but I'll have a look at it.

--Patrick


More information about the cmake-developers mailing list