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

I have created a WL#5161 with a task dedicated to supporting a unified build
system 
based on CMake (http://www.cmake.org/). CMake has been in use for 3 years to
compile
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,
http://lists.mysql.com/internals/35894 (cmake building on Linux or
crossplatform)
and here
http://lists.mysql.com/internals/36444 (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
https://code.launchpad.net/~mysql/mysql-server/mysql-next-mr-cmake
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
http://www.cmake.org/Wiki/Really_Cool_CMake_Features lists a lot many of
them.

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 
tree. 

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
http://www.cmake.org/cmake/resources/software.html
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
CMake)
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
cmake . -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 #
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
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
modified, 
bzr commit prior to this step)

make dist

That was it. Nothing new, except having an out-of-source build. It becomes
more 
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 
http://playcontrol.net/ewing/screencasts/getting_started_with_cmake_.html
could be 
useful, it demonstrates running CMake build on Linux, Mac and Windows
side-by-side
with and without IDEs. Screencast does not use MySQL for demonstration, but
the 
instructions would be almost the same.

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

BUILD/autorun.sh && ./configure  && make

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

- For programmers interested in CMake, "Getting started" pointers.

http://www.elpauer.org/stuff/learning_cmake.pdf (slides)
http://www.cmake.org/Wiki/CMake_FAQ (FAQ, good)
http://www.cmake.org/Wiki
http://www.cmake.org/cmake/help/cmake-2-8-docs.html  (official
documentation)

Cheers,
Vladislav 

Thread
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