Scripted Compilation on Linux Debian/Ubuntu: Difference between revisions

Jump to navigation Jump to search
Document new options --sg-cmake-arg and --fg-cmake-arg
(→‎OpenRTI undefined reference errors: Option --cleanup can simpify this)
(Document new options --sg-cmake-arg and --fg-cmake-arg)
Line 495: Line 495:
=== Passing custom arguments to CMake ===
=== 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:
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> (October 2020 or later), this can be done for SimGear and FlightGear using the <code>--sg-cmake-arg</code> and <code>--fg-cmake-arg</code> options (the environment variables <tt>SG_CMAKEARGS</tt> and <tt>FG_CMAKEARGS</tt> are still supported, but they don't allow one to pass arguments containing spaces). 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
  $ download_and_compile.sh --sg-cmake-arg='-DSYSTEM_EXPAT=ON' SIMGEAR
Similarly, disabling HID-based input when building FlightGear can be achieved this way:
Similarly, disabling HID-based input when building FlightGear can be achieved this way:
  $ FG_CMAKEARGS='-DENABLE_HID_INPUT=OFF' download_and_compile.sh FGFS
  $ download_and_compile.sh --fg-cmake-arg='-DENABLE_HID_INPUT=OFF' FGFS


{{Note|Such options are typically defined in <tt>CMakeLists.txt</tt> files, for example {{simgear source
{{Note|Such options are typically defined in <tt>CMakeLists.txt</tt> files, for example {{simgear source
Line 508: Line 508:
}} for FlightGear.}}
}} 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 {{forum link|t=35740|text=here}} for example). This is often convenient when using the development version of FlightGear, but doesn't mean such bugs shouldn't be reported!
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 {{forum link|t=35740|text=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:
If you have several such options to pass, just use <code>--sg-cmake-arg</code> and/or <code>--fg-cmake-arg</code> several times:
  $ FG_CMAKEARGS='-DENABLE_SWIFT=ON -DENABLE_HID_INPUT=OFF' download_and_compile.sh FGFS
  $ download_and_compile.sh --fg-cmake-arg='-DENABLE_SWIFT=ON' \
Of course, the same thing can also be achieved this way in Bourne-style shells:
                          --fg-cmake-arg='-DENABLE_HID_INPUT=OFF' FGFS
  $ export FG_CMAKEARGS='-DENABLE_SWIFT=ON -DENABLE_HID_INPUT=OFF'
It is even possible to pass arguments containing spaces to CMake, as in:
  $ download_and_compile.sh FGFS
  $ download_and_compile.sh \
    --sg-cmake-arg='-DCMAKE_CXX_FLAGS=-Wno-deprecated-declarations -Wall' \
    SIMGEAR
(just a silly example to show a working syntax) or:
  $ download_and_compile.sh \
    --fg-cmake-arg="-DCMAKE_CXX_FLAGS=$(pkg-config --cflags gl)" \
    FGFS
Note the use of double-quotes here to enable the <code>$(...)</code> command substitution.


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:
Using the (half-deprecated) environment variables <tt>SG_CMAKEARGS</tt> and <tt>FG_CMAKEARGS</tt>, it is also possible to define CMake arguments in a single place that are going to be used for both SimGear and FlightGear. However, this technique doesn't allow one to pass arguments containing spaces to CMake.
  $ export SG_CMAKEARGS='-DSYSTEM_EXPAT=ON'
  $ export SG_CMAKEARGS='-DSYSTEM_EXPAT=ON'
  $ export FG_CMAKEARGS='-DENABLE_SWIFT=ON -DENABLE_HID_INPUT=OFF'
  $ export FG_CMAKEARGS='-DENABLE_SWIFT=ON -DENABLE_HID_INPUT=OFF'
377

edits

Navigation menu