Browse Source

QtAutogen: Use the basename for resource files.

The rcc tool generates a cpp file with a symbol called qInitResources
or called qInitResources_${name}, if the name is passed. The
qInitResources symbol clashes if multiple qrc files are used in
one target.

Always pass the name to ensure that the symbol is unique. This is also
the behavior of the qtx_add_resource macros.
Stephen Kelly 11 years ago
parent
commit
261acd9109

+ 2 - 0
Source/cmQtAutoGenerators.cxx

@@ -2074,6 +2074,8 @@ bool cmQtAutoGenerators::GenerateQrc()
           }
         }
 
+      command.push_back("-name");
+      command.push_back(basename);
       command.push_back("-o");
       command.push_back(rcc_output_file);
       command.push_back(*si);

+ 1 - 1
Tests/QtAutogen/CMakeLists.txt

@@ -66,7 +66,7 @@ add_custom_command(
 
 add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
                xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
-               test.qrc resourcetester.cpp generated.cpp
+               test.qrc second_resource.qrc resourcetester.cpp generated.cpp
 )
 set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h")
 

+ 2 - 0
Tests/QtAutogen/resourcetester.cpp

@@ -16,6 +16,8 @@ void ResourceTester::doTest()
 {
   if (!QFile::exists(":/CMakeLists.txt"))
       qApp->exit(EXIT_FAILURE);
+  if (!QFile::exists(":/main.cpp"))
+      qApp->exit(EXIT_FAILURE);
 
   QTimer::singleShot(0, qApp, SLOT(quit()));
 }

+ 5 - 0
Tests/QtAutogen/second_resource.qrc

@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+    <file>main.cpp</file>
+</qresource>
+</RCC>