CMake
Building the viewer using CMake
We're experimenting with the possibility of switching to CMake for building the Second Life viewer.
== Why change what we're doing?
Our current build system is unsatisfactory in several respects.
Within Linden Lab, we use different tools on each platform: scons on Linux, Visual Studio 2003 on Windows, and XCode on OS X.
- Any time we add or rename a source file, updating the various build instructions is painful.
- We can't easily stay up to date with newer tools, such as Visual Studio 2005 or 2008.
- Merging changes to the project files used by XCode and Visual Studio is a nightmare.
What does CMake buy us?
CMake has the advantage of generating per-platform build files for us. On Linux, it will generate Makefiles and KDevelop project files. On OS X, it will generate Makefiles and XCode project files. On Windows, it will generate Makefiles (for nmake) and Visual Studio project files.
All of the "smarts" stay in the CMake files, so there's just one authoritative source of build knowledge. This means that people can use the development environment they prefer without having to worry so much about breaking other people's builds. Because CMake files are plain text, merging is easy, as is maintaining experimental patches.
What are the disadvantages of CMake?
The CMake configuration language is weird and ugly.
The documentation is poor. This is a much bigger problem for new projects than ones that already have CMake in place. We've already survived the early "WTF?" stages; it's much easier to hack on existing CMake files than it is to create new ones from scratch.
Experimenting with CMake
First of all, you'll need to download CMake, and install it. On Linux distros, it's usually available as a native package. On Windows and OS X, just use the prebuilt binaries.
These are Linux/Mac instructions. The Windows instructions are presumably similar, except you wave your mouse around instead of running commands.
Check out a copy of the viewer cmake branch:
svn co http://svn.secondlife.com/svn/linden/branches/cmake
Create a build directory:
mkdir mybuild
Go into your build directory, and run cmake
or ccmake
in there, pointing it at the parent directory. If you want to generate a makefile for use by GNU Make, the defaults will work.
cmake ..
If you're on a Mac and want to use XCode, use this command instead.
cmake -G XCode ..
This does not run a build. It just generates the makefiles, project files, or whatever that you'll need. After you're done, you'll have a top-level makefile or project file in your build directory. Run make
or load it into your IDE, and away you go!