CMake: Provide old style CMake variables for target info
This change provides the following per-module variables Qt6Widgets_LIBRARIES, Qt6Widgets_INCLUDE_DIRS, Qt6Widgets_DEFINITIONS, Qt6Widgets_COMPILE_DEFINITIONS, Qt6Widgets_PRIVATE_INCLUDE_DIRS. These are deprecated and are only intended for easier porting from Qt5 to Qt6. Qt consumers should instead rely on the Qt module targets e.g target_link_libraries(app PRIVATE Qt6::Widgets) Note that the variable contents includes transitive values for everything except the _LIBRARIES variant. So Qt6Widgets_INCLUDE_DIRS will contain values for Widgets, Gui and Core. Qt6Widgets_LIBRARIES only contains a value like Qt6::Widgets, and when that is used in target_link_libraries(), CMake will take care of the transitivity. Change-Id: I625e25aab7ba5eaf14de1dc76ba2a1a0c85e6226 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
bc29555e6e
commit
054b66a657
@ -19,6 +19,62 @@ if (NOT QT_NO_CREATE_TARGETS)
|
||||
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
|
||||
endif()
|
||||
|
||||
# DEPRECATED
|
||||
# Provide old style variables for includes, compile definitions, etc.
|
||||
# These variables are deprecated and only provided on a best-effort basis to facilitate porting.
|
||||
# Consider using target_link_libraries(app PRIVATE @QT_CMAKE_EXPORT_NAMESPACE@@target@) instead.
|
||||
set(@QT_CMAKE_EXPORT_NAMESPACE@@target@_LIBRARIES "@QT_CMAKE_EXPORT_NAMESPACE@::@target@")
|
||||
|
||||
get_target_property(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_INCLUDE_DIRS
|
||||
@QT_CMAKE_EXPORT_NAMESPACE@::@target@ INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(NOT _@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_INCLUDE_DIRS)
|
||||
set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_INCLUDE_DIRS "")
|
||||
endif()
|
||||
|
||||
if(TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@Private)
|
||||
get_target_property(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_PRIVATE_INCLUDE_DIRS
|
||||
@QT_CMAKE_EXPORT_NAMESPACE@::@target@Private INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(NOT _@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_PRIVATE_INCLUDE_DIRS)
|
||||
set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_PRIVATE_INCLUDE_DIRS "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_target_property(@QT_CMAKE_EXPORT_NAMESPACE@@target@_DEFINITIONS
|
||||
@QT_CMAKE_EXPORT_NAMESPACE@::@target@ INTERFACE_COMPILE_DEFINITIONS)
|
||||
if(NOT @QT_CMAKE_EXPORT_NAMESPACE@@target@_DEFINITIONS)
|
||||
set(@QT_CMAKE_EXPORT_NAMESPACE@@target@_DEFINITIONS "")
|
||||
else()
|
||||
list(TRANSFORM @QT_CMAKE_EXPORT_NAMESPACE@@target@_DEFINITIONS PREPEND "-D")
|
||||
endif()
|
||||
|
||||
get_target_property(@QT_CMAKE_EXPORT_NAMESPACE@@target@_COMPILE_DEFINITIONS
|
||||
@QT_CMAKE_EXPORT_NAMESPACE@::@target@ INTERFACE_COMPILE_DEFINITIONS)
|
||||
if(NOT @QT_CMAKE_EXPORT_NAMESPACE@@target@_COMPILE_DEFINITIONS)
|
||||
set(@QT_CMAKE_EXPORT_NAMESPACE@@target@_COMPILE_DEFINITIONS "")
|
||||
endif()
|
||||
|
||||
set(@QT_CMAKE_EXPORT_NAMESPACE@@target@_INCLUDE_DIRS
|
||||
${_@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_INCLUDE_DIRS})
|
||||
|
||||
set(@QT_CMAKE_EXPORT_NAMESPACE@@target@_PRIVATE_INCLUDE_DIRS
|
||||
${_@QT_CMAKE_EXPORT_NAMESPACE@@target@_OWN_PRIVATE_INCLUDE_DIRS})
|
||||
|
||||
foreach(_module_dep ${_@QT_CMAKE_EXPORT_NAMESPACE@@target@_MODULE_DEPENDENCIES})
|
||||
list(APPEND @QT_CMAKE_EXPORT_NAMESPACE@@target@_INCLUDE_DIRS
|
||||
${@QT_CMAKE_EXPORT_NAMESPACE@${_module_dep}_INCLUDE_DIRS})
|
||||
list(APPEND @QT_CMAKE_EXPORT_NAMESPACE@@target@_PRIVATE_INCLUDE_DIRS
|
||||
${@QT_CMAKE_EXPORT_NAMESPACE@${_module_dep}_PRIVATE_INCLUDE_DIRS})
|
||||
list(APPEND @QT_CMAKE_EXPORT_NAMESPACE@@target@_DEFINITIONS
|
||||
${@QT_CMAKE_EXPORT_NAMESPACE@${_module_dep}_DEFINITIONS})
|
||||
list(APPEND @QT_CMAKE_EXPORT_NAMESPACE@@target@_COMPILE_DEFINITIONS
|
||||
${@QT_CMAKE_EXPORT_NAMESPACE@${_module_dep}_COMPILE_DEFINITIONS})
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES @QT_CMAKE_EXPORT_NAMESPACE@@target@_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES @QT_CMAKE_EXPORT_NAMESPACE@@target@_PRIVATE_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES @QT_CMAKE_EXPORT_NAMESPACE@@target@_DEFINITIONS)
|
||||
list(REMOVE_DUPLICATES @QT_CMAKE_EXPORT_NAMESPACE@@target@_COMPILE_DEFINITIONS)
|
||||
endif()
|
||||
|
||||
foreach(extra_cmake_include @extra_cmake_includes@)
|
||||
|
@ -88,4 +88,5 @@ foreach(_target_dep ${_target_deps})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_MODULE_DEPENDENCIES "@qt_module_dependencies@")
|
||||
|
||||
|
@ -77,6 +77,7 @@ function(qt_internal_create_module_depends_file target)
|
||||
# ModuleDependencies.cmake.
|
||||
get_target_property(target_deps "${target}" _qt_target_deps)
|
||||
set(target_deps_seen "")
|
||||
set(qt_module_dependencies "")
|
||||
|
||||
if(NOT arg_HEADER_MODULE)
|
||||
get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES)
|
||||
@ -164,6 +165,10 @@ function(qt_internal_create_module_depends_file target)
|
||||
endif()
|
||||
|
||||
list(APPEND target_deps_seen "${dep_name}\;${dep_ver}")
|
||||
|
||||
if (dep_name MATCHES "${INSTALL_CMAKE_NAMESPACE}(.*)")
|
||||
list(APPEND qt_module_dependencies "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
Loading…
Reference in New Issue
Block a user