diff options
author | Brad King <brad.king@kitware.com> | 2021-09-22 18:55:42 (GMT) |
---|---|---|
committer | Igor S. Gerasimov <i.s.ger@ya.ru> | 2021-10-05 14:41:36 (GMT) |
commit | 9b69307b56376e2bd0a82539562f9e59a808194b (patch) | |
tree | 549ac8a41a7dcd38c3949a46594805dda4b9791d /Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake | |
parent | 91fd645d46adeaa22221b0c08307d2dc35b81ade (diff) | |
download | CMake-9b69307b56376e2bd0a82539562f9e59a808194b.zip CMake-9b69307b56376e2bd0a82539562f9e59a808194b.tar.gz CMake-9b69307b56376e2bd0a82539562f9e59a808194b.tar.bz2 |
Find{BLAS,LAPACK}: De-duplicate and generalize test creation logic
Interpret `CMake_TEST_FindBLAS` and `CMake_TEST_FindLAPACK` as a
sequence of option assignments intermixed with vendor names.
Diffstat (limited to 'Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake')
-rw-r--r-- | Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake b/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake new file mode 100644 index 0000000..db33404 --- /dev/null +++ b/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake @@ -0,0 +1,43 @@ +function(add_BLAS_LAPACK_tests var) + if(var MATCHES "^CMake_TEST_Find(BLAS|LAPACK)$") + set(package "${CMAKE_MATCH_1}") + else() + message(FATAL_ERROR "Test list variable '${var}' not supported.") + endif() + + set(all "") + set(compiler "") + set(static "") + + foreach(variant IN LISTS ${var}) + if(variant MATCHES "^(all|compiler|static)=(.*)$") + set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") + continue() + elseif(variant MATCHES "^([^=]+)=(.*)$") + message(FATAL_ERROR "Unknown variable '${variant}'") + endif() + set(variant_name "${variant}") + set(variant_options "-DBLA_VENDOR=${variant}") + if(variant STREQUAL "All" AND all) + list(APPEND variant_options "-DEXPECT_All=${all}") + endif() + if(compiler) + string(APPEND variant_name "_${compiler}") + list(APPEND variant_options "-DCMAKE_C_COMPILER=${compiler}") + endif() + if(static) + string(APPEND variant_name "_Static") + list(APPEND variant_options "-DBLA_STATIC=ON") + endif() + add_test(NAME Find${package}.Test_${variant_name} COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Find${package}/Test" + "${CMake_BINARY_DIR}/Tests/Find${package}/Test_${variant_name}" + ${build_generator_args} + --build-project TestFind${package} + --build-options ${build_options} ${variant_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + endforeach() +endfunction() |