mirror of
https://github.com/reactos/CMake.git
synced 2025-01-31 08:52:21 +00:00
load_cache: Allow READ_WITH_PREFIX mode in cmake scripts
This commit is contained in:
parent
7e62ffc028
commit
5e9ecaae0e
5
Help/release/dev/load_cache-script-mode.rst
Normal file
5
Help/release/dev/load_cache-script-mode.rst
Normal file
@ -0,0 +1,5 @@
|
||||
load_cache-script-mode
|
||||
----------------------
|
||||
|
||||
* The :command:`load_cache(READ_WITH_PREFIX)` command mode is now allowed
|
||||
when using ``cmake -P`` to :ref:`Run a Script <Script Processing Mode>`.
|
@ -198,6 +198,7 @@ void GetScriptingCommands(cmState* state)
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
state->AddBuiltinCommand("cmake_host_system_information",
|
||||
cmCMakeHostSystemInformationCommand);
|
||||
state->AddBuiltinCommand("load_cache", cmLoadCacheCommand);
|
||||
state->AddBuiltinCommand("remove", cmRemoveCommand);
|
||||
state->AddBuiltinCommand("variable_watch", cmVariableWatchCommand);
|
||||
state->AddBuiltinCommand("write_file", cmWriteFileCommand);
|
||||
@ -279,7 +280,6 @@ void GetProjectCommands(cmState* state)
|
||||
state->AddBuiltinCommand("target_link_options", cmTargetLinkOptionsCommand);
|
||||
state->AddBuiltinCommand("target_link_directories",
|
||||
cmTargetLinkDirectoriesCommand);
|
||||
state->AddBuiltinCommand("load_cache", cmLoadCacheCommand);
|
||||
state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand);
|
||||
state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand);
|
||||
state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand);
|
||||
@ -339,7 +339,6 @@ void GetProjectCommandsInScriptMode(cmState* state)
|
||||
CM_UNEXPECTED_PROJECT_COMMAND("install");
|
||||
CM_UNEXPECTED_PROJECT_COMMAND("link_directories");
|
||||
CM_UNEXPECTED_PROJECT_COMMAND("link_libraries");
|
||||
CM_UNEXPECTED_PROJECT_COMMAND("load_cache");
|
||||
CM_UNEXPECTED_PROJECT_COMMAND("project");
|
||||
CM_UNEXPECTED_PROJECT_COMMAND("qt_wrap_cpp");
|
||||
CM_UNEXPECTED_PROJECT_COMMAND("qt_wrap_ui");
|
||||
|
@ -24,12 +24,20 @@ bool cmLoadCacheCommand(std::vector<std::string> const& args,
|
||||
{
|
||||
if (args.empty()) {
|
||||
status.SetError("called with wrong number of arguments.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.size() >= 2 && args[1] == "READ_WITH_PREFIX") {
|
||||
return ReadWithPrefix(args, status);
|
||||
}
|
||||
|
||||
if (status.GetMakefile().GetCMakeInstance()->GetWorkingMode() ==
|
||||
cmake::SCRIPT_MODE) {
|
||||
status.SetError(
|
||||
"Only load_cache(READ_WITH_PREFIX) may be used in script mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cache entries to be excluded from the import list.
|
||||
// If this set is empty, all cache entries are brought in
|
||||
// and they can not be overridden.
|
||||
|
@ -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)
|
||||
|
3
Tests/RunCMake/load_cache/CMakeLists.txt
Normal file
3
Tests/RunCMake/load_cache/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
16
Tests/RunCMake/load_cache/NewForm_Project.cmake
Normal file
16
Tests/RunCMake/load_cache/NewForm_Project.cmake
Normal file
@ -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()
|
16
Tests/RunCMake/load_cache/NewForm_Script.cmake
Normal file
16
Tests/RunCMake/load_cache/NewForm_Script.cmake
Normal file
@ -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()
|
1
Tests/RunCMake/load_cache/OldForm_Script-result.txt
Normal file
1
Tests/RunCMake/load_cache/OldForm_Script-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
2
Tests/RunCMake/load_cache/OldForm_Script-stderr.txt
Normal file
2
Tests/RunCMake/load_cache/OldForm_Script-stderr.txt
Normal file
@ -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$
|
13
Tests/RunCMake/load_cache/OldForm_Script.cmake
Normal file
13
Tests/RunCMake/load_cache/OldForm_Script.cmake
Normal file
@ -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()
|
13
Tests/RunCMake/load_cache/RunCMakeTest.cmake
Normal file
13
Tests/RunCMake/load_cache/RunCMakeTest.cmake
Normal file
@ -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")
|
Loading…
x
Reference in New Issue
Block a user