[CMake] Performing cross-platform build - how ?

Alexander Neundorf a.neundorf-work at gmx.net
Tue Nov 13 16:55:34 EST 2007


On Tuesday 13 November 2007, Stephen Collyer wrote:
> I am almost a total cmake newbie. I've been looking through
> the wiki for information on how one actually performs a cross-platform
> build with cmake, but I can't find any. Can someone tell me if my
> thinking outline here makes sense:
>
> 1. Let's assume I want to do a Linux and Win32 build from the
> same source tree.
>
> 2. I have a directory tree like:
>
> ./src/<whatever>
> ./build/linux
> ./build/win32
> ./install/linux/<whatever>
> ./install/win32/<whatever>
>
> All of my cross-platform source resides uder src. This whole
> tree, both src and build is mounted so as to be visible to
> my Linux box and Windows machine.
>
> 3. I set up CMakeList.txt files appropriately in . and the
> various subdirs of src
>
> 4. On my Linux box, I cd into build/linux and I type:
>
> cmake ../..
>
> which creates all of the cmake files and directories suitable
> for a Linux build under build/linux. I type
>
> make all
>
> >from the same directory, and everything is built for my Linux
>
> environment under build/linux
>
> 5. On my Windows box, I cd into build/src, and I type the
> same(ish) commands, to have a build made under build/win32.

Yes. But that depends what you want to use for building: MSVC, cl+nmake, 
mingw, ... 

> 6. (Now things get very fuzzy ..) I run some command
> (make install, I guess) which moves my deliverable binaries
> into the install/linux and install/win32 trees, based
> upon some CMakeList.txt configuration I did earlier to
> pick out the stuff I want to deliver

Yes, it's the install target.

> 7. (Things get even fuzzier ..) I run some commands to
> package stuff up from the install trees into .tgz, .rpm
> etc using CPack. I have no idea at the moment how this works.

Build the "packages" target, that should do it.

Alex


More information about the CMake mailing list