cmake/Source/cmGetSourceFilePropertyCommand.cxx

44 lines
1.2 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetSourceFilePropertyCommand.h"
2017-04-14 19:02:05 +02:00
#include "cmMakefile.h"
#include "cmSourceFile.h"
2017-04-14 19:02:05 +02:00
class cmExecutionStatus;
// cmSetSourceFilePropertyCommand
2016-07-09 11:21:54 +02:00
bool cmGetSourceFilePropertyCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
2016-07-09 11:21:54 +02:00
if (args.size() != 3) {
this->SetError("called with incorrect number of arguments");
return false;
2016-07-09 11:21:54 +02:00
}
2017-07-20 19:35:53 +02:00
std::string const& var = args[0];
std::string const& file = args[1];
cmSourceFile* sf = this->Makefile->GetSource(file);
// for the location we must create a source file first
2016-07-09 11:21:54 +02:00
if (!sf && args[2] == "LOCATION") {
2015-04-27 22:25:09 +02:00
sf = this->Makefile->CreateSource(file);
2016-07-09 11:21:54 +02:00
}
if (sf) {
if (args[2] == "LANGUAGE") {
2015-04-27 22:25:09 +02:00
this->Makefile->AddDefinition(var, sf->GetLanguage().c_str());
return true;
2016-07-09 11:21:54 +02:00
}
2018-01-26 17:06:56 +01:00
const char* prop = nullptr;
2016-07-09 11:21:54 +02:00
if (!args[2].empty()) {
2015-11-17 17:22:37 +01:00
prop = sf->GetPropertyForUser(args[2]);
2016-07-09 11:21:54 +02:00
}
if (prop) {
this->Makefile->AddDefinition(var, prop);
return true;
}
2016-07-09 11:21:54 +02:00
}
this->Makefile->AddDefinition(var, "NOTFOUND");
return true;
}