diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-07-17 15:05:38 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-07-17 19:19:58 (GMT) |
commit | 1ca82e7a04b16159721c44385c3b5b8a2762f735 (patch) | |
tree | de3f9e03c95980f2cba241faf0cbee8f0fd6981d /Source/cmCMakeLanguageCommand.cxx | |
parent | 051cea7b7ecb2dd84199407165843006765588cf (diff) | |
download | CMake-1ca82e7a04b16159721c44385c3b5b8a2762f735.zip CMake-1ca82e7a04b16159721c44385c3b5b8a2762f735.tar.gz CMake-1ca82e7a04b16159721c44385c3b5b8a2762f735.tar.bz2 |
cmake_language(): Add undocumented GET_EXPERIMENTAL_FEATURE_ENABLED mode
Diffstat (limited to 'Source/cmCMakeLanguageCommand.cxx')
-rw-r--r-- | Source/cmCMakeLanguageCommand.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Source/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx index c7e9209..d65543a 100644 --- a/Source/cmCMakeLanguageCommand.cxx +++ b/Source/cmCMakeLanguageCommand.cxx @@ -17,6 +17,7 @@ #include "cmArgumentParserTypes.h" #include "cmDependencyProvider.h" #include "cmExecutionStatus.h" +#include "cmExperimental.h" #include "cmGlobalGenerator.h" #include "cmListFileCache.h" #include "cmMakefile.h" @@ -328,6 +329,46 @@ bool cmCMakeLanguageCommandGET_MESSAGE_LOG_LEVEL( makefile.AddDefinition(outputVariable, outputValue); return true; } + +bool cmCMakeLanguageCommandGET_EXPERIMENTAL_FEATURE_ENABLED( + std::vector<cmListFileArgument> const& args, cmExecutionStatus& status) +{ + cmMakefile& makefile = status.GetMakefile(); + std::vector<std::string> expandedArgs; + makefile.ExpandArguments(args, expandedArgs); + + if (expandedArgs.size() != 3) { + return FatalError(status, + "sub-command GET_EXPERIMENTAL_FEATURE_ENABLED expects " + "exactly two arguments"); + } + + auto const& featureName = expandedArgs[1]; + auto const& variableName = expandedArgs[2]; + + auto feature = cmExperimental::Feature::Sentinel; + for (std::size_t i = 0; + i < static_cast<std::size_t>(cmExperimental::Feature::Sentinel); i++) { + if (cmExperimental::DataForFeature(static_cast<cmExperimental::Feature>(i)) + .Name == featureName) { + feature = static_cast<cmExperimental::Feature>(i); + break; + } + } + if (feature == cmExperimental::Feature::Sentinel) { + return FatalError(status, + cmStrCat("Experimental feature name \"", featureName, + "\" does not exist.")); + } + + if (cmExperimental::HasSupportEnabled(makefile, feature)) { + makefile.AddDefinition(variableName, "TRUE"); + } else { + makefile.AddDefinition(variableName, "FALSE"); + } + + return true; +} } bool cmCMakeLanguageCommand(std::vector<cmListFileArgument> const& args, @@ -480,5 +521,10 @@ bool cmCMakeLanguageCommand(std::vector<cmListFileArgument> const& args, return cmCMakeLanguageCommandGET_MESSAGE_LOG_LEVEL(args, status); } + if (expArgs[expArg] == "GET_EXPERIMENTAL_FEATURE_ENABLED") { + return cmCMakeLanguageCommandGET_EXPERIMENTAL_FEATURE_ENABLED(args, + status); + } + return FatalError(status, "called with unknown meta-operation"); } |