summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-12 16:04:16 (GMT)
committerBrad King <brad.king@kitware.com>2023-01-12 16:04:16 (GMT)
commit2f85ec0a37d1ad75956dd81016a8c7ab90ff845b (patch)
tree013175e4c246fa8d1097c15ddc091d814b320bcc /Tests
parent6b92224f6c8758e5e84b1425273f4abf3b278f54 (diff)
downloadCMake-2f85ec0a37d1ad75956dd81016a8c7ab90ff845b.zip
CMake-2f85ec0a37d1ad75956dd81016a8c7ab90ff845b.tar.gz
CMake-2f85ec0a37d1ad75956dd81016a8c7ab90ff845b.tar.bz2
try_run: Avoid crash in keyword-dispatched signature when cross-compiling
Since commit aa9220d3a0 (try_compile: Add keyword-dispatched signature, 2022-09-02, v3.25.0-rc1~178^2) the `DoNotRunExecutable` code path may be reached with no single source-file argument. Do not assume it exists. Fixes: #24295
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/try_run/CrossCompile.cmake8
-rw-r--r--Tests/RunCMake/try_run/old_and_new_signature_tests.cmake2
2 files changed, 10 insertions, 0 deletions
diff --git a/Tests/RunCMake/try_run/CrossCompile.cmake b/Tests/RunCMake/try_run/CrossCompile.cmake
new file mode 100644
index 0000000..4993768
--- /dev/null
+++ b/Tests/RunCMake/try_run/CrossCompile.cmake
@@ -0,0 +1,8 @@
+include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS})
+
+# Pretend we are cross-compiling to take that try_run code path.
+set(CMAKE_CROSSCOMPILING 1)
+set(RUN_RESULT 0)
+try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src.c)
+unset(CMAKE_CROSSCOMPILING)
diff --git a/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake b/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake
index e1c1784..2b51eb2 100644
--- a/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake
+++ b/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake
@@ -11,6 +11,8 @@ run_cmake(BadLinkLibraries)
run_cmake(BinDirEmpty)
run_cmake(BinDirRelative)
+run_cmake(CrossCompile)
+
run_cmake(WorkingDirArg)
run_cmake(NoCompileOutputVariable)