Building using CMake: Difference between revisions

Jump to navigation Jump to search
Usage of <syntaxhighlight> tags for all shell commands.
(Usage of <syntaxhighlight> tags for all shell commands.)
Line 16: Line 16:
* '''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:
* '''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/:
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/:
<pre>sudo su # to become root
<syntaxhighlight lang="sh">sudo su # to become root
cd /usr/share/cmake-2.8/Modules/ # again, use the proper path of your system
cd /usr/share/cmake-2.8/Modules/ # again, use the proper path of your system
$EDITOR FindOpenAL.cmake
$EDITOR FindOpenAL.cmake
Line 24: Line 24:
# Save it
# Save it
# Quit your editor
# Quit your editor
exit # to leave root</pre>
exit # to leave root</syntaxhighlight>
2. (As I did) Set a symbolic link so cmake can find it:
2. (As I did) Set a symbolic link so cmake can find it:
<pre>sudo su # again, become root
<syntaxhighlight lang="sh">sudo su # again, become root
cd /usr/lib/
cd /usr/lib/
ln -s x86_64-linux-gnu/* . # ignore that error for pkconfig for now
ln -s x86_64-linux-gnu/* . # ignore that error for pkconfig for now
cd pkconfig/
cd pkconfig/
ln -s ../x86_64-linux-gnu/pkgconfig/* .</pre>
ln -s ../x86_64-linux-gnu/pkgconfig/* .</syntaxhighlight>
* 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. :)
* 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:
* If you have OSG/PLIB on different directories than the usual, use environmental variables OSG_DIR/PLIBDIR, e.g. addd to ~/.bashrc:
<pre># OSG/PLIB special directory
<syntaxhighlight lang="sh"># OSG/PLIB special directory
export OSG_DIR=/opt/my-osg-path
export OSG_DIR=/opt/my-osg-path
export PLIBDIR=/opt/my-plib-path</pre>
export PLIBDIR=/opt/my-plib-path</syntaxhighlight>


Note: In order to set the CFLAGS/CXXFLAGS variables for make/gcc, simply configure cmake and define
Note: In order to set the CFLAGS/CXXFLAGS variables for make/gcc, simply configure cmake and define
Line 41: Line 41:
For example, to enable gprof:  
For example, to enable gprof:  


<pre>
<syntaxhighlight lang="sh">
cmake ../flightgear -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_FLAGS=-pg -DCMAKE_CXX_FLAGS=-pg
cmake ../flightgear -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_FLAGS=-pg -DCMAKE_CXX_FLAGS=-pg
</pre>
</syntaxhighlight>


===Mac===
===Mac===
Line 94: Line 94:
/home/curt/projects/fgbuild. Change into the new directory, and run
/home/curt/projects/fgbuild. Change into the new directory, and run


    cmake ../flightgear
<syntaxhighlight lang="sh">
cmake ../flightgear
</syntaxhighlight>


To generate standard Unix Makefiles in fgbuild.
To generate standard Unix Makefiles in fgbuild.
Line 102: Line 104:
Probably you want to specify an install prefix:
Probably you want to specify an install prefix:


    cmake -DCMAKE_INSTALL_PREFIX=/usr ../flightgear
<syntaxhighlight lang="sh">
cmake -DCMAKE_INSTALL_PREFIX=/usr ../flightgear
</syntaxhighlight>


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


    cmake -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs" ../flightgear
<syntaxhighlight lang="sh">
cmake -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs" ../flightgear
</syntaxhighlight>


(note the use of semi-colons to specify multiple prefix paths)
(note the use of semi-colons to specify multiple prefix paths)
Line 126: Line 132:
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 -DCMAKE_BUILD_TYPE=RelWithDebInfo ../flightgear
<syntaxhighlight lang="sh">
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../flightgear
</syntaxhighlight>


(or MinSizeRel, or Debug)
(or MinSizeRel, or Debug)
Line 156: Line 164:
To set an optional feature, do
To set an optional feature, do


    cmake -DFEATURE_NAME=ON  ../flightgear
<syntaxhighlight lang="sh">
cmake -DFEATURE_NAME=ON  ../flightgear
</syntaxhighlight>


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


    cmake -L ../flighgear
<syntaxhighlight lang="sh">
cmake -L ../flighgear
</syntaxhighlight>


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 -LH ../flightgear
<syntaxhighlight lang="sh">
cmake -LH ../flightgear
</syntaxhighlight>


== Build Targets ==  
== Build Targets ==  
Line 194: Line 208:
To be able to do so he's run cmake for both Simgear and FlightGear as follows:  
To be able to do so he's run cmake for both Simgear and FlightGear as follows:  


<pre>
<syntaxhighlight lang="sh">
cmake -DCMAKE_AR=/usr/bin/gcc-ar \
cmake -DCMAKE_AR=/usr/bin/gcc-ar \
  -DCMAKE_RANLIB=/usr/bin/gcc-ranlib \
  -DCMAKE_RANLIB=/usr/bin/gcc-ranlib \
Line 201: Line 215:
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_CXX_FLAGS:STRING="-Os march=native -mtune=native -msse3 -mfpmath=sse -flto"  
  -DCMAKE_CXX_FLAGS:STRING="-Os march=native -mtune=native -msse3 -mfpmath=sse -flto"  
</pre>
</syntaxhighlight>


After applying one patch to SimGear he got it compiling.  
After applying one patch to SimGear he got it compiling.  

Navigation menu