I had an old folder of C++ exercises, containing a Makefile and some source files. Each source file would compile to one executable. I imported that folder into NetBeans then wondered how to run and debug each executable as a different 'Main Project'. After some twiddling, the solution (hack?) is to define different configurations for the project, one for each executable.
- Select your project's context menu item Set Configuration / Manage Configurations….
- In the Project Properties dialog, press the Manage Configurations button (I know that's rather confusing).
- In the Configurations dialog, create a new configuration with the target executable file name.
- Press the OK button to close the Configurations dialog.
- In the Project Properties dialog, select the Categories / Build / Make node.
- Select your configuration from the Configuration: drop down list. Note that you have to select any node other than General otherwise the Configuration: drop down list is disabled.
- In the Makefile panel:
- Working Directory = . (current directory)
- Build Command = ${MAKE} -f Makefile <file.exe>
- Clean Command = ${MAKE} -f Makefile clean
- Build Result = <file.exe>
- Press the OK button
Now, to run or debug a different executable, I just change the project's Active Configuration.