BUG: Only create library if target does not exist#34
Open
Conversation
With CMake 3.15 and Qt 5.14, the following command: ```cmake find_package(Qt5 5.14 CONFIG REQUIRED COMPONENTS Gui) ``` results in these errors: ``` CMake Error at /.../qt5/lib/cmake/Qt5Gui/Qt5Gui_QSvgPlugin.cmake:3 (add_library): add_library cannot create imported target "Qt5::QSvgPlugin" because another target with the same name already exists. Call Stack (most recent call first): /.../qt5/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:337 (include) /.../qt5/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package) ``` and ``` CMake Error at /.../qt5/lib/cmake/Qt5Svg/Qt5Svg_QSvgIconPlugin.cmake:2 (add_library): add_library cannot create imported target "Qt5::QSvgIconPlugin" because another target with the same name already exists. Call Stack (most recent call first): /.../qt5/lib/cmake/Qt5Svg/Qt5SvgConfig.cmake:337 (include) /.../qt5/lib/cmake/Qt5Gui/Qt5Gui_QSvgIconPlugin.cmake:8 (find_package) /.../qt5/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:337 (include) ```
Author
Contributor
|
+1 |
Contributor
|
@agirault This is only a mirror - see https://wiki.qt.io/Qt_Contribution_Guidelines for instructions on how to contribute. |
|
|
qtprojectorg
pushed a commit
that referenced
this pull request
Feb 14, 2025
Similar to commit 12d4bf1, which was for QLocale. Like it, QResource can be used very late in the execution, like for example the logging system. For example (simplified): #9 0x00007ffff759d497 in resourceMutex () at /io/qresource.cpp:188 #10 0x00007ffff759d615 in QResourcePrivate::load (this=0x41c940, file=...) at /io/qresource.cpp:333 #11 0x00007ffff759dc19 in QResourcePrivate::ensureInitialized (this=0x41c940) at /io/qresource.cpp:386 #14 0x00007ffff75011a9 in QLibrarySettings::load() at /global/qlibraryinfo.cpp:80 #22 0x00007ffff7501756 in havePaths () at /global/qlibraryinfo.cpp:149 #23 0x00007ffff75028e3 in QLibraryInfoPrivate::paths (p=QLibraryInfo::DataPath, usageMode=QLibraryInfoPrivate::RegularUsage) at /global/qlibraryinfo.cpp:613 #26 0x00007ffff758e4f0 in QLoggingRegistry::initializeRules () at /io/qloggingregistry.cpp:309 #34 0x00007ffff758f007 in QLoggingRegistry::instance () at io/qloggingregistry.cpp:424 #35 0x00007ffff758c50b in QLoggingCategory::init () at io/qloggingcategory.cpp:188 #43 0x00007ffff758c6bb in QLoggingCategory::defaultCategory () at io/qloggingcategory.cpp:317 #44 0x00007ffff750ff8e in qt_message_print (msgType=QtWarningMsg, context=..., message=...) at global/qlogging.cpp:2036 #45 0x00007ffff7509515 in qt_message(msgType=QtWarningMsg, context=..., msg=...) at global/qlogging.cpp:360 #46 0x00007ffff750a712 in QMessageLogger::warning (this=0x7fffffffd8b0, msg=...) at global/qlogging.cpp:600 #47 0x00007ffff790e083 in QThreadStorageData::finish (p=0x41b588) at thread/qthreadstorage.cpp:160 #50 0x00007ffff78ed423 in QThreadPrivate::finish (this=0x41b5e0) at thread/qthread_unix.cpp:404 #51 0x00007ffff78ec8ed in destroy_current_thread_data (p=0x41b520) at thread/qthread_unix.cpp:154 #52 0x00007ffff78ec9ec in Cleanup::~Cleanup () at thread/qthread_unix.cpp:204 Task-number: QTBUG-133206 Task-number: QTBUG-133500 Pick-to: 6.9 6.8 Change-Id: I7b653afb1b41ef3c1c9afffdaa93e6558740016b Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
qtprojectorg
pushed a commit
that referenced
this pull request
Feb 15, 2025
Similar to commit 12d4bf1, which was for QLocale. Like it, QResource can be used very late in the execution, like for example the logging system. For example (simplified): #9 0x00007ffff759d497 in resourceMutex () at /io/qresource.cpp:188 #10 0x00007ffff759d615 in QResourcePrivate::load (this=0x41c940, file=...) at /io/qresource.cpp:333 #11 0x00007ffff759dc19 in QResourcePrivate::ensureInitialized (this=0x41c940) at /io/qresource.cpp:386 #14 0x00007ffff75011a9 in QLibrarySettings::load() at /global/qlibraryinfo.cpp:80 #22 0x00007ffff7501756 in havePaths () at /global/qlibraryinfo.cpp:149 #23 0x00007ffff75028e3 in QLibraryInfoPrivate::paths (p=QLibraryInfo::DataPath, usageMode=QLibraryInfoPrivate::RegularUsage) at /global/qlibraryinfo.cpp:613 #26 0x00007ffff758e4f0 in QLoggingRegistry::initializeRules () at /io/qloggingregistry.cpp:309 #34 0x00007ffff758f007 in QLoggingRegistry::instance () at io/qloggingregistry.cpp:424 #35 0x00007ffff758c50b in QLoggingCategory::init () at io/qloggingcategory.cpp:188 #43 0x00007ffff758c6bb in QLoggingCategory::defaultCategory () at io/qloggingcategory.cpp:317 #44 0x00007ffff750ff8e in qt_message_print (msgType=QtWarningMsg, context=..., message=...) at global/qlogging.cpp:2036 #45 0x00007ffff7509515 in qt_message(msgType=QtWarningMsg, context=..., msg=...) at global/qlogging.cpp:360 #46 0x00007ffff750a712 in QMessageLogger::warning (this=0x7fffffffd8b0, msg=...) at global/qlogging.cpp:600 #47 0x00007ffff790e083 in QThreadStorageData::finish (p=0x41b588) at thread/qthreadstorage.cpp:160 #50 0x00007ffff78ed423 in QThreadPrivate::finish (this=0x41b5e0) at thread/qthread_unix.cpp:404 #51 0x00007ffff78ec8ed in destroy_current_thread_data (p=0x41b520) at thread/qthread_unix.cpp:154 #52 0x00007ffff78ec9ec in Cleanup::~Cleanup () at thread/qthread_unix.cpp:204 Task-number: QTBUG-133206 Task-number: QTBUG-133500 Pick-to: 6.8 Change-Id: I7b653afb1b41ef3c1c9afffdaa93e6558740016b Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit ba18ae3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg
pushed a commit
that referenced
this pull request
Feb 15, 2025
Similar to commit 12d4bf1, which was for QLocale. Like it, QResource can be used very late in the execution, like for example the logging system. For example (simplified): #9 0x00007ffff759d497 in resourceMutex () at /io/qresource.cpp:188 #10 0x00007ffff759d615 in QResourcePrivate::load (this=0x41c940, file=...) at /io/qresource.cpp:333 #11 0x00007ffff759dc19 in QResourcePrivate::ensureInitialized (this=0x41c940) at /io/qresource.cpp:386 #14 0x00007ffff75011a9 in QLibrarySettings::load() at /global/qlibraryinfo.cpp:80 #22 0x00007ffff7501756 in havePaths () at /global/qlibraryinfo.cpp:149 #23 0x00007ffff75028e3 in QLibraryInfoPrivate::paths (p=QLibraryInfo::DataPath, usageMode=QLibraryInfoPrivate::RegularUsage) at /global/qlibraryinfo.cpp:613 #26 0x00007ffff758e4f0 in QLoggingRegistry::initializeRules () at /io/qloggingregistry.cpp:309 #34 0x00007ffff758f007 in QLoggingRegistry::instance () at io/qloggingregistry.cpp:424 #35 0x00007ffff758c50b in QLoggingCategory::init () at io/qloggingcategory.cpp:188 #43 0x00007ffff758c6bb in QLoggingCategory::defaultCategory () at io/qloggingcategory.cpp:317 #44 0x00007ffff750ff8e in qt_message_print (msgType=QtWarningMsg, context=..., message=...) at global/qlogging.cpp:2036 #45 0x00007ffff7509515 in qt_message(msgType=QtWarningMsg, context=..., msg=...) at global/qlogging.cpp:360 #46 0x00007ffff750a712 in QMessageLogger::warning (this=0x7fffffffd8b0, msg=...) at global/qlogging.cpp:600 #47 0x00007ffff790e083 in QThreadStorageData::finish (p=0x41b588) at thread/qthreadstorage.cpp:160 #50 0x00007ffff78ed423 in QThreadPrivate::finish (this=0x41b5e0) at thread/qthread_unix.cpp:404 #51 0x00007ffff78ec8ed in destroy_current_thread_data (p=0x41b520) at thread/qthread_unix.cpp:154 #52 0x00007ffff78ec9ec in Cleanup::~Cleanup () at thread/qthread_unix.cpp:204 Task-number: QTBUG-133206 Task-number: QTBUG-133500 Change-Id: I7b653afb1b41ef3c1c9afffdaa93e6558740016b Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit ba18ae3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit c6fdf95)
qtprojectorg
pushed a commit
that referenced
this pull request
Mar 28, 2025
When the test functions runs off the end (or returns from a failed
QCOMPARE/QVERIFY), `activeMenu` is destroyed while it's the
QMenuBarPrivate::activeMenu, and the following focusInEvent() on the
QMenuBar causes QMenuBarPrivate::setCurrentAction() to access
`activeMenu` when it has already ceased to be a QMenu.
Says UBSan:
qpointer.h:75:14: runtime error: downcast of address 0x7fff87934860 which does not point to an object of type 'QMenu'
0x7fff87934860: note: object is of type 'QWidget'
00 00 00 00 08 f1 0e be 17 7f 00 00 80 c8 00 00 90 61 00 00 b8 f2 0e be 17 7f 00 00 00 00 62 c6
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'QWidget'
#0 0x7f17baf57be5 in QPointer<QMenu>::data() const qpointer.h:75
#1 0x7f17baf57be5 in QPointer<QMenu>::operator QMenu*() const qpointer.h:83
#2 0x7f17baf57be5 in QMenuBarPrivate::setCurrentAction(QAction*, bool, bool) qmenubar.cpp:351
#3 0x7f17baf5a200 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:245
#4 0x7f17baf5b727 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:1260
#5 0x7f17baf5b727 in QMenuBar::focusInEvent(QFocusEvent*) qmenubar.cpp:1259
[...]
#34 0x7f17b93373d6 in QWidget::~QWidget() qwidget.cpp:1508
#35 0x7f17badb4658 in QMenu::~QMenu() qmenu.cpp:1789
Since I couldn't fix the problem on short notice, I created
QTBUG-135151 to track it.
For now, simply close the QMenuBar on all exists from the test
function to avoid this code path.
Task-number: QTBUG-135151
Pick-to: 6.9 6.8 6.5
Change-Id: Id8c9ee090d8bbc5ec22ce3f2ff7485766640ab43
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
qtprojectorg
pushed a commit
that referenced
this pull request
Mar 28, 2025
When the test functions runs off the end (or returns from a failed
QCOMPARE/QVERIFY), `activeMenu` is destroyed while it's the
QMenuBarPrivate::activeMenu, and the following focusInEvent() on the
QMenuBar causes QMenuBarPrivate::setCurrentAction() to access
`activeMenu` when it has already ceased to be a QMenu.
Says UBSan:
qpointer.h:75:14: runtime error: downcast of address 0x7fff87934860 which does not point to an object of type 'QMenu'
0x7fff87934860: note: object is of type 'QWidget'
00 00 00 00 08 f1 0e be 17 7f 00 00 80 c8 00 00 90 61 00 00 b8 f2 0e be 17 7f 00 00 00 00 62 c6
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'QWidget'
#0 0x7f17baf57be5 in QPointer<QMenu>::data() const qpointer.h:75
#1 0x7f17baf57be5 in QPointer<QMenu>::operator QMenu*() const qpointer.h:83
#2 0x7f17baf57be5 in QMenuBarPrivate::setCurrentAction(QAction*, bool, bool) qmenubar.cpp:351
#3 0x7f17baf5a200 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:245
#4 0x7f17baf5b727 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:1260
#5 0x7f17baf5b727 in QMenuBar::focusInEvent(QFocusEvent*) qmenubar.cpp:1259
[...]
#34 0x7f17b93373d6 in QWidget::~QWidget() qwidget.cpp:1508
#35 0x7f17badb4658 in QMenu::~QMenu() qmenu.cpp:1789
Since I couldn't fix the problem on short notice, I created
QTBUG-135151 to track it.
For now, simply close the QMenuBar on all exists from the test
function to avoid this code path.
Task-number: QTBUG-135151
Pick-to: 6.8 6.5
Change-Id: Id8c9ee090d8bbc5ec22ce3f2ff7485766640ab43
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 83af06b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg
pushed a commit
that referenced
this pull request
Mar 29, 2025
When the test functions runs off the end (or returns from a failed
QCOMPARE/QVERIFY), `activeMenu` is destroyed while it's the
QMenuBarPrivate::activeMenu, and the following focusInEvent() on the
QMenuBar causes QMenuBarPrivate::setCurrentAction() to access
`activeMenu` when it has already ceased to be a QMenu.
Says UBSan:
qpointer.h:75:14: runtime error: downcast of address 0x7fff87934860 which does not point to an object of type 'QMenu'
0x7fff87934860: note: object is of type 'QWidget'
00 00 00 00 08 f1 0e be 17 7f 00 00 80 c8 00 00 90 61 00 00 b8 f2 0e be 17 7f 00 00 00 00 62 c6
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'QWidget'
#0 0x7f17baf57be5 in QPointer<QMenu>::data() const qpointer.h:75
#1 0x7f17baf57be5 in QPointer<QMenu>::operator QMenu*() const qpointer.h:83
#2 0x7f17baf57be5 in QMenuBarPrivate::setCurrentAction(QAction*, bool, bool) qmenubar.cpp:351
#3 0x7f17baf5a200 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:245
#4 0x7f17baf5b727 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:1260
#5 0x7f17baf5b727 in QMenuBar::focusInEvent(QFocusEvent*) qmenubar.cpp:1259
[...]
#34 0x7f17b93373d6 in QWidget::~QWidget() qwidget.cpp:1508
#35 0x7f17badb4658 in QMenu::~QMenu() qmenu.cpp:1789
Since I couldn't fix the problem on short notice, I created
QTBUG-135151 to track it.
For now, simply close the QMenuBar on all exists from the test
function to avoid this code path.
Task-number: QTBUG-135151
Pick-to: 6.5
Change-Id: Id8c9ee090d8bbc5ec22ce3f2ff7485766640ab43
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 83af06b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c6ae521)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With CMake 3.15 and Qt 5.14, the following command:
find_package(Qt5 5.14 CONFIG REQUIRED COMPONENTS Gui)results in these errors:
and
because the following targets are defined in two files:
Qt5Gui_QSvgIconPlugin.cmakeandQt5Svg_QSvgIconPlugin.cmakeQt5Gui_QSvgPlugin.cmakeandQt5Svg_QSvgPlugin.cmakeNote: Qt 5.14 was retrieved as the official commercial build, not built from source.