cmake: Generate config files with Qt:: prefix
Generate CMake config files which export Qt targets with a Qt:: prefix (i.e. without a major version suffix in the namespace) Change-Id: Ia07f98be6d0e24c196e3880b7469f1f0c6232c06 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
f2bb48e635
commit
aef11e420d
@ -80,6 +80,10 @@ install(TARGETS Platform GlobalConfig GlobalConfigPrivate EXPORT "${INSTALL_CMAK
|
||||
install(EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets" NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}:: DESTINATION "${config_install_dir}")
|
||||
export(EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets")
|
||||
|
||||
qt_internal_export_modern_cmake_config_targets_file(TARGETS Platform GlobalConfig GlobalConfigPrivate
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}
|
||||
CONFIG_INSTALL_DIR ${config_install_dir})
|
||||
|
||||
## Install some QtBase specific CMake files:
|
||||
install(FILES
|
||||
cmake/QtBuild.cmake
|
||||
|
@ -130,6 +130,23 @@ endif()
|
||||
|
||||
# Functions and macros:
|
||||
|
||||
function(qt_internal_export_modern_cmake_config_targets_file)
|
||||
cmake_parse_arguments(__arg "" "EXPORT_NAME_PREFIX;CONFIG_INSTALL_DIR" "TARGETS" ${ARGN})
|
||||
|
||||
foreach(target ${__arg_TARGETS})
|
||||
if (TARGET "${target}Versionless")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
add_library("${target}Versionless" INTERFACE)
|
||||
target_link_libraries("${target}Versionless" INTERFACE "${target}")
|
||||
set_target_properties("${target}Versionless" PROPERTIES EXPORT_NAME "${target}")
|
||||
install(TARGETS "${target}Versionless" EXPORT "${__arg_EXPORT_NAME_PREFIX}VersionlessTargets")
|
||||
endforeach()
|
||||
|
||||
install(EXPORT "${__arg_EXPORT_NAME_PREFIX}VersionlessTargets" NAMESPACE Qt:: DESTINATION "${__arg_CONFIG_INSTALL_DIR}")
|
||||
endfunction()
|
||||
|
||||
# Print all variables defined in the current scope.
|
||||
macro(qt_debug_print_variables)
|
||||
cmake_parse_arguments(__arg "DEDUP" "" "MATCH;IGNORE" ${ARGN})
|
||||
@ -678,10 +695,13 @@ function(add_qt_module target)
|
||||
PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${module}
|
||||
PRIVATE_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${module}/${PROJECT_VERSION}/${module}/private
|
||||
)
|
||||
|
||||
set(config_install_dir "${INSTALL_LIBDIR}/cmake/${INSTALL_CMAKE_NAMESPACE}${target}")
|
||||
install(EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets" NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}:: DESTINATION ${config_install_dir})
|
||||
|
||||
qt_internal_export_modern_cmake_config_targets_file(TARGETS "${target}" "${target_private}"
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
|
||||
CONFIG_INSTALL_DIR "${config_install_dir}")
|
||||
|
||||
set(extra_cmake_files)
|
||||
set(extra_cmake_includes)
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake")
|
||||
@ -816,6 +836,10 @@ endif()
|
||||
install(EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets"
|
||||
NAMESPACE "${QT_CMAKE_EXPORT_NAMESPACE}::"
|
||||
DESTINATION "${INSTALL_LIBDIR}/cmake/${INSTALL_CMAKE_NAMESPACE}${target}")
|
||||
|
||||
qt_internal_export_modern_cmake_config_targets_file(TARGETS ${QT_KNOWN_MODULE_${module_name}_TOOLS}
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
|
||||
CONFIG_INSTALL_DIR ${config_install_dir})
|
||||
endfunction()
|
||||
|
||||
function(qt_internal_check_directory_or_type name dir type default result_var)
|
||||
|
@ -9,6 +9,8 @@ get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
|
||||
|
||||
# if (NOT @INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS)
|
||||
# set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "The Qt package requires at least one component")
|
||||
# set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
|
||||
|
@ -12,6 +12,8 @@ endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
|
||||
|
||||
foreach(extra_cmake_include @extra_cmake_includes@)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}")
|
||||
endforeach()
|
||||
|
Loading…
Reference in New Issue
Block a user