summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-09-29 11:58:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-09-29 11:59:02 (GMT)
commitcadcb6a5f0e1ebaefd74f8c52151e410c57cfa96 (patch)
tree7f8c0b72d3d8e7a01cc06262fa1ef37047503217 /Tests
parentb1ecce8ae7b8aea03b98f11335ca6514b425e7c5 (diff)
parent09b30515247b95358fa9126ce76e35f2d177c241 (diff)
downloadCMake-cadcb6a5f0e1ebaefd74f8c52151e410c57cfa96.zip
CMake-cadcb6a5f0e1ebaefd74f8c52151e410c57cfa96.tar.gz
CMake-cadcb6a5f0e1ebaefd74f8c52151e410c57cfa96.tar.bz2
Merge topic 'try_compile-no-cache'
09b3051524 try_compile: Add NO_CACHE option (also try_run) Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7723
Diffstat (limited to 'Tests')
-rw-r--r--Tests/TryCompile/old_and_new_signature_tests.cmake52
1 files changed, 52 insertions, 0 deletions
diff --git a/Tests/TryCompile/old_and_new_signature_tests.cmake b/Tests/TryCompile/old_and_new_signature_tests.cmake
index 997a5a3..ab548f7 100644
--- a/Tests/TryCompile/old_and_new_signature_tests.cmake
+++ b/Tests/TryCompile/old_and_new_signature_tests.cmake
@@ -140,6 +140,28 @@ if(APPLE)
EXPECT_FAIL(SHOULD_FAIL "${TRY_OUT}")
endif()
+# check that try_compile honors NO_CACHE
+function(try_compile_scope_test)
+ try_compile(
+ CACHED_RESULT
+ ${try_compile_bindir_or_SOURCES}
+ ${TryCompile_SOURCE_DIR}/pass.c)
+ try_compile(
+ SHOULD_NOT_ESCAPE_SCOPE_RESULT
+ ${try_compile_bindir_or_SOURCES}
+ ${TryCompile_SOURCE_DIR}/pass.c
+ NO_CACHE)
+endfunction()
+
+try_compile_scope_test()
+
+if(NOT DEFINED CACHE{CACHED_RESULT})
+ message(SEND_ERROR " Result from try_compile was not cached")
+endif()
+if(DEFINED SHOULD_NOT_ESCAPE_SCOPE_RESULT)
+ message(SEND_ERROR " Result from try_compile(NO_CACHE) leaked")
+endif()
+
######################################
# now test try_run()
@@ -222,3 +244,33 @@ endif()
if(NOT "${RUN_OUTPUT_STDERR}" MATCHES "error")
message(SEND_ERROR " RUN_OUTPUT_STDERR didn't contain \"error\": \"${RUN_OUTPUT_STDERR}\"")
endif()
+
+# check that try_run honors NO_CACHE
+function(try_run_scope_test)
+ try_run(
+ CACHED_RUN_RESULT
+ CACHED_COMPILE_RESULT
+ ${try_compile_bindir_or_SOURCES}
+ ${TryCompile_SOURCE_DIR}/exit_success.c)
+ try_run(
+ SHOULD_NOT_ESCAPE_SCOPE_RUN_RESULT
+ SHOULD_NOT_ESCAPE_SCOPE_COMPILE_RESULT
+ ${try_compile_bindir_or_SOURCES}
+ ${TryCompile_SOURCE_DIR}/exit_success.c
+ NO_CACHE)
+endfunction()
+
+try_run_scope_test()
+
+if(NOT DEFINED CACHE{CACHED_COMPILE_RESULT})
+ message(SEND_ERROR " Compile result from try_run was not cached")
+endif()
+if(NOT DEFINED CACHE{CACHED_RUN_RESULT})
+ message(SEND_ERROR " Run result from try_run was not cached")
+endif()
+if(DEFINED SHOULD_NOT_ESCAPE_SCOPE_COMPILE_RESULT)
+ message(SEND_ERROR " Compile result from try_run(NO_CACHE) leaked")
+endif()
+if(DEFINED SHOULD_NOT_ESCAPE_SCOPE_RUN_RESULT)
+ message(SEND_ERROR " Run result from try_run(NO_CACHE) leaked")
+endif()