[CMake] "unit" testing your CMakeLists.txt

Tyler Roscoe tyler at cryptio.net
Mon Feb 9 15:15:33 EST 2009


My company is adopting Test-Driven Development. I am wondering if any of
you build engineers in a similar position have given any thought to how
one might use this approach when developing your build systems.

In one sense, you can say, "Well, the build is the test. If I say 'go'
and I end up with SuperProduct.exe (and maybe a bunch of unit test
successes) then everything works and I don't need any tests."

OTOH, it would be nice to gain some of the benefits of TDD (e.g.,
fearless refactoring) in the build system. Sometimes there are build
artifacts that should be generated which are not code and therefore
won't generate "build errors" (documentation perhaps).

One approach I've thought of is a simple script that simply makes
sure that each CMake project deposits an expected list of files in a
certain place. I have a hierarchy of "buildables" so it might be nice to
know that the header at the bottom of the dependency tree is built
correctly, and that the libraries that use it find that header and build
correctly, and that the executable that use those libraries find
everything and build correctly.

Does anyone do anything like this? Are there tools around to help? Is
this a worthwhile thing to think about?

Thanks,
tyler


More information about the CMake mailing list