[CMake] Using CMake for cross-compîling?

Brad King brad.king at kitware.com
Tue Aug 29 08:52:59 EDT 2006


Eric Noulard wrote:
> Let's say I want to cross-compile my Windows application/library
> on my Linux box using a cross-gcc (like mingw)?
> 
> Is it possible to indicate to CMake that we will use
> a cross compiler?
> 
> In order to avoid (for example) to get a mylib.so file
> if we want a mylib.dll.

You can try editing the Modules/Platform files to adjust the prefixes
and extensions used when computing library names.  Then you just need to
setup the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS variables correctly and make
sure the project doesn't do any TRY_RUNs.  You can specify the actual
compiler by setting the CC and CXX environment variables before running
CMake the first time in a new build tree.

> Does CMake support cross-compiling in any way?

Not officially, but IIRC a few people have gotten it working in some
limited cases.  I don't have any references for you though.

> If not is it planned?

Yes, we plan to separate the notion of host and target platform in order
to support cross compiling.  However this is still a way off in the future.

-Brad


More information about the CMake mailing list