[Cmake] Force a generator?

Andy Cedilnik andy.cedilnik at kitware.com
Mon, 26 Apr 2004 14:18:41 -0400


Hi Gordon,

On Mon, 2004-04-26 at 14:04, Schumacher, Gordon wrote:
> Let me clarify a little... I'm using CMake in an unusual circumstance.  Our
> application is
> portable on both multiple hosts *and* targets; we don't support
> "cross-compiling" per se,
> but we do as far as CMake is concerned.  That's because one of our target
> platforms is
> DOS DJGPP, which is 32-bit extended DOS.  I intend to run CMake under
> Windows, using the
> DOS build tools (and, perhaps someday, explicitly call "i386-msdosdjgpp-gcc"
> cross-build
> tools, but that's down the road.)  The point is, even running the native
> DJGPP "gcc" and
> "make", it's still using a Win32 version of CMake... so from CMake's point
> of view, it's
> a cross-build.

That sounds cool. Any issues with that setup?

> So when I'm saying "target platform", I mean "binary target" - not "host
> platform".
> 
> Right now, the way I'm doing this is as follows:
> 
> cmake -G"Unix Makefiles" -DTARGET:STRING=dos32
> or
> cmake -G"Visual Studio 6" -DTARGET:STRING=win32
> 
> It'd be really nice, though, if code like the following worked (though I
> already know that it doesn't):
> IF(TARGET MATCHES dos32)
>    SET(GENERATOR "Unix Makefiles")
> ENDIF(TARGET MATCHES dos32)
> IF(TARGET MATCHES dos32)
>    SET(GENERATOR "Visual Studio 6")
> ENDIF(TARGET MATCHES dos32)

You can sort of do it. It's a hack, but try this. Write this mess into a file let say target_detect.cmake:
IF(TARGET MATCHES dos32)
   SET(GENERATOR "Unix Makefiles")
ENDIF(TARGET MATCHES dos32)
IF(TARGET MATCHES dos32)
  SET(GENERATOR "Visual Studio 6")
ENDIF(TARGET MATCHES dos32)

Then run cmake:

cmake -DTARGET:STRING=dos32 -Ctarget_detect.cmake

Works here...

Otherwise, put feature request for this on the bug tracker.

			Andy