2

I'm using KDevelop and CMake to develop a project that includes many targets, including a few of executables and libraries and many unit-tests of them.

Every time when I start to build my project, I have to wait a long time, because KDevelop / CMake always build all the targets defined in CMakeList.txt. Most of the time, I only modified a bit of the codes, and merely want to build a single target to validate whether the modification is correct.

So, my question is:

Is there a way, I can let KDevelop and CMake only build a single or couple of the targets? Thanks!

Leon
  • 1,489
  • 1
  • 12
  • 31
  • Off topic, but you should investigate [ccache](https://ccache.dev/) to speed up builds. It's super easy to use and provides massive speed gains when building the same unchanged code over and over. Be sure to set a large cache size (I use 5x the size of all my object files rounded up to the nearest 10 gigabytes). – Jesper Juhl Nov 10 '19 at 14:53

1 Answers1

2

Usually, projects offer a way to disable tests:

option(MYPROJECT_TEST "Enable tests" OFF)

if(MYPROJECT_TEST)
    add_subdirectory(test)
endif()

Then in the cmake project configuration in KDevelop, a checkbox will appear to enable and disable tests.

Also, in KDevelop itself, there are targets displayed in the project panel. They are represented as a square box with a play symbol in it. You can right click and compile from there to build a single target (and it's required dependencies)

Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141