Merge topic 'fix-automoc-no-qt'
a223a3b
Automoc: Don't create automoc targets if Qt is not used (#13999)65b5c1e
Merge branch 'property-link-depends-no-crash' into fix-automoc-no-qt
This commit is contained in:
commit
26bfece1af
|
@ -1086,12 +1086,14 @@ void cmGlobalGenerator::CreateAutomocTargets()
|
||||||
if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported())
|
if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported())
|
||||||
{
|
{
|
||||||
cmQtAutomoc automoc;
|
cmQtAutomoc automoc;
|
||||||
automoc.InitializeMocSourceFile(&target);
|
if(automoc.InitializeMocSourceFile(&target))
|
||||||
|
{
|
||||||
automocs.push_back(std::make_pair(automoc, &target));
|
automocs.push_back(std::make_pair(automoc, &target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (Automocs::iterator it = automocs.begin(); it != automocs.end();
|
for (Automocs::iterator it = automocs.begin(); it != automocs.end();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,10 +119,21 @@ cmQtAutomoc::cmQtAutomoc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutomoc::InitializeMocSourceFile(cmTarget* target)
|
bool cmQtAutomoc::InitializeMocSourceFile(cmTarget* target)
|
||||||
{
|
{
|
||||||
|
cmMakefile* makefile = target->GetMakefile();
|
||||||
|
// don't do anything if there is no Qt4 or Qt5Core (which contains moc):
|
||||||
|
std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
|
||||||
|
if (qtMajorVersion == "")
|
||||||
|
{
|
||||||
|
qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
|
||||||
|
}
|
||||||
|
if (qtMajorVersion != "4" && qtMajorVersion != "5")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::string automocTargetName = target->GetName();
|
std::string automocTargetName = target->GetName();
|
||||||
cmMakefile *makefile = target->GetMakefile();
|
|
||||||
automocTargetName += "_automoc";
|
automocTargetName += "_automoc";
|
||||||
std::string mocCppFile = makefile->GetCurrentOutputDirectory();
|
std::string mocCppFile = makefile->GetCurrentOutputDirectory();
|
||||||
mocCppFile += "/";
|
mocCppFile += "/";
|
||||||
|
@ -134,6 +145,7 @@ void cmQtAutomoc::InitializeMocSourceFile(cmTarget* target)
|
||||||
mocCppFile.c_str(), false);
|
mocCppFile.c_str(), false);
|
||||||
|
|
||||||
target->AddSourceFile(mocCppSource);
|
target->AddSourceFile(mocCppSource);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
|
void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
|
||||||
|
@ -141,16 +153,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
cmMakefile* makefile = target->GetMakefile();
|
||||||
cmLocalGenerator* localGen = makefile->GetLocalGenerator();
|
cmLocalGenerator* localGen = makefile->GetLocalGenerator();
|
||||||
const char* targetName = target->GetName();
|
const char* targetName = target->GetName();
|
||||||
// don't do anything if there is no Qt4 or Qt5Core (which contains moc):
|
|
||||||
std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
|
|
||||||
if (qtMajorVersion == "")
|
|
||||||
{
|
|
||||||
qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
|
|
||||||
}
|
|
||||||
if (qtMajorVersion != "4" && qtMajorVersion != "5")
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
|
bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
cmQtAutomoc();
|
cmQtAutomoc();
|
||||||
bool Run(const char* targetDirectory);
|
bool Run(const char* targetDirectory);
|
||||||
|
|
||||||
void InitializeMocSourceFile(cmTarget* target);
|
bool InitializeMocSourceFile(cmTarget* target);
|
||||||
void SetupAutomocTarget(cmTarget* target);
|
void SetupAutomocTarget(cmTarget* target);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -993,6 +993,16 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
|
||||||
)
|
)
|
||||||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment")
|
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment")
|
||||||
|
|
||||||
|
add_test(QtAutomocNoQt ${CMAKE_CTEST_COMMAND}
|
||||||
|
--build-and-test
|
||||||
|
"${CMake_SOURCE_DIR}/Tests/QtAutomocNoQt"
|
||||||
|
"${CMake_BINARY_DIR}/Tests/QtAutomocNoQt"
|
||||||
|
${build_generator_args}
|
||||||
|
--build-project QtAutomocNoQt
|
||||||
|
--build-options -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
|
||||||
|
)
|
||||||
|
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
|
||||||
|
|
||||||
if(QT4_WORKS AND QT_QTGUI_FOUND)
|
if(QT4_WORKS AND QT_QTGUI_FOUND)
|
||||||
add_test(QtAutomoc ${CMAKE_CTEST_COMMAND}
|
add_test(QtAutomoc ${CMAKE_CTEST_COMMAND}
|
||||||
--build-and-test
|
--build-and-test
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
project(QtAutomocNoQt)
|
||||||
|
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
|
add_executable(hello main.c)
|
|
@ -0,0 +1,4 @@
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue