mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 20:46:37 +08:00
Autogen: Read skip files from makefile
This allows to pass SKIP_AUTOMOC hints to the FOO_autogen target from files that are not listed in the target sources. The problem was that if main.cpp was listed in the source but not main.h, then SKIP_AUTOMOC for main.h was ignored.
This commit is contained in:
@@ -194,6 +194,13 @@ static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
|
|||||||
key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
|
key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
|
||||||
|
const std::set<std::string>& values)
|
||||||
|
{
|
||||||
|
makefile->AddDefinition(
|
||||||
|
key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName,
|
static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName,
|
||||||
cmQtAutoGeneratorCommon::GeneratorType genType)
|
cmQtAutoGeneratorCommon::GeneratorType genType)
|
||||||
{
|
{
|
||||||
@@ -275,8 +282,8 @@ struct AutogenSetup
|
|||||||
std::vector<std::string> sources;
|
std::vector<std::string> sources;
|
||||||
std::vector<std::string> headers;
|
std::vector<std::string> headers;
|
||||||
|
|
||||||
std::vector<std::string> mocSkip;
|
std::set<std::string> mocSkip;
|
||||||
std::vector<std::string> uicSkip;
|
std::set<std::string> uicSkip;
|
||||||
|
|
||||||
std::map<std::string, std::string> configSuffix;
|
std::map<std::string, std::string> configSuffix;
|
||||||
std::map<std::string, std::string> configMocIncludes;
|
std::map<std::string, std::string> configMocIncludes;
|
||||||
@@ -289,9 +296,40 @@ static void SetupAcquireScanFiles(cmGeneratorTarget const* target,
|
|||||||
const std::vector<cmSourceFile*>& srcFiles,
|
const std::vector<cmSourceFile*>& srcFiles,
|
||||||
AutogenSetup& setup)
|
AutogenSetup& setup)
|
||||||
{
|
{
|
||||||
|
// Read skip files from makefile sources
|
||||||
|
{
|
||||||
|
const std::vector<cmSourceFile*>& allSources =
|
||||||
|
target->Makefile->GetSourceFiles();
|
||||||
|
for (std::vector<cmSourceFile*>::const_iterator fit = allSources.begin();
|
||||||
|
fit != allSources.end(); ++fit) {
|
||||||
|
cmSourceFile* sf = *fit;
|
||||||
|
// sf->GetExtension() is only valid after sf->GetFullPath() ...
|
||||||
|
const std::string& fPath = sf->GetFullPath();
|
||||||
|
const cmSystemTools::FileFormat fileType =
|
||||||
|
cmSystemTools::GetFileFormat(sf->GetExtension().c_str());
|
||||||
|
if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) &&
|
||||||
|
!(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const bool skipAll = sf->GetPropertyAsBool("SKIP_AUTOGEN");
|
||||||
|
const bool mocSkip =
|
||||||
|
mocEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOMOC"));
|
||||||
|
const bool uicSkip =
|
||||||
|
uicEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOUIC"));
|
||||||
|
if (mocSkip || uicSkip) {
|
||||||
|
const std::string absFile = cmsys::SystemTools::GetRealPath(fPath);
|
||||||
|
if (mocSkip) {
|
||||||
|
setup.mocSkip.insert(absFile);
|
||||||
|
}
|
||||||
|
if (uicSkip) {
|
||||||
|
setup.uicSkip.insert(absFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const cmPolicies::PolicyStatus CMP0071_status =
|
const cmPolicies::PolicyStatus CMP0071_status =
|
||||||
target->Makefile->GetPolicyStatus(cmPolicies::CMP0071);
|
target->Makefile->GetPolicyStatus(cmPolicies::CMP0071);
|
||||||
|
|
||||||
for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
|
for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
|
||||||
fileIt != srcFiles.end(); ++fileIt) {
|
fileIt != srcFiles.end(); ++fileIt) {
|
||||||
cmSourceFile* sf = *fileIt;
|
cmSourceFile* sf = *fileIt;
|
||||||
@@ -305,14 +343,15 @@ static void SetupAcquireScanFiles(cmGeneratorTarget const* target,
|
|||||||
}
|
}
|
||||||
// Real file path
|
// Real file path
|
||||||
const std::string absFile = cmsys::SystemTools::GetRealPath(fPath);
|
const std::string absFile = cmsys::SystemTools::GetRealPath(fPath);
|
||||||
// Skip flags
|
// Skip test
|
||||||
const bool skipAll = sf->GetPropertyAsBool("SKIP_AUTOGEN");
|
const bool mocSkip = !mocEnabled || (setup.mocSkip.count(absFile) != 0);
|
||||||
const bool mocSkip = skipAll || sf->GetPropertyAsBool("SKIP_AUTOMOC");
|
const bool uicSkip = !uicEnabled || (setup.uicSkip.count(absFile) != 0);
|
||||||
const bool uicSkip = skipAll || sf->GetPropertyAsBool("SKIP_AUTOUIC");
|
if (mocSkip && uicSkip) {
|
||||||
const bool accept = (mocEnabled && !mocSkip) || (uicEnabled && !uicSkip);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// For GENERATED files check status of policy CMP0071
|
// For GENERATED files check status of policy CMP0071
|
||||||
if (accept && sf->GetPropertyAsBool("GENERATED")) {
|
if (sf->GetPropertyAsBool("GENERATED")) {
|
||||||
bool policyAccept = false;
|
bool policyAccept = false;
|
||||||
switch (CMP0071_status) {
|
switch (CMP0071_status) {
|
||||||
case cmPolicies::WARN: {
|
case cmPolicies::WARN: {
|
||||||
@@ -338,29 +377,16 @@ static void SetupAcquireScanFiles(cmGeneratorTarget const* target,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add file name to skip lists.
|
// Add file name to sources or headers list
|
||||||
// Do this even when the file is not added to the sources/headers lists
|
switch (fileType) {
|
||||||
// because the file name may be extracted from an other file when
|
case cmSystemTools::CXX_FILE_FORMAT:
|
||||||
// processing
|
setup.sources.push_back(absFile);
|
||||||
if (mocSkip) {
|
break;
|
||||||
setup.mocSkip.push_back(absFile);
|
case cmSystemTools::HEADER_FILE_FORMAT:
|
||||||
}
|
setup.headers.push_back(absFile);
|
||||||
if (uicSkip) {
|
break;
|
||||||
setup.uicSkip.push_back(absFile);
|
default:
|
||||||
}
|
break;
|
||||||
|
|
||||||
if (accept) {
|
|
||||||
// Add file name to sources or headers list
|
|
||||||
switch (fileType) {
|
|
||||||
case cmSystemTools::CXX_FILE_FORMAT:
|
|
||||||
setup.sources.push_back(absFile);
|
|
||||||
break;
|
|
||||||
case cmSystemTools::HEADER_FILE_FORMAT:
|
|
||||||
setup.headers.push_back(absFile);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user