CMake: Don't show the incompatible version warning when not needed
If a find_package(Qt6Foo) call has the QUIET option passed, don't display the incompatible version warning. Also if the find_package call has the EXACT option passed, and the searched for version does not match the package version exactly, there's no point in showing the warning because find_package will reject the package anyway, even if we set PACKAGE_VERSION_COMPATIBLE to TRUE Pick-to: 6.2 6.3 6.4 Change-Id: I78ef95cf4a045034fc50853465f3ba1db84bba63 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
3b12305575
commit
74d8321771
@ -17,9 +17,17 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(__qt_disable_package_version_check)
|
if(__qt_disable_package_version_check)
|
||||||
|
# Don't show the warning needlessly if we know that we're doing an exact search, and the
|
||||||
|
# version found is not the exactly same.
|
||||||
|
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT
|
||||||
|
AND NOT PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||||
|
set(QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Warn if version check is disabled regardless if it's a Qt repo build or user project build.
|
# Warn if version check is disabled regardless if it's a Qt repo build or user project build.
|
||||||
# Allow to opt out of warning.
|
# Allow to opt out of warning.
|
||||||
if(__qt_package_version_incompatible AND NOT QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING)
|
if(__qt_package_version_incompatible AND NOT QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING
|
||||||
|
AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Package ${PACKAGE_FIND_NAME} with version ${PACKAGE_VERSION} was accepted as "
|
"Package ${PACKAGE_FIND_NAME} with version ${PACKAGE_VERSION} was accepted as "
|
||||||
"compatible because QT_NO_PACKAGE_VERSION_CHECK was set to TRUE. There is no guarantee "
|
"compatible because QT_NO_PACKAGE_VERSION_CHECK was set to TRUE. There is no guarantee "
|
||||||
|
Loading…
Reference in New Issue
Block a user