Allow switching of QT_NO_CREATE_VERSIONLESS_TARGETS
Fixes: QTBUG-83774 Change-Id: Ib3f2507a917046426b94a779e205012ce52cbfe9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
ec2ac17c10
commit
fcceae605a
@ -419,14 +419,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
|
|||||||
!!ENDIF
|
!!ENDIF
|
||||||
!!ENDIF
|
!!ENDIF
|
||||||
|
|
||||||
# Add a versionless target, for compatibility with Qt6.
|
|
||||||
if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME})
|
|
||||||
add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
|
|
||||||
set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES
|
|
||||||
INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
!!IF !equals(TEMPLATE, aux)
|
!!IF !equals(TEMPLATE, aux)
|
||||||
!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
|
!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
|
||||||
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
|
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
|
||||||
@ -648,3 +640,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
|
|||||||
|
|
||||||
_qt5_$${CMAKE_MODULE_NAME}_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake\")
|
_qt5_$${CMAKE_MODULE_NAME}_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake\")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Add a versionless target, for compatibility with Qt6.
|
||||||
|
if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND TARGET Qt5::$${CMAKE_MODULE_NAME} AND NOT TARGET Qt::$${CMAKE_MODULE_NAME})
|
||||||
|
add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
|
||||||
|
set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES
|
||||||
|
INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
@ -162,3 +162,4 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.8)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
expect_pass(test_import_plugins BINARY ${CMAKE_CTEST_COMMAND})
|
expect_pass(test_import_plugins BINARY ${CMAKE_CTEST_COMMAND})
|
||||||
|
expect_pass(test_versionless_targets)
|
||||||
|
23
tests/auto/cmake/test_versionless_targets/CMakeLists.txt
Normal file
23
tests/auto/cmake/test_versionless_targets/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
|
||||||
|
project(versionless_targets)
|
||||||
|
|
||||||
|
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
|
||||||
|
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
|
||||||
|
if (NOT TARGET Qt5::Core)
|
||||||
|
message(SEND_ERROR "Qt5::Core target not defined!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (TARGET Qt::Core)
|
||||||
|
message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
|
||||||
|
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
|
||||||
|
if (NOT TARGET Qt::Core)
|
||||||
|
message(SEND_ERROR "Qt::Core target not defined!")
|
||||||
|
endif()
|
Loading…
Reference in New Issue
Block a user