diff options
author | Brad King <brad.king@kitware.com> | 2019-11-21 16:02:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-11-21 16:03:09 (GMT) |
commit | ae7d99fbd51e31e012f1434ebe7ba16ea1bef060 (patch) | |
tree | 35c47d28997ef376ea69503d2da6cfca3d30ed6f /Tests | |
parent | d9cf0ec4d4a942aec3360d66855379f7360ab00d (diff) | |
parent | 5e9ecaae0e191aba8b02243cb94a68983d6ce3f0 (diff) | |
download | CMake-ae7d99fbd51e31e012f1434ebe7ba16ea1bef060.zip CMake-ae7d99fbd51e31e012f1434ebe7ba16ea1bef060.tar.gz CMake-ae7d99fbd51e31e012f1434ebe7ba16ea1bef060.tar.bz2 |
Merge topic 'load_cache_in_script'
5e9ecaae0e load_cache: Allow READ_WITH_PREFIX mode in cmake scripts
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4042
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/load_cache/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/load_cache/NewForm_Project.cmake | 16 | ||||
-rw-r--r-- | Tests/RunCMake/load_cache/NewForm_Script.cmake | 16 | ||||
-rw-r--r-- | Tests/RunCMake/load_cache/OldForm_Script-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/load_cache/OldForm_Script-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/load_cache/OldForm_Script.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/load_cache/RunCMakeTest.cmake | 13 |
8 files changed, 65 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e88b29d..1b3577f 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") |