summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx5
-rw-r--r--Tests/QtAutogen/ObjectLibrary/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt6
3 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
index f79ffd4..f8d18f2 100644
--- a/Source/cmQtAutoGenGlobalInitializer.cxx
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -97,6 +97,11 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
}
std::set<std::string> const& languages =
target->GetAllConfigCompileLanguages();
+ // cmGeneratorTarget::GetAllConfigCompileLanguages caches the target's
+ // sources. Clear it so that OBJECT library targets that are AUTOGEN
+ // initialized after this target get their added mocs_compilation.cpp
+ // source acknowledged by this target.
+ target->ClearSourcesCache();
if (languages.count("CSharp")) {
// Don't process target if it's a CSharp target
continue;
diff --git a/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt
index ec204e7..e8af6c9 100644
--- a/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt
+++ b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt
@@ -16,3 +16,8 @@ target_compile_features(b PRIVATE ${QT_COMPILE_FEATURES})
# Executable with OBJECT library generator expressions
add_executable(someProgram main.cpp $<TARGET_OBJECTS:a> $<TARGET_OBJECTS:b>)
target_link_libraries(someProgram ${QT_LIBRARIES})
+
+# Executable without its own AUTOMOC.
+add_executable(someProgram2 main.cpp)
+target_link_libraries(someProgram2 PRIVATE a b ${QT_LIBRARIES})
+set_property(TARGET someProgram2 PROPERTY AUTOMOC OFF)
diff --git a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt
index cb1a2e5..69230b6 100644
--- a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt
@@ -10,4 +10,10 @@ CMake Error at OwnSources.cmake:[0-9]+ \(add_library\):
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
+
+CMake Error at OwnSources.cmake:[0-9]+ \(add_library\):
+ The SOURCES of "A" use a generator expression that depends on the SOURCES
+ themselves.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
CMake Generate step failed\. Build files cannot be regenerated correctly\.$