Project Configuration

Project configuration involves setting the correct build flags for targets, groups and the project itself. You can set these flags in their respective properties dialogs.

You can freely use autoconf and automake variables that are automatically set for the project during configuration. Apart from these automatically set variables, you can also define your own variables in Project Properties and use them in properties. This will make it easy to update flags later, especially when a variable is used in several targets.

Some of the many common variables are listed here. For full list of them see the automake info documentation.

  • $(prefix): The installation prefix. The project is installed under various subdirectories under this prefix. By default it is /usr/local.
  • $(bindir): The installation directory for executable binaries. All your executable and script targets will be installed in this directory. By default, it is $(prefix)/bin.
  • $(libdir): The installation directory for libraries. All your library targets (both shared and static) will be installed in this directory or a subdirectory below it. By default, it is $(prefix)/lib.
  • $(module_CFLAGS) and $(module_LIBS): These flags are set by configure for the packages that your project depends on. The packages used by the project are set in Project Properties. 'module' is a package group that you specify in the project properties as described below.

4.6.1. Project properties

The project properties dialog can be opened only by choosing Project ▸ Properties from the toplevel menu bar. You can:

  • Set the project name, version and URL in the General page. configure variables can also be use in these fields. The URL is the bug report URL for the project.
  • Add and remove dependencies for your project in the Packages page. See below for details.
  • Create more configure variables in the Variables page to use in group and target properties.

Dependencies are external packages that the project uses and are hence required to build it. Only packages installed using pkg-config can be added from this interface. For others, the configure.ac file can be edited manually.

Figure 4-2Project properties dialog

External package dependencies are grouped into modules, so that their combined build flags can be conveniently added to different targets. Modules are just arbitrary groups of packages and can be named anything (only alphanumeric characters and _ are allowed in module names). Usually, they follow the name of targets they would be used in. Consequently, for small projects with single targets, just one module to hold all dependencies is enough.

Each package exports a set of compiler flags and libraries. They are aggregated together for all packages under a module, and configure variables $(module_CFLAGS) and $(module_LIBS) are defined. These variables can then be used in Group properties and Target properties.

To add a package dependency:

  • Select Project ▸ Properties to bring up the project properties dialog.
  • Select the tab Packages to bring up the Packages page.
  • Select the module to add the package to. If there is no module created yet or there is no appropriate module, create one by clicking Add module. Give a sensible name to the module, preferably in UPPERCASE to match other configure variables (only use alphanumeric and '_' characters) and press Enter to create it.
  • Click Add Package to bring up the package selection dialog.
  • Select the package to add and click Add.
  • Click Close to close the properties dialog.

4.6.2. Group properties

To edit a group's properties, double-click the group in the Project window to open the Group Properties dialog. (You can alternatively right-click the group and select Properties from the context menu.)

Figure 4-3Group properties dialog

Properties set for a group apply to all the targets under it. So any compiler or linker flags set for a group will be automatically be part of all the targets in it (in addition to each target's individual properties). The following fields are available in the Group Properties dialog.

  • Includes: Set your include directories for your C and C++ targets here. You need to provide the full include options of the compiler here, e.g. -I/usr/include/blah. The include paths will be used to find header files included by your source files. (You can also add other compiler flags here, but it's preferable to set them in their respective compiler flags fields as described below.)
  • Compiler flags: Set your compiler-specific flags here. There are different fields for different compiler categories. Flags that can be set here depend on the actual compiler used. The default compiler used for C/C++ is gcc/g++ (the GNU C compiler). Check out the gcc info documentation for more details.
  • Install directories: The dialog will display a field for each target in the group that requires an installation directory. Set each installation directory as relative to one of the many automake directory variables, such as $(prefix), $(bindir), $(libdir), or $(datadir).

4.6.3. Target properties

Any properties set for a target apply to that target only. A target also inherits properties from its containing group.

To set a target's properties, double-click the target in the Project window to open the Target Properties dialog. (You can alternatively right-click the target and select Properties from the context menu.)

Figure 4-4Target properties dialog

You can add the modules you have added in Project properties to a specific target here. To activate the module simply toggle the checkbox next to the module name. This will automatically add include and linker flags to that target and enable you to use the module within this target.

4.6.3.1. Advanced target options

The following fields are available in the advanced target configuration that you reach when you clicked the Advanded... button in the target properties dialog.

Figure 4-5Target properties dialog
  • Compiler settings: Set your compiler-specific flags here. There are different fields for different compiler categories. Flags that can be set here depend on the actual compiler used. The default compiler used for C/C++ is gcc/g++ (the GNU C compiler). Check out the gcc info documentation for more details.
  • Linker flags: Set linker flags that should be used when linking the target. These flags apply only to Program and Library targets. See the ld info documentation for available linker options.
  • Libraries: Set the libraries that the target depends on.