Building using CMake: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (added category)
m (cmake option-source order altered)
Line 55: Line 55:


     cmake ../flightgear
     cmake ../flightgear
   
 
To generate standard Unix Makefiles in fgbuild.
To generate standard Unix Makefiles in fgbuild.


Line 62: Line 62:
Probably you want to specify an install prefix:
Probably you want to specify an install prefix:


     cmake ../flightgear -DCMAKE_INSTALL_PREFIX=/usr
     cmake -DCMAKE_INSTALL_PREFIX=/usr ../flightgear


Note the install prefix is automatically searched for required libraries
Note the install prefix is automatically searched for required libraries
Line 71: Line 71:
you can specify one or more via CMAKE_PREFIX_PATH:
you can specify one or more via CMAKE_PREFIX_PATH:


     cmake ../flightgear -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs"
     cmake -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs" ../flightgear


(note the use of semi-colons to specify multiple prefix paths)
(note the use of semi-colons to specify multiple prefix paths)
Line 84: Line 84:
By default, we select a release build. To create a debug build, use
By default, we select a release build. To create a debug build, use


     cmake ../flightgear -DCMAKE_BUILD_TYPE=Debug
     cmake -DCMAKE_BUILD_TYPE=Debug ../flightgear
   
 
(or MinSizeRel, or RelWithDbg)
(or MinSizeRel, or RelWithDbg)


Line 110: Line 110:
To set an optional feature, do
To set an optional feature, do


     cmake ../flightgear -DFEATURE_NAME=ON
     cmake -DFEATURE_NAME=ON  ../flightgear


(or 'OFF' to disable )
(or 'OFF' to disable )
Line 117: Line 117:
run one of the GUI front ends, or the following command:
run one of the GUI front ends, or the following command:


     cmake ../flighgear -L
     cmake -L ../flighgear


Add 'A' to see all the options (including advanced options), or 'H' to see
Add 'A' to see all the options (including advanced options), or 'H' to see
the help for each option (similar to running configure --help under autoconf):
the help for each option (similar to running configure --help under autoconf):


     cmake ../flightgear -LH
     cmake -LH ../flightgear


== Build Targets ==  
== Build Targets ==  

Revision as of 15:59, 21 August 2012

1rightarrow.png See Building Flightgear for the main article about this subject.

Build Environment & Dependencies

Linux / Unix

FIXME - provide a list of package names for Ubuntu

  • Get the OpenSceneGraph sources, either from subversion or a zip
  • NOTE: On Debian AMD64 (or not 32-bit) systems (maybe including Ubuntu) there is currently a packaging error which leads to false detection of OpenAL. Until it got repaired, you have 2 options left:

1. Goto /usr/share/cmake-2.8/Modules/ (it is the right patch on my Debian system) and expand the search path with lib/x86_64-linux-gnu/:

sudo su # to become root
cd /usr/share/cmake-2.8/Modules/ # again, use the proper path of your system
$EDITOR FindOpenAL.cmake
# Search for FIND_LIBRARY(OPENAL_LIBRARY
# Search again for PATH_SUFFIXES
# Append behind "lib": lib/x86_64-linux-gnu/
# Save it
# Quit your editor
exit # to leave root

2. (As I did) Set a symbolic link so cmake can find it:

sudo su # again, become root
cd /usr/lib/
ln -s x86_64-linux-gnu/* . # ignore that error for pkconfig for now
cd pkconfig/
ln -s ../x86_64-linux-gnu/pkgconfig/* .
  • Both steps have advantages and disadvantages, e.g. when it comes to updates, so you might need to repeat your desired path and fix your symbolic links by removing them first (!) and then re-create them. A big "thanks" to James for giving me the hints. :)
  • If you have OSG/PLIB on different directories than the usual, use environmental variables OSG_DIR/PLIBDIR, e.g. addd to ~/.bashrc:
# OSG/PLIB special directory
export OSG_DIR=/opt/my-osg-path
export PLIBDIR=/opt/my-plib-path

Mac

  • Install Xcode (from the App Store) and MacPorts (for Boost & PLIB - or build them some other way if you prefer)
  • Grab James' ALUT framework and add it to /Library/Frameworks
  • Get the OpenSceneGraph sources, either from subversion or a zip

Windows

See Building using CMake - Windows

Getting started with CMake

(These instructions apply to Unix-like systems, including Cygwin and Mac. To build using Visual Studio or some other IDE supported by CMake, most of the information below still applies)

Always compile in a separate directory to the code. For example, if the code (eg, from Git) is at /home/curt/projects/flightgear, you might create /home/curt/projects/fgbuild. Change into the new directory, and run

   cmake ../flightgear

To generate standard Unix Makefiles in fgbuild.

All these instructions apply equally to OpenSceneGraph, SimGear and finally FlightGear.

Probably you want to specify an install prefix:

   cmake -DCMAKE_INSTALL_PREFIX=/usr ../flightgear

Note the install prefix is automatically searched for required libraries and header files, so if you install PLIB, OpenSceneGraph and SimGear to the same prefix, most configuration options are unnecessary.

If for some reason you have a dependency (or several) at a different prefix, you can specify one or more via CMAKE_PREFIX_PATH:

   cmake -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs" ../flightgear

(note the use of semi-colons to specify multiple prefix paths)

Standard prefixes are searched automatically (/usr, /usr/local, /opt/local)

Most dependencies also expose an environment variable to specify their installation directory explicitly eg OSG_DIR or PLIBDIR. Any of the methods described above will work, but specifying an INSTALL_PREFIX or PREFIX_PATH is usually simpler.

By default, we select a release build. To create a debug build, use

   cmake -DCMAKE_BUILD_TYPE=Debug ../flightgear

(or MinSizeRel, or RelWithDbg)

Debug builds will automatically use corresponding debug builds of required libraries, if they are available. For example you can install debug builds of SimGear and OpenSceneGraph, and a debug FlightGear build will use them.

(Debug builds of libraries have the 'd' suffix by default - Release builds have no additional suffix)

Note most IDE projects (eg Xcode and Visual Studio) support building all the build types from the same project, so you can omit the CMAKE_BUILD_TYPE option when running cmake, and simply pick the build configuration as normal in the IDE.

It's common to have several build directories with different build configurations, eg

   /home/curt/projects/flightgear (the git clone)
   /home/curt/projects/fgdebug
   /home/curt/projects/fgrelease
   /home/curt/projects/fg-with-svn-osg

To set an optional feature, do

   cmake -DFEATURE_NAME=ON  ../flightgear

(or 'OFF' to disable )

To see the variables that can be configured / are currently defined, you can run one of the GUI front ends, or the following command:

   cmake -L ../flighgear

Add 'A' to see all the options (including advanced options), or 'H' to see the help for each option (similar to running configure --help under autoconf):

   cmake -LH ../flightgear

Build Targets

For a Unix makefile build, 'make dist', 'make uninstall' and 'make test' are all available and should work as expected. 'make clean' is also as normal, but there is *no* 'make distclean' target. The equivalent is to completely remove your build directory, and start with a fresh one.