QtAutogen: Fix AUTOGEN depends on custom command output with VS.
Visual Studio is handled as a special case for autogen depends. However, the special handling works only for target dependencies, not file dependencies output by a custom command. Use a PRE_BUILD step only if all depends are targets.
This commit is contained in:
parent
948d5d18fd
commit
112cba927a
|
@ -260,6 +260,18 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
|
||||||
// This also works around a VS 11 bug that may skip updating the target:
|
// This also works around a VS 11 bug that may skip updating the target:
|
||||||
// https://connect.microsoft.com/VisualStudio/feedback/details/769495
|
// https://connect.microsoft.com/VisualStudio/feedback/details/769495
|
||||||
usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7;
|
usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7;
|
||||||
|
if(usePRE_BUILD)
|
||||||
|
{
|
||||||
|
for (std::vector<std::string>::iterator it = depends.begin();
|
||||||
|
it != depends.end(); ++it)
|
||||||
|
{
|
||||||
|
if(!makefile->FindTargetToUse(it->c_str()))
|
||||||
|
{
|
||||||
|
usePRE_BUILD = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(usePRE_BUILD)
|
if(usePRE_BUILD)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,11 +58,17 @@ add_custom_target(generate_moc_input
|
||||||
COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h"
|
COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h"
|
||||||
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in"
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
|
add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
|
||||||
xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
|
xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
|
||||||
test.qrc resourcetester.cpp generated.cpp
|
test.qrc resourcetester.cpp generated.cpp
|
||||||
)
|
)
|
||||||
set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input)
|
set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h")
|
||||||
|
|
||||||
set_target_properties(QtAutogen codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
|
set_target_properties(QtAutogen codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "myinterface.h"
|
#include "myinterface.h"
|
||||||
|
#include "myotherinterface.h"
|
||||||
|
|
||||||
class Generated : public QObject, MyInterface
|
class Generated : public QObject, MyInterface, MyOtherInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(MyInterface)
|
Q_INTERFACES(MyInterface MyOtherInterface)
|
||||||
public:
|
public:
|
||||||
explicit Generated(QObject *parent = 0);
|
explicit Generated(QObject *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
#ifndef MYOTHERINTERFACE_H
|
||||||
|
#define MYOTHERINTERFACE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class MyOtherInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_INTERFACE(MyOtherInterface, "org.cmake.example.MyOtherInterface")
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue