2018-10-24 13:20:27 +00:00
|
|
|
function(qt_internal_write_depends_file target)
|
|
|
|
set(module Qt${target})
|
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
|
|
|
set(outfile "${QT_BUILD_DIR}/include/${module}/${module}Depends")
|
2018-10-24 13:20:27 +00:00
|
|
|
message("Generate ${outfile}...")
|
|
|
|
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()
|
|
|
|
|
|
|
|
if(NOT arg_HEADER_MODULE)
|
|
|
|
get_target_property(depends "${target}" LINK_LIBRARIES)
|
|
|
|
endif()
|
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}")
|
|
|
|
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)
|
2019-05-03 14:03:15 +00:00
|
|
|
if (${hasModuleHeaders})
|
|
|
|
qt_internal_write_depends_file("${target}" ${qtdeps})
|
|
|
|
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)
|
|
|
|
|
|
|
|
message("Generating ModuleDepends files and CMake ModuleDependencies files for ${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-08-20 13:24:14 +00:00
|
|
|
message("Generating CMake PluginDependencies files for ${QT_KNOWN_PLUGINS}...")
|
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()
|
|
|
|
|
2019-05-15 11:57:15 +00:00
|
|
|
function(qt_generate_build_internals_extra_cmake_code)
|
|
|
|
if(PROJECT_NAME STREQUAL "QtBase")
|
2019-08-13 13:51:56 +00:00
|
|
|
set(QT_EXTRA_BUILD_INTERNALS_VARS)
|
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-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}")
|
|
|
|
|
|
|
|
list(JOIN QT_REPO_KNOWN_MODULES " " QT_REPO_KNOWN_MODULES_STRING)
|
|
|
|
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"
|
|
|
|
"${config_build_dir}/${CMAKE_PROJECT_NAME}TestsConfig.cmake"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
qt_install(FILES
|
|
|
|
"${config_build_dir}/${CMAKE_PROJECT_NAME}TestsConfig.cmake"
|
|
|
|
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()
|