3.4. Custom Make targets

In addition to the project level build definitions, CDT allows you to define custom make targets that may appear at any level in the build hierarchy. Custom make targets may be defined by right clicking on any Makefile in your build hierarchy as displayed in the Project Explorer view to bring up the context menu. Select Make Targets, then Create... to bring up the Create Make Target dialog. With one exception, standard CDT procedures for defining custom make targets work for nmake. The exception is the setting for the Build Command field of the Create Make target dialog. When some versions of CDT run the specified build command, they do not set environment variable PWD appropriately for targets not at project root. This leads to incorrect values for nmake variables such as VROOT. A workaround is to execute nmake through a simple shell wrapper script. A sample script is shown in Example 1, “Sample nmake shell wrapper script”. In addition to wrapping nmake, the displayed script filters out unwanted compiler warnings.

Example 1. Sample nmake shell wrapper script

(
  set -x
  nmake $*
) 2>&1 | grep -v 'please use -iquote instead'
echo end $0 $*

To use the script, place the it in a file called nmk in a directory on your PATH and use ksh nmk instead of nmake in the Build Command field when creating a custom make target:

Figure 4. Custom make target creation dialog.

custom make target creation

Custom make targets display in the Make Targets view:

Figure 5. Custom make targets view.

make targets view

Double click on the target icon to build the target, or select the target and click the target toolbar icon.