Difference between revisions of "Global compiler variables"
Line 25: | Line 25: | ||
[[Image:Globvarsdir.png]] | [[Image:Globvarsdir.png]] | ||
− | The above image shows both per-procect and global variables. <tt> | + | The above image shows both per-procect and global variables. <tt>WX_CFG</tt> is defined in the project, but <tt>WX</tt> is a global user variable. |
Revision as of 09:13, 6 November 2005
Synopsis
Working as a developer on a project which relies on 3rd party libraries involves a lot of unnecessary repetitive tasks, such as setting up build variables according to the local filesystem layout. In the case of project files, care must be taken to not accidentially commit a locally modified copy.
The concept of global compiler variables is an unique new solution for Code::Blocks which addresses this problem. Global compiler variables allow you to set up a project once, and any number of developers using any number of different filesystem layouts will be able to compile and develop the project. No local layout information needs to be changed more than once.
Names and Members
Global compiler variables in Code::Blocks are discriminated from per-project variables by a leading hash sign. Global compiler variables are structured; every variable consists of a name and an optional member. Names are freely definable, while the member structure is built into the IDE. Although you can choose anything for a variable name in principle, it is advisable to pick a known identifier for common packages. This way, the amount of information that the user needs to provide is minimised. The Code::Blocks team provides a list of recommended variables for known packages.
The members dir and base resolve to the same value as the variable name uses without a member (alias). The members include and lib are by default aliases for base/include and base/lib, respectively. However, a user can redefine them if another setup is desired. It is recommended to always use $(#variable.include) instead of $(#variable)/include, as this offers additional flexibility at otherwise exactly identical functionality. The members cflags and lflags are empty by default and can be used to provide the ability to feed the same consistent set of compiler/linker flags to all builds on one machine.
Using Global Compiler Variables
All you need to do to start using global compiler variables is to put them in your project!
When the IDE detects the presence of an unknown global variable, it will prompt you to enter its value. The value will be saved in your settings, so you never need to enter the information twice.
If you need to modify or delete a variable at a later time, you can do so from the settings menu.
Example:
The above image shows both per-procect and global variables. WX_CFG is defined in the project, but WX is a global user variable.