2020-05-15 09:37:08 +00:00
|
|
|
function(qt_internal_write_depends_file module)
|
2020-01-26 11:25:40 +00:00
|
|
|
set(outfile "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}/${module}/${module}Depends")
|
2018-10-24 13:20:27 +00:00
|
|
|
set(contents "/* This file was generated by cmake with the info from ${module} target. */\n")
|
|
|
|
string(APPEND contents "#ifdef __cplusplus /* create empty PCH in C mode */\n")
|
|
|
|
foreach (m ${ARGN})
|
|
|
|
string(APPEND contents "# include <Qt${m}/Qt${m}>\n")
|
|
|
|
endforeach()
|
|
|
|
string(APPEND contents "#endif\n")
|
|
|
|
|
2018-10-30 14:25:53 +00:00
|
|
|
file(GENERATE OUTPUT "${outfile}" CONTENT "${contents}")
|
2018-10-24 13:20:27 +00:00
|
|
|
endfunction()
|
|
|
|
|
2019-09-24 13:53:41 +00:00
|
|
|
macro(qt_collect_third_party_deps target)
|
|
|
|
set(_target_is_static OFF)
|
|
|
|
get_target_property(_target_type ${target} TYPE)
|
|
|
|
if (${_target_type} STREQUAL "STATIC_LIBRARY")
|
|
|
|
set(_target_is_static ON)
|
|
|
|
endif()
|
|
|
|
unset(_target_type)
|
2019-05-03 14:03:15 +00:00
|
|
|
# If we are doing a non-static Qt build, we only want to propagate public dependencies.
|
|
|
|
# If we are doing a static Qt build, we need to propagate all dependencies.
|
|
|
|
set(depends_var "public_depends")
|
2019-09-24 13:53:41 +00:00
|
|
|
if(_target_is_static)
|
2019-05-03 14:03:15 +00:00
|
|
|
set(depends_var "depends")
|
|
|
|
endif()
|
2019-09-24 13:53:41 +00:00
|
|
|
unset(_target_is_static)
|
2019-05-03 14:03:15 +00:00
|
|
|
|
|
|
|
foreach(dep ${${depends_var}})
|
|
|
|
# Gather third party packages that should be found when using the Qt module.
|
|
|
|
# Also handle nolink target dependencies.
|
|
|
|
string(REGEX REPLACE "_nolink$" "" base_dep "${dep}")
|
|
|
|
if(NOT base_dep STREQUAL dep)
|
|
|
|
# Resets target name like Vulkan_nolink to Vulkan, because we need to call
|
|
|
|
# find_package(Vulkan).
|
|
|
|
set(dep ${base_dep})
|
|
|
|
endif()
|
2018-10-30 14:25:53 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
if(TARGET ${dep})
|
|
|
|
list(FIND third_party_deps_seen ${dep} dep_seen)
|
2019-04-29 12:36:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
get_target_property(package_name ${dep} INTERFACE_QT_PACKAGE_NAME)
|
|
|
|
if(dep_seen EQUAL -1 AND package_name)
|
|
|
|
list(APPEND third_party_deps_seen ${dep})
|
|
|
|
get_target_property(package_version ${dep} INTERFACE_QT_PACKAGE_VERSION)
|
|
|
|
if(NOT package_version)
|
|
|
|
set(package_version "")
|
2019-04-29 12:36:25 +00:00
|
|
|
endif()
|
2019-05-03 14:03:15 +00:00
|
|
|
|
|
|
|
get_target_property(package_components ${dep} INTERFACE_QT_PACKAGE_COMPONENTS)
|
|
|
|
if(NOT package_components)
|
|
|
|
set(package_components "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND third_party_deps
|
|
|
|
"${package_name}\;${package_version}\;${package_components}")
|
2018-10-24 13:20:27 +00:00
|
|
|
endif()
|
2019-05-03 14:03:15 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
function(qt_internal_create_module_depends_file target)
|
2019-08-19 13:07:22 +00:00
|
|
|
get_target_property(target_type "${target}" TYPE)
|
|
|
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
set(arg_HEADER_MODULE ON)
|
|
|
|
else()
|
|
|
|
set(arg_HEADER_MODULE OFF)
|
|
|
|
endif()
|
|
|
|
|
2020-02-11 15:49:54 +00:00
|
|
|
set(depends "")
|
|
|
|
if(target_type STREQUAL "STATIC_LIBRARY" AND NOT arg_HEADER_MODULE)
|
2019-08-19 13:07:22 +00:00
|
|
|
get_target_property(depends "${target}" LINK_LIBRARIES)
|
|
|
|
endif()
|
2020-02-11 15:49:54 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
|
2019-08-20 13:46:12 +00:00
|
|
|
|
|
|
|
# Used for collecting Qt module dependencies that should be find_package()'d in
|
|
|
|
# ModuleDependencies.cmake.
|
2019-05-03 14:03:15 +00:00
|
|
|
get_target_property(target_deps "${target}" _qt_target_deps)
|
|
|
|
set(target_deps_seen "")
|
2018-10-30 14:25:53 +00:00
|
|
|
|
2019-08-19 13:07:22 +00:00
|
|
|
if(NOT arg_HEADER_MODULE)
|
|
|
|
get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES)
|
|
|
|
endif()
|
2019-06-12 11:09:13 +00:00
|
|
|
if(NOT extra_depends STREQUAL "${extra_depends}-NOTFOUND")
|
2019-11-15 15:28:17 +00:00
|
|
|
list(APPEND target_deps "${extra_depends}")
|
2019-06-12 11:09:13 +00:00
|
|
|
endif()
|
|
|
|
|
2019-08-20 13:46:12 +00:00
|
|
|
# Used for assembling the content of an include/Module/ModuleDepends.h header.
|
2019-05-03 14:03:15 +00:00
|
|
|
set(qtdeps "")
|
2019-08-20 13:46:12 +00:00
|
|
|
|
|
|
|
# Used for collecting third party dependencies that should be find_package()'d in
|
|
|
|
# ModuleDependencies.cmake.
|
2019-05-03 14:03:15 +00:00
|
|
|
set(third_party_deps "")
|
|
|
|
set(third_party_deps_seen "")
|
2019-08-20 13:46:12 +00:00
|
|
|
|
|
|
|
# Used for collecting Qt tool dependencies that should be find_package()'d in
|
|
|
|
# ModuleToolsDependencies.cmake.
|
2019-05-03 14:03:15 +00:00
|
|
|
set(tool_deps "")
|
|
|
|
set(tool_deps_seen "")
|
2019-08-20 13:46:12 +00:00
|
|
|
|
|
|
|
# Used for collecting Qt tool dependencies that should be find_package()'d in
|
|
|
|
# ModuleDependencies.cmake.
|
2019-05-03 14:03:15 +00:00
|
|
|
set(main_module_tool_deps "")
|
|
|
|
|
2019-08-20 13:24:14 +00:00
|
|
|
qt_internal_get_qt_all_known_modules(known_modules)
|
2019-08-20 13:44:34 +00:00
|
|
|
|
|
|
|
set(all_depends ${depends} ${public_depends})
|
|
|
|
foreach (dep ${all_depends})
|
2019-05-03 14:03:15 +00:00
|
|
|
# Normalize module by stripping leading "Qt::" and trailing "Private"
|
|
|
|
if (dep MATCHES "Qt::(.*)")
|
|
|
|
set(dep "${CMAKE_MATCH_1}")
|
2020-03-05 13:28:15 +00:00
|
|
|
if (TARGET Qt::${dep})
|
|
|
|
get_target_property(dep_type Qt::${dep} TYPE)
|
|
|
|
if (NOT dep_type STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
get_target_property(skip_module_depends_include Qt::${dep} QT_MODULE_SKIP_DEPENDS_INCLUDE)
|
|
|
|
if (skip_module_depends_include)
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2019-05-03 14:03:15 +00:00
|
|
|
endif()
|
|
|
|
if (dep MATCHES "(.*)Private")
|
|
|
|
set(dep "${CMAKE_MATCH_1}")
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
endif()
|
|
|
|
|
2019-08-20 13:24:14 +00:00
|
|
|
list(FIND known_modules "${dep}" _pos)
|
2019-05-03 14:03:15 +00:00
|
|
|
if (_pos GREATER -1)
|
|
|
|
list(APPEND qtdeps "${dep}")
|
2019-05-03 13:21:30 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
# Make the ModuleTool package depend on dep's ModuleTool package.
|
|
|
|
list(FIND tool_deps_seen ${dep} dep_seen)
|
|
|
|
if(dep_seen EQUAL -1 AND ${dep} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS)
|
|
|
|
list(APPEND tool_deps_seen ${dep})
|
|
|
|
list(APPEND tool_deps
|
|
|
|
"${INSTALL_CMAKE_NAMESPACE}${dep}Tools\;${PROJECT_VERSION}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
|
2019-09-24 13:53:41 +00:00
|
|
|
qt_collect_third_party_deps(${target})
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
# Add dependency to the main ModuleTool package to ModuleDependencies file.
|
|
|
|
if(${target} IN_LIST QT_KNOWN_MODULES_WITH_TOOLS)
|
|
|
|
set(main_module_tool_deps
|
|
|
|
"${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${PROJECT_VERSION}")
|
|
|
|
endif()
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
# Dirty hack because https://gitlab.kitware.com/cmake/cmake/issues/19200
|
|
|
|
foreach(dep ${target_deps})
|
|
|
|
if(dep)
|
|
|
|
list(FIND target_deps_seen "${dep}" dep_seen)
|
|
|
|
if(dep_seen EQUAL -1)
|
|
|
|
list(LENGTH dep len)
|
|
|
|
if(NOT (len EQUAL 2))
|
|
|
|
message(FATAL_ERROR "List '${dep}' should look like QtFoo;version")
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
endif()
|
2019-05-03 14:03:15 +00:00
|
|
|
list(GET dep 0 dep_name)
|
|
|
|
list(GET dep 1 dep_ver)
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
list(APPEND target_deps_seen "${dep_name}\;${dep_ver}")
|
|
|
|
endif()
|
2019-04-29 12:36:25 +00:00
|
|
|
endif()
|
2019-05-03 14:03:15 +00:00
|
|
|
endforeach()
|
|
|
|
set(target_deps "${target_deps_seen}")
|
|
|
|
|
|
|
|
if (DEFINED qtdeps)
|
|
|
|
list(REMOVE_DUPLICATES qtdeps)
|
|
|
|
endif()
|
|
|
|
|
2019-08-19 13:07:22 +00:00
|
|
|
get_target_property(hasModuleHeaders "${target}" INTERFACE_MODULE_HAS_HEADERS)
|
2020-05-20 14:17:06 +00:00
|
|
|
if (${hasModuleHeaders})
|
2020-05-15 09:37:08 +00:00
|
|
|
get_target_property(module_include_name "${target}" INTERFACE_MODULE_INCLUDE_NAME)
|
|
|
|
qt_internal_write_depends_file(${module_include_name} ${qtdeps})
|
2019-05-03 14:03:15 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(third_party_deps OR main_module_tool_deps OR target_deps)
|
|
|
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
|
|
|
|
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
|
|
|
|
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
|
|
|
|
|
|
|
|
# Configure and install ModuleDependencies file.
|
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in"
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
2019-04-29 12:36:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
endif()
|
|
|
|
if(tool_deps)
|
2019-11-15 15:28:17 +00:00
|
|
|
# The value of the property will be used by qt_export_tools.
|
|
|
|
set_property(TARGET "${target}" PROPERTY _qt_tools_package_deps "${tool_deps}")
|
2019-05-03 14:03:15 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_create_plugin_depends_file target)
|
|
|
|
get_target_property(qt_module "${target}" QT_MODULE)
|
2019-06-12 13:08:24 +00:00
|
|
|
get_target_property(depends "${target}" LINK_LIBRARIES)
|
|
|
|
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
|
2019-05-03 14:03:15 +00:00
|
|
|
get_target_property(target_deps "${target}" _qt_target_deps)
|
|
|
|
set(target_deps_seen "")
|
|
|
|
|
2019-09-24 13:53:41 +00:00
|
|
|
qt_collect_third_party_deps(${target})
|
2019-05-03 14:03:15 +00:00
|
|
|
|
|
|
|
# Dirty hack because https://gitlab.kitware.com/cmake/cmake/issues/19200
|
|
|
|
foreach(dep ${target_deps})
|
|
|
|
if(dep)
|
|
|
|
list(FIND target_deps_seen "${dep}" dep_seen)
|
|
|
|
if(dep_seen EQUAL -1)
|
|
|
|
list(LENGTH dep len)
|
|
|
|
if(NOT (len EQUAL 2))
|
|
|
|
message(FATAL_ERROR "List '${dep}' should look like QtFoo;version")
|
2019-05-03 09:38:41 +00:00
|
|
|
endif()
|
2019-05-03 14:03:15 +00:00
|
|
|
list(GET dep 0 dep_name)
|
|
|
|
list(GET dep 1 dep_ver)
|
2019-05-03 09:38:41 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
list(APPEND target_deps_seen "${dep_name}\;${dep_ver}")
|
|
|
|
endif()
|
2018-10-30 14:25:53 +00:00
|
|
|
endif()
|
2019-05-03 14:03:15 +00:00
|
|
|
endforeach()
|
|
|
|
set(target_deps "${target_deps_seen}")
|
2018-10-30 14:25:53 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
if(third_party_deps OR target_deps)
|
|
|
|
# Setup build and install paths
|
|
|
|
if(qt_module)
|
|
|
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${qt_module}")
|
|
|
|
else()
|
|
|
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
|
2018-10-24 13:20:27 +00:00
|
|
|
endif()
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
|
|
|
|
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
|
Implement developer / non-prefix builds
A non-prefix build is a build where you don't have to run
make install.
To do a non-prefix build, pass -DFEATURE_developer_build=ON when
invoking CMake on qtbase. Note that this of course also enables
developer build features (private tests, etc).
When doing a non-prefix build, the CMAKE_INSTALL_PREFIX cache variable
will point to the qtbase build directory.
Tests can be run without installing Qt (QPA plugins are picked up from
the build dir).
This patch stops installation of any files by forcing the
make "install" target be a no-op.
When invoking cmake on the qtsvg module (or any other module),
the CMAKE_INSTALL_PREFIX variable should be set to the qtbase build
directory.
The developer-build feature is propagated via the QtCore Config file,
so that when building other modules, you don't have to specify it
on the command line again.
As a result of the change, all libraries, plugins, tools, include dirs,
CMake Config files, CMake Targets files, Macro files, etc,
will be placed in the qtbase build directory, mimicking the file layout
of an installed Qt file layout.
Only examples and tests are kept in the separate module build
directories, which is equivalent to how qmake does it.
The following global variables contain paths for the
appropriate prefix or non prefix builds:
QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR,
QT_CONFIG_INSTALL_DIR. These should be used by developers
when deciding where files should be placed.
All usages of install() are replaced by qt_install(), which has some
additional logic on how to handle associationg of CMake targets to
export names.
When installing files, some consideration should be taken if
qt_copy_or_install() needs to be used instead of qt_install(),
which takes care of copying files from the source dir to the build dir
when doing non-prefix builds.
Tested with qtbase and qtsvg, developer builds, non-developer builds
and static developer builds on Windows, Linux and macOS.
Task-number: QTBUG-75581
Change-Id: I0ed27fb6467662dd24fb23aee6b95dd2c9c4061f
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-08 12:45:41 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
# Configure and install ModuleDependencies file.
|
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtPluginDependencies.cmake.in"
|
|
|
|
"${config_build_dir}/${target}Dependencies.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
Implement developer / non-prefix builds
A non-prefix build is a build where you don't have to run
make install.
To do a non-prefix build, pass -DFEATURE_developer_build=ON when
invoking CMake on qtbase. Note that this of course also enables
developer build features (private tests, etc).
When doing a non-prefix build, the CMAKE_INSTALL_PREFIX cache variable
will point to the qtbase build directory.
Tests can be run without installing Qt (QPA plugins are picked up from
the build dir).
This patch stops installation of any files by forcing the
make "install" target be a no-op.
When invoking cmake on the qtsvg module (or any other module),
the CMAKE_INSTALL_PREFIX variable should be set to the qtbase build
directory.
The developer-build feature is propagated via the QtCore Config file,
so that when building other modules, you don't have to specify it
on the command line again.
As a result of the change, all libraries, plugins, tools, include dirs,
CMake Config files, CMake Targets files, Macro files, etc,
will be placed in the qtbase build directory, mimicking the file layout
of an installed Qt file layout.
Only examples and tests are kept in the separate module build
directories, which is equivalent to how qmake does it.
The following global variables contain paths for the
appropriate prefix or non prefix builds:
QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR,
QT_CONFIG_INSTALL_DIR. These should be used by developers
when deciding where files should be placed.
All usages of install() are replaced by qt_install(), which has some
additional logic on how to handle associationg of CMake targets to
export names.
When installing files, some consideration should be taken if
qt_copy_or_install() needs to be used instead of qt_install(),
which takes care of copying files from the source dir to the build dir
when doing non-prefix builds.
Tested with qtbase and qtsvg, developer builds, non-developer builds
and static developer builds on Windows, Linux and macOS.
Task-number: QTBUG-75581
Change-Id: I0ed27fb6467662dd24fb23aee6b95dd2c9c4061f
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-08 12:45:41 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${target}Dependencies.cmake"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Create Depends.cmake & Depends.h files for all modules and plug-ins.
|
|
|
|
function(qt_internal_create_depends_files)
|
2019-08-20 13:24:14 +00:00
|
|
|
qt_internal_get_qt_repo_known_modules(repo_known_modules)
|
|
|
|
|
|
|
|
foreach (target ${repo_known_modules})
|
2019-05-03 14:03:15 +00:00
|
|
|
qt_internal_create_module_depends_file(${target})
|
2018-10-24 13:20:27 +00:00
|
|
|
endforeach()
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
foreach (target ${QT_KNOWN_PLUGINS})
|
|
|
|
qt_internal_create_plugin_depends_file(${target})
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-24 15:14:25 +00:00
|
|
|
|
2019-05-03 14:03:15 +00:00
|
|
|
# This function creates the Qt<Module>Plugins.cmake used to list all
|
|
|
|
# the plug-in target files.
|
|
|
|
function(qt_internal_create_plugins_files)
|
2019-09-05 15:16:31 +00:00
|
|
|
# The plugins cmake configuration is only needed for static builds. Dynamic builds don't need
|
|
|
|
# the application to link against plugins at build time.
|
2019-09-06 09:42:17 +00:00
|
|
|
if(QT_BUILD_SHARED_LIBS)
|
2019-09-05 15:16:31 +00:00
|
|
|
return()
|
|
|
|
endif()
|
2019-08-20 13:24:14 +00:00
|
|
|
qt_internal_get_qt_repo_known_modules(repo_known_modules)
|
|
|
|
|
|
|
|
message("Generating Plugins files for ${repo_known_modules}...")
|
|
|
|
foreach (QT_MODULE ${repo_known_modules})
|
2019-08-19 13:07:22 +00:00
|
|
|
get_target_property(target_type "${QT_MODULE}" TYPE)
|
|
|
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
# No plugins are provided by a header only module.
|
|
|
|
continue()
|
|
|
|
endif()
|
2019-06-07 07:13:31 +00:00
|
|
|
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${INSTALL_CMAKE_NAMESPACE}${QT_MODULE})
|
|
|
|
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${INSTALL_CMAKE_NAMESPACE}${QT_MODULE})
|
|
|
|
set(QT_MODULE_PLUGIN_INCLUDES "")
|
2019-05-03 14:03:15 +00:00
|
|
|
|
2019-06-07 07:13:31 +00:00
|
|
|
get_target_property(qt_plugins "${QT_MODULE}" QT_PLUGINS)
|
2019-05-03 14:03:15 +00:00
|
|
|
if(qt_plugins)
|
2019-06-07 07:13:31 +00:00
|
|
|
foreach (pluginTarget ${qt_plugins})
|
|
|
|
set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES}include(\"\${CMAKE_CURRENT_LIST_DIR}/${pluginTarget}Config.cmake\")\n")
|
2019-05-03 14:03:15 +00:00
|
|
|
endforeach()
|
2019-06-07 07:13:31 +00:00
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtPlugins.cmake.in"
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${QT_MODULE}Plugins.cmake"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
2019-05-03 14:03:15 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2018-10-24 13:20:27 +00:00
|
|
|
endfunction()
|
|
|
|
|
2020-03-06 16:06:45 +00:00
|
|
|
function(qt_generate_install_prefixes out_var)
|
|
|
|
set(content "\n")
|
|
|
|
set(vars INSTALL_BINDIR INSTALL_INCLUDEDIR INSTALL_LIBDIR INSTALL_MKSPECSDIR INSTALL_ARCHDATADIR
|
|
|
|
INSTALL_PLUGINSDIR INSTALL_LIBEXECDIR INSTALL_QMLDIR INSTALL_DATADIR INSTALL_DOCDIR
|
|
|
|
INSTALL_TRANSLATIONSDIR INSTALL_SYSCONFDIR INSTALL_EXAMPLESDIR INSTALL_TESTSDIR
|
|
|
|
INSTALL_DESCRIPTIONSDIR)
|
|
|
|
|
|
|
|
foreach(var ${vars})
|
|
|
|
get_property(docstring CACHE "${var}" PROPERTY HELPSTRING)
|
|
|
|
string(APPEND content "set(${var} \"${${var}}\" CACHE STRING \"${docstring}\" FORCE)\n")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(${out_var} "${content}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2020-05-13 16:31:26 +00:00
|
|
|
function(qt_wrap_string_in_if_multi_config content out_var)
|
|
|
|
set(${out_var} "
|
|
|
|
get_property(__qt_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
|
|
if(__qt_is_multi_config)
|
|
|
|
${content}endif()
|
|
|
|
unset(__qt_is_multi_config)\n" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_wrap_string_in_if_ninja_multi_config content out_var)
|
|
|
|
set(${out_var} "if(CMAKE_GENERATOR STREQUAL \"Ninja Multi-Config\")
|
|
|
|
${content}endif()\n" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2020-06-23 13:12:27 +00:00
|
|
|
function(qt_create_hostinfo_package)
|
|
|
|
set(package "${INSTALL_CMAKE_NAMESPACE}HostInfo")
|
|
|
|
qt_path_join(config_file_path "${QT_CONFIG_BUILD_DIR}/${package}/${package}Config.cmake")
|
|
|
|
qt_path_join(install_destination ${QT_CONFIG_INSTALL_DIR} ${package})
|
|
|
|
set(var_prefix "QT${PROJECT_VERSION_MAJOR}_HOST_INFO_")
|
|
|
|
configure_package_config_file(
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/QtHostInfoConfig.cmake.in"
|
|
|
|
"${config_file_path}"
|
|
|
|
INSTALL_DESTINATION "${install_destination}"
|
|
|
|
NO_SET_AND_CHECK_MACRO
|
|
|
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
|
|
|
qt_install(FILES "${config_file_path}" DESTINATION "${install_destination}")
|
|
|
|
endfunction()
|
|
|
|
|
2019-05-15 11:57:15 +00:00
|
|
|
function(qt_generate_build_internals_extra_cmake_code)
|
|
|
|
if(PROJECT_NAME STREQUAL "QtBase")
|
2020-06-23 13:12:27 +00:00
|
|
|
qt_create_hostinfo_package()
|
|
|
|
|
2019-11-07 14:52:33 +00:00
|
|
|
foreach(var IN LISTS QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT)
|
2019-08-13 13:51:56 +00:00
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "set(${var} \"${${var}}\" CACHE INTERNAL \"\")\n")
|
|
|
|
endforeach()
|
Ugly fix for handling QT_SOURCE_TREE
QT_SOURCE_TREE is a variable that is set in qtbase/.qmake.conf.
In qtbase, it's used throughout various
projects to find cpp sources when building standalone tests (among
other things).
Everything works fine with qmake, because even if qmake is invoked
on the tests subfolder, qmake searches up the source directory tree
until it finds a .qmake.conf file, and uses that.
When building qttools with qmake, the qdoc project expects
to have a QT_SOURCE_TREE value, but it's not actually set in the
qttools/.qmake.conf file, so the generated include paths that use
that value are incorrect. Curiously the build still succeeds.
Now in CMake land we replaced QT_SOURCE_TREE with
CMAKE_SOURCE_DIR, but that does not work properly when doing a
standalone tests build, because the project in that case is the
tests one, and not the qtbase one, so configuration fails in a
developer build when trying to configure some private tests.
So far I've found that only qtbase actively uses this value.
A temporary fix is to save the qtbase source directory into a
QT_SOURCE_TREE variable inside the generated
BuildInternalsExtra.cmake file.
The pro2cmake script is changed to handle presence of QT_SOURCE_TREE
in a qrc file path. This is handled by finding the location of a
.qmake.conf file starting from the project file absolute path.
This is needed to stop the script from crashing when handling
the mimedatabase test projects for example.
The change also regenerates the relevant failing test projects, and
thus standalone tests (when doing developer builds aka private_tests
enabled) now configure and build successfully.
Change-Id: I15adc6f4ab6e3056c43ed850196204e2229c4d98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 16:59:53 +00:00
|
|
|
|
|
|
|
set(QT_SOURCE_TREE "${QtBase_SOURCE_DIR}")
|
2019-05-15 11:57:15 +00:00
|
|
|
qt_path_join(extra_file_path
|
|
|
|
${QT_CONFIG_BUILD_DIR}
|
|
|
|
${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake)
|
2019-12-06 14:12:17 +00:00
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE)
|
2020-01-30 13:21:34 +00:00
|
|
|
# Need to force set, because CMake itself initializes a value for CMAKE_BUILD_TYPE
|
|
|
|
# at the start of project configuration (with an empty value),
|
|
|
|
# so we need to force override it.
|
2019-12-06 14:12:17 +00:00
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
2020-01-30 13:21:34 +00:00
|
|
|
"set(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" CACHE STRING \"Choose the type of build.\" FORCE)\n")
|
|
|
|
|
2019-12-06 14:12:17 +00:00
|
|
|
endif()
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
2020-05-13 16:31:26 +00:00
|
|
|
string(APPEND multi_config_specific
|
|
|
|
" set(CMAKE_CONFIGURATION_TYPES \"${CMAKE_CONFIGURATION_TYPES}\" CACHE STRING \"\" FORCE)\n")
|
2019-12-06 14:12:17 +00:00
|
|
|
endif()
|
|
|
|
if(CMAKE_TRY_COMPILE_CONFIGURATION)
|
2020-05-13 16:31:26 +00:00
|
|
|
string(APPEND multi_config_specific
|
|
|
|
" set(CMAKE_TRY_COMPILE_CONFIGURATION \"${CMAKE_TRY_COMPILE_CONFIGURATION}\")\n")
|
|
|
|
endif()
|
|
|
|
if(multi_config_specific)
|
|
|
|
qt_wrap_string_in_if_multi_config(
|
|
|
|
"${multi_config_specific}"
|
|
|
|
multi_config_specific)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${multi_config_specific}")
|
2019-12-06 14:12:17 +00:00
|
|
|
endif()
|
2020-05-13 16:31:26 +00:00
|
|
|
|
2019-12-06 14:12:17 +00:00
|
|
|
if(QT_MULTI_CONFIG_FIRST_CONFIG)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
2020-05-13 16:31:26 +00:00
|
|
|
"\nset(QT_MULTI_CONFIG_FIRST_CONFIG \"${QT_MULTI_CONFIG_FIRST_CONFIG}\")\n")
|
|
|
|
endif()
|
|
|
|
# When building standalone tests against a multi-config Qt, we want to choose the first
|
|
|
|
# configuration, rather than default to Debug.
|
|
|
|
if(multi_config_specific)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "
|
|
|
|
if(QT_BUILD_STANDALONE_TESTS)
|
|
|
|
set(CMAKE_BUILD_TYPE \"\${QT_MULTI_CONFIG_FIRST_CONFIG}\" CACHE STRING \"Choose the type of build.\" FORCE)
|
|
|
|
endif()\n")
|
2019-12-06 14:12:17 +00:00
|
|
|
endif()
|
2020-05-13 16:31:26 +00:00
|
|
|
|
2020-03-02 13:16:38 +00:00
|
|
|
if(CMAKE_CROSS_CONFIGS)
|
2020-05-13 16:31:26 +00:00
|
|
|
string(APPEND ninja_multi_config_specific
|
|
|
|
" set(CMAKE_CROSS_CONFIGS \"${CMAKE_CROSS_CONFIGS}\" CACHE STRING \"\")\n")
|
2019-12-06 14:12:17 +00:00
|
|
|
endif()
|
2020-03-02 13:16:38 +00:00
|
|
|
if(CMAKE_DEFAULT_BUILD_TYPE)
|
2020-05-13 16:31:26 +00:00
|
|
|
string(APPEND ninja_multi_config_specific
|
|
|
|
" set(CMAKE_DEFAULT_BUILD_TYPE \"${CMAKE_DEFAULT_BUILD_TYPE}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
2020-05-14 15:02:59 +00:00
|
|
|
if(CMAKE_DEFAULT_CONFIGS)
|
|
|
|
string(APPEND ninja_multi_config_specific
|
|
|
|
" set(CMAKE_DEFAULT_CONFIGS \"${CMAKE_DEFAULT_CONFIGS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
2020-05-13 16:31:26 +00:00
|
|
|
if(ninja_multi_config_specific)
|
|
|
|
qt_wrap_string_in_if_ninja_multi_config(
|
|
|
|
"${ninja_multi_config_specific}"
|
|
|
|
ninja_multi_config_specific)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${ninja_multi_config_specific}")
|
2019-12-06 14:12:17 +00:00
|
|
|
endif()
|
2020-05-13 16:31:26 +00:00
|
|
|
|
2020-03-24 10:19:21 +00:00
|
|
|
if(DEFINED BUILD_WITH_PCH)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(BUILD_WITH_PCH \"${BUILD_WITH_PCH}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
2019-12-06 14:12:17 +00:00
|
|
|
|
2020-04-27 13:04:57 +00:00
|
|
|
if(CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING \"TRUE\" CACHE BOOL \"\" FORCE)\n")
|
|
|
|
endif()
|
|
|
|
|
2020-06-15 07:50:42 +00:00
|
|
|
if(ECM_ENABLE_SANITIZERS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(ECM_ENABLE_SANITIZERS \"${ECM_ENABLE_SANITIZERS}\" CACHE BOOL \"\" FORCE)\n")
|
|
|
|
endif()
|
|
|
|
|
CMake: Handle automatic rpath embedding correctly
Instead of using CMAKE_INSTALL_RPATH to embed an absolute path
to prefix/libdir into all targets, use the more sophisticated aproach
that qmake does.
For certain targets (modules, plugins, tools) use relative rpaths.
Otherwise embed absolute paths (examples, regular binaries).
Installed tests currently have no rpaths.
On certain platforms rpaths are not used (Windows, Android,
iOS / uikit).
Frameworks, app bundles and shallow bundles should also be handled
correctly.
Additional rpaths can be provided via QT_EXTRA_RPATHS variable
(similar to the -R option that configure takes).
Automatic embedding can be disabled either via QT_FEATURE_rpath=OFF
or QT_DISABLE_RPATH=ON.
Note that installed examples are not relocatable at the moment (due
to always having an absolute path rpath), so this is a missing feature
compared to qmake. This is due to missing information on where
examples will be installed, so a relative rpath can not be computed.
By default a Qt installation is relocatable, so there is no need to
pass -DQT_EXTRA_RPATHS=. like Coin used to do with qmake e.g. -R .
Relative rpaths will have the appropriate 'relative base' prefixed
to them (e.g $ORIGIN on linux and @loader_path on darwin platforms).
There is currently no support for other platforms that might have a
different 'relative base' than the ones mentioned above.
Any extra rpaths are saved to BuildInternalsExtra which are re-used
when building other repositories.
configurejson2cmake modified to include correct conditions for the
rpath feature.
It's very likely that we will need a new qt_add_internal_app()
function for gui apps that are to be installed to prefix/bin.
For example for Assistant from qttools. Currently such apps
use qt_add_executable().
The distinction is necessary to make sure that relative rpaths are
embedded into apps, but not executables (which tests are part of).
Amends e835a6853b9c0fb7af32798ed8965de3adf0e15b
Task-number: QTBUG-83497
Change-Id: I3510f63c0a59489741116cc8ec3ef6a0a7704f25
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-15 16:48:26 +00:00
|
|
|
# Rpath related things that need to be re-used when building other repos.
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(CMAKE_INSTALL_RPATH \"${CMAKE_INSTALL_RPATH}\" CACHE STRING \"\")\n")
|
|
|
|
if(DEFINED QT_DISABLE_RPATH)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_DISABLE_RPATH \"${QT_DISABLE_RPATH}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
if(DEFINED QT_EXTRA_RPATHS)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(QT_EXTRA_RPATHS \"${QT_EXTRA_RPATHS}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
|
CMake: Don't use libraries in /usr/local by default on macOS
qmake builds of Qt don't use libraries in /usr/local because the
path is not considered a system path. Only the SDK path should be
used as a source of system libraries.
We should do the same for the CMake builds, which involves a couple of
things.
Tell CMake not to consider /usr/local (and a bunch of other
paths) as system prefix paths.
Disable pkg-config usage which by default is not used in qmake
Windows and macOS builds.
If a user wishes to use libraries located in /usr/local on macOS, they
can explicitly enable the behavior via -DFEATURE_pkg_config=ON.
In addition to enabling pkg-config, that will also disable the system
prefix modification described above.
Implementation notes
To disable pkg-config usage, we set an empty path for
PKG_CONFIG_EXECUTABLE, because there is no other good way. The
downside to this is that a lot of warning messages will be printed
that the pkg-config package can not be found.
The pkg-config feature needs to be computed in QtBuildInternals before
qtbase/src/configure.cmake, because it's too late to do it in that
file where a few qt_find_package calls already exist.
The feature value is also saved to QtBuildInternalsExtra, to make sure
that pkg-config is disabled whenever building another repo.
System prefix adjustment is done by removing paths from
CMAKE_SYSTEM_PREFIX_PATH.
Ideally we would remove also /usr as a path, to match what qmake does,
but that breaks find_program() calls for perl, python, etc.
We have to make sure that qt_find_package does not look in
PATH when looking for packages, which is the default behavior, because
PATH on macOS most likely contains /usr/local.
One last curiosity for future generations is that CMake 3.18+ has
merged a change to prioritise SDK locations over regular /usr/lib.
Fixes: QTBUG-85261
Change-Id: I28fe5bae7997507a83b37b4eb1e0188e64062c57
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-25 16:02:52 +00:00
|
|
|
# Save pkg-config feature value to be able to query it internally as soon as BuildInternals
|
|
|
|
# package is loaded. This is to avoid any pkg-config package from being found when
|
|
|
|
# find_package(Qt6Core) is called in case if the feature was disabled.
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "
|
|
|
|
if(NOT QT_SKIP_BUILD_INTERNALS_PKG_CONFIG_FEATURE)
|
|
|
|
set(FEATURE_pkg_config \"${FEATURE_pkg_config}\" CACHE STRING \"Using pkg-config\" FORCE)
|
|
|
|
endif()\n")
|
|
|
|
|
2020-06-04 15:10:51 +00:00
|
|
|
# The OpenSSL root dir needs to be saved so that repos other than qtbase (like qtopcua) can
|
|
|
|
# still successfully find_package(WrapOpenSSL) in the CI.
|
|
|
|
# qmake saves any additional include paths passed via the configure like '-I/foo'
|
|
|
|
# in mkspecs/qmodule.pri, so this file is the closest equivalent.
|
|
|
|
if(DEFINED OPENSSL_ROOT_DIR)
|
|
|
|
file(TO_CMAKE_PATH "${OPENSSL_ROOT_DIR}" openssl_root_cmake_path)
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
|
|
|
"set(OPENSSL_ROOT_DIR \"${openssl_root_cmake_path}\" CACHE STRING \"\")\n")
|
|
|
|
endif()
|
|
|
|
|
2020-03-06 16:06:45 +00:00
|
|
|
qt_generate_install_prefixes(install_prefix_content)
|
|
|
|
|
|
|
|
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${install_prefix_content}")
|
|
|
|
|
CMake: Make build system of installed Qt more relocatable
Aka handle CMAKE_INSTALL_PREFIX in a more relocatable way.
The following story inspired this change.
If a user wants to build a Qt repo into a different install prefix
than the usual Qt one, this will fail configuration because we
look for various things like syncqt, qdoc, etc relative to
CMAKE_INSTALL_PREFIX, which will now point to a different location
where none of the above tools are located.
The intent for such a use case is to support building Qt packages with
Conan, which sets a random install prefix when configuring a repo.
The idea is to derive the qt prefix dynamically from the
QtBuildInternals package location. Essentially it's a reverse relative
path from the QtBuildInternalsConfig.cmake file to the install prefix
that was specified when initially configuring qtbase.
Once the dynamic prefix is computed (so we know where the possibly
relocated Qt is), we can find tools like syncqt and qdoc.
This is an initial attempt to support a use case like that.
More design work will probably needed in case if tools / libs need to
be found in a location different than the Qt install prefix (so
support for multiple install prefixes / search paths).
An example of such a case would be when building qtdeclarative and
qtquickcontrols2 as Conan packages in one go. Most likely the
qmltyperegistrar tool will be located in the random install prefix
set by Conan, so building qtquickcontrols2 might fail due to not
finding the tool in the original Qt install prefix.
As to the implementation details, the change does the following:
- Dynamically computes and sets the
QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX variable when
find_package()'ing QtBuildInternals. It's an absolute path
pointing to where the relocated Qt is.
- When building qtbase this variable is not yet available (due
to QtBuildInternalsExtra not existing), in that case we set
the variable to the absolute path of CMAKE_INSTALL_PREFIX
(but only for the initial qtbase configuration).
- Remove QT_BUILD_INTERNALS_ORIGINAL_INSTALL_PREFIX which was used
for standalone tests purposes. It's not needed now that we compute
the location of the Qt prefix dynamically.
- The Unixy qt-cmake and qt-cmake-private shell scripts now
use a relative path to find the toolchain file we created.
- The toolchain file also dynamically computes the location of the Qt
packages, and adds them to CMAKE_PREFIX_PATH.
- A lot of existing CMAKE_INSTALL_PREFIX uses are replaced with
QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX. This includes finding
tool locations, mkspecs dir, path environment setup for tools, etc.
- Some places still use CMAKE_PREFIX_PATH in the following cases
- When determining paths while configuring qtbase (valid cases)
- When I wasn't sure what the behavior should be, so I left them
as-is (an example is documentation generation, do we want to
install it into the random Conan prefix, or into the main prefix?
Currently it installs in the random prefix).
Note that relocating a Qt installation does not work for non-prefix /
non-installed builds, due to hardcoded paths to include directories
and libraries in generated FooTargets.cmake files.
Task-number: QTBUG-83999
Change-Id: I87d6558729db93121b1715771034b03ce3295923
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-05 08:30:35 +00:00
|
|
|
qt_compute_relative_path_from_cmake_config_dir_to_prefix()
|
2019-06-05 15:15:20 +00:00
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake.in"
|
|
|
|
"${extra_file_path}"
|
|
|
|
@ONLY
|
|
|
|
)
|
2019-05-15 11:57:15 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2019-06-24 12:54:40 +00:00
|
|
|
# For every Qt module check if there any android dependencies that require
|
|
|
|
# processing.
|
|
|
|
function(qt_modules_process_android_dependencies)
|
2019-08-20 13:24:14 +00:00
|
|
|
qt_internal_get_qt_repo_known_modules(repo_known_modules)
|
|
|
|
foreach (target ${repo_known_modules})
|
2019-06-24 12:54:40 +00:00
|
|
|
qt_android_dependencies(${target})
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2019-09-21 19:22:09 +00:00
|
|
|
function(qt_create_tools_config_files)
|
|
|
|
# Create packages like Qt6CoreTools/Qt6CoreToolsConfig.cmake.
|
|
|
|
foreach(module_name ${QT_KNOWN_MODULES_WITH_TOOLS})
|
|
|
|
qt_export_tools("${module_name}")
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2019-11-01 10:48:23 +00:00
|
|
|
function(qt_internal_create_config_file_for_standalone_tests)
|
|
|
|
set(standalone_tests_config_dir "StandaloneTests")
|
|
|
|
qt_path_join(config_build_dir
|
|
|
|
${QT_CONFIG_BUILD_DIR}
|
|
|
|
"${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
|
|
|
|
qt_path_join(config_install_dir
|
|
|
|
${QT_CONFIG_INSTALL_DIR}
|
|
|
|
"${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
|
|
|
|
|
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that:
- the python scripts do not ignore certain system_foo features anymore
(it is a hardcoded list for now just to be safe)
- configurejson2cmake now outputs
qt_find_package(WrapSystemFoo) calls for bundled libraries
(see below)
- the harfbuzz .pro file is modified to accommodate pro2cmake
not being able to correctly parse some conditional scopes
- the freetype .pro file is modified to make sure linking of the
library succeeds without duplicate symbol errors, which qmake
doesn't encounter due to magical exclusion of cpp files that are
included in other cpp files (presumably for include moc_foo.cpp
support)
- feature evaluation for Core, Gui, Network now happens in the
qtbase/src directory, so that bundled libraries can be conditionally
built
- for each bundled library there are now two FindWrap scripts:
- FindWrapSystemFoo which finds an installed library in the system
- FindWrapFoo which either uses the system installed library or
the built bundled one depending on a condition
- projects that intend to use bundled libraries need to link against
WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets
(this is handled by pro2cmake).
Unfortunately manually added qt_find_package(WrapFoo) calls might
still be needed as is the case for WrapFreetype and others.
- a new cmake/QtFindWrapHelper.cmake file is added that provides
a macro to simplify creation of WrapFoo targets that link against
a bundled or system library. The implementation is fairly ugly
due to CMake macro constraints, but it was deemed better than
copy-pasting a bunch of almost identical code across all
FindWrapFoo.cmake files.
- a qtzlib header-only module is now created when using bundled
zlib, to provide public syncqt created headers for consumers
that need them. These are projects that have
'QT_PRIVATE += zlib-private' in their .pro files
(e.g. qtimageformats, qtlocation, qt3d, etc.)
This is unfortunately needed due to QtNetwork using zlib
types in its private C++ API.
The change includes support for building the following bundled
libraries:
- zlib
- libpng
- libjpeg
- Freetype
- Harfbuzz-ng
- PCRE2
The following 3rd party libraries are still using an old
implementation within the CMake build system, and should be migrated
to the new one in the near future:
- double-conversion
- Old harfbuzz
The are a few libraries that are not yet ported:
- system-sqlite
- systemxcb
- maybe others
Among other things, this change allows building qtbase on Windows
without requiring vcpkg.
Task-number: QTBUG-82167
Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
2020-02-14 13:53:28 +00:00
|
|
|
# Filter out bundled system libraries. Otherwise when looking for their dependencies
|
|
|
|
# (like PNG for Freetype) FindWrapPNG is searched for during configuration of
|
|
|
|
# standalone tests, and it can happen that Core or Gui features are not
|
|
|
|
# imported early enough, which means FindWrapPNG will try to find a system PNG library instead
|
|
|
|
# of the bundled one.
|
|
|
|
set(modules)
|
|
|
|
foreach(m ${QT_REPO_KNOWN_MODULES})
|
|
|
|
get_target_property(target_type "${m}" TYPE)
|
|
|
|
|
|
|
|
# Interface libraries are never bundled system libraries (hopefully).
|
|
|
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
list(APPEND modules "${m}")
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_target_property(is_3rd_party "${m}" QT_MODULE_IS_3RDPARTY_LIBRARY)
|
|
|
|
if(NOT is_3rd_party)
|
|
|
|
list(APPEND modules "${m}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
list(JOIN modules " " QT_REPO_KNOWN_MODULES_STRING)
|
2019-11-01 10:48:23 +00:00
|
|
|
string(STRIP "${QT_REPO_KNOWN_MODULES_STRING}" QT_REPO_KNOWN_MODULES_STRING)
|
|
|
|
|
2019-11-12 11:57:17 +00:00
|
|
|
# Skip generating and installing file if no modules were built. This make sure not to install
|
|
|
|
# anything when build qtx11extras on macOS for example.
|
|
|
|
if(NOT QT_REPO_KNOWN_MODULES_STRING)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2019-11-01 10:48:23 +00:00
|
|
|
# Ceate a Config file that calls find_package on the modules that were built as part
|
|
|
|
# of the current repo. This is used for standalone tests.
|
|
|
|
configure_file(
|
|
|
|
"${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in"
|
2019-11-21 12:33:28 +00:00
|
|
|
"${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake"
|
2019-11-01 10:48:23 +00:00
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
qt_install(FILES
|
2019-11-21 12:33:28 +00:00
|
|
|
"${config_build_dir}/${PROJECT_NAME}TestsConfig.cmake"
|
2019-11-01 10:48:23 +00:00
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
COMPONENT Devel
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
qt_internal_create_depends_files()
|
2019-05-15 11:57:15 +00:00
|
|
|
qt_generate_build_internals_extra_cmake_code()
|
2019-05-03 14:03:15 +00:00
|
|
|
qt_internal_create_plugins_files()
|
2019-11-01 10:48:23 +00:00
|
|
|
qt_internal_create_config_file_for_standalone_tests()
|
2019-06-24 12:54:40 +00:00
|
|
|
|
2019-11-15 15:28:17 +00:00
|
|
|
# Needs to run after qt_internal_create_depends_files.
|
|
|
|
qt_create_tools_config_files()
|
|
|
|
|
2019-06-24 12:54:40 +00:00
|
|
|
if (ANDROID)
|
|
|
|
qt_modules_process_android_dependencies()
|
|
|
|
endif()
|
2020-03-12 15:16:55 +00:00
|
|
|
|
|
|
|
# Install prl files
|
2020-06-12 19:34:52 +00:00
|
|
|
get_property(prl_install_dirs GLOBAL PROPERTY QT_PRL_INSTALL_DIRS)
|
|
|
|
foreach(prl_install_dir ${prl_install_dirs})
|
|
|
|
qt_install(DIRECTORY "${PROJECT_BINARY_DIR}/${prl_install_dir}/"
|
|
|
|
DESTINATION ${prl_install_dir}
|
|
|
|
FILES_MATCHING PATTERN "*.prl"
|
|
|
|
)
|
|
|
|
endforeach()
|