mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
Tests/RunCMake/CompilerChange: Simplify test cases
This commit is contained in:
@@ -1,2 +1 @@
|
||||
message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
|
||||
message(STATUS "CMAKE_C_COMPILER is '${CMAKE_C_COMPILER}'")
|
||||
|
||||
3
Tests/RunCMake/CompilerChange/EmptyCompiler-stdout.txt
Normal file
3
Tests/RunCMake/CompilerChange/EmptyCompiler-stdout.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc2.sh'
|
||||
.*
|
||||
-- CMAKE_C_COMPILER is 'CMAKE_C_COMPILER-NOTFOUND'
|
||||
@@ -1 +1 @@
|
||||
-- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc1.sh"
|
||||
-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc1.sh'
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
enable_language(C)
|
||||
message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
|
||||
message(STATUS "CMAKE_C_COMPILER is '${CMAKE_C_COMPILER}'")
|
||||
|
||||
@@ -25,34 +25,13 @@ set(cc3 CMAKE_C_COMPILER-NOTFOUND)
|
||||
configure_file(${ccIn} ${cc1} @ONLY)
|
||||
configure_file(${ccIn} ${cc2} @ONLY)
|
||||
|
||||
# Use a single build tree for remaining tests without cleaning.
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
|
||||
# Check build with compiler wrapper 1.
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc1})
|
||||
set(ENV{RunCMake_TEST} "FirstCompiler")
|
||||
run_cmake(FirstCompiler)
|
||||
include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
|
||||
if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc1}")
|
||||
message(FATAL_ERROR "FirstCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc1}")
|
||||
endif()
|
||||
|
||||
# Check rebuild with compiler wrapper 2.
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc2})
|
||||
set(ENV{RunCMake_TEST} "SecondCompiler")
|
||||
run_cmake(SecondCompiler)
|
||||
include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
|
||||
if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc2}")
|
||||
message(FATAL_ERROR "SecondCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc2}")
|
||||
endif()
|
||||
|
||||
# Check failure with an empty compiler string.
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=)
|
||||
set(ENV{RunCMake_TEST} "EmptyCompiler")
|
||||
run_cmake(EmptyCompiler)
|
||||
include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
|
||||
if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc3}")
|
||||
message(FATAL_ERROR "Empty built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc3}")
|
||||
endif()
|
||||
block()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build)
|
||||
set(ENV{RunCMake_TEST} "FirstCompiler")
|
||||
run_cmake_with_options(FirstCompiler -DCMAKE_C_COMPILER=${cc1})
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(ENV{RunCMake_TEST} "SecondCompiler")
|
||||
run_cmake_with_options(SecondCompiler -DCMAKE_C_COMPILER=${cc2})
|
||||
set(ENV{RunCMake_TEST} "EmptyCompiler")
|
||||
run_cmake_with_options(EmptyCompiler -DCMAKE_C_COMPILER=)
|
||||
endblock()
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
-- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc2.sh"
|
||||
-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc1.sh'
|
||||
.*
|
||||
-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc2.sh'
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
enable_language(C)
|
||||
message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
|
||||
message(STATUS "CMAKE_C_COMPILER is '${CMAKE_C_COMPILER}'")
|
||||
|
||||
Reference in New Issue
Block a user