CMake

From Second Life Wiki
Revision as of 19:38, 22 December 2008 by Rob Linden (talk | contribs) (Tightened up and clarified)
Jump to navigation Jump to search

This page describes how to build the Second Life viewer with CMake. CMake is a system for generating per-platform build files. 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.

Performing a build with CMake

Set up your environment

The instructions below assume you already have the source code and have set up your build environment. If you haven't done that yet, please see Get source and compile. Per platform instructions are available in these topics:

Configuring your tree

Before you first run a build, you'll need to configure things. There's a develop.py script that will create a reasonably sane default configuration for you.

From the command line, cd into the indra subdirectory and run one of the following commands (depending on your choice of platform and build environment):

  • Windows
    • VisualStudio 2005: "python develop.py -G VC80"
    • VisualStudio 2008: "python develop.py -G VC90"
  • Mac OS X
    • XCode: "./develop.py"
    • make: "./develop.py -G 'Unix Makefiles'"
  • Linux
    • make: "./develop.py"
    • KDevelop: "./develop.py -G KDevelop3"

NOTE: The above commands will configure a "non-standalone" version of the source code tree. This means that the required third party library packages (as built by Linden Lab) will be downloaded during the CMake process.


Finding your build directory

In the CMake world, we keep source and object files separate. The develop.py script will create and populate a build directory for you.

  • Windows - it will be 'build-vc71' (VS 2003) , 'build-vc80' (VS 2005) or 'build-vc90' (VS 2008).
  • Mac OS X - object code location: build-darwin-universal.
  • Linux - this will be named viewer-linux-ARCH-BUILD (where "ARCH" is "i686" or "x86_64", and "BUILD" varies on debug level)

Compiling

Running develop.py does not actually start a build (unless started as "./develop build"). To start a build, find your build directory (see above), change to it, then run make or load it into your IDE, and away you go!

Where's the built viewer?

The location of the newly built viewer depends on your platform.

Windows

On Windows, the built viewer ought to run from VS2005.

Mac OS X

On OS X, your viewer build will be here by default:

build-darwin-universal/newview/RelWithDebInfo/Second Life.app

If you change the kind of build you use, the intermediate directory will also change, e.g. from RelWithDebInfo to Release.

Linux

On Linux, your build will be here:

viewer-linux-ARCH-BUILD/newview/packaged

...where "ARCH" is something like "i686" or "x86_64" (depending on your platform), and "BUILD" depends on which debug level you chose.

Prebuilt libraries vs. standalone builds

While many users will want to use the prebuilt libraries that we provide, we're also interested in making life as easy as possible for packagers who want to use their platform's native libraries.

If you run ccmake, you should see a STANDALONE option that determines whether the build will use your system's libraries or our prepackaged ones. Flipping this to ON should be all you need to do to perform a packager-friendly build.

For standalone builds, we'd really like to beef up the checks for system libraries so that for example cmake will fail if a required library (such as OpenJPEG) isn't installed. We welcome all patches that help out with this.

  • TODO : "How to configure a standalone source code tree." (probably as a link to a new page, as this is a significantly involved task and will break up the flow of this document).
  • cmake-SL: a script for standalone, pre-built and mixed libraries viewer builds under Linux.

What to do if it doesn't work for you

Please also see the (user contributed) instructions at User:Michelle2_Zenovka/cmake