mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
CMAKE_TOOLCHAIN_FILE: Account for empty values when detecting changes
Initially empty CMAKE_TOOLCHAIN_FILE values should not result in an include() statement but should be recorded to later detect changes. Fixes: #28231
This commit is contained in:
5 files changed
+24
-3
No files matched your search
@@ -225,12 +225,16 @@ if(CMAKE_BINARY_DIR)
|
||||
# if a toolchain file is used, it needs to be included in the configured file,
|
||||
# so settings done there are also available if they don't go in the cache and in try_compile()
|
||||
set(INCLUDE_CMAKE_TOOLCHAIN_FILE_IF_REQUIRED)
|
||||
if(CMAKE_TOOLCHAIN_FILE)
|
||||
if(DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
string(CONCAT INCLUDE_CMAKE_TOOLCHAIN_FILE_IF_REQUIRED
|
||||
"set(_CMAKE_INPUT_TOOLCHAIN_FILE [==[${_CMAKE_INPUT_TOOLCHAIN_FILE}]==])\n"
|
||||
"set(_CMAKE_SYSTEM_TOOLCHAIN_FILE \"${CMAKE_TOOLCHAIN_FILE}\")\n"
|
||||
"include(\"\${_CMAKE_SYSTEM_TOOLCHAIN_FILE}\")"
|
||||
)
|
||||
if(_INCLUDED_TOOLCHAIN_FILE)
|
||||
string(APPEND INCLUDE_CMAKE_TOOLCHAIN_FILE_IF_REQUIRED
|
||||
"set(_CMAKE_SYSTEM_TOOLCHAIN_FILE \"${CMAKE_TOOLCHAIN_FILE}\")\n"
|
||||
"include(\"\${_CMAKE_SYSTEM_TOOLCHAIN_FILE}\")"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# configure variables set in this file for fast reload, the template file is defined at the top of this file
|
||||
|
||||
@@ -45,6 +45,17 @@ if(UNIX AND "${RunCMake_GENERATOR}" MATCHES "Unix Makefiles|Ninja|FASTBuild")
|
||||
endblock()
|
||||
endif()
|
||||
|
||||
# Running with empty toolchain argument does not trigger reconfigure
|
||||
block()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ToolchainEmpty-build)
|
||||
set(RunCMake-stdout-file
|
||||
${RunCMake_SOURCE_DIR}/ToolchainEmpty-stdout.txt
|
||||
)
|
||||
run_cmake_with_options(ToolchainEmpty-step1 "-DCMAKE_TOOLCHAIN_FILE=")
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake(ToolchainEmpty-step2)
|
||||
endblock()
|
||||
|
||||
# Set up "toolchain" files
|
||||
file(WRITE "${RunCMake_BINARY_DIR}/foo.cmake" "set(toolchain_var foo)\n")
|
||||
file(WRITE "${RunCMake_BINARY_DIR}/bar.cmake" "set(toolchain_var bar)\n")
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Toolchain file: $
|
||||
-- Using toolchain: $
|
||||
@@ -0,0 +1,2 @@
|
||||
message(STATUS "Toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
message(STATUS "Using toolchain: ${toolchain_var}")
|
||||
@@ -0,0 +1,2 @@
|
||||
message(STATUS "Toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
message(STATUS "Using toolchain: ${toolchain_var}")
|
||||
Reference in new issue
Block a user