mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-08 16:50:48 +00:00
Tests: Enable toolchain parts of RunCMake.CompilerChange on Windows
A regression was missed partially due to this suite's condition. The compiler specific pieces still need this condition because a shell script needs to pretend to be a compiler, but the toolchain parts are platform agnostic. Issue: #28024
This commit is contained in:
@@ -392,9 +392,7 @@ add_RunCMake_test(CMakeRelease -DCMake_TEST_JQ=${CMake_TEST_JQ})
|
||||
if(CMAKE_GENERATOR MATCHES "Make|Ninja")
|
||||
add_RunCMake_test(Color)
|
||||
endif()
|
||||
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja|FASTBuild")
|
||||
add_RunCMake_test(CompilerChange)
|
||||
endif()
|
||||
add_RunCMake_test(CompilerChange)
|
||||
add_RunCMake_test(CompilerNotFound)
|
||||
if(DEFINED CMake_TEST_OBJC)
|
||||
list(APPEND CMake_TEST_LANG_VARS -DCMake_TEST_OBJC=${CMake_TEST_OBJC})
|
||||
|
||||
@@ -1,47 +1,49 @@
|
||||
include(RunCMake)
|
||||
|
||||
# Detect the compiler in use in the current environment.
|
||||
run_cmake(FindCompiler)
|
||||
include(${RunCMake_BINARY_DIR}/FindCompiler-build/cc.cmake)
|
||||
if(NOT CMAKE_C_COMPILER)
|
||||
message(FATAL_ERROR "FindCompiler provided no compiler!")
|
||||
if(UNIX AND "${RunCMake_GENERATOR}" MATCHES "Unix Makefiles|Ninja|FASTBuild")
|
||||
# Detect the compiler in use in the current environment.
|
||||
run_cmake(FindCompiler)
|
||||
include(${RunCMake_BINARY_DIR}/FindCompiler-build/cc.cmake)
|
||||
if(NOT CMAKE_C_COMPILER)
|
||||
message(FATAL_ERROR "FindCompiler provided no compiler!")
|
||||
endif()
|
||||
if(NOT IS_ABSOLUTE "${CMAKE_C_COMPILER}")
|
||||
message(FATAL_ERROR "FindCompiler provided non-absolute path \"${CMAKE_C_COMPILER}\"!")
|
||||
endif()
|
||||
if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
||||
message(FATAL_ERROR "FindCompiler provided non-existing path \"${CMAKE_C_COMPILER}\"!")
|
||||
endif()
|
||||
|
||||
# Now that we have the full compiler path, hide CC.
|
||||
unset(ENV{CC})
|
||||
|
||||
# Wrap around the real compiler so we can change the compiler
|
||||
# path without changing the underlying compiler.
|
||||
set(ccIn ${RunCMake_SOURCE_DIR}/cc.sh.in)
|
||||
set(cc1 ${RunCMake_BINARY_DIR}/cc1.sh)
|
||||
set(cc2 ${RunCMake_BINARY_DIR}/cc2.sh)
|
||||
set(cc3 CMAKE_C_COMPILER-NOTFOUND)
|
||||
configure_file(${ccIn} ${cc1} @ONLY)
|
||||
configure_file(${ccIn} ${cc2} @ONLY)
|
||||
|
||||
block()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build)
|
||||
run_cmake_with_options(FirstCompiler -DCMAKE_C_COMPILER=${cc1})
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake_with_options(SecondCompiler -DCMAKE_C_COMPILER=${cc2})
|
||||
run_cmake_with_options(EmptyCompiler -DCMAKE_C_COMPILER=)
|
||||
endblock()
|
||||
|
||||
block()
|
||||
set(cc1_dot ${RunCMake_BINARY_DIR}/./cc1.sh)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CompilerPath-build)
|
||||
set(RunCMake_TEST_VARIANT_DESCRIPTION "-step1")
|
||||
run_cmake_with_options(CompilerPath "-DCMAKE_C_COMPILER=${cc1_dot}" -DCACHE_ENTRY=cached)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_VARIANT_DESCRIPTION "-step2")
|
||||
run_cmake_with_options(CompilerPath "-DCMAKE_C_COMPILER=${cc1_dot}")
|
||||
endblock()
|
||||
endif()
|
||||
if(NOT IS_ABSOLUTE "${CMAKE_C_COMPILER}")
|
||||
message(FATAL_ERROR "FindCompiler provided non-absolute path \"${CMAKE_C_COMPILER}\"!")
|
||||
endif()
|
||||
if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
||||
message(FATAL_ERROR "FindCompiler provided non-existing path \"${CMAKE_C_COMPILER}\"!")
|
||||
endif()
|
||||
|
||||
# Now that we have the full compiler path, hide CC.
|
||||
unset(ENV{CC})
|
||||
|
||||
# Wrap around the real compiler so we can change the compiler
|
||||
# path without changing the underlying compiler.
|
||||
set(ccIn ${RunCMake_SOURCE_DIR}/cc.sh.in)
|
||||
set(cc1 ${RunCMake_BINARY_DIR}/cc1.sh)
|
||||
set(cc2 ${RunCMake_BINARY_DIR}/cc2.sh)
|
||||
set(cc3 CMAKE_C_COMPILER-NOTFOUND)
|
||||
configure_file(${ccIn} ${cc1} @ONLY)
|
||||
configure_file(${ccIn} ${cc2} @ONLY)
|
||||
|
||||
block()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build)
|
||||
run_cmake_with_options(FirstCompiler -DCMAKE_C_COMPILER=${cc1})
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake_with_options(SecondCompiler -DCMAKE_C_COMPILER=${cc2})
|
||||
run_cmake_with_options(EmptyCompiler -DCMAKE_C_COMPILER=)
|
||||
endblock()
|
||||
|
||||
block()
|
||||
set(cc1_dot ${RunCMake_BINARY_DIR}/./cc1.sh)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CompilerPath-build)
|
||||
set(RunCMake_TEST_VARIANT_DESCRIPTION "-step1")
|
||||
run_cmake_with_options(CompilerPath "-DCMAKE_C_COMPILER=${cc1_dot}" -DCACHE_ENTRY=cached)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_VARIANT_DESCRIPTION "-step2")
|
||||
run_cmake_with_options(CompilerPath "-DCMAKE_C_COMPILER=${cc1_dot}")
|
||||
endblock()
|
||||
|
||||
# Set up "toolchain" files
|
||||
file(WRITE "${RunCMake_BINARY_DIR}/foo.cmake" "set(toolchain_var foo)\n")
|
||||
|
||||
Reference in New Issue
Block a user