Go to Edit/Editor Preferences, select "All Settings" and type "CPU" in the sarch box. It should find the setting titled "Use Less CPU when in Background", and you want to uncheck this checkbox.
This can be a machine performance issue, check your hard drive performance.
Add these to your cmake command line -D CMAKE_C_COMPILER=gcc-6 -D CMAKE_CXX_COMPILER=g++-6
.