summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-09-22 18:55:42 (GMT)
committerIgor S. Gerasimov <i.s.ger@ya.ru>2021-10-05 14:41:36 (GMT)
commit9b69307b56376e2bd0a82539562f9e59a808194b (patch)
tree549ac8a41a7dcd38c3949a46594805dda4b9791d
parent91fd645d46adeaa22221b0c08307d2dc35b81ade (diff)
downloadCMake-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.
-rw-r--r--.gitlab/ci/configure_debian10_aarch64_ninja.cmake6
-rw-r--r--.gitlab/ci/configure_debian10_ninja.cmake6
-rw-r--r--.gitlab/ci/configure_fedora34_makefiles.cmake6
-rw-r--r--.gitlab/ci/configure_intelcompiler_common.cmake15
-rw-r--r--Tests/FindBLAS/CMakeLists.txt51
-rw-r--r--Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake43
-rw-r--r--Tests/FindLAPACK/CMakeLists.txt51
7 files changed, 60 insertions, 118 deletions
diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
index a6b7cb5..8e03eef 100644
--- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
+++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
@@ -1,6 +1,5 @@
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
-set(CMake_TEST_FindBLAS "All" CACHE STRING "")
-set(CMake_TEST_FindBLAS_STATIC "Generic" CACHE STRING "")
+set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "")
set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "")
@@ -25,8 +24,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "")
-set(CMake_TEST_FindLAPACK "All" CACHE STRING "")
-set(CMake_TEST_FindLAPACK_STATIC "Generic" CACHE STRING "")
+set(CMake_TEST_FindLAPACK "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "")
set(CMake_TEST_FindLibinput "ON" CACHE BOOL "")
set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake
index 10d0997..d50ab1f 100644
--- a/.gitlab/ci/configure_debian10_ninja.cmake
+++ b/.gitlab/ci/configure_debian10_ninja.cmake
@@ -1,6 +1,5 @@
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
-set(CMake_TEST_FindBLAS "All" CACHE STRING "")
-set(CMake_TEST_FindBLAS_STATIC "Generic" CACHE STRING "")
+set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "")
set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "")
@@ -25,8 +24,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "")
-set(CMake_TEST_FindLAPACK "All" CACHE STRING "")
-set(CMake_TEST_FindLAPACK_STATIC "Generic" CACHE STRING "")
+set(CMake_TEST_FindLAPACK "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "")
set(CMake_TEST_FindLibinput "ON" CACHE BOOL "")
set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_fedora34_makefiles.cmake b/.gitlab/ci/configure_fedora34_makefiles.cmake
index d4bdb6a..a482378 100644
--- a/.gitlab/ci/configure_fedora34_makefiles.cmake
+++ b/.gitlab/ci/configure_fedora34_makefiles.cmake
@@ -1,6 +1,5 @@
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
-set(CMake_TEST_FindBLAS "All" CACHE STRING "")
-set(CMake_TEST_FindBLAS_STATIC "Generic" CACHE STRING "")
+set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "")
set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "")
@@ -25,8 +24,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "")
-set(CMake_TEST_FindLAPACK "All" CACHE STRING "")
-set(CMake_TEST_FindLAPACK_STATIC "Generic" CACHE STRING "")
+set(CMake_TEST_FindLAPACK "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "")
set(CMake_TEST_FindLibinput "ON" CACHE BOOL "")
set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_intelcompiler_common.cmake b/.gitlab/ci/configure_intelcompiler_common.cmake
index be175e4..2698f88 100644
--- a/.gitlab/ci/configure_intelcompiler_common.cmake
+++ b/.gitlab/ci/configure_intelcompiler_common.cmake
@@ -1,10 +1,9 @@
-set(CMake_TEST_FindBLAS "All;Intel10_64lp;Intel10_64lp.gcc" CACHE STRING "")
-set(CMake_TEST_FindBLAS_All "Intel10_64lp" CACHE STRING "")
-set(CMake_TEST_FindBLAS_STATIC "All;Intel10_64lp;Intel10_64lp.gcc" CACHE STRING "")
-set(CMake_TEST_FindBLAS_STATIC_All "Intel10_64lp" CACHE STRING "")
-set(CMake_TEST_FindLAPACK "All;Intel10_64lp;Intel10_64lp.gcc" CACHE STRING "")
-set(CMake_TEST_FindLAPACK_All "Intel10_64lp" CACHE STRING "")
-set(CMake_TEST_FindLAPACK_STATIC "All;Intel10_64lp;Intel10_64lp.gcc" CACHE STRING "")
-set(CMake_TEST_FindLAPACK_STATIC_All "Intel10_64lp" CACHE STRING "")
+set(blas_lapack_cases
+ all=Intel10_64lp
+ static=0 All Intel10_64lp compiler=gcc Intel10_64lp compiler=
+ static=1 All Intel10_64lp compiler=gcc Intel10_64lp compiler=
+ )
+set(CMake_TEST_FindBLAS "${blas_lapack_cases}" CACHE STRING "")
+set(CMake_TEST_FindLAPACK "${blas_lapack_cases}" CACHE STRING "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/Tests/FindBLAS/CMakeLists.txt b/Tests/FindBLAS/CMakeLists.txt
index 482cee8..00b254d 100644
--- a/Tests/FindBLAS/CMakeLists.txt
+++ b/Tests/FindBLAS/CMakeLists.txt
@@ -1,49 +1,2 @@
-foreach(variant IN LISTS CMake_TEST_FindBLAS)
- if(variant MATCHES "^([^.]+)\\.(.*)$")
- set(vendor "${CMAKE_MATCH_1}")
- set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}")
- else()
- set(vendor "${variant}")
- set(alt_compiler "")
- endif()
- if(vendor STREQUAL "All" AND CMake_TEST_FindBLAS_All)
- set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindBLAS_All}")
- else()
- set(EXPECT_All "")
- endif()
- add_test(NAME FindBLAS.Test_${variant} COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test"
- "${CMake_BINARY_DIR}/Tests/FindBLAS/Test_${variant}"
- ${build_generator_args}
- --build-project TestFindBLAS
- --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor}
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
-endforeach()
-
-foreach(variant IN LISTS CMake_TEST_FindBLAS_STATIC)
- if(variant MATCHES "^([^.]+)\\.(.*)$")
- set(vendor "${CMAKE_MATCH_1}")
- set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}")
- else()
- set(vendor "${variant}")
- set(alt_compiler "")
- endif()
- if(vendor STREQUAL "All" AND CMake_TEST_FindBLAS_STATIC_All)
- set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindBLAS_STATIC_All}")
- else()
- set(EXPECT_All "")
- endif()
- add_test(NAME FindBLAS.Test_${variant}_Static COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test"
- "${CMake_BINARY_DIR}/Tests/FindBLAS/Test_${variant}_Static"
- ${build_generator_args}
- --build-project TestFindBLAS
- --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor} -DBLA_STATIC=ON
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
-endforeach()
+include("${CMake_SOURCE_DIR}/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake")
+add_BLAS_LAPACK_tests(CMake_TEST_FindBLAS)
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()
diff --git a/Tests/FindLAPACK/CMakeLists.txt b/Tests/FindLAPACK/CMakeLists.txt
index 535c7b6..a2470ef 100644
--- a/Tests/FindLAPACK/CMakeLists.txt
+++ b/Tests/FindLAPACK/CMakeLists.txt
@@ -1,49 +1,2 @@
-foreach(variant IN LISTS CMake_TEST_FindLAPACK)
- if(variant MATCHES "^([^.]+)\\.(.*)$")
- set(vendor "${CMAKE_MATCH_1}")
- set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}")
- else()
- set(vendor "${variant}")
- set(alt_compiler "")
- endif()
- if(vendor STREQUAL "All" AND CMake_TEST_FindLAPACK_All)
- set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindLAPACK_All}")
- else()
- set(EXPECT_All "")
- endif()
- add_test(NAME FindLAPACK.Test_${variant} COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test"
- "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test_${variant}"
- ${build_generator_args}
- --build-project TestFindLAPACK
- --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor}
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
-endforeach()
-
-foreach(variant IN LISTS CMake_TEST_FindLAPACK_STATIC)
- if(variant MATCHES "^([^.]+)\\.(.*)$")
- set(vendor "${CMAKE_MATCH_1}")
- set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}")
- else()
- set(vendor "${variant}")
- set(alt_compiler "")
- endif()
- if(vendor STREQUAL "All" AND CMake_TEST_FindLAPACK_STATIC_All)
- set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindLAPACK_STATIC_All}")
- else()
- set(EXPECT_All "")
- endif()
- add_test(NAME FindLAPACK.Test_${variant}_Static COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test"
- "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test_${variant}_Static"
- ${build_generator_args}
- --build-project TestFindLAPACK
- --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor} -DBLA_STATIC=ON
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
-endforeach()
+include("${CMake_SOURCE_DIR}/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake")
+add_BLAS_LAPACK_tests(CMake_TEST_FindLAPACK)