diff options
author | Brad King <brad.king@kitware.com> | 2024-09-20 15:13:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-09-20 21:48:07 (GMT) |
commit | 38cacd83a57b6f0e162b04eedc16181185ddcbac (patch) | |
tree | 0e2ff594fbe5637baa3bb2f698ee37825e3f8722 | |
parent | 37173f1cccc14b71f9e6d1bbc2bb3a68f041d542 (diff) | |
download | CMake-38cacd83a57b6f0e162b04eedc16181185ddcbac.zip CMake-38cacd83a57b6f0e162b04eedc16181185ddcbac.tar.gz CMake-38cacd83a57b6f0e162b04eedc16181185ddcbac.tar.bz2 |
Tests: Migrate compiler id tests to RunCMake infrastructure
29 files changed, 97 insertions, 144 deletions
diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 727c7fc..4ceb768 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -35,29 +35,11 @@ endif() add_CMakeOnly_test(CheckStructHasMember) -add_CMakeOnly_test(CompilerIdC) -add_CMakeOnly_test(CompilerIdCXX) - if (APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") - add_CMakeOnly_test(CompilerIdOBJC) add_CMakeOnly_test(CheckOBJCCompilerFlag) - add_CMakeOnly_test(CompilerIdOBJCXX) add_CMakeOnly_test(CheckOBJCXXCompilerFlag) endif() -if(CMake_TEST_CUDA) - add_CMakeOnly_test(CompilerIdCUDA) -endif() - - -if(CMAKE_Fortran_COMPILER) - add_CMakeOnly_test(CompilerIdFortran) - set_property(TEST CMakeOnly.CompilerIdFortran APPEND PROPERTY LABELS "Fortran") -endif() -if(CMAKE_GENERATOR MATCHES "Visual Studio") - add_CMakeOnly_test(CompilerIdCSharp) -endif() - add_test(CMakeOnly.AllFindModules ${CMAKE_CMAKE_COMMAND} -DTEST=AllFindModules -DCMAKE_ARGS=-DCMake_TEST_CMakeOnly.AllFindModules_NO_VERSION=${CMake_TEST_CMakeOnly.AllFindModules_NO_VERSION} diff --git a/Tests/CMakeOnly/CompilerIdC/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdC/CMakeLists.txt deleted file mode 100644 index 6fea73e..0000000 --- a/Tests/CMakeOnly/CompilerIdC/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.9) -project(CompilerIdC C) - -foreach(v - CMAKE_C_COMPILER - CMAKE_C_COMPILER_ID - CMAKE_C_COMPILER_VERSION - ) - if(${v}) - message(STATUS "${v}=[${${v}}]") - else() - message(SEND_ERROR "${v} not set!") - endif() -endforeach() - -# Version numbers may only contain numbers and periods. -if(NOT CMAKE_C_COMPILER_VERSION MATCHES - "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$" - ) - message(SEND_ERROR "Compiler version is not numeric!") -endif() diff --git a/Tests/CMakeOnly/CompilerIdCSharp/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdCSharp/CMakeLists.txt deleted file mode 100644 index 6c07037..0000000 --- a/Tests/CMakeOnly/CompilerIdCSharp/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.7.0) -project(CompilerIdCSharp CSharp) - -foreach(v - CMAKE_CSharp_COMPILER - CMAKE_CSharp_COMPILER_ID - CMAKE_CSharp_COMPILER_VERSION - ) - if(${v}) - message(STATUS "${v}=[${${v}}]") - else() - message(SEND_ERROR "${v} not set!") - endif() -endforeach() - -# Version numbers may only contain numbers and periods. -if(NOT CMAKE_CSharp_COMPILER_VERSION MATCHES - "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$" - ) - message(SEND_ERROR "Compiler version is not numeric!") -endif() diff --git a/Tests/CMakeOnly/CompilerIdCUDA/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdCUDA/CMakeLists.txt deleted file mode 100644 index da14000..0000000 --- a/Tests/CMakeOnly/CompilerIdCUDA/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.18) -project(CompilerIdCUDA CUDA) - -foreach(v - CMAKE_CUDA_COMPILER - CMAKE_CUDA_COMPILER_ID - CMAKE_CUDA_COMPILER_VERSION - ) - if(${v}) - message(STATUS "${v}=[${${v}}]") - else() - message(SEND_ERROR "${v} not set!") - endif() -endforeach() diff --git a/Tests/CMakeOnly/CompilerIdCXX/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdCXX/CMakeLists.txt deleted file mode 100644 index 05e6bb2..0000000 --- a/Tests/CMakeOnly/CompilerIdCXX/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.9) -project(CompilerIdCXX CXX) - -foreach(v - CMAKE_CXX_COMPILER - CMAKE_CXX_COMPILER_ID - CMAKE_CXX_COMPILER_VERSION - ) - if(${v}) - message(STATUS "${v}=[${${v}}]") - else() - message(SEND_ERROR "${v} not set!") - endif() -endforeach() - -# Version numbers may only contain numbers and periods. -if(NOT CMAKE_CXX_COMPILER_VERSION MATCHES - "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$" - ) - message(SEND_ERROR "Compiler version is not numeric!") -endif() diff --git a/Tests/CMakeOnly/CompilerIdFortran/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdFortran/CMakeLists.txt deleted file mode 100644 index 067fb8c..0000000 --- a/Tests/CMakeOnly/CompilerIdFortran/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.9) -project(CompilerIdFortran Fortran) - -foreach(v - CMAKE_Fortran_COMPILER - CMAKE_Fortran_COMPILER_ID - CMAKE_Fortran_COMPILER_VERSION - ) - if(${v}) - message(STATUS "${v}=[${${v}}]") - else() - message(SEND_ERROR "${v} not set!") - endif() -endforeach() - -# Version numbers may only contain numbers and periods. -if(NOT CMAKE_Fortran_COMPILER_VERSION MATCHES - "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$" - ) - message(SEND_ERROR "Compiler version is not numeric!") -endif() diff --git a/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt deleted file mode 100644 index 18a1ff6..0000000 --- a/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(CompilerIdOBJC OBJC) - -foreach(v - CMAKE_OBJC_COMPILER - CMAKE_OBJC_COMPILER_ID - CMAKE_OBJC_COMPILER_VERSION - ) - if(${v}) - message(STATUS "${v}=[${${v}}]") - else() - message(SEND_ERROR "${v} not set!") - endif() -endforeach() diff --git a/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt deleted file mode 100644 index 76c1e4b..0000000 --- a/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(CompilerIdOBJCXX OBJCXX) - -foreach(v - CMAKE_OBJCXX_COMPILER - CMAKE_OBJCXX_COMPILER_ID - CMAKE_OBJCXX_COMPILER_VERSION - ) - if(${v}) - message(STATUS "${v}=[${${v}}]") - else() - message(SEND_ERROR "${v} not set!") - endif() -endforeach() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 2e11a32..29351eb 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -389,6 +389,8 @@ foreach(lang IN ITEMS CUDA HIP ISPC) list(APPEND CMake_TEST_LANG_VARS -DCMake_TEST_${lang}=1) endif() endforeach() +add_RunCMake_test(CompilerId ${CMake_TEST_LANG_VARS}) +set_property(TEST RunCMake.CompilerId APPEND PROPERTY LABELS "CUDA" "HIP" "ISPC" "Fortran") add_RunCMake_test(CompilerTest ${CMake_TEST_LANG_VARS}) set_property(TEST RunCMake.CompilerTest APPEND PROPERTY LABELS "CUDA" "HIP" "ISPC" "Fortran") add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE}) diff --git a/Tests/RunCMake/CompilerId/C-stdout.txt b/Tests/RunCMake/CompilerId/C-stdout.txt new file mode 100644 index 0000000..e9ce46b --- /dev/null +++ b/Tests/RunCMake/CompilerId/C-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_C_COMPILER='[^']+' +-- CMAKE_C_COMPILER_ID='[A-Za-z]+' +-- CMAKE_C_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/C.cmake b/Tests/RunCMake/CompilerId/C.cmake new file mode 100644 index 0000000..3bf943f --- /dev/null +++ b/Tests/RunCMake/CompilerId/C.cmake @@ -0,0 +1,4 @@ +enable_language(C) +message(STATUS "CMAKE_C_COMPILER='${CMAKE_C_COMPILER}'") +message(STATUS "CMAKE_C_COMPILER_ID='${CMAKE_C_COMPILER_ID}'") +message(STATUS "CMAKE_C_COMPILER_VERSION='${CMAKE_C_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/CMakeLists.txt b/Tests/RunCMake/CompilerId/CMakeLists.txt new file mode 100644 index 0000000..dda37d8 --- /dev/null +++ b/Tests/RunCMake/CompilerId/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.30) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompilerId/CSharp-stdout.txt b/Tests/RunCMake/CompilerId/CSharp-stdout.txt new file mode 100644 index 0000000..e36df6a --- /dev/null +++ b/Tests/RunCMake/CompilerId/CSharp-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_CSharp_COMPILER='[^']+' +-- CMAKE_CSharp_COMPILER_ID='[A-Za-z ]+' +-- CMAKE_CSharp_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/CSharp.cmake b/Tests/RunCMake/CompilerId/CSharp.cmake new file mode 100644 index 0000000..2ffd41d --- /dev/null +++ b/Tests/RunCMake/CompilerId/CSharp.cmake @@ -0,0 +1,4 @@ +enable_language(CSharp) +message(STATUS "CMAKE_CSharp_COMPILER='${CMAKE_CSharp_COMPILER}'") +message(STATUS "CMAKE_CSharp_COMPILER_ID='${CMAKE_CSharp_COMPILER_ID}'") +message(STATUS "CMAKE_CSharp_COMPILER_VERSION='${CMAKE_CSharp_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/CUDA-stdout.txt b/Tests/RunCMake/CompilerId/CUDA-stdout.txt new file mode 100644 index 0000000..f5387d4 --- /dev/null +++ b/Tests/RunCMake/CompilerId/CUDA-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_CUDA_COMPILER='[^']+' +-- CMAKE_CUDA_COMPILER_ID='[A-Za-z]+' +-- CMAKE_CUDA_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/CUDA.cmake b/Tests/RunCMake/CompilerId/CUDA.cmake new file mode 100644 index 0000000..ae6d57c --- /dev/null +++ b/Tests/RunCMake/CompilerId/CUDA.cmake @@ -0,0 +1,4 @@ +enable_language(CUDA) +message(STATUS "CMAKE_CUDA_COMPILER='${CMAKE_CUDA_COMPILER}'") +message(STATUS "CMAKE_CUDA_COMPILER_ID='${CMAKE_CUDA_COMPILER_ID}'") +message(STATUS "CMAKE_CUDA_COMPILER_VERSION='${CMAKE_CUDA_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/CXX-stdout.txt b/Tests/RunCMake/CompilerId/CXX-stdout.txt new file mode 100644 index 0000000..4062a97 --- /dev/null +++ b/Tests/RunCMake/CompilerId/CXX-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_CXX_COMPILER='[^']+' +-- CMAKE_CXX_COMPILER_ID='[A-Za-z]+' +-- CMAKE_CXX_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/CXX.cmake b/Tests/RunCMake/CompilerId/CXX.cmake new file mode 100644 index 0000000..4d8bd0e --- /dev/null +++ b/Tests/RunCMake/CompilerId/CXX.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +message(STATUS "CMAKE_CXX_COMPILER='${CMAKE_CXX_COMPILER}'") +message(STATUS "CMAKE_CXX_COMPILER_ID='${CMAKE_CXX_COMPILER_ID}'") +message(STATUS "CMAKE_CXX_COMPILER_VERSION='${CMAKE_CXX_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/Fortran-stdout.txt b/Tests/RunCMake/CompilerId/Fortran-stdout.txt new file mode 100644 index 0000000..6a59c66 --- /dev/null +++ b/Tests/RunCMake/CompilerId/Fortran-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_Fortran_COMPILER='[^']+' +-- CMAKE_Fortran_COMPILER_ID='[A-Za-z]+' +-- CMAKE_Fortran_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/Fortran.cmake b/Tests/RunCMake/CompilerId/Fortran.cmake new file mode 100644 index 0000000..d4ed039 --- /dev/null +++ b/Tests/RunCMake/CompilerId/Fortran.cmake @@ -0,0 +1,4 @@ +enable_language(Fortran) +message(STATUS "CMAKE_Fortran_COMPILER='${CMAKE_Fortran_COMPILER}'") +message(STATUS "CMAKE_Fortran_COMPILER_ID='${CMAKE_Fortran_COMPILER_ID}'") +message(STATUS "CMAKE_Fortran_COMPILER_VERSION='${CMAKE_Fortran_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/HIP-stdout.txt b/Tests/RunCMake/CompilerId/HIP-stdout.txt new file mode 100644 index 0000000..d3d71f2 --- /dev/null +++ b/Tests/RunCMake/CompilerId/HIP-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_HIP_COMPILER='[^']+' +-- CMAKE_HIP_COMPILER_ID='[A-Za-z]+' +-- CMAKE_HIP_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/HIP.cmake b/Tests/RunCMake/CompilerId/HIP.cmake new file mode 100644 index 0000000..ae1147d --- /dev/null +++ b/Tests/RunCMake/CompilerId/HIP.cmake @@ -0,0 +1,4 @@ +enable_language(HIP) +message(STATUS "CMAKE_HIP_COMPILER='${CMAKE_HIP_COMPILER}'") +message(STATUS "CMAKE_HIP_COMPILER_ID='${CMAKE_HIP_COMPILER_ID}'") +message(STATUS "CMAKE_HIP_COMPILER_VERSION='${CMAKE_HIP_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/ISPC-stdout.txt b/Tests/RunCMake/CompilerId/ISPC-stdout.txt new file mode 100644 index 0000000..c45ea5a --- /dev/null +++ b/Tests/RunCMake/CompilerId/ISPC-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_ISPC_COMPILER='[^']+' +-- CMAKE_ISPC_COMPILER_ID='[A-Za-z]+' +-- CMAKE_ISPC_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/ISPC.cmake b/Tests/RunCMake/CompilerId/ISPC.cmake new file mode 100644 index 0000000..a022db4 --- /dev/null +++ b/Tests/RunCMake/CompilerId/ISPC.cmake @@ -0,0 +1,4 @@ +enable_language(ISPC) +message(STATUS "CMAKE_ISPC_COMPILER='${CMAKE_ISPC_COMPILER}'") +message(STATUS "CMAKE_ISPC_COMPILER_ID='${CMAKE_ISPC_COMPILER_ID}'") +message(STATUS "CMAKE_ISPC_COMPILER_VERSION='${CMAKE_ISPC_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/OBJC-stdout.txt b/Tests/RunCMake/CompilerId/OBJC-stdout.txt new file mode 100644 index 0000000..528675a --- /dev/null +++ b/Tests/RunCMake/CompilerId/OBJC-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_OBJC_COMPILER='[^']+' +-- CMAKE_OBJC_COMPILER_ID='[A-Za-z]+' +-- CMAKE_OBJC_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/OBJC.cmake b/Tests/RunCMake/CompilerId/OBJC.cmake new file mode 100644 index 0000000..5ae4681 --- /dev/null +++ b/Tests/RunCMake/CompilerId/OBJC.cmake @@ -0,0 +1,4 @@ +enable_language(OBJC) +message(STATUS "CMAKE_OBJC_COMPILER='${CMAKE_OBJC_COMPILER}'") +message(STATUS "CMAKE_OBJC_COMPILER_ID='${CMAKE_OBJC_COMPILER_ID}'") +message(STATUS "CMAKE_OBJC_COMPILER_VERSION='${CMAKE_OBJC_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/OBJCXX-stdout.txt b/Tests/RunCMake/CompilerId/OBJCXX-stdout.txt new file mode 100644 index 0000000..9d7f822 --- /dev/null +++ b/Tests/RunCMake/CompilerId/OBJCXX-stdout.txt @@ -0,0 +1,3 @@ +-- CMAKE_OBJCXX_COMPILER='[^']+' +-- CMAKE_OBJCXX_COMPILER_ID='[A-Za-z]+' +-- CMAKE_OBJCXX_COMPILER_VERSION='([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?' diff --git a/Tests/RunCMake/CompilerId/OBJCXX.cmake b/Tests/RunCMake/CompilerId/OBJCXX.cmake new file mode 100644 index 0000000..0e1875b --- /dev/null +++ b/Tests/RunCMake/CompilerId/OBJCXX.cmake @@ -0,0 +1,4 @@ +enable_language(OBJCXX) +message(STATUS "CMAKE_OBJCXX_COMPILER='${CMAKE_OBJCXX_COMPILER}'") +message(STATUS "CMAKE_OBJCXX_COMPILER_ID='${CMAKE_OBJCXX_COMPILER_ID}'") +message(STATUS "CMAKE_OBJCXX_COMPILER_VERSION='${CMAKE_OBJCXX_COMPILER_VERSION}'") diff --git a/Tests/RunCMake/CompilerId/RunCMakeTest.cmake b/Tests/RunCMake/CompilerId/RunCMakeTest.cmake new file mode 100644 index 0000000..64e397b --- /dev/null +++ b/Tests/RunCMake/CompilerId/RunCMakeTest.cmake @@ -0,0 +1,29 @@ +include(RunCMake) + +run_cmake(C) +run_cmake(CXX) + +if(CMake_TEST_CUDA) + run_cmake(CUDA) +endif() + +if(CMake_TEST_Fortran) + run_cmake(Fortran) +endif() + +if(CMake_TEST_HIP) + run_cmake(HIP) +endif() + +if(CMake_TEST_ISPC) + run_cmake(ISPC) +endif() + +if(CMake_TEST_OBJC) + run_cmake(OBJC) + run_cmake(OBJCXX) +endif() + +if(RunCMake_GENERATOR MATCHES "Visual Studio") + run_cmake(CSharp) +endif() |