You can use macros to modify the way that the project system refers to files. Macros are divided into four classes:
- System Macros
- These are provided by the Studio application and are used to relay information from the environment, such as paths to common directories.
- Global Macros
- These macros are saved in the environment and are shared across all solutions and projects. Typically, you would set up paths to library or external items here.
- Project Macros
- These macros are saved in the project file as project properties and can define macro values specific to the solution/project they are defined in.
- Build Macros
- These macros are generated by the project system whenever a build occurs.
System macros
The following macro values are defined by CrossStudio itself:
Macro | Description |
StudioDir | The install directory of the CrossStudio application. |
System macros can be used in build properties and also for environment settings.
Global macros
To define a global macro
- Select Macros from the Project menu.
- Click on the the Global tab.
- Set the macro using the syntax name = replacement text.
Project macros
To define a project macro
- Select Macros from the Project menu.
- Click on the Project tab.
- Select the solution or project the macro should apply to.
- Set the macro using the syntax name = replacement text.
Alternatively you can set the project macros from the properties window:
- Select the appropriate solution/project in the Project Explorer.
- In the properties window, select the Macros property in the General Options group.
- Click on the the ellipsis button on the right.
- Set the macro using the syntax name = replacement text.
Build macros
The following macro values are defined by the project system for a build of a given project node.
Macro | Description |
ProjectDir | The project directory. |
ProjectName | The project name. |
Configuration | The selected build configuration. |
SolutionDir | The directory containing the solution file. |
SolutionName | The solution name. |
InputFileName | The name of an input file relative to its project directory. |
InputName | The name of an input file relative to its project directory without its extension. |
InputExt | The extension of an input file. |
IntDir | The macro-expanded value of the Intermediate Directory property. |
OutDir | The macro-expanded value of the Output Directory property. |
EXE | The default file extension for an executable file including the dot. |
LIB | The default file extension for a library file including the dot. |
OBJ | The default file extension for an object file including the dot. |
LibExt | A platform specific library extension that is generated based on project property values. |
Using macros
You can use a macro in a project property or an environment setting using the $(macro) syntax. For example the Object File Name property has a default value of $(IntDir)/$(InputName)$(OBJ).
To enable debugging of builds you should use the Build Information... dialog that is on the context menu of the project explorer. This dialog will give a full list of the macros that are specified for the project node selected together with the macro expanded property values.