Scripted Compilation on Linux Debian/Ubuntu: Difference between revisions

→‎Task-specific instructions: Add section “Passing custom arguments to CMake”
m (More consistent header names)
(→‎Task-specific instructions: Add section “Passing custom arguments to CMake”)
Line 404: Line 404:


{{Note|The development version of FlightGear changes on an almost daily basis. It provides the latest features, but is not guaranteed to always work reliably. If you don't want to take the risk of finding new bugs when updating, you may prefer to use the latest stable release.}}
{{Note|The development version of FlightGear changes on an almost daily basis. It provides the latest features, but is not guaranteed to always work reliably. If you don't want to take the risk of finding new bugs when updating, you may prefer to use the latest stable release.}}
=== Passing custom arguments to CMake ===
Sometimes, when building a program, you may want to enable a feature that is not enabled by default, or disable a feature that is enabled by default. With recent versions of <tt>download_and_compile.sh</tt> (April 2019 or later), the environment variables <tt>SG_CMAKEARGS</tt> and <tt>FG_CMAKEARGS</tt> allow one to do that for SimGear and FlightGear. For instance, in order to link SimGear with the system Expat library, you can do:
$ SG_CMAKEARGS='-DSYSTEM_EXPAT=ON' download_and_compile.sh SIMGEAR
Similarly, disabling HID-based input when building FlightGear can be achieved this way:
$ FG_CMAKEARGS='-DENABLE_HID_INPUT=OFF' download_and_compile.sh FGFS
{{Note|Such options are typically defined in <tt>CMakeLists.txt</tt> files, for example {{simgear source
| path = CMakeLists.txt
| text = here
}} for SimGear and {{flightgear source
| path = CMakeLists.txt
| text = here
}} for FlightGear.}}
This can be useful for instance to work around bugs in a part of SimGear or FlightGear that you don't need, but causes a build or runtime failure (see [https://forum.flightgear.org/viewtopic.php?f=45&t=35740 here] for example). This is often convenient when using the development version of FlightGear, but doesn't mean such bugs shouldn't be reported!
If you have several such options to pass, just use spaces to separate them inside the quotes:
$ FG_CMAKEARGS='-DENABLE_SWIFT=ON -DENABLE_HID_INPUT=OFF' download_and_compile.sh FGFS
Of course, the same thing can also be achieved this way in Bourne-style shells:
$ export FG_CMAKEARGS='-DENABLE_SWIFT=ON -DENABLE_HID_INPUT=OFF'
$ download_and_compile.sh FGFS
It is also possible to set both <tt>SG_CMAKEARGS</tt> and <tt>FG_CMAKEARGS</tt> at the same time for a given <tt>download_and_compile.sh</tt> run:
$ export SG_CMAKEARGS='-DSYSTEM_EXPAT=ON'
$ export FG_CMAKEARGS='-DENABLE_SWIFT=ON -DENABLE_HID_INPUT=OFF'
$ download_and_compile.sh


=== Launching FlightGear ===
=== Launching FlightGear ===
377

edits