diff options
author | Craig Scott <craig.scott@crascit.com> | 2023-06-02 07:16:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-06-05 10:20:50 (GMT) |
commit | 99b2ccf80dc87ccf6832508cc3f8889a70c2785f (patch) | |
tree | 6ff990a8878c0e90ee9c5b88ce876f7893e5c882 /Source/cmFileAPI.cxx | |
parent | 9a63aa8d57394fbddf913ce35c2d32bbf523f0e6 (diff) | |
download | CMake-99b2ccf80dc87ccf6832508cc3f8889a70c2785f.zip CMake-99b2ccf80dc87ccf6832508cc3f8889a70c2785f.tar.gz CMake-99b2ccf80dc87ccf6832508cc3f8889a70c2785f.tar.bz2 |
cmake_file_api: New project command
Projects can use the new command to request file API replies for the current
run. No query files are generated, the query is tracked internally. Replies are
created in the file system at generation time in the usual way.
Fixes: #24951
Diffstat (limited to 'Source/cmFileAPI.cxx')
-rw-r--r-- | Source/cmFileAPI.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index 8b98916..8abb5a8 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -978,3 +978,45 @@ Json::Value cmFileAPI::ReportCapabilities() return capabilities; } + +bool cmFileAPI::AddProjectQuery(cmFileAPI::ObjectKind kind, + unsigned majorVersion, unsigned minorVersion) +{ + switch (kind) { + case ObjectKind::CodeModel: + if (majorVersion != 2 || minorVersion > CodeModelV2Minor) { + return false; + } + break; + case ObjectKind::Cache: + if (majorVersion != 2 || minorVersion > CacheV2Minor) { + return false; + } + break; + case ObjectKind::CMakeFiles: + if (majorVersion != 1 || minorVersion > CMakeFilesV1Minor) { + return false; + } + break; + case ObjectKind::Toolchains: + if (majorVersion != 1 || minorVersion > ToolchainsV1Minor) { + return false; + } + break; + // These cannot be requested by the project + case ObjectKind::ConfigureLog: + case ObjectKind::InternalTest: + return false; + } + + Object query; + query.Kind = kind; + query.Version = majorVersion; + if (std::find(this->TopQuery.Known.begin(), this->TopQuery.Known.end(), + query) == this->TopQuery.Known.end()) { + this->TopQuery.Known.emplace_back(query); + this->QueryExists = true; + } + + return true; +} |