mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-11 03:50:43 -05:00
Merge topic 'autogen-generators-refactor'
51fd7b71Autogen: Tests: Add a change-not test to the mocRerun testc8f92db7Autogen: Tests: Disable an AUTOMOC_DEPENDS_FILTER test for Ninja3c77515eAutogen: Tests: Refactor the QtAutogenRebuild rccDepends test04a0daeeAutogen: Tests: Move each rerun test script to a NAME.cmake filee5c6610aAutogen: Tests: Extend CMAKE_AUTOMOC_DEPEND_FILTERS rebuild test93265652Autogen: Tests: Add <SUBDIR>/ui_view.h AUTOUIC includes to sameName test4eb7d817Autogen: Tests: Add <SUBDIR>/item.moc includes to sameName test3f223743Autogen: Read relative paths from rcc output ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1244
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmQtAutoGen.h"
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
#include "cmsys/FStream.hxx"
|
||||
@@ -158,15 +159,18 @@ static bool RccListInputsQt5(const std::string& rccCommand,
|
||||
std::string rccStdOut;
|
||||
std::string rccStdErr;
|
||||
int retVal = 0;
|
||||
bool result =
|
||||
cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
|
||||
nullptr, cmSystemTools::OUTPUT_NONE);
|
||||
bool result = cmSystemTools::RunSingleCommand(
|
||||
command, &rccStdOut, &rccStdErr, &retVal, nullptr,
|
||||
cmSystemTools::OUTPUT_NONE, 0.0, cmProcessOutput::Auto);
|
||||
if (result && retVal == 0 &&
|
||||
rccStdOut.find("--list") != std::string::npos) {
|
||||
hasDashDashList = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string const fileDir = cmSystemTools::GetFilenamePath(fileName);
|
||||
std::string const fileNameName = cmSystemTools::GetFilenameName(fileName);
|
||||
|
||||
// Run rcc list command
|
||||
bool result = false;
|
||||
int retVal = 0;
|
||||
@@ -176,16 +180,16 @@ static bool RccListInputsQt5(const std::string& rccCommand,
|
||||
std::vector<std::string> command;
|
||||
command.push_back(rccCommand);
|
||||
command.push_back(hasDashDashList ? "--list" : "-list");
|
||||
command.push_back(fileName);
|
||||
result =
|
||||
cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
|
||||
nullptr, cmSystemTools::OUTPUT_NONE);
|
||||
command.push_back(fileNameName);
|
||||
result = cmSystemTools::RunSingleCommand(
|
||||
command, &rccStdOut, &rccStdErr, &retVal, fileDir.c_str(),
|
||||
cmSystemTools::OUTPUT_NONE, 0.0, cmProcessOutput::Auto);
|
||||
}
|
||||
if (!result || retVal) {
|
||||
if (errorMessage != nullptr) {
|
||||
std::ostringstream ost;
|
||||
ost << "rcc list process for " << cmQtAutoGen::Quoted(fileName)
|
||||
<< " failed:\n"
|
||||
ost << "rcc list process failed for\n " << cmQtAutoGen::Quoted(fileName)
|
||||
<< "\n"
|
||||
<< rccStdOut << "\n"
|
||||
<< rccStdErr << "\n";
|
||||
*errorMessage = ost.str();
|
||||
@@ -230,6 +234,11 @@ static bool RccListInputsQt5(const std::string& rccCommand,
|
||||
}
|
||||
}
|
||||
|
||||
// Convert relative paths to absolute paths
|
||||
for (std::string& resFile : files) {
|
||||
resFile = cmSystemTools::CollapseCombinedPath(fileDir, resFile);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@
|
||||
#include "cmsys/RegularExpression.hxx"
|
||||
|
||||
#include <map>
|
||||
#include <memory> // IWYU pragma: keep
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -21,7 +22,7 @@ class cmQtAutoGenerators
|
||||
CM_DISABLE_COPY(cmQtAutoGenerators)
|
||||
public:
|
||||
cmQtAutoGenerators();
|
||||
bool Run(const std::string& targetDirectory, const std::string& config);
|
||||
bool Run(std::string const& targetDirectory, std::string const& config);
|
||||
|
||||
private:
|
||||
// -- Types
|
||||
@@ -37,7 +38,7 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
KeyRegExp(const std::string& key, const std::string& regExp)
|
||||
KeyRegExp(std::string const& key, std::string const& regExp)
|
||||
: Key(key)
|
||||
, RegExp(regExp)
|
||||
{
|
||||
@@ -47,6 +48,38 @@ private:
|
||||
cmsys::RegularExpression RegExp;
|
||||
};
|
||||
|
||||
/// @brief Source file job
|
||||
struct SourceJob
|
||||
{
|
||||
bool Moc = false;
|
||||
bool Uic = false;
|
||||
};
|
||||
|
||||
/// @brief MOC job
|
||||
struct MocJobAuto
|
||||
{
|
||||
std::string SourceFile;
|
||||
std::string BuildFileRel;
|
||||
std::set<std::string> Depends;
|
||||
};
|
||||
|
||||
/// @brief MOC job
|
||||
struct MocJobIncluded : MocJobAuto
|
||||
{
|
||||
bool DependsValid = false;
|
||||
std::string Includer;
|
||||
std::string IncludeString;
|
||||
};
|
||||
|
||||
/// @brief UIC job
|
||||
struct UicJob
|
||||
{
|
||||
std::string SourceFile;
|
||||
std::string BuildFileRel;
|
||||
std::string Includer;
|
||||
std::string IncludeString;
|
||||
};
|
||||
|
||||
/// @brief RCC job
|
||||
struct RccJob
|
||||
{
|
||||
@@ -56,149 +89,110 @@ private:
|
||||
std::vector<std::string> Inputs;
|
||||
};
|
||||
|
||||
// -- Configuration
|
||||
bool MocDependFilterPush(const std::string& key, const std::string& regExp);
|
||||
bool ReadAutogenInfoFile(cmMakefile* makefile,
|
||||
const std::string& targetDirectory,
|
||||
const std::string& config);
|
||||
|
||||
bool MocEnabled() const { return !this->MocExecutable.empty(); }
|
||||
bool UicEnabled() const { return !this->UicExecutable.empty(); }
|
||||
bool RccEnabled() const { return !this->RccExecutable.empty(); }
|
||||
// -- Initialization
|
||||
bool InitInfoFile(cmMakefile* makefile, std::string const& targetDirectory,
|
||||
std::string const& config);
|
||||
|
||||
// -- Settings file
|
||||
void SettingsFileRead(cmMakefile* makefile);
|
||||
bool SettingsFileWrite();
|
||||
|
||||
bool AnySettingsChanged() const
|
||||
bool SettingsChanged() const
|
||||
{
|
||||
return (this->MocSettingsChanged || this->RccSettingsChanged ||
|
||||
this->UicSettingsChanged);
|
||||
}
|
||||
|
||||
// -- Init and run
|
||||
void Init(cmMakefile* makefile);
|
||||
bool RunAutogen();
|
||||
// -- Central processing
|
||||
bool Process();
|
||||
|
||||
// -- Content analysis
|
||||
bool MocRequired(const std::string& contentText,
|
||||
// -- Source parsing
|
||||
bool ParseSourceFile(std::string const& absFilename, const SourceJob& job);
|
||||
bool ParseHeaderFile(std::string const& absFilename, const SourceJob& job);
|
||||
bool ParsePostprocess();
|
||||
|
||||
// -- Moc
|
||||
bool MocEnabled() const { return !this->MocExecutable.empty(); }
|
||||
bool MocSkip(std::string const& absFilename) const;
|
||||
bool MocRequired(std::string const& contentText,
|
||||
std::string* macroName = nullptr);
|
||||
void MocFindDepends(
|
||||
const std::string& absFilename, const std::string& contentText,
|
||||
std::map<std::string, std::set<std::string>>& mocDepends);
|
||||
// Moc strings
|
||||
std::string MocStringMacros() const;
|
||||
std::string MocStringHeaders(std::string const& fileBase) const;
|
||||
std::string MocFindIncludedHeader(std::string const& sourcePath,
|
||||
std::string const& includeBase) const;
|
||||
bool MocFindIncludedFile(std::string& absFile, std::string const& sourceFile,
|
||||
std::string const& includeString) const;
|
||||
// Moc depends
|
||||
bool MocDependFilterPush(std::string const& key, std::string const& regExp);
|
||||
void MocFindDepends(std::string const& absFilename,
|
||||
std::string const& contentText,
|
||||
std::set<std::string>& depends);
|
||||
// Moc
|
||||
bool MocParseSourceContent(std::string const& absFilename,
|
||||
std::string const& contentText);
|
||||
void MocParseHeaderContent(std::string const& absFilename,
|
||||
std::string const& contentText);
|
||||
|
||||
bool MocSkip(const std::string& absFilename) const;
|
||||
bool UicSkip(const std::string& absFilename) const;
|
||||
bool MocGenerateAll();
|
||||
bool MocGenerateFile(const MocJobAuto& mocJob, bool* generated = nullptr);
|
||||
|
||||
bool ParseSourceFile(
|
||||
const std::string& absFilename,
|
||||
std::map<std::string, std::string>& mocsIncluded,
|
||||
std::map<std::string, std::set<std::string>>& mocDepends,
|
||||
std::map<std::string, std::vector<std::string>>& includedUis,
|
||||
bool relaxed);
|
||||
// -- Uic
|
||||
bool UicEnabled() const { return !this->UicExecutable.empty(); }
|
||||
bool UicSkip(std::string const& absFilename) const;
|
||||
bool UicParseContent(std::string const& fileName,
|
||||
std::string const& contentText);
|
||||
bool UicFindIncludedFile(std::string& absFile, std::string const& sourceFile,
|
||||
std::string const& includeString);
|
||||
bool UicGenerateAll();
|
||||
bool UicGenerateFile(const UicJob& uicJob);
|
||||
|
||||
void SearchHeadersForSourceFile(const std::string& absFilename,
|
||||
std::set<std::string>& mocHeaderFiles,
|
||||
std::set<std::string>& uicHeaderFiles) const;
|
||||
|
||||
bool ParseHeaders(
|
||||
const std::set<std::string>& mocHeaderFiles,
|
||||
const std::set<std::string>& uicHeaderFiles,
|
||||
const std::map<std::string, std::string>& mocsIncluded,
|
||||
std::map<std::string, std::string>& mocsNotIncluded,
|
||||
std::map<std::string, std::set<std::string>>& mocDepends,
|
||||
std::map<std::string, std::vector<std::string>>& includedUis);
|
||||
|
||||
void UicParseContent(
|
||||
const std::string& fileName, const std::string& contentText,
|
||||
std::map<std::string, std::vector<std::string>>& includedUis);
|
||||
|
||||
std::string MocMacroNamesString() const;
|
||||
std::string MocHeaderSuffixesString() const;
|
||||
|
||||
bool MocParseSourceContent(
|
||||
const std::string& absFilename, const std::string& contentText,
|
||||
std::map<std::string, std::string>& mocsIncluded,
|
||||
std::map<std::string, std::set<std::string>>& mocDepends, bool relaxed);
|
||||
|
||||
void MocParseHeaderContent(
|
||||
const std::string& absFilename, const std::string& contentText,
|
||||
std::map<std::string, std::string>& mocsNotIncluded,
|
||||
std::map<std::string, std::set<std::string>>& mocDepends);
|
||||
|
||||
// -- Moc file generation
|
||||
bool MocGenerateAll(
|
||||
const std::map<std::string, std::string>& mocsIncluded,
|
||||
const std::map<std::string, std::string>& mocsNotIncluded,
|
||||
const std::map<std::string, std::set<std::string>>& mocDepends);
|
||||
bool MocGenerateFile(
|
||||
const std::string& sourceFile, const std::string& mocFileName,
|
||||
const std::map<std::string, std::set<std::string>>& mocDepends,
|
||||
bool included);
|
||||
|
||||
// -- Uic file generation
|
||||
bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile,
|
||||
const std::string& searchPath,
|
||||
const std::string& searchFile);
|
||||
bool UicGenerateAll(
|
||||
const std::map<std::string, std::vector<std::string>>& includedUis);
|
||||
bool UicGenerateFile(const std::string& realName,
|
||||
const std::string& uiInputFile,
|
||||
const std::string& uiOutputFile);
|
||||
|
||||
// -- Rcc file generation
|
||||
// -- Rcc
|
||||
bool RccEnabled() const { return !this->RccExecutable.empty(); }
|
||||
bool RccGenerateAll();
|
||||
bool RccGenerateFile(const RccJob& rccJob);
|
||||
|
||||
// -- Log info
|
||||
void LogBold(const std::string& message) const;
|
||||
void LogBold(std::string const& message) const;
|
||||
void LogInfo(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& message) const;
|
||||
std::string const& message) const;
|
||||
// -- Log warning
|
||||
void LogWarning(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& message) const;
|
||||
std::string const& message) const;
|
||||
void LogFileWarning(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& filename,
|
||||
const std::string& message) const;
|
||||
std::string const& filename,
|
||||
std::string const& message) const;
|
||||
// -- Log error
|
||||
void LogError(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& message) const;
|
||||
std::string const& message) const;
|
||||
void LogFileError(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& filename,
|
||||
const std::string& message) const;
|
||||
std::string const& filename,
|
||||
std::string const& message) const;
|
||||
void LogCommandError(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& message,
|
||||
const std::vector<std::string>& command,
|
||||
const std::string& output) const;
|
||||
void LogNameCollisionError(
|
||||
cmQtAutoGen::GeneratorType genType, const std::string& message,
|
||||
const std::multimap<std::string, std::string>& collisions) const;
|
||||
std::string const& message,
|
||||
std::vector<std::string> const& command,
|
||||
std::string const& output) const;
|
||||
|
||||
// -- Utility
|
||||
bool NameCollisionTest(
|
||||
const std::map<std::string, std::string>& genFiles,
|
||||
std::multimap<std::string, std::string>& collisions) const;
|
||||
std::string ChecksumedPath(const std::string& sourceFile,
|
||||
const std::string& basePrefix,
|
||||
const std::string& baseSuffix) const;
|
||||
bool MakeParentDirectory(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& filename) const;
|
||||
bool FileDiffers(const std::string& filename, const std::string& content);
|
||||
std::string const& filename) const;
|
||||
bool FileDiffers(std::string const& filename, std::string const& content);
|
||||
bool FileWrite(cmQtAutoGen::GeneratorType genType,
|
||||
const std::string& filename, const std::string& content);
|
||||
|
||||
bool RunCommand(const std::vector<std::string>& command,
|
||||
std::string const& filename, std::string const& content);
|
||||
bool FindHeader(std::string& header, std::string const& testBasePath) const;
|
||||
bool RunCommand(std::vector<std::string> const& command,
|
||||
std::string& output) const;
|
||||
|
||||
bool FindHeader(std::string& header, const std::string& testBasePath) const;
|
||||
|
||||
std::string MocFindHeader(const std::string& sourcePath,
|
||||
const std::string& includeBase) const;
|
||||
bool MocFindIncludedFile(std::string& absFile, const std::string& sourceFile,
|
||||
const std::string& includeString) const;
|
||||
|
||||
// -- Meta
|
||||
std::string ConfigSuffix;
|
||||
std::string InfoFile;
|
||||
// -- Settings
|
||||
bool IncludeProjectDirsBefore;
|
||||
bool Verbose;
|
||||
bool ColorOutput;
|
||||
std::string SettingsFile;
|
||||
std::string SettingsStringMoc;
|
||||
std::string SettingsStringUic;
|
||||
std::string SettingsStringRcc;
|
||||
// -- Directories
|
||||
std::string ProjectSourceDir;
|
||||
std::string ProjectBinaryDir;
|
||||
@@ -213,23 +207,14 @@ private:
|
||||
std::string UicExecutable;
|
||||
std::string RccExecutable;
|
||||
// -- File lists
|
||||
std::vector<std::string> Sources;
|
||||
std::vector<std::string> Headers;
|
||||
std::map<std::string, SourceJob> HeaderJobs;
|
||||
std::map<std::string, SourceJob> SourceJobs;
|
||||
std::vector<std::string> HeaderExtensions;
|
||||
cmFilePathChecksum FPathChecksum;
|
||||
// -- Settings
|
||||
bool IncludeProjectDirsBefore;
|
||||
bool Verbose;
|
||||
bool ColorOutput;
|
||||
std::string SettingsFile;
|
||||
std::string SettingsStringMoc;
|
||||
std::string SettingsStringUic;
|
||||
std::string SettingsStringRcc;
|
||||
cmFilePathChecksum FilePathChecksum;
|
||||
// -- Moc
|
||||
bool MocSettingsChanged;
|
||||
bool MocPredefsChanged;
|
||||
bool MocRelaxedMode;
|
||||
bool MocRunFailed;
|
||||
std::string MocCompFileRel;
|
||||
std::string MocCompFileAbs;
|
||||
std::string MocPredefsFileRel;
|
||||
@@ -239,21 +224,23 @@ private:
|
||||
std::vector<std::string> MocIncludes;
|
||||
std::vector<std::string> MocDefinitions;
|
||||
std::vector<std::string> MocOptions;
|
||||
std::vector<std::string> MocAllOptions;
|
||||
std::vector<std::string> MocPredefsCmd;
|
||||
std::vector<KeyRegExp> MocDependFilters;
|
||||
std::vector<KeyRegExp> MocMacroFilters;
|
||||
cmsys::RegularExpression MocRegExpInclude;
|
||||
std::vector<std::unique_ptr<MocJobIncluded>> MocJobsIncluded;
|
||||
std::vector<std::unique_ptr<MocJobAuto>> MocJobsAuto;
|
||||
// -- Uic
|
||||
bool UicSettingsChanged;
|
||||
bool UicRunFailed;
|
||||
std::vector<std::string> UicSkipList;
|
||||
std::vector<std::string> UicTargetOptions;
|
||||
std::map<std::string, std::vector<std::string>> UicOptions;
|
||||
std::vector<std::string> UicSearchPaths;
|
||||
cmsys::RegularExpression UicRegExpInclude;
|
||||
std::vector<std::unique_ptr<UicJob>> UicJobs;
|
||||
// -- Rcc
|
||||
bool RccSettingsChanged;
|
||||
bool RccRunFailed;
|
||||
std::vector<RccJob> RccJobs;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ add_executable(sameName
|
||||
main.cpp
|
||||
)
|
||||
target_link_libraries(sameName ${QT_LIBRARIES})
|
||||
set_target_properties(sameName PROPERTIES AUTOMOC TRUE AUTORCC TRUE)
|
||||
set_target_properties(sameName PROPERTIES
|
||||
AUTOMOC TRUE
|
||||
AUTOUIC TRUE
|
||||
AUTORCC TRUE)
|
||||
|
||||
# Set different compression levels
|
||||
if (QT_TEST_VERSION STREQUAL 4)
|
||||
|
||||
@@ -3,8 +3,20 @@
|
||||
namespace aaa {
|
||||
namespace bbb {
|
||||
|
||||
class MocLocal : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
MocLocal() = default;
|
||||
~MocLocal() = default;
|
||||
};
|
||||
|
||||
void Item::go()
|
||||
{
|
||||
MocLocal obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "aaa/bbb/item.moc"
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
#include "item.hpp"
|
||||
// Include ui_view.h only in header
|
||||
|
||||
namespace aaa {
|
||||
|
||||
class MocLocal : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
MocLocal() = default;
|
||||
~MocLocal() = default;
|
||||
};
|
||||
|
||||
void Item::go()
|
||||
{
|
||||
Ui_ViewAAA ui;
|
||||
MocLocal obj;
|
||||
}
|
||||
}
|
||||
|
||||
#include "aaa/item.moc"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define AAA_ITEM_HPP
|
||||
|
||||
#include <QObject>
|
||||
// Include ui_view.h only in header
|
||||
#include <aaa/ui_view.h>
|
||||
|
||||
namespace aaa {
|
||||
|
||||
|
||||
24
Tests/QtAutogen/sameName/aaa/view.ui
Normal file
24
Tests/QtAutogen/sameName/aaa/view.ui
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ViewAAA</class>
|
||||
<widget class="QWidget" name="Base">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -3,8 +3,20 @@
|
||||
namespace bbb {
|
||||
namespace aaa {
|
||||
|
||||
class MocLocal : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
MocLocal() = default;
|
||||
~MocLocal() = default;
|
||||
};
|
||||
|
||||
void Item::go()
|
||||
{
|
||||
MocLocal obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "bbb/aaa/item.moc"
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
#include "item.hpp"
|
||||
// Include ui_view.h only in source
|
||||
#include <bbb/ui_view.h>
|
||||
|
||||
namespace bbb {
|
||||
|
||||
class MocLocal : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
MocLocal() = default;
|
||||
~MocLocal() = default;
|
||||
};
|
||||
|
||||
void Item::go()
|
||||
{
|
||||
Ui_ViewBBB ui;
|
||||
MocLocal obj;
|
||||
}
|
||||
}
|
||||
|
||||
#include "bbb/item.moc"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define BBB_ITEM_HPP
|
||||
|
||||
#include <QObject>
|
||||
// Include ui_view.h only in source
|
||||
|
||||
namespace bbb {
|
||||
|
||||
|
||||
24
Tests/QtAutogen/sameName/bbb/view.ui
Normal file
24
Tests/QtAutogen/sameName/bbb/view.ui
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ViewBBB</class>
|
||||
<widget class="QWidget" name="Base">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,23 +1,25 @@
|
||||
#include "item.hpp"
|
||||
// Include ui_view.h in source and header
|
||||
#include <ccc/ui_view.h>
|
||||
|
||||
namespace ccc {
|
||||
|
||||
void Item::go()
|
||||
{
|
||||
}
|
||||
|
||||
class MocTest : public QObject
|
||||
class MocLocal : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
Q_SLOT
|
||||
void go();
|
||||
|
||||
public:
|
||||
MocLocal() = default;
|
||||
~MocLocal() = default;
|
||||
};
|
||||
|
||||
void MocTest::go()
|
||||
void Item::go()
|
||||
{
|
||||
Ui_ViewCCC ui;
|
||||
MocLocal obj;
|
||||
}
|
||||
}
|
||||
|
||||
// Include own moc files
|
||||
#include "item.moc"
|
||||
#include "ccc/item.moc"
|
||||
#include "moc_item.cpp"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define CCC_ITEM_HPP
|
||||
|
||||
#include <QObject>
|
||||
// Include ui_view.h in source and header
|
||||
#include <ccc/ui_view.h>
|
||||
|
||||
namespace ccc {
|
||||
|
||||
|
||||
24
Tests/QtAutogen/sameName/ccc/view.ui
Normal file
24
Tests/QtAutogen/sameName/ccc/view.ui
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ViewCCC</class>
|
||||
<widget class="QWidget" name="Base">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,5 +1,20 @@
|
||||
#include "item.hpp"
|
||||
// Include ui_view.h in source and header
|
||||
#include <ui_view.h>
|
||||
|
||||
class MocLocal : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
MocLocal() = default;
|
||||
~MocLocal() = default;
|
||||
};
|
||||
|
||||
void Item::go()
|
||||
{
|
||||
Ui_View ui;
|
||||
MocLocal obj;
|
||||
}
|
||||
|
||||
#include "item.moc"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define ITEM_HPP
|
||||
|
||||
#include <QObject>
|
||||
// Include ui_view.h in source and header
|
||||
#include <ui_view.h>
|
||||
|
||||
class Item : public QObject
|
||||
{
|
||||
|
||||
24
Tests/QtAutogen/sameName/view.ui
Normal file
24
Tests/QtAutogen/sameName/view.ui
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>View</class>
|
||||
<widget class="QWidget" name="Base">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -36,204 +36,17 @@ else()
|
||||
|
||||
endif()
|
||||
|
||||
# -- Test
|
||||
# Dummy test to generate clean target
|
||||
# Dummy executable to generate clean target
|
||||
add_executable(dummy dummy.cpp)
|
||||
|
||||
# -- Test
|
||||
# When a file listed in a .qrc file changes the target must be rebuilt
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
set(RCC_DEPENDS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends")
|
||||
set(RCC_DEPENDS_BIN "${CMAKE_CURRENT_BINARY_DIR}/rccDepends")
|
||||
configure_file(${RCC_DEPENDS_SRC}/res1a.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY)
|
||||
configure_file(${RCC_DEPENDS_SRC}/res2a.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY)
|
||||
try_compile(RCC_DEPENDS
|
||||
"${RCC_DEPENDS_BIN}"
|
||||
"${RCC_DEPENDS_SRC}"
|
||||
rccDepends
|
||||
CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
|
||||
"-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
if (NOT RCC_DEPENDS)
|
||||
message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
|
||||
endif()
|
||||
# Get name and timestamp of the output binary
|
||||
file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList ENCODING UTF-8)
|
||||
list(GET targetList 0 rccDependsBin)
|
||||
file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}")
|
||||
# Sleep, touch regular qrc input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Second build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}")
|
||||
if (NOT timeStep1 GREATER timeBegin)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!")
|
||||
endif()
|
||||
# Sleep, update regular qrc file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
configure_file(${RCC_DEPENDS_SRC}/res1b.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Third build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}")
|
||||
if (NOT timeStep2 GREATER timeStep1)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the second step!")
|
||||
endif()
|
||||
# Sleep, touch regular qrc newly added input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Fourth build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep3 "${timeformat}")
|
||||
if (NOT timeStep3 GREATER timeStep2)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the third step!")
|
||||
endif()
|
||||
# Sleep, touch generated qrc input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Fifth build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep4 "${timeformat}")
|
||||
if (NOT timeStep4 GREATER timeStep3)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fourth step!")
|
||||
endif()
|
||||
# Sleep, update generated qrc file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
configure_file(${RCC_DEPENDS_SRC}/res2b.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Sixth build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep5 "${timeformat}")
|
||||
if (NOT timeStep5 GREATER timeStep4)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fitfh step!")
|
||||
endif()
|
||||
# Sleep, touch generated qrc newly added input file, rebuild and compare timestamp
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Seventh build of rccDepends failed.")
|
||||
endif()
|
||||
file(TIMESTAMP "${rccDependsBin}" timeStep6 "${timeformat}")
|
||||
if (NOT timeStep6 GREATER timeStep5)
|
||||
message(SEND_ERROR "File (${rccDependsBin}) should have changed in the sixth step!")
|
||||
endif()
|
||||
|
||||
|
||||
# -- Test
|
||||
# Ensure a repeated build succeeds when a header containing a QObject changes
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
configure_file(mocRerun/test1a.h.in mocRerun/test1.h COPYONLY)
|
||||
try_compile(MOC_RERUN
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mocRerun"
|
||||
mocRerun
|
||||
CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
|
||||
"-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
if (NOT MOC_RERUN)
|
||||
message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}")
|
||||
endif()
|
||||
# Get name and timestamp of the output binary
|
||||
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List ENCODING UTF-8)
|
||||
list(GET target1List 0 binFile)
|
||||
file(TIMESTAMP "${binFile}" timeBegin "${timeformat}")
|
||||
# Change file content and rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
|
||||
RESULT_VARIABLE mocRerun_result
|
||||
)
|
||||
if (mocRerun_result)
|
||||
message(SEND_ERROR "Second build of mocRerun failed.")
|
||||
endif()
|
||||
# Compare timestamps
|
||||
file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}")
|
||||
if (NOT timeStep1 GREATER timeBegin)
|
||||
message(SEND_ERROR "File (${binFile}) should have changed in the first step!")
|
||||
endif()
|
||||
|
||||
include("mocRerun.cmake")
|
||||
|
||||
# -- Test
|
||||
# Tests Q_PLUGIN_METADATA json file change detection
|
||||
if (NOT QT_TEST_VERSION STREQUAL 4)
|
||||
try_compile(MOC_PLUGIN
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/mocPlugin"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin"
|
||||
mocPlugin
|
||||
CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
if (NOT MOC_PLUGIN)
|
||||
message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}")
|
||||
endif()
|
||||
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin")
|
||||
set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin")
|
||||
find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
|
||||
file(TIMESTAMP "${plAFile}" plABefore "${timeformat}")
|
||||
file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
|
||||
|
||||
# Ensure that the timestamp will change and change the json files
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json")
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
|
||||
|
||||
file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
|
||||
|
||||
if (plAAfter GREATER plABefore)
|
||||
message(SEND_ERROR "file (${plAFile}) should not have changed!")
|
||||
endif()
|
||||
if (plBAfter GREATER plBBefore)
|
||||
message(SEND_ERROR "file (${plBFile}) should not have changed!")
|
||||
endif()
|
||||
if (NOT plCAfter GREATER plCBefore)
|
||||
message(SEND_ERROR "file (${plCFile}) should have changed!")
|
||||
endif()
|
||||
if (NOT plDAfter GREATER plDBefore)
|
||||
message(SEND_ERROR "file (${plDFile}) should have changed!")
|
||||
endif()
|
||||
|
||||
# Test custom macro
|
||||
file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json")
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
|
||||
file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
|
||||
if (NOT plCAfter GREATER plCBefore)
|
||||
message(SEND_ERROR "file (${plCFile}) should have changed!")
|
||||
endif()
|
||||
if (NOT plDAfter GREATER plDBefore)
|
||||
message(SEND_ERROR "file (${plDFile}) should have changed!")
|
||||
endif()
|
||||
|
||||
include("mocPlugin.cmake")
|
||||
endif()
|
||||
|
||||
# -- Test
|
||||
include("rccDepends.cmake")
|
||||
|
||||
96
Tests/QtAutogenRerun/mocPlugin.cmake
Normal file
96
Tests/QtAutogenRerun/mocPlugin.cmake
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
# Utility variables
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin")
|
||||
set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin")
|
||||
|
||||
# Initial buid
|
||||
try_compile(MOC_PLUGIN
|
||||
"${mocPlugBinDir}"
|
||||
"${mocPlugSrcDir}"
|
||||
mocPlugin
|
||||
CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
if (NOT MOC_PLUGIN)
|
||||
message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}")
|
||||
endif()
|
||||
|
||||
find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
|
||||
|
||||
# - Ensure that the timestamp will change.
|
||||
# - Change the json files referenced by Q_PLUGIN_METADATA
|
||||
# - Rebuild
|
||||
file(TIMESTAMP "${plAFile}" plABefore "${timeformat}")
|
||||
file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}")
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json")
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json")
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
|
||||
|
||||
file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}")
|
||||
|
||||
if (plAAfter GREATER plABefore)
|
||||
message(SEND_ERROR "file (${plAFile}) should not have changed!")
|
||||
endif()
|
||||
if (plBAfter GREATER plBBefore)
|
||||
message(SEND_ERROR "file (${plBFile}) should not have changed!")
|
||||
endif()
|
||||
if (NOT plCAfter GREATER plCBefore)
|
||||
message(SEND_ERROR "file (${plCFile}) should have changed!")
|
||||
endif()
|
||||
if (NOT plDAfter GREATER plDBefore)
|
||||
message(SEND_ERROR "file (${plDFile}) should have changed!")
|
||||
endif()
|
||||
if (NOT plEAfter GREATER plEBefore)
|
||||
# There's a bug in Ninja on Windows
|
||||
# https://gitlab.kitware.com/cmake/cmake/issues/16776
|
||||
if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
|
||||
message(SEND_ERROR "file (${plEFile}) should have changed!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# - Ensure that the timestamp will change.
|
||||
# - Change the json files referenced by A_CUSTOM_MACRO
|
||||
# - Rebuild
|
||||
file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
|
||||
file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}")
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json")
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json")
|
||||
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
|
||||
|
||||
file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
|
||||
file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}")
|
||||
|
||||
if (NOT plCAfter GREATER plCBefore)
|
||||
message(SEND_ERROR "file (${plCFile}) should have changed!")
|
||||
endif()
|
||||
if (NOT plDAfter GREATER plDBefore)
|
||||
message(SEND_ERROR "file (${plDFile}) should have changed!")
|
||||
endif()
|
||||
if (NOT plEAfter GREATER plEBefore)
|
||||
# There's a bug in Ninja on Windows
|
||||
# https://gitlab.kitware.com/cmake/cmake/issues/16776
|
||||
if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
|
||||
message(SEND_ERROR "file (${plEFile}) should have changed!")
|
||||
endif()
|
||||
endif()
|
||||
@@ -16,9 +16,11 @@ if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
|
||||
endif()
|
||||
|
||||
configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json)
|
||||
configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json)
|
||||
configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json)
|
||||
configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json)
|
||||
configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json)
|
||||
configure_file(jsonIn/StyleE.json jsonFiles/StyleE.json)
|
||||
configure_file(jsonIn/StyleE.json jsonFiles/StyleE_Custom.json)
|
||||
|
||||
# Enable automoc
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef STYLEA_HPP
|
||||
#define STYLEA_HPP
|
||||
|
||||
#include "StyleCommon.hpp"
|
||||
#include "UtilityMacros.hpp"
|
||||
#include <QStylePlugin>
|
||||
|
||||
class StyleA : public QStylePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
// Json file in local directory
|
||||
// Json file in source local directory
|
||||
Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json")
|
||||
A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg)
|
||||
public:
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef STYLEB_HPP
|
||||
#define STYLEB_HPP
|
||||
|
||||
#include "StyleCommon.hpp"
|
||||
#include "UtilityMacros.hpp"
|
||||
#include <QStylePlugin>
|
||||
|
||||
class StyleB : public QStylePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
// Json file in local subdirectory
|
||||
// Json file in source local subdirectory
|
||||
Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json")
|
||||
A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg)
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STYLEC_HPP
|
||||
#define STYLEC_HPP
|
||||
|
||||
#include "StyleCommon.hpp"
|
||||
#include "UtilityMacros.hpp"
|
||||
#include <QStylePlugin>
|
||||
|
||||
class StyleC : public QStylePlugin
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STYLED_HPP
|
||||
#define STYLED_HPP
|
||||
|
||||
#include "StyleCommon.hpp"
|
||||
#include "UtilityMacros.hpp"
|
||||
#include <QStylePlugin>
|
||||
|
||||
class StyleD : public QStylePlugin
|
||||
|
||||
@@ -4,3 +4,6 @@ QStyle* StyleE::create(const QString& key)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// AUTOMOC the StyleEInclude.hpp header
|
||||
#include "moc_StyleEInclude.cpp"
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
#ifndef STYLEE_HPP
|
||||
#define STYLEE_HPP
|
||||
|
||||
#include "StyleCommon.hpp"
|
||||
#include <QStylePlugin>
|
||||
|
||||
class StyleE : public QStylePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
// No Json file
|
||||
Q_PLUGIN_METADATA(IID "org.styles.E")
|
||||
A_CUSTOM_MACRO(SomeArg, InvalidFileArg, AnotherArg)
|
||||
public:
|
||||
QStyle* create(const QString& key);
|
||||
};
|
||||
// The included file is not in the sources list and won't be detected by
|
||||
// AUTOMOC source file with the same base name.
|
||||
// It is registered to AUTOMOCed via a moc_<NAME>.cpp include in StyleE.cpp
|
||||
// though.
|
||||
#include "StyleEInclude.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
17
Tests/QtAutogenRerun/mocPlugin/StyleEInclude.hpp
Normal file
17
Tests/QtAutogenRerun/mocPlugin/StyleEInclude.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef STYLEE_INCLUDE_HPP
|
||||
#define STYLEE_INCLUDE_HPP
|
||||
|
||||
#include "UtilityMacros.hpp"
|
||||
#include <QStylePlugin>
|
||||
|
||||
class StyleE : public QStylePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
// Json files in global root directory
|
||||
Q_PLUGIN_METADATA(IID "org.styles.E" FILE "StyleE.json")
|
||||
A_CUSTOM_MACRO(SomeArg, "StyleE_Custom.json", AnotherArg)
|
||||
public:
|
||||
QStyle* create(const QString& key);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef STYLECOMMON_HPP
|
||||
#define STYLECOMMON_HPP
|
||||
#ifndef UTILITYMACROS_HPP
|
||||
#define UTILITYMACROS_HPP
|
||||
|
||||
// Empty test macro definition
|
||||
#define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations)
|
||||
@@ -1 +1 @@
|
||||
{ "Keys": [ "Rocket", "StarbusterB" ] }
|
||||
{ "Keys": [ "Red", "Green" ] }
|
||||
|
||||
1
Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleE.json
Normal file
1
Tests/QtAutogenRerun/mocPlugin/jsonIn/StyleE.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "Keys": [ "Floor", "Ceiling" ] }
|
||||
60
Tests/QtAutogenRerun/mocRerun.cmake
Normal file
60
Tests/QtAutogenRerun/mocRerun.cmake
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
set(mocRerunSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun")
|
||||
set(mocRerunBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocRerun")
|
||||
|
||||
# Initial build
|
||||
configure_file("${mocRerunSrcDir}/test1a.h.in" "${mocRerunBinDir}/test1.h" COPYONLY)
|
||||
try_compile(MOC_RERUN
|
||||
"${mocRerunBinDir}"
|
||||
"${mocRerunSrcDir}"
|
||||
mocRerun
|
||||
CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
|
||||
"-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
if (NOT MOC_RERUN)
|
||||
message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}")
|
||||
endif()
|
||||
# Get name of the output binary
|
||||
file(STRINGS "${mocRerunBinDir}/mocRerun.txt" mocRerunList ENCODING UTF-8)
|
||||
list(GET mocRerunList 0 mocRerunBin)
|
||||
|
||||
message("Changing the header content for a MOC rerun")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change header file content and rebuild
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file("${mocRerunSrcDir}/test1b.h.in" "${mocRerunBinDir}/test1.h" COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocRerunBinDir}" RESULT_VARIABLE result )
|
||||
if (result)
|
||||
message(SEND_ERROR "Second build of mocRerun failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT timeAfter GREATER timeBefore)
|
||||
message(SEND_ERROR "File (${mocRerunBin}) should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing nothing for a MOC rerun")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeBefore "${timeformat}")
|
||||
# - Ensure that the timestamp would change
|
||||
# - Change nothing
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocRerunBinDir}" RESULT_VARIABLE result )
|
||||
if (result)
|
||||
message(SEND_ERROR "Third build of mocRerun failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${mocRerunBin}" timeAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (timeAfter GREATER timeBefore)
|
||||
message(SEND_ERROR "File (${mocRerunBin}) should not have changed!")
|
||||
endif()
|
||||
@@ -19,17 +19,15 @@ set(CMAKE_AUTORCC ON)
|
||||
|
||||
# Generated source file
|
||||
add_custom_command(OUTPUT main.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
||||
)
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp)
|
||||
|
||||
add_executable(mocRerun
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test1.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
||||
res1.qrc
|
||||
)
|
||||
res1.qrc)
|
||||
target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(mocRerun ${QT_CORE_TARGET})
|
||||
# Write target name to text file
|
||||
add_custom_command(TARGET mocRerun POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > target1.txt)
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > mocRerun.txt)
|
||||
|
||||
131
Tests/QtAutogenRerun/rccDepends.cmake
Normal file
131
Tests/QtAutogenRerun/rccDepends.cmake
Normal file
@@ -0,0 +1,131 @@
|
||||
# When a .qrc or a file listed in a .qrc file changes,
|
||||
# the target must be rebuilt
|
||||
set(timeformat "%Y%j%H%M%S")
|
||||
set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends")
|
||||
set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/rccDepends")
|
||||
|
||||
# Initial build
|
||||
configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
|
||||
configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
|
||||
try_compile(RCC_DEPENDS
|
||||
"${rccDepBD}"
|
||||
"${rccDepSD}"
|
||||
rccDepends
|
||||
CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
|
||||
"-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
if (NOT RCC_DEPENDS)
|
||||
message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
|
||||
endif()
|
||||
|
||||
# Get name of the output binaries
|
||||
file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8)
|
||||
file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8)
|
||||
list(GET targetListPlain 0 rccDepBinPlain)
|
||||
list(GET targetListGen 0 rccDepBinGen)
|
||||
message("Target that uses a plain .qrc file is:\n ${rccDepBinPlain}")
|
||||
message("Target that uses a GENERATED .qrc file is:\n ${rccDepBinGen}")
|
||||
|
||||
|
||||
message("Changing a resource files listed in the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change a resource files listed in the .qrc file
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/input.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Second build of rccDepends failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
|
||||
endif()
|
||||
if (NOT rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing a the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change the .qrc file
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
|
||||
configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Third build of rccDepends failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
|
||||
endif()
|
||||
if (NOT rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing a newly added resource files listed in the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change a newly added resource files listed in the .qrc file
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/inputAdded.txt")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Fourth build of rccDepends failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (NOT rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
|
||||
endif()
|
||||
if (NOT rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
|
||||
endif()
|
||||
|
||||
|
||||
message("Changing nothing in the .qrc file")
|
||||
# - Acquire binary timestamps before the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
|
||||
# - Ensure that the timestamp will change
|
||||
# - Change nothing
|
||||
# - Rebuild
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Fifth build of rccDepends failed.")
|
||||
endif()
|
||||
# - Acquire binary timestamps after the build
|
||||
file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
|
||||
file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
|
||||
# - Test if timestamps changed
|
||||
if (rdPlainAfter GREATER rdPlainBefore)
|
||||
message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should NOT have changed!")
|
||||
endif()
|
||||
if (rdGenAfter GREATER rdGenBefore)
|
||||
message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should NOT have changed!")
|
||||
endif()
|
||||
@@ -1,8 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(rccDepends CXX)
|
||||
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
if (QT_TEST_VERSION STREQUAL 4)
|
||||
find_package(Qt4 REQUIRED)
|
||||
set(QT_CORE_TARGET Qt4::QtCore)
|
||||
@@ -15,21 +13,29 @@ else()
|
||||
set(QT_CORE_TARGET Qt5::Core)
|
||||
endif()
|
||||
|
||||
configure_file(res/input1.txt.in res1/input.txt COPYONLY)
|
||||
configure_file(res/input1.txt.in res1/inputAdded.txt COPYONLY)
|
||||
configure_file(res/input2.txt.in res2/input.txt COPYONLY)
|
||||
configure_file(res/input2.txt.in res2/inputAdded.txt COPYONLY)
|
||||
# Dependency generated qrc file
|
||||
add_custom_command(OUTPUT res2.qrc
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc
|
||||
)
|
||||
# Enable AUTORCC for all targets
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
add_executable(rccDepends
|
||||
main.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/res1.qrc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/res2.qrc )
|
||||
target_link_libraries(rccDepends ${QT_CORE_TARGET})
|
||||
add_custom_command(TARGET rccDepends POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDepends>" > target.txt)
|
||||
# Initial resource files setup
|
||||
configure_file(resPlain/input.txt.in resPlain/input.txt COPYONLY)
|
||||
configure_file(resPlain/input.txt.in resPlain/inputAdded.txt COPYONLY)
|
||||
configure_file(resGen/input.txt.in resGen/input.txt COPYONLY)
|
||||
configure_file(resGen/input.txt.in resGen/inputAdded.txt COPYONLY)
|
||||
|
||||
# Generated qrc file with dependency
|
||||
add_custom_command(OUTPUT resGen.qrc
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in
|
||||
COMMAND ${CMAKE_COMMAND} -E sleep 2
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc)
|
||||
|
||||
# Target that uses a plain .qrc file
|
||||
add_executable(rccDependsPlain main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resPlain.qrc)
|
||||
target_link_libraries(rccDependsPlain ${QT_CORE_TARGET})
|
||||
add_custom_command(TARGET rccDependsPlain POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsPlain>" > targetPlain.txt)
|
||||
|
||||
# Target that uses a GENERATED .qrc file
|
||||
add_executable(rccDependsGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc )
|
||||
target_link_libraries(rccDependsGen ${QT_CORE_TARGET})
|
||||
add_custom_command(TARGET rccDependsGen POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsGen>" > targetGen.txt)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Res1 input.
|
||||
@@ -1 +0,0 @@
|
||||
Res2 input.
|
||||
@@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts1">
|
||||
<file>res1/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,6 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts1">
|
||||
<file>res1/input.txt</file>
|
||||
<file alias="Added">res1/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts2">
|
||||
<file>res2/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,6 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/Texts2">
|
||||
<file>res2/input.txt</file>
|
||||
<file alias="Added">res2/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
1
Tests/QtAutogenRerun/rccDepends/resGen/input.txt.in
Normal file
1
Tests/QtAutogenRerun/rccDepends/resGen/input.txt.in
Normal file
@@ -0,0 +1 @@
|
||||
Generated resource input.
|
||||
1
Tests/QtAutogenRerun/rccDepends/resGen/inputAdded.txt.in
Normal file
1
Tests/QtAutogenRerun/rccDepends/resGen/inputAdded.txt.in
Normal file
@@ -0,0 +1 @@
|
||||
Generated resource input.
|
||||
5
Tests/QtAutogenRerun/rccDepends/resGenA.qrc.in
Normal file
5
Tests/QtAutogenRerun/rccDepends/resGenA.qrc.in
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsGenerated">
|
||||
<file>resGen/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
6
Tests/QtAutogenRerun/rccDepends/resGenB.qrc.in
Normal file
6
Tests/QtAutogenRerun/rccDepends/resGenB.qrc.in
Normal file
@@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsGenerated">
|
||||
<file>resGen/input.txt</file>
|
||||
<file alias="Added">resGen/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
1
Tests/QtAutogenRerun/rccDepends/resPlain/input.txt.in
Normal file
1
Tests/QtAutogenRerun/rccDepends/resPlain/input.txt.in
Normal file
@@ -0,0 +1 @@
|
||||
Plaint resource input.
|
||||
@@ -0,0 +1 @@
|
||||
Plaint resource input.
|
||||
5
Tests/QtAutogenRerun/rccDepends/resPlainA.qrc.in
Normal file
5
Tests/QtAutogenRerun/rccDepends/resPlainA.qrc.in
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsPlain">
|
||||
<file>resPlain/input.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
6
Tests/QtAutogenRerun/rccDepends/resPlainB.qrc.in
Normal file
6
Tests/QtAutogenRerun/rccDepends/resPlainB.qrc.in
Normal file
@@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/TextsPlain">
|
||||
<file>resPlain/input.txt</file>
|
||||
<file alias="Added">resPlain/inputAdded.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
Reference in New Issue
Block a user