From 7704505fbf7d969ff918f8bf2ff9ed976194987a Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Fri, 27 Dec 2019 17:34:05 +0400 Subject: [PATCH] build: CMake: made it easier to run tests in parallel As of now `make -jN check` executes test suite sequentially (although it builds test executables in parallel). This takes a bit too long, so it would be nice to run tests in parallel. `ctest -jN` or `make test ARGS=-jN` runs tests concurrently, however it does not build test executables, instead it fails if any test binary is missing. Also `test` target is a bit special and it's impossible to add dependencies to it, see https://gitlab.kitware.com/cmake/cmake/issues/8438 To work around the problem define `test_suite` target which builds the tests suite without running it, so one can both compile and run tests in parallel make -j8 test_suite make test ARGS=-j8 --- CMakeLists.txt | 1 + check/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9aec3279..20ce8e19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ set(ginaclib_version ${ginaclib_soversion}.${ginac_lt_age}.${ginac_lt_revision}) # make check enable_testing() add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) +add_custom_target(test_suite) if (WIN32) if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) diff --git a/check/CMakeLists.txt b/check/CMakeLists.txt index 9c38932c..544c412e 100644 --- a/check/CMakeLists.txt +++ b/check/CMakeLists.txt @@ -71,6 +71,7 @@ macro(add_ginac_test thename) endif() add_executable(${thename} EXCLUDE_FROM_ALL ${${thename}_sources}) target_link_libraries(${thename} ginac ${LIBDL_LIBRARIES}) + add_dependencies(test_suite ${thename}) add_dependencies(check ${thename}) add_test(NAME ${thename} COMMAND $) endmacro() -- 2.44.0