1

A project at my work uses CMake to generate build targets then executed from Eclipse. I want to pass -J4 to the "Build Command" (i.e. make.exe) to allow parallel compilation. For the moment I manually edit the .cproject file but I'd like CMake to automatically do this.

So how can I append -J4 to the build command?

gramm
  • 18,786
  • 7
  • 27
  • 27
  • 2
    How do you run `cmake` from eclipse? Do you use some plugins? What build command does eclipse execute? – KamilCuk Mar 07 '19 at 07:42
  • If you are looking for IDE-agnostic way, then see that SO question: https://stackoverflow.com/questions/41684793/from-cmake-setup-make-to-use-j-option-by-default. If you ask about Eclipse-specific problem, then, please, add corresponded tag and describe your CMake usage in Eclipse in more details, as KamilCuk asks. – Tsyvarev Mar 07 '19 at 08:28
  • That's out of scope of the generation of the build files. But you can use cmake's command line mode (--build, -j) to achieve this. – Th. Thielemann Mar 07 '19 at 08:38

1 Answers1

0

Finally accidentally found an answer in another thread.

Eclipse .cproject files are generated using the '-G "Eclipse CDT4 - Unix Makefiles"' argument. The following arguments are used to pass parameters to make in the .cproject target:

-DCMAKE_ECLIPSE_MAKE_ARGUMENTS=...

in my case

-DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8

gramm
  • 18,786
  • 7
  • 27
  • 27