Merge topic 'fix-automoc-linker-language'
79568f9
automoc: Add source file to target early to set the linker language
This commit is contained in:
commit
6e567cabea
|
@ -1067,6 +1067,8 @@ bool cmGlobalGenerator::CheckTargets()
|
|||
void cmGlobalGenerator::CreateAutomocTargets()
|
||||
{
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
typedef std::vector<std::pair<cmQtAutomoc, cmTarget*> > Automocs;
|
||||
Automocs automocs;
|
||||
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
|
||||
{
|
||||
cmTargets& targets =
|
||||
|
@ -1084,11 +1086,17 @@ void cmGlobalGenerator::CreateAutomocTargets()
|
|||
if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported())
|
||||
{
|
||||
cmQtAutomoc automoc;
|
||||
automoc.SetupAutomocTarget(&target);
|
||||
automoc.InitializeMocSourceFile(&target);
|
||||
automocs.push_back(std::make_pair(automoc, &target));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Automocs::iterator it = automocs.begin(); it != automocs.end();
|
||||
++it)
|
||||
{
|
||||
it->first.SetupAutomocTarget(it->second);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,22 @@ cmQtAutomoc::cmQtAutomoc()
|
|||
}
|
||||
}
|
||||
|
||||
void cmQtAutomoc::InitializeMocSourceFile(cmTarget* target)
|
||||
{
|
||||
std::string automocTargetName = target->GetName();
|
||||
cmMakefile *makefile = target->GetMakefile();
|
||||
automocTargetName += "_automoc";
|
||||
std::string mocCppFile = makefile->GetCurrentOutputDirectory();
|
||||
mocCppFile += "/";
|
||||
mocCppFile += automocTargetName;
|
||||
mocCppFile += ".cpp";
|
||||
cmSourceFile* mocCppSource = makefile->GetOrCreateSource(mocCppFile.c_str(),
|
||||
true);
|
||||
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
|
||||
mocCppFile.c_str(), false);
|
||||
|
||||
target->AddSourceFile(mocCppSource);
|
||||
}
|
||||
|
||||
void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
|
||||
{
|
||||
|
@ -268,17 +284,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
|
|||
outputFile += "/AutomocInfo.cmake";
|
||||
makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
|
||||
false, true, false);
|
||||
|
||||
std::string mocCppFile = makefile->GetCurrentOutputDirectory();
|
||||
mocCppFile += "/";
|
||||
mocCppFile += automocTargetName;
|
||||
mocCppFile += ".cpp";
|
||||
cmSourceFile* mocCppSource = makefile->GetOrCreateSource(mocCppFile.c_str(),
|
||||
true);
|
||||
target->AddSourceFile(mocCppSource);
|
||||
|
||||
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
|
||||
mocCppFile.c_str(), false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
cmQtAutomoc();
|
||||
bool Run(const char* targetDirectory);
|
||||
|
||||
void InitializeMocSourceFile(cmTarget* target);
|
||||
void SetupAutomocTarget(cmTarget* target);
|
||||
|
||||
private:
|
||||
|
|
|
@ -38,3 +38,9 @@ generate_export_header(libC)
|
|||
target_link_libraries(libC LINK_PUBLIC libB)
|
||||
|
||||
target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} libC)
|
||||
|
||||
add_library(empty STATIC empty.cpp)
|
||||
set_target_properties(empty PROPERTIES AUTOMOC TRUE)
|
||||
target_link_libraries(empty no_link_language)
|
||||
add_library(no_link_language STATIC empty.h)
|
||||
set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
// No content
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
class Empty : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Empty(QObject *parent = 0) {}
|
||||
};
|
Loading…
Reference in New Issue