diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Source/cmCMakeCommand.cxx | 47 | ||||
-rw-r--r-- | Source/cmCMakeCommand.h | 20 | ||||
-rw-r--r-- | Source/cmCommands.cxx | 2 |
4 files changed, 71 insertions, 0 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index c57f713..24370aa 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -484,6 +484,8 @@ set(SRCS cmBuildCommand.h cmBuildNameCommand.cxx cmBuildNameCommand.h + cmCMakeCommand.cxx + cmCMakeCommand.h cmCMakeHostSystemInformationCommand.cxx cmCMakeHostSystemInformationCommand.h cmCMakeMinimumRequired.cxx diff --git a/Source/cmCMakeCommand.cxx b/Source/cmCMakeCommand.cxx new file mode 100644 index 0000000..5699086 --- /dev/null +++ b/Source/cmCMakeCommand.cxx @@ -0,0 +1,47 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCMakeCommand.h" + +#include <cstddef> + +#include "cmExecutionStatus.h" +#include "cmListFileCache.h" +#include "cmMakefile.h" + +bool cmCMakeCommand(std::vector<std::string> const& args, + cmExecutionStatus& status) +{ + if (args.empty()) { + status.SetError("called with incorrect number of arguments"); + return false; + } + + cmMakefile& makefile = status.GetMakefile(); + cmListFileContext context = makefile.GetExecutionContext(); + + if (args[0] == "INVOKE") { + if (args.size() == 1) { + status.SetError("called with incorrect number of arguments"); + return false; + } + + // First argument is the name of the function to call + cmListFileFunction func; + func.Name = args[1]; + func.Line = context.Line; + + // The rest of the arguments are passed to the function call above + func.Arguments.resize(args.size() - 1); + for (size_t i = 2; i < args.size(); ++i) { + cmListFileArgument lfarg; + lfarg.Line = context.Line; + lfarg.Value = args[i]; + func.Arguments.emplace_back(lfarg); + } + + return makefile.ExecuteCommand(func, status); + } + + status.SetError("called with unknown meta-operation"); + return false; +} diff --git a/Source/cmCMakeCommand.h b/Source/cmCMakeCommand.h new file mode 100644 index 0000000..cf9f4c3 --- /dev/null +++ b/Source/cmCMakeCommand.h @@ -0,0 +1,20 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCMakeCommand_h +#define cmCMakeCommand_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <string> +#include <vector> + +class cmExecutionStatus; + +/** + * \brief Calls a scripted or build-in command + * + */ +bool cmCMakeCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); + +#endif diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 896b6a9..28b4267 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -91,6 +91,7 @@ # include "cmAddLinkOptionsCommand.h" # include "cmAuxSourceDirectoryCommand.h" # include "cmBuildNameCommand.h" +# include "cmCMakeCommand.h" # include "cmCMakeHostSystemInformationCommand.h" # include "cmExportCommand.h" # include "cmExportLibraryDependenciesCommand.h" @@ -196,6 +197,7 @@ void GetScriptingCommands(cmState* state) "match the opening WHILE command."); #if !defined(CMAKE_BOOTSTRAP) + state->AddBuiltinCommand("cmake_command", cmCMakeCommand); state->AddBuiltinCommand("cmake_host_system_information", cmCMakeHostSystemInformationCommand); state->AddBuiltinCommand("load_cache", cmLoadCacheCommand); |