CMake: Unify creation of target aliases
For Qt6 we want to have Qt6::foo and Qt::foo. Enable that consistently. Change-Id: I3cf05c4171b13029bf508d307945e8be4687e86b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
This commit is contained in:
parent
78d34c3a30
commit
ece38e7e18
@ -533,6 +533,19 @@ function(qt_read_headers_pri module resultVarPrefix)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Add Qt::target and Qt6::target as aliases for the target
|
||||||
|
function(qt_internal_add_target_aliases target)
|
||||||
|
get_target_property(type "${target}" TYPE)
|
||||||
|
if (type STREQUAL EXECUTABLE)
|
||||||
|
add_executable("Qt::${target}" ALIAS "${target}")
|
||||||
|
add_executable("Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}")
|
||||||
|
else()
|
||||||
|
add_library("Qt::${target}" ALIAS "${target}")
|
||||||
|
add_library("Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
# This is the main entry function for creating a Qt module, that typically
|
# This is the main entry function for creating a Qt module, that typically
|
||||||
# consists of a library, public header files, private header files and configurable
|
# consists of a library, public header files, private header files and configurable
|
||||||
# features.
|
# features.
|
||||||
@ -559,12 +572,12 @@ function(add_qt_module target)
|
|||||||
else()
|
else()
|
||||||
add_library("${target}" STATIC)
|
add_library("${target}" STATIC)
|
||||||
endif()
|
endif()
|
||||||
add_library("Qt::${target}" ALIAS "${target}")
|
qt_internal_add_target_aliases("${target}")
|
||||||
|
|
||||||
# Add _private target to link against the private headers:
|
# Add _private target to link against the private headers:
|
||||||
set(target_private "${target}Private")
|
set(target_private "${target}Private")
|
||||||
add_library("${target_private}" INTERFACE)
|
add_library("${target_private}" INTERFACE)
|
||||||
add_library("Qt::${target_private}" ALIAS ${target_private})
|
qt_internal_add_target_aliases("${target_private}")
|
||||||
|
|
||||||
if(NOT DEFINED arg_CONFIG_MODULE_NAME)
|
if(NOT DEFINED arg_CONFIG_MODULE_NAME)
|
||||||
set(arg_CONFIG_MODULE_NAME "${module_lower}")
|
set(arg_CONFIG_MODULE_NAME "${module_lower}")
|
||||||
@ -587,7 +600,9 @@ function(add_qt_module target)
|
|||||||
qt_pull_features_into_current_scope(PUBLIC_FEATURES ${publicDep})
|
qt_pull_features_into_current_scope(PUBLIC_FEATURES ${publicDep})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(NOT ${arg_NO_MODULE_HEADERS})
|
if(${arg_NO_MODULE_HEADERS})
|
||||||
|
set_target_properties("${target}" PROPERTIES MODULE_HAS_HEADERS OFF)
|
||||||
|
else()
|
||||||
qt_ensure_perl()
|
qt_ensure_perl()
|
||||||
if(NOT DEFINED QT_SYNCQT)
|
if(NOT DEFINED QT_SYNCQT)
|
||||||
get_target_property(mocPath "Qt::moc" LOCATION)
|
get_target_property(mocPath "Qt::moc" LOCATION)
|
||||||
@ -598,17 +613,14 @@ function(add_qt_module target)
|
|||||||
set(QT_SYNCQT "${binDirectory}/syncqt.pl")
|
set(QT_SYNCQT "${binDirectory}/syncqt.pl")
|
||||||
endif()
|
endif()
|
||||||
execute_process(COMMAND "${HOST_PERL}" -w "${QT_SYNCQT}" -quiet -module "${module}" -version "${PROJECT_VERSION}" -outdir "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}")
|
execute_process(COMMAND "${HOST_PERL}" -w "${QT_SYNCQT}" -quiet -module "${module}" -version "${PROJECT_VERSION}" -outdir "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}")
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ${arg_NO_MODULE_HEADERS})
|
|
||||||
set_target_properties("${target}" PROPERTIES MODULE_HAS_HEADERS ON)
|
set_target_properties("${target}" PROPERTIES MODULE_HAS_HEADERS ON)
|
||||||
else()
|
|
||||||
set_target_properties("${target}" PROPERTIES MODULE_HAS_HEADERS OFF)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties("${target}" PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_LIBDIR}")
|
set_target_properties("${target}" PROPERTIES
|
||||||
set_target_properties("${target}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}")
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_LIBDIR}"
|
||||||
set_target_properties("${target}" PROPERTIES OUTPUT_NAME "${module_versioned}")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}"
|
||||||
|
OUTPUT_NAME "${module_versioned}")
|
||||||
|
|
||||||
qt_internal_module_include_dir(include_dir "${module}")
|
qt_internal_module_include_dir(include_dir "${module}")
|
||||||
|
|
||||||
@ -920,7 +932,7 @@ function(add_qt_tool name)
|
|||||||
LIBRARIES ${corelib} ${arg_LIBRARIES}
|
LIBRARIES ${corelib} ${arg_LIBRARIES}
|
||||||
)
|
)
|
||||||
target_sources("${name}" PRIVATE "${arg_SOURCES}")
|
target_sources("${name}" PRIVATE "${arg_SOURCES}")
|
||||||
add_executable("Qt::${name}" ALIAS "${name}")
|
qt_internal_add_target_aliases("${name}")
|
||||||
|
|
||||||
if (NOT arg_BOOTSTRAP)
|
if (NOT arg_BOOTSTRAP)
|
||||||
qt_internal_process_automatic_sources("${name}" ${arg_SOURCES})
|
qt_internal_process_automatic_sources("${name}" ${arg_SOURCES})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user