Difference between revisions of "CMake"

From Second Life Wiki
Jump to navigation Jump to search
(Tightened up and clarified)
m
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page describes how to build the Second Life viewer with [http://cmake.org 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.
CMake is a system for generating per-platform build files.   Visit [http://cmake.org cmake.org] for general information about CMake.  


= Performing a build with CMake =
Linden Lab switched to CMake for building the Second Life viewer (starting with version 1.21); we are currently using version 2.8.10.2


== Set up your environment ==
= Introduction to CMake =


The instructions below assume you already have the source code and have set up your build environmentIf you haven't done that yet, please see [[Get source and compile]]Per platform instructions are available in these topics:
CMake has the advantage of generating per-platform build files for usOn Linux, it will generate Makefiles and KDevelop project filesOn OS X, it will generate Makefiles and Xcode project files.  On Windows, it will generate Makefiles (for nmake) and Visual Studio project files.
* [[Microsoft Windows Builds|Microsoft Windows]]
* [[Compiling the viewer (Mac OS X)|Mac OS X]]
* [[Compiling the viewer (Linux)|Linux]]
* [[Compiling the viewer (FreeBSD)|FreeBSD]]


== Configuring your tree ==
All of the "smarts" stay in the CMake files, so there's just one authoritative source of build knowledgeThis 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.
Before you first run a build, you'll need to configure thingsThere's a <code>develop.py</code> 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):
CMake tells your build system how to rebuild its input files when it detects changes to CMake's configuration files. This means that you only need to run <code>cmake</code> once. After that, <code>make</code> or your IDE should keep the CMake files and its own project files in sync for you.
*'''Windows'''
** VisualStudio 2005: <code>"python develop.py -G VC80"</code>
** VisualStudio 2008: <code>"python develop.py -G VC90"</code>
*'''Mac OS X'''
** XCode: <code>"./develop.py"</code>
** make: <code>"./develop.py -G 'Unix Makefiles'"
*'''Linux'''
** make: <code>"./develop.py"</code>
** KDevelop: <code>"./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.
= Performing a build with CMake =


Our builds are now managed one layer further out then CMake, using [[Autobuild]]; starting there is recommended.


== Finding your build directory ==
Per platform build instructions for CMake-based builds of the Second Life viewer are available for these platforms:
 
* [[Microsoft Windows Builds|Microsoft Windows]]
In the CMake world, we keep source and object files separate.  The <code>develop.py</code> script will create and populate a build directory for you. 
* [[Compiling the viewer (Mac OS X)|Mac OS X]]
 
* [[Compiling the viewer (Linux)|Linux]]
* '''Windows''' - it will be <code>'build-vc71'</code> (VS 2003) , <code>'build-vc80'</code> (VS 2005) or <code>'build-vc90'</code> (VS 2008).
*  '''Mac OS X''' - object code location: <code>build-darwin-universal</code>. 
* '''Linux''' - this will be named <code>viewer-linux-ARCH-BUILD</code> (where "ARCH" is "i686" or "x86_64", and "BUILD" varies on debug level)
 
== Compiling ==
 
Running <code>develop.py</code> 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 <code>make</code> 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:
<pre>
build-darwin-universal/newview/RelWithDebInfo/Second Life.app
</pre>
If you change the kind of build you use, the intermediate directory will also change, e.g. from <code>RelWithDebInfo</code> to <code>Release</code>.
 
=== Linux ===
 
On Linux, your build will be here:
<pre>
viewer-linux-ARCH-BUILD/newview/packaged
</pre>
 
...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 <code>ccmake</code>, you should see a <code>STANDALONE</code> option that determines whether the build will use your system's libraries or our prepackaged ones.  Flipping this to <code>ON</code> 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 <code>cmake</code> will fail if a required library (such as OpenJPEG) isn't installed.  We welcome all patches that help out with this.
= Modifying CMake Files =


*'''''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).
== What to modify ==


* [[Building_the_viewer_with_CMake/cmake-SL_script|cmake-SL]]: a script for standalone, pre-built and mixed libraries viewer builds under Linux.
'''TODO'' - discuss structure of CMake files


* [[Talk:CMake| Compiling standalone builds on Linux Ubuntu]]
= Patching guidelines =


= What to do if it doesn't work for you =
We welcome your patches!  We can't test on every permutation of platform, compiler, IDE, and libraries, so if you have problems that you can fix, please contribute your fixes and we'll do our best to ensure that you only have to fix problems once.


* Ask for help on [[IRC]] (irc.efnet.org #opensl)
If you're sending patches in, please follow a few simple guidelines:
* Find someone on the [[SLDev|SLDev mailing list]]
* Follow the existing coding style in the CMake files. I don't like code shouting at me, so prefer lowercase letters.
* Fix it: [[Modifying CMake Files‎]] (and please, submit a patch!)
* One logical change per patch.
* Use spaces for indentation, not tabs.


Please also see the (user contributed) instructions at [[User:Michelle2_Zenovka/cmake]]
See [[Submitting patches]] for more details.


[[Category:Open Source Portal]]
[[Category:Compiling viewer]]
[[Category:Compiling viewer]]

Latest revision as of 10:35, 13 February 2013

CMake is a system for generating per-platform build files. Visit cmake.org for general information about CMake.

Linden Lab switched to CMake for building the Second Life viewer (starting with version 1.21); we are currently using version 2.8.10.2

Introduction to CMake

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.

CMake tells your build system how to rebuild its input files when it detects changes to CMake's configuration files. This means that you only need to run cmake once. After that, make or your IDE should keep the CMake files and its own project files in sync for you.

Performing a build with CMake

Our builds are now managed one layer further out then CMake, using Autobuild; starting there is recommended.

Per platform build instructions for CMake-based builds of the Second Life viewer are available for these platforms:


Modifying CMake Files

What to modify

'TODO - discuss structure of CMake files

Patching guidelines

We welcome your patches! We can't test on every permutation of platform, compiler, IDE, and libraries, so if you have problems that you can fix, please contribute your fixes and we'll do our best to ensure that you only have to fix problems once.

If you're sending patches in, please follow a few simple guidelines:

  • Follow the existing coding style in the CMake files. I don't like code shouting at me, so prefer lowercase letters.
  • One logical change per patch.
  • Use spaces for indentation, not tabs.

See Submitting patches for more details.