[CMake] Having design issues implementing Xbox360 Generator support

Alexander Neundorf a.neundorf-work at gmx.net
Wed Jan 20 12:22:51 EST 2010


On Wednesday 20 January 2010, David Genest wrote:
> > Ok, so it is definitely cross compiling.
> > In the sense that CMAKE_CROSSCOMPILING needs to be set (which indicates
> > e.g.
> > to TRY_RUN() that it cannot run the executables).
>
> Ok, so can I hard-code this in the generator? Because the only place which

Yes, I think this should be ok. Do it as early as possible.

> I see that the CMAKE_CROSSCOMPILING  variable is set is in the
> CMakeDetermineSystem.cmake file. Paraphrasing comments: This is set only if
> a toolchain set it or that it was specified on the cmake commandline. I
> know I will always be cross-compiling.
>
> > What's the operating system on the XBox ?
>
> It is a derivative of NT. It's programmed almost exactly like windows, with
> specific console APIs.
>
> > In which way do you think doesn't it match the cross compiling
> > philosopy of
> > cmake ?
>
> I was wrong in my understanding. Since the cross compiling was enabled only
> when CMAKE_SYSTEM_NAME is set and in this case (Xbox360) it is still
> "Windows" and the cross compiling is wholly taken in charge by Visual
> Studio, I had the impression that cmake did not have to know about it. But
> as you say, the TRY_RUN() would definitively fail. I may be mistaken, but
> TRY_RUN() is not going to be used a whole lot when building xbox360
> projects.

Well, you never know what will happen :-)

> > Windows-cl.cmake needs to be refactored in order to support cross
> > compiling,
> > XBox, Win CE etc. It will look different afterwards.
>
> Ok. So Windows-cl can be the fallback if other scripts have not set the
> _INIT variables. So I can conclude that a form of IF(NOT VariableSet) SET
> Variable ENDIF() will be needed in this file.

Well, Windows-cl.cmake is executed for the Makefile generators as well as for 
the Visual Studio project generators.
For the Makefile generators MSVC_VERSION is set in this file, for the VS 
generators it is set in the CMakeVS*FindMake.cmake files.

Then there is this part in Windows-cl.cmake:

# default to Debug builds
IF(MSVC_VERSION GREATER 1310)
...set a lot of variables

You probably would have to do something there.
Either you need to detect the architecture of the current compiler (same issue 
as in the bug report ?) and based on that decide what flags to set.
Or maybe also set a variable XBOX360 to TRUE in your generator (but this 
wouldn't be very flexible).

Also I think, it should be possible to set split the Windows (NT) specific cl 
settings and the cl-specific settings into separate files.
This would mean creating MSVC-C/CXX.cmake files in Modules/Compiler/, which 
would set a lot of the variables, and operating system related settings would 
stay in Windows-cl.cmake, like I guess setting stack sizes, setting 
CMAKE_C_STANDARD_LIBRARIES_INIT, setting CMAKE_CREATE_WIN32_EXE and 
CMAKE_CREATE_CONSOLE_EXE.

Maybe you could also create a Modules/WindowsXBox360.cmake file (and set 
CMAKE_SYSTEM_NAME to WindowsXBox360 in your generator). 
This would make some things easier, with the downside that if there are cmake 
scripts check for CMAKE_SYSTEM_NAME STREQUAL Windows they would fail then 
(MATCHES Windows would still work).

Alex


More information about the CMake mailing list