8

For example I have 2 Makefiles: Makefile.Debug and Makefile.Release.

I can switch between them by setting different commands in:

C/C++ Build -> Builder Settings -> build command : make -f Makefile.Debug -j4 or make -f Makefile.Release -j4, but how can I switch between two makefiles in Eclipse GUI (Like in Visual Studio debug/release configurations)?

enter image description here

mrgloom
  • 20,061
  • 36
  • 171
  • 301

1 Answers1

7

Create two Build configurations in Eclipse, each with a different make command. Then, you can click the down arrow near the hammer in Eclipse's top bar to switch configuration.

Detailed steps:

  1. Right click on Project, click Properties
  2. Left sidebar, click C/C++ Build
  3. Top right corner, "Manage Configurations..."
  4. Add
  5. Set "Name" and select "Existing configuration: xxxxx"
  6. Ok
  7. Ok
  8. Switch between the configurations setting what's required (in your case, under the C/C++ Build section, in the "Builder Settings" tab, select "External builder" type in the "Builder type" combo, then deselect "Use default build command" and enter yours in the "Build command" field
  9. Confirm with OK
  10. Use the hammer

(I haven't a copy of Eclipse on this PC right now so I can't send screenshots, sorry.)

Francis Straccia
  • 894
  • 1
  • 7
  • 20
  • For Eclipse CDT Version: 3.8.1 steps are litle different but idea is the same, but when I switch between builds with hummer I also need to perform clean of the projects, how can I automate this? Also maybe I can rebuild only changed files but not all solution? – mrgloom Apr 18 '16 at 14:08
  • You could create two directories, target-1 and target-2 with the two different makefiles in them. The makefiles will then refer to the sources present in the parent directory of both (which is your source folder). This way, makefiles and build process output are nicely separed in different folders. – Francis Straccia Apr 19 '16 at 13:46