List:Internals« Previous MessageNext Message »
From:Vladislav Vaintroub Date:November 12 2009 7:54pm
Subject:Cross-platform build with CMake
View as plain text  

I have created a WL#5161 with a task dedicated to supporting a unified build
based on CMake ( CMake has been in use for 3 years to
on Windows. 

We have not got yet to leverage its cross-platform capabilities yet, but
there have been some talk about this on this list, (cmake building on Linux or
and here (How to build mysql server in Mac
using xcode?)

I have a tree where the mentioned worklog is done and awaiting reviews. The
tree is 
mirrored on Launchpad
Here, you can build with MySQL with CMake instead of autotools, and do it on
any platform 
MySQL supports.

While the main goal is to have a single system working on any platform,
there are nice
features in CMake that people might find useful, even if they never use
Windows lists a lot many of

Quite important: autotools are not killed  and CMake will peacefully coexist
with autotools at least for some time. Speaking about the _long_ term I do
not see how 
having 2 build systems would simplify development (so if CMake appears to be
good, and 
people will like it my hope is that we can get rid of autotools)

Below are the basic instructions on how to build for the interested (I hope
there are
interested people:) Also look at BUILD-CMAKE in the top-level source
directory of that 

1. Get CMake

Linux : "apt-get install cmake" or equivalents. I recommend to install
cmake-gui too, 
I do not know if every Linux has this, but trying "apt-get install
cmake-gui" would not 
hurt.Windows and Mac: Download from
OpenSolaris : pfexec pkg install SUNWcmake. 

2. branch bzr tree
bzr branch lp:~mysql/mysql-server/mysql-next-mr-cmake

3. Create build directory. We will compile out-of-source, (as recommended by
mkdir build_server
cd build_server

3. Run initial system-checks
cmake ../mysql-next-mr-cmake

4. (Optional) configure build options
- From command line :
cmake . -LH  # lists  options
set options

Note: -D<param>=<value> can be passed already in step 3)

- From GUI with
cmake-gui .
(Select options you want, click on Configure/Generate when ready)

- Using curses interface (*nix)
ccmake .

5.Build, test 
make test-force # this takes a while 

6. Create binary package
make package

7. Create source package (Attention: uses bzr export, so if source is
bzr commit prior to this step)

make dist

That was it. Nothing new, except having an out-of-source build. It becomes
interesting, with IDEs

Mac users could try now:

mkdir ../build_xcode
cd ../build_xcode
cmake -GXcode ../mysql-next-mr-cmake
open MySQL.xcodeproj
("Build and Run" to compile)

This basically concludes the tutorial. 

- For people absolutely new to CMake, 
"How to get started (End-User Perspective)" screencast at
could be 
useful, it demonstrates running CMake build on Linux, Mac and Windows
with and without IDEs. Screencast does not use MySQL for demonstration, but
instructions would be almost the same.

- You can build mysql exactly the same way you did prior, that is

BUILD/ && ./configure  && make

builds with cmake, if cmake is installed. Though, it does not produce Xcode
and does not have out-of-souce build support

- For programmers interested in CMake, "Getting started" pointers. (slides) (FAQ, good)  (official


Cross-platform build with CMakeVladislav Vaintroub12 Nov
  • Re: Cross-platform build with CMakeKristian Nielsen12 Nov
    • Re: Cross-platform build with CMakeReggie Burnett12 Nov
    • Re: Cross-platform build with CMakeSergei Golubchik12 Nov
    • RE: Cross-platform build with CMakeVladislav Vaintroub12 Nov
    • Re: Cross-platform build with CMakeMats Kindahl13 Nov