diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2023-11-11 14:35:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-12-01 15:57:15 (GMT) |
commit | 80a64c9ce5ecb00a62a97d86c88fd8db33e73a08 (patch) | |
tree | 8a0552f0c506de998fb654401a13153980eefd54 /Source/cmFileAPICodemodel.cxx | |
parent | 2d0b7798dbaa5625496907a97973087be8db5f53 (diff) | |
download | CMake-80a64c9ce5ecb00a62a97d86c88fd8db33e73a08.zip CMake-80a64c9ce5ecb00a62a97d86c88fd8db33e73a08.tar.gz CMake-80a64c9ce5ecb00a62a97d86c88fd8db33e73a08.tar.bz2 |
fileapi: Add cross-compiling emulator to codemodel-v2
Fixes: #25408
Diffstat (limited to 'Source/cmFileAPICodemodel.cxx')
-rw-r--r-- | Source/cmFileAPICodemodel.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index d069186..a6c3c66 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -41,10 +41,12 @@ #include "cmInstallSubdirectoryGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmLinkLineComputer.h" // IWYU pragma: keep +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceGroup.h" #include "cmState.h" @@ -503,6 +505,8 @@ class Target Json::Value DumpDependencies(); Json::Value DumpDependency(cmTargetDepend const& td); Json::Value DumpFolder(); + Json::Value DumpLauncher(const char* name, const char* type); + Json::Value DumpLaunchers(); public: Target(cmGeneratorTarget* gt, std::string const& config); @@ -1223,6 +1227,13 @@ Json::Value Target::Dump() target["archive"] = this->DumpArchive(); } + if (type == cmStateEnums::EXECUTABLE) { + Json::Value launchers = this->DumpLaunchers(); + if (!launchers.empty()) { + target["launchers"] = std::move(launchers); + } + } + Json::Value dependencies = this->DumpDependencies(); if (!dependencies.empty()) { target["dependencies"] = dependencies; @@ -2075,6 +2086,41 @@ Json::Value Target::DumpFolder() } return folder; } + +Json::Value Target::DumpLauncher(const char* name, const char* type) +{ + cmValue property = this->GT->GetProperty(name); + Json::Value launcher; + if (property) { + cmList commandWithArgs{ *property }; + std::string command(commandWithArgs[0]); + cmSystemTools::ConvertToUnixSlashes(command); + launcher = Json::objectValue; + launcher["command"] = RelativeIfUnder(this->TopSource, command); + launcher["type"] = type; + Json::Value args; + for (std::string const& arg : cmMakeRange(commandWithArgs).advance(1)) { + args.append(arg); + } + launcher["arguments"] = args; + } + return launcher; +} + +Json::Value Target::DumpLaunchers() +{ + Json::Value launchers; + bool allow = + this->GT->Makefile->GetDefinition("CMAKE_CROSSCOMPILING").IsOn(); + Json::Value launcher; + if (allow) { + launcher = DumpLauncher("CROSSCOMPILING_EMULATOR", "emulator"); + if (!launcher.empty()) { + launchers.append(launcher); + } + } + return launchers; +} } Json::Value cmFileAPICodemodelDump(cmFileAPI& fileAPI, unsigned long version) |