[CMake] Building all tests in parallel (whole subtrees)

Brett Delle Grazie brett.dellegrazie at gmail.com
Thu Jan 24 04:44:47 EST 2013


On 24 January 2013 00:07, Matthew Woehlke <matthew.woehlke at kitware.com>wrote:

> On 2013-01-23 18:08, Wojciech Knapik wrote:
>
>> I set up targets that build the unit test executables and
>> marked them with EXCLUDE_FROM_ALL, because I don't want to tie building
>> them to building the application code. Now I need a way to build and run
>> these tests en masse, since there are too many to do it one at a time.
>>
>> Ideally I'd like to have a make target, that I could call to build all
>> unit tests in the current directory and below *in*parallel*.
>>
>
> I'm not sure if this is possible (or at least feasible)... different
> generators may or may not have the concept of targets in directories. I
> think you would need to create a uniquely named target per directory.
>
> Now, assuming you are okay creating one top-level target to build
> everything, it's easy:
>
> root/CMakeLists.txt:
> add_custom_target(all_tests)
>
> root/some_subdir/test/**CMakeLists.txt:
> add_dependency(all_tests my_test_executable)
>
> The tests will have the same ability to be built in parallel as any other
> targets.
>
> If you are using Makefiles, this *might* 'just happen' to do what you want
> for directory-level granularity, but it won't work with other generators
> (e.g. ninja, MSVS, etc.). Otherwise, you can probably figure out how to
> extend the above idea to directory-level targets.
>
> (On an unrelated note, I would suggest looking at ninja; it's a whole
> bunch faster than make, nmake, or MSVS.)


+1 for this, Ninja is _incredibly_ quick compared to mingw32-make / msys
make both on full and incremental builds.
One other advantage is its parallel by default and the output display isn't
mangled like it is with mingw32-make when you use -j <num_cores>



>
> --
> Matthew
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130124/2dfa8889/attachment-0002.htm>


More information about the CMake mailing list