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

wmknapik@gmail.com wmknapik at gmail.com
Thu Jan 24 06:05:09 EST 2013


Sorry for the top-posting, I'm using my phone to send this.

The unique names in each subdir are not an acceptable solution for me. 

Also, the project builds on Linux only, where gmake is fine.

Thanks,
WK

----- Reply message -----
From: "Matthew Woehlke" <matthew.woehlke at kitware.com>
To: <cmake at cmake.org>
Cc: <public-cmake-wChDC6UyXvPYtjvyW6yDsg at plane.gmane.org>
Subject: [CMake] Building all tests in parallel (whole subtrees)
Date: Thu, Jan 24, 2013 01:07


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.)

-- 
Matthew

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130124/c580e455/attachment-0002.htm>


More information about the CMake mailing list