[CMake] on cmake supporting one arch per project (from CMake IR)

James Johnston JamesJ at motionview3d.com
Thu Aug 6 12:58:58 EDT 2015


> -----Original Message-----
> From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Greg Marr
> Sent: Wednesday, August 05, 2015 18:42
> To: Raymond Wan; Scott Aron Bloom
> Cc: cmake at cmake.org
> Subject: Re: [CMake] on cmake supporting one arch per project (from
> CMake IR)
>  
> 
> Gilles Khouzam from Microsoft has created an experimental fork, current as
> of 3.2.1, that adds this support.
> https://github.com/Microsoft/CMake/tree/feature/MSMultiPlatform
> 
> Adding experimental MultiPlatform support to CMake for Windows and VS
> 2012 and above.
> 
> By setting the CMAKE_VS_EFFECTIVE_PLATFORMS variable, the user is able
> to specify that multiple platforms should be produced for the same
project.
> 
> The supported platforms are Win32, ARM and x64 (not applicable to
> Windows Phone) and should be specified as a delimited string
> Win32;ARM;x64 for example.

I read this and also glanced through the patch (look for commit ID
065bdceb0fbe5253b229faa843fce6b1c271f047 in his repo).  It feels a little
goofy and too VS-centric to me.

How should existing end-user code like this be handled?

if(MSVC90 AND NOT CMAKE_CL_64)
    # set 32-bit VC2008 flags
    set(CMAKE_CXX_FLAGS <stuff>)
    # snip
elseif(MSVC90 AND CMAKE_CL_64)
    # set some 64-bit VC2008 flags
    set(CMAKE_CXX_FLAGS <stuff>)
    # snip
endif()

Well, it seems like you would need platform-specific CXX_FLAGS variables, in
addition to the configuration-specific CXX_FLAGS variables already offered.
So you'd need a lot new CMake variables for the compiler, linker, etc.
Ideally you'd want to figure out how to do this without completely breaking
every piece of user code that previously ever touched those variables.
While you're at it, you'd want platform-specific variables containing
platform-specific paths to each compiler.  (e.g. path to 32-bit cl.exe, path
to 64-bit cl.exe.)  Of course, that opens the door to mixing VC++ and
non-VC++ compilers in the same CMake project...

Also, the meaning of variables like "MSVC90" or even "CMAKE_CL_64" change:
previously CMAKE_CL_64 meant "building for 64-bit" whereas maybe now it
means "you may or may not be building for 64-bit" ???  What is CMAKE_CL_64
supposed to do if CMAKE_VS_EFFECTIVE_PLATFORMS is set to Win32;x64?

Also, you're still limited to VS generator in his patch, as evidenced by
"VS" in "CMAKE_VS_EFFECTIVE_PLATFORMS".  I guess that's all fine & well as
far as Microsoft's concerned.  What if I want to build multi-platforms with
the Ninja generator?  GNU Make generator?  Multi-platforms on Linux? Mac?
(Personally I dislike the VS generator / MSBuild on Windows for big builds
because the parallelization in MSBuild and cl.exe isn't coordinated, leading
to significant over/under-subscription problems that can be avoided with any
other generator on Windows.)

I'm not making this up, if CMake supported multi-platform building, I would
be needing/wanting to specify multiple platforms for the project I'm working
on right now: (1) VC++ 32-bit, (2) VC++ 64-bit, (3) GCC cross-compiler, (4)
C++ Builder.  Some targets would be built for multiple platforms; others
would be built for only one of those four platforms.  I have annoying
requirements that multi-platform could help with like: the cross-compiler
requires a custom build step/tool that is built using Visual Studio.

Very flexible multi-platform can/should be "easy" for the makefile
generators to handle.  And the VS generator can handle #1 and #2 fine enough
but what if I want it to generate a CMake project containing the GCC/BCC32
targets, for example?  How the heck does that work?  And what if I want
multiple VC++ versions in my platform list - say, VC2008 and VS2013?  (After
all, I could point to differing versions of cl.exe with my platform-specific
COMPILER variables).  Again that's something that multi-platform makefile
generators can/should handle "easily" but what if the VS generator is asked
to generate for VC2008 and VC2013 platforms?  Right now the VS generators
have it easy - they only have one cl.exe version to contend with (and it's
guaranteed to be a cl.exe to begin with).  I guess you could have the
Ninja/makefile generators happily generate true multi-platform stuff while
have the VS generator just croak, but then what if I want to use the VS IDE
for my VC++ targets?

It would be awesome if CMake could support multi-platform - it could really
simplify things for me (as now I am working on a superbuild that iterates
through all the above platforms) - but I'd rather see it in a form that is
baked into the core of CMake, rather than something VS-specific hacked onto
the VS generator that I feel won't interact well with anything non-VS.

Best regards,

James Johnston



More information about the CMake mailing list