summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorCharles Barto <chbarto@microsoft.com>2019-11-13 01:17:17 (GMT)
committerBrad King <brad.king@kitware.com>2019-11-19 19:39:00 (GMT)
commit5e9ecaae0e191aba8b02243cb94a68983d6ce3f0 (patch)
treefcc019812b0735542892afe2ae611375f056c893 /Tests
parent7e62ffc028cbaea17d5dc19d5dd4c2f5fcbfa137 (diff)
downloadCMake-5e9ecaae0e191aba8b02243cb94a68983d6ce3f0.zip
CMake-5e9ecaae0e191aba8b02243cb94a68983d6ce3f0.tar.gz
CMake-5e9ecaae0e191aba8b02243cb94a68983d6ce3f0.tar.bz2
load_cache: Allow READ_WITH_PREFIX mode in cmake scripts
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/load_cache/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/load_cache/NewForm_Project.cmake16
-rw-r--r--Tests/RunCMake/load_cache/NewForm_Script.cmake16
-rw-r--r--Tests/RunCMake/load_cache/OldForm_Script-result.txt1
-rw-r--r--Tests/RunCMake/load_cache/OldForm_Script-stderr.txt2
-rw-r--r--Tests/RunCMake/load_cache/OldForm_Script.cmake13
-rw-r--r--Tests/RunCMake/load_cache/RunCMakeTest.cmake13
8 files changed, 65 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1371295..51a3db5 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -279,6 +279,7 @@ add_RunCMake_test(include)
add_RunCMake_test(include_directories)
add_RunCMake_test(include_guard)
add_RunCMake_test(list)
+add_RunCMake_test(load_cache)
add_RunCMake_test(math)
add_RunCMake_test(message)
add_RunCMake_test(option)
diff --git a/Tests/RunCMake/load_cache/CMakeLists.txt b/Tests/RunCMake/load_cache/CMakeLists.txt
new file mode 100644
index 0000000..2632ffa
--- /dev/null
+++ b/Tests/RunCMake/load_cache/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.16)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/load_cache/NewForm_Project.cmake b/Tests/RunCMake/load_cache/NewForm_Project.cmake
new file mode 100644
index 0000000..13a450b
--- /dev/null
+++ b/Tests/RunCMake/load_cache/NewForm_Project.cmake
@@ -0,0 +1,16 @@
+load_cache(${CMAKE_CURRENT_BINARY_DIR}/../test_project READ_WITH_PREFIX LOAD_CACHE_TEST_
+ CACHE_STRING
+ CACHE_BOOL
+ CACHE_INTERNAL)
+
+if(NOT LOAD_CACHE_TEST_CACHE_STRING STREQUAL "cache string")
+ message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"")
+endif()
+
+if(NOT LOAD_CACHE_TEST_CACHE_BOOL)
+ message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON")
+endif()
+
+if(NOT LOAD_CACHE_TEST_CACHE_INTERNAL STREQUAL "cache internal")
+ message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"")
+endif()
diff --git a/Tests/RunCMake/load_cache/NewForm_Script.cmake b/Tests/RunCMake/load_cache/NewForm_Script.cmake
new file mode 100644
index 0000000..f3cee92
--- /dev/null
+++ b/Tests/RunCMake/load_cache/NewForm_Script.cmake
@@ -0,0 +1,16 @@
+load_cache(${RunCMake_BINARY_DIR}/test_project READ_WITH_PREFIX LOAD_CACHE_TEST_
+ CACHE_STRING
+ CACHE_BOOL
+ CACHE_INTERNAL)
+
+if(NOT LOAD_CACHE_TEST_CACHE_STRING STREQUAL "cache string")
+ message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"")
+endif()
+
+if(NOT LOAD_CACHE_TEST_CACHE_BOOL)
+ message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON")
+endif()
+
+if(NOT LOAD_CACHE_TEST_CACHE_INTERNAL STREQUAL "cache internal")
+ message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"")
+endif()
diff --git a/Tests/RunCMake/load_cache/OldForm_Script-result.txt b/Tests/RunCMake/load_cache/OldForm_Script-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/load_cache/OldForm_Script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt b/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt
new file mode 100644
index 0000000..9ad5c80
--- /dev/null
+++ b/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at.*/Tests/RunCMake/load_cache/OldForm_Script.cmake:1 \(load_cache\):
+ load_cache Only load_cache\(READ_WITH_PREFIX\) may be used in script mode$
diff --git a/Tests/RunCMake/load_cache/OldForm_Script.cmake b/Tests/RunCMake/load_cache/OldForm_Script.cmake
new file mode 100644
index 0000000..9560f61
--- /dev/null
+++ b/Tests/RunCMake/load_cache/OldForm_Script.cmake
@@ -0,0 +1,13 @@
+load_cache(${RunCMake_BINARY_DIR}/test_project INCLUDE_INTERNALS CACHE_INTERNAL)
+
+if(NOT CACHE_STRING STREQUAL "cache string")
+ message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"")
+endif()
+
+if(NOT CACHE_BOOL)
+ message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON")
+endif()
+
+if(NOT CACHE_INTERNAL STREQUAL "cache internal")
+ message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"")
+endif()
diff --git a/Tests/RunCMake/load_cache/RunCMakeTest.cmake b/Tests/RunCMake/load_cache/RunCMakeTest.cmake
new file mode 100644
index 0000000..a0d54ea
--- /dev/null
+++ b/Tests/RunCMake/load_cache/RunCMakeTest.cmake
@@ -0,0 +1,13 @@
+include(RunCMake)
+
+file(WRITE ${RunCMake_BINARY_DIR}/test_project/CMakeCache.txt [[
+CACHE_STRING:STRING=cache string
+CACHE_BOOL:BOOL=ON
+CACHE_INTERNAL:INTERNAL=cache internal
+]])
+
+run_cmake(NewForm_Project)
+run_cmake_command(NewForm_Script ${CMAKE_COMMAND} -DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR}
+ -P "${RunCMake_SOURCE_DIR}/NewForm_Script.cmake")
+run_cmake_command(OldForm_Script ${CMAKE_COMMAND} -DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR}
+ -P "${RunCMake_SOURCE_DIR}/OldForm_Script.cmake")