2018-10-24 13:20:27 +00:00
include ( CMakePackageConfigHelpers )
2020-02-26 10:41:20 +00:00
include ( QtSeparateDebugInfo )
2018-10-24 13:20:27 +00:00
2020-03-06 16:06:45 +00:00
function ( qt_configure_process_path name default docstring )
# Values are computed once for qtbase, and then exported and reused for other projects.
if ( NOT PROJECT_NAME STREQUAL "QtBase" )
return ( )
endif ( )
# No value provided, set the default.
if ( NOT DEFINED "${name}" )
set ( "${name}" "${default}" CACHE STRING "${docstring}" )
else ( )
get_filename_component ( given_path_as_abs "${${name}}" ABSOLUTE BASE_DIR
" $ { C M A K E _ I N S T A L L _ P R E F I X } " )
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
file ( RELATIVE_PATH rel_path "${CMAKE_INSTALL_PREFIX}"
" $ { g i v e n _ p a t h _ a s _ a b s } " )
2020-03-06 16:06:45 +00:00
# If absolute path given, check that it's inside the prefix (error out if not).
# TODO: Figure out if we need to support paths that are outside the prefix.
#
# If relative path given, it's relative to the install prefix (rather than the binary dir,
# which is what qmake does for some reason).
# In both cases, store the value as a relative path.
2020-03-24 21:58:14 +00:00
if ( "${rel_path}" STREQUAL "" )
# file(RELATIVE_PATH) returns an empty string if the given absolute paths are equal
set ( rel_path "." )
elseif ( rel_path MATCHES "^\.\./" )
2020-03-06 16:06:45 +00:00
message ( FATAL_ERROR
" P a t h c o m p o n e n t ' $ { n a m e } ' i s o u t s i d e c o m p u t e d i n s t a l l p r e f i x : $ { r e l _ p a t h } " )
endif ( )
set ( "${name}" "${rel_path}" CACHE STRING "${docstring}" FORCE )
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
# Install locations:
2020-03-06 16:06:45 +00:00
qt_configure_process_path ( INSTALL_BINDIR "bin" "Executables [PREFIX/bin]" )
qt_configure_process_path ( INSTALL_INCLUDEDIR "include" "Header files [PREFIX/include]" )
qt_configure_process_path ( INSTALL_LIBDIR "lib" "Libraries [PREFIX/lib]" )
qt_configure_process_path ( INSTALL_MKSPECSDIR "mkspecs" "Mkspecs files [PREFIX/mkspecs]" )
qt_configure_process_path ( INSTALL_ARCHDATADIR "." "Arch-dependent data [PREFIX]" )
qt_configure_process_path ( INSTALL_PLUGINSDIR
" $ { I N S T A L L _ A R C H D A T A D I R } / p l u g i n s "
" P l u g i n s [ A R C H D A T A D I R / p l u g i n s ] " )
2018-10-24 13:20:27 +00:00
2020-05-15 13:21:21 +00:00
# Given CMAKE_CONFIG and ALL_CMAKE_CONFIGS, determines if a directory suffix needs to be appended
# to each destination, and sets the computed install target destination arguments in OUT_VAR.
# Defaults used for each of the destination types, and can be configured per destination type.
function ( qt_get_install_target_default_args )
qt_parse_all_arguments ( arg "qt_get_install_target_default_args"
" " " O U T _ V A R ; C M A K E _ C O N F I G ; R U N T I M E ; L I B R A R Y ; A R C H I V E ; I N C L U D E S ; B U N D L E "
" A L L _ C M A K E _ C O N F I G S " $ { A R G N } )
if ( NOT arg_CMAKE_CONFIG )
message ( FATAL_ERROR "No value given for CMAKE_CONFIG." )
endif ( )
if ( NOT arg_ALL_CMAKE_CONFIGS )
message ( FATAL_ERROR "No value given for ALL_CMAKE_CONFIGS." )
endif ( )
list ( LENGTH arg_ALL_CMAKE_CONFIGS all_configs_count )
list ( GET arg_ALL_CMAKE_CONFIGS 0 first_config )
set ( suffix "" )
if ( all_configs_count GREATER 1 AND NOT arg_CMAKE_CONFIG STREQUAL first_config )
set ( suffix "/${arg_CMAKE_CONFIG}" )
endif ( )
set ( runtime "${INSTALL_BINDIR}" )
if ( arg_RUNTIME )
set ( runtime "${arg_RUNTIME}" )
endif ( )
set ( library "${INSTALL_LIBDIR}" )
if ( arg_LIBRARY )
set ( library "${arg_LIBRARY}" )
endif ( )
set ( archive "${INSTALL_LIBDIR}" )
if ( arg_ARCHIVE )
set ( archive "${arg_ARCHIVE}" )
endif ( )
set ( includes "${INSTALL_INCLUDEDIR}" )
if ( arg_INCLUDES )
set ( includes "${arg_INCLUDES}" )
endif ( )
set ( bundle "${INSTALL_BINDIR}" )
if ( arg_BUNDLE )
set ( bundle "${arg_BUNDLE}" )
endif ( )
set ( args
R U N T I M E D E S T I N A T I O N " $ { r u n t i m e } $ { s u f f i x } "
L I B R A R Y D E S T I N A T I O N " $ { l i b r a r y } $ { s u f f i x } "
A R C H I V E D E S T I N A T I O N " $ { a r c h i v e } $ { s u f f i x } " C O M P O N E N T D e v e l
B U N D L E D E S T I N A T I O N " $ { b u n d l e } $ { s u f f i x } "
I N C L U D E S D E S T I N A T I O N " $ { i n c l u d e s } $ { s u f f i x } " )
set ( ${ arg_OUT_VAR } "${args}" PARENT_SCOPE )
endfunction ( )
2018-10-24 13:20:27 +00:00
if ( WIN32 )
set ( _default_libexec "${INSTALL_ARCHDATADIR}/bin" )
else ( )
set ( _default_libexec "${INSTALL_ARCHDATADIR}/libexec" )
endif ( )
2020-03-06 16:06:45 +00:00
qt_configure_process_path (
I N S T A L L _ L I B E X E C D I R
" $ { _ d e f a u l t _ l i b e x e c } "
2018-10-24 13:20:27 +00:00
" H e l p e r p r o g r a m s [ A R C H D A T A D I R / b i n o n W i n d o w s , A R C H D A T A D I R / l i b e x e c o t h e r w i s e ] " )
2020-03-06 16:06:45 +00:00
qt_configure_process_path ( INSTALL_QMLDIR
" $ { I N S T A L L _ A R C H D A T A D I R } / q m l "
" Q M L 2 i m p o r t s [ A R C H D A T A D I R / q m l ] " )
qt_configure_process_path ( INSTALL_DATADIR "." "Arch-independent data [PREFIX]" )
qt_configure_process_path ( INSTALL_DOCDIR "${INSTALL_DATADIR}/doc" "Documentation [DATADIR/doc]" )
qt_configure_process_path ( INSTALL_TRANSLATIONSDIR "${INSTALL_DATADIR}/translations"
2018-10-24 13:20:27 +00:00
" T r a n s l a t i o n s [ D A T A D I R / t r a n s l a t i o n s ] " )
2020-03-06 16:06:45 +00:00
qt_configure_process_path ( INSTALL_SYSCONFDIR
" e t c / x d g "
" S e t t i n g s u s e d b y Q t p r o g r a m s [ P R E F I X / e t c / x d g ] " )
qt_configure_process_path ( INSTALL_EXAMPLESDIR "examples" "Examples [PREFIX/examples]" )
qt_configure_process_path ( INSTALL_TESTSDIR "tests" "Tests [PREFIX/tests]" )
qt_configure_process_path ( INSTALL_DESCRIPTIONSDIR
" $ { I N S T A L L _ D A T A D I R } / m o d u l e s "
" M o d u l e d e s c r i p t i o n f i l e s d i r e c t o r y " )
2018-10-24 13:20:27 +00:00
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
function ( qt_internal_set_up_global_paths )
# Compute the values of QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR, QT_CONFIG_INSTALL_DIR
# taking into account whether the current build is a prefix build or a non-prefix build,
# and whether it is a superbuild or non-superbuild.
# A third case is when another module or standalone tests are built against a super-built Qt.
# The layout for the third case is the same as for non-superbuilds.
#
# These values should be prepended to file paths in commands or properties,
# in order to correctly place generated Config files, generated Targets files,
# excutables / libraries, when copying / installing files, etc.
#
# The build dir variables will always be absolute paths.
# The QT_INSTALL_DIR variable will have a relative path in a prefix build,
# which means that it can be empty, so use qt_join_path to prevent accidental absolute paths.
if ( QT_SUPERBUILD )
# In this case, we always copy all the build products in qtbase/{bin,lib,...}
if ( QT_WILL_INSTALL )
set ( QT_BUILD_DIR "${QtBase_BINARY_DIR}" )
set ( QT_INSTALL_DIR "" )
else ( )
set ( QT_BUILD_DIR "${QtBase_BINARY_DIR}" )
set ( QT_INSTALL_DIR "${QtBase_BINARY_DIR}" )
endif ( )
else ( )
if ( QT_WILL_INSTALL )
# In the usual prefix build case, the build dir is the current module build dir,
# and the install dir is the prefix, so we don't set it.
set ( QT_BUILD_DIR "${CMAKE_BINARY_DIR}" )
set ( QT_INSTALL_DIR "" )
else ( )
# When doing a non-prefix build, both the build dir and install dir are the same,
# pointing to the qtbase build dir.
set ( QT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}" )
set ( QT_INSTALL_DIR "${QT_BUILD_DIR}" )
endif ( )
endif ( )
set ( __config_path_part "${INSTALL_LIBDIR}/cmake" )
set ( QT_CONFIG_BUILD_DIR "${QT_BUILD_DIR}/${__config_path_part}" )
set ( QT_CONFIG_INSTALL_DIR "${QT_INSTALL_DIR}" )
if ( QT_CONFIG_INSTALL_DIR )
string ( APPEND QT_CONFIG_INSTALL_DIR "/" )
endif ( )
string ( APPEND QT_CONFIG_INSTALL_DIR ${ __config_path_part } )
set ( QT_BUILD_DIR "${QT_BUILD_DIR}" PARENT_SCOPE )
set ( QT_INSTALL_DIR "${QT_INSTALL_DIR}" PARENT_SCOPE )
set ( QT_CONFIG_BUILD_DIR "${QT_CONFIG_BUILD_DIR}" PARENT_SCOPE )
set ( QT_CONFIG_INSTALL_DIR "${QT_CONFIG_INSTALL_DIR}" PARENT_SCOPE )
endfunction ( )
qt_internal_set_up_global_paths ( )
qt_get_relocatable_install_prefix ( QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX )
Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.
Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.
Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
have a .git subdir and thus defaults to be built in Release
mode, even though qtbase might have been built in Debug, so to
avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
the tests project doesn't specify a major version, and if we
override the values, the moc / uic targets don't get the correct
major version prefix and configuration fails
Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 08:22:08 +00:00
# The variables might have already been set in QtBuildInternalsExtra.cmake if the file is included
# while building a new module and not QtBase. In that case, stop overriding the value.
if ( NOT INSTALL_CMAKE_NAMESPACE )
set ( INSTALL_CMAKE_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
C A C H E S T R I N G " C M a k e n a m e s p a c e [ Q t $ { P R O J E C T _ V E R S I O N _ M A J O R } ] " )
endif ( )
if ( NOT QT_CMAKE_EXPORT_NAMESPACE )
set ( QT_CMAKE_EXPORT_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
C A C H E S T R I N G " C M a k e n a m e s p a c e u s e d w h e n e x p o r t i n g t a r g e t s [ Q t $ { P R O J E C T _ V E R S I O N _ M A J O R } ] " )
endif ( )
2019-02-11 10:34:35 +00:00
2019-02-13 08:45:18 +00:00
set ( QT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" )
2019-02-12 09:02:15 +00:00
2019-11-21 12:33:28 +00:00
# Find the path to mkspecs/, depending on whether we are building as part of a standard qtbuild,
# or a module against an already installed version of qt.
if ( NOT QT_MKSPECS_DIR )
if ( "${QT_BUILD_INTERNALS_PATH}" STREQUAL "" )
get_filename_component ( QT_MKSPECS_DIR "${CMAKE_CURRENT_LIST_DIR}/../mkspecs" ABSOLUTE )
else ( )
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
# We can rely on QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX being set by
# QtBuildInternalsExtra.cmake.
get_filename_component (
Q T _ M K S P E C S _ D I R
" $ { Q T _ B U I L D _ I N T E R N A L S _ R E L O C A T A B L E _ I N S T A L L _ P R E F I X } / $ { I N S T A L L _ M K S P E C S D I R } " A B S O L U T E )
2019-11-21 12:33:28 +00:00
endif ( )
set ( QT_MKSPECS_DIR "${QT_MKSPECS_DIR}" CACHE INTERNAL "" )
endif ( )
2019-02-11 14:45:56 +00:00
# the default RPATH to be used when installing, but only if it's not a system directory
2020-04-15 09:13:46 +00:00
list ( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" isSystemDir )
if ( "${isSystemDir}" STREQUAL "-1" )
set ( _default_install_rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" )
endif ( "${isSystemDir}" STREQUAL "-1" )
2019-02-11 14:45:56 +00:00
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
# The default rpath settings for installed targets is empty.
# The rpaths will instead be computed for each target separately using qt_apply_rpaths().
# Additional rpaths can be passed via QT_EXTRA_RPATHS.
# By default this will include $ORIGIN / @loader_path, so the installation is relocatable.
# Bottom line: No need to pass anything to CMAKE_INSTALL_RPATH.
set ( CMAKE_INSTALL_RPATH "" CACHE STRING "RPATH for installed binaries" )
2019-02-11 14:45:56 +00:00
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
2020-04-15 09:13:46 +00:00
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
2019-02-11 14:45:56 +00:00
2019-09-24 09:42:15 +00:00
# Generate a module description file based on the template in ModuleDescription.json.in
function ( qt_describe_module target )
set ( path_suffix "${INSTALL_DESCRIPTIONSDIR}" )
qt_path_join ( build_dir ${ QT_BUILD_DIR } ${ path_suffix } )
qt_path_join ( install_dir ${ QT_INSTALL_DIR } ${ path_suffix } )
set ( descfile_in "${QT_CMAKE_DIR}/ModuleDescription.json.in" )
set ( descfile_out "${build_dir}/${target}.json" )
set ( cross_compilation "false" )
2020-03-26 13:13:18 +00:00
if ( CMAKE_CROSSCOMPILING )
2019-09-24 09:42:15 +00:00
set ( cross_compilation "true" )
endif ( )
configure_file ( "${descfile_in}" "${descfile_out}" )
qt_install ( FILES "${descfile_out}" DESTINATION "${install_dir}" )
endfunction ( )
2019-09-04 08:52:18 +00:00
function ( qt_setup_tool_path_command )
if ( NOT WIN32 )
return ( )
endif ( )
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
set ( bindir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}" )
2019-09-04 08:52:18 +00:00
file ( TO_NATIVE_PATH "${bindir}" bindir )
2019-09-04 13:47:11 +00:00
list ( APPEND command COMMAND )
2020-05-29 09:34:23 +00:00
list ( APPEND command set \"PATH=${bindir}$<SEMICOLON>%PATH%\")
2019-09-04 08:52:18 +00:00
set ( QT_TOOL_PATH_SETUP_COMMAND "${command}" CACHE INTERNAL "internal command prefix for tool invocations" FORCE )
endfunction ( )
qt_setup_tool_path_command ( )
2018-10-24 13:20:27 +00:00
# Platform define path, etc.
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC "" )
2018-10-24 13:20:27 +00:00
if ( WIN32 )
set ( QT_DEFAULT_PLATFORM_DEFINITIONS UNICODE _UNICODE WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
list ( APPEND QT_DEFAULT_PLATFORM_DEFINITIONS WIN64 _WIN64 )
endif ( )
if ( MSVC )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC win32-msvc )
2019-11-22 16:11:22 +00:00
elseif ( CLANG AND MINGW )
set ( QT_QMAKE_TARGET_MKSPEC win32-clang-g++ )
2019-05-03 13:46:02 +00:00
elseif ( MINGW )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC win32-g++ )
2019-11-22 16:11:22 +00:00
endif ( )
if ( MINGW )
2020-04-30 15:50:22 +00:00
list ( APPEND QT_DEFAULT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0601 MINGW_HAS_SECURE_API=1 )
2018-10-24 13:20:27 +00:00
endif ( )
elseif ( LINUX )
if ( GCC )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC linux-g++ )
2018-10-24 13:20:27 +00:00
elseif ( CLANG )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC linux-clang )
2019-06-17 10:13:48 +00:00
elseif ( ICC )
set ( QT_QMAKE_TARGET_MKSPEC linux-icc-64 )
2018-10-24 13:20:27 +00:00
endif ( )
2019-05-29 14:22:38 +00:00
elseif ( ANDROID )
if ( GCC )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC android-g++ )
2019-05-29 14:22:38 +00:00
elseif ( CLANG )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC android-clang )
2019-05-29 14:22:38 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
elseif ( APPLE )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC macx-clang )
2019-08-28 13:59:11 +00:00
elseif ( EMSCRIPTEN )
set ( QT_QMAKE_TARGET_MKSPEC wasm-emscripten )
2019-05-31 14:30:09 +00:00
endif ( )
# TODO: Fixme to be correct.
set ( QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}" )
2020-01-15 22:01:16 +00:00
# Platform definition dir provided by user on command line.
# Derive the absolute one relative to the current source dir.
if ( QT_PLATFORM_DEFINITION_DIR )
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR "${QT_PLATFORM_DEFINITION_DIR}" )
get_filename_component (
Q T _ D E F A U L T _ P L A T F O R M _ D E F I N I T I O N _ D I R _ A B S O L U T E
" $ { Q T _ P L A T F O R M _ D E F I N I T I O N _ D I R } "
A B S O L U T E )
elseif ( QT_QMAKE_TARGET_MKSPEC )
# Used by consumers of prefix builds via INSTALL_INTERFACE (relative path).
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR "${INSTALL_MKSPECSDIR}/${QT_QMAKE_TARGET_MKSPEC}" )
# Used by qtbase itself and consumers of non-prefix builds via BUILD_INTERFACE (absolute path).
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE "${QT_MKSPECS_DIR}/${QT_QMAKE_TARGET_MKSPEC}" )
2018-10-24 13:20:27 +00:00
endif ( )
if ( NOT DEFINED QT_DEFAULT_PLATFORM_DEFINITIONS )
set ( QT_DEFAULT_PLATFORM_DEFINITIONS "" )
endif ( )
set ( QT_PLATFORM_DEFINITIONS ${ QT_DEFAULT_PLATFORM_DEFINITIONS }
C A C H E S T R I N G " Q t p l a t f o r m s p e c i f i c p r e - p r o c e s s o r d e f i n e s " )
2020-01-15 22:01:16 +00:00
set ( QT_PLATFORM_DEFINITION_DIR "${QT_DEFAULT_PLATFORM_DEFINITION_DIR}"
2018-10-24 13:20:27 +00:00
C A C H E P A T H " P a t h t o d i r e c t o r y t h a t c o n t a i n s q p l a t f o r m d e f s . h " )
2020-01-15 22:01:16 +00:00
set ( QT_PLATFORM_DEFINITION_DIR_ABSOLUTE "${QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE}"
C A C H E I N T E R N A L " P a t h t o d i r e c t o r y t h a t c o n t a i n s q p l a t f o r m d e f s . h " )
2018-10-24 13:20:27 +00:00
set ( QT_NAMESPACE "" CACHE STRING "Qt Namespace" )
2019-01-30 15:31:06 +00:00
if ( QT_NAMESPACE STREQUAL "" )
set ( QT_HAS_NAMESPACE OFF )
else ( )
set ( QT_HAS_NAMESPACE ON )
endif ( )
2018-10-24 13:20:27 +00:00
2019-08-20 13:24:14 +00:00
function ( qt_internal_clear_qt_repo_known_modules )
set ( QT_REPO_KNOWN_MODULES "" CACHE INTERNAL "Known current repo Qt modules" FORCE )
endfunction ( )
function ( qt_internal_add_qt_repo_known_module )
set ( QT_REPO_KNOWN_MODULES ${ QT_REPO_KNOWN_MODULES } ${ ARGN }
C A C H E I N T E R N A L " K n o w n c u r r e n t r e p o Q t m o d u l e s " F O R C E )
endfunction ( )
function ( qt_internal_get_qt_repo_known_modules out_var )
set ( "${out_var}" "${QT_REPO_KNOWN_MODULES}" PARENT_SCOPE )
endfunction ( )
# Gets the list of all known Qt modules both found and that were built as part of the
# current project.
function ( qt_internal_get_qt_all_known_modules out_var )
qt_internal_get_qt_repo_known_modules ( repo_known_modules )
set ( known_modules ${ QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE } ${ repo_known_modules } )
list ( REMOVE_DUPLICATES known_modules )
set ( "${out_var}" "${known_modules}" PARENT_SCOPE )
endfunction ( )
2019-05-03 14:03:15 +00:00
macro ( qt_internal_set_qt_known_plugins )
set ( QT_KNOWN_PLUGINS ${ ARGN } CACHE INTERNAL "Known Qt plugins" FORCE )
endmacro ( )
2018-10-24 13:20:27 +00:00
2019-09-23 14:57:06 +00:00
### Global plug-in types handling ###
# QT_REPO_KNOWN_PLUGIN_TYPES and QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE
# hold a list of plug-in types (e.G. "imageformats;bearer")
function ( qt_internal_clear_qt_repo_known_plugin_types )
set ( QT_REPO_KNOWN_PLUGIN_TYPES "" CACHE INTERNAL "Known current repo Qt plug-in types" FORCE )
endfunction ( )
function ( qt_internal_add_qt_repo_known_plugin_types )
set ( QT_REPO_KNOWN_PLUGIN_TYPES ${ QT_REPO_KNOWN_PLUGIN_TYPES } ${ ARGN }
C A C H E I N T E R N A L " K n o w n c u r r e n t r e p o Q t p l u g - i n t y p e s " F O R C E )
endfunction ( )
function ( qt_internal_get_qt_repo_known_plugin_types out_var )
set ( "${out_var}" "${QT_REPO_KNOWN_PLUGIN_TYPES}" PARENT_SCOPE )
endfunction ( )
function ( qt_internal_get_qt_all_known_plugin_types out_var )
qt_internal_get_qt_repo_known_plugin_types ( repo_known_plugin_types )
set ( known ${ QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE } ${ repo_known_plugin_types } )
list ( REMOVE_DUPLICATES known )
set ( "${out_var}" "${known}" PARENT_SCOPE )
endfunction ( )
2018-11-08 21:29:54 +00:00
# Reset:
2019-09-23 14:57:06 +00:00
qt_internal_clear_qt_repo_known_modules ( )
qt_internal_clear_qt_repo_known_plugin_types ( )
2019-05-03 14:03:15 +00:00
qt_internal_set_qt_known_plugins ( "" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
set ( QT_KNOWN_MODULES_WITH_TOOLS "" CACHE INTERNAL "Known Qt modules with tools" FORCE )
macro ( qt_internal_append_known_modules_with_tools module )
if ( NOT ${ module } IN_LIST QT_KNOWN_MODULES_WITH_TOOLS )
set ( QT_KNOWN_MODULES_WITH_TOOLS "${QT_KNOWN_MODULES_WITH_TOOLS};${module}"
C A C H E I N T E R N A L " K n o w n Q t m o d u l e s w i t h t o o l s " F O R C E )
2019-12-05 14:47:24 +00:00
set ( QT_KNOWN_MODULE_ ${ module } _TOOLS ""
C A C H E I N T E R N A L " K n o w n Q t m o d u l e $ { m o d u l e } t o o l s " F O R C E )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
endif ( )
endmacro ( )
macro ( qt_internal_append_known_module_tool module tool )
if ( NOT ${ tool } IN_LIST QT_KNOWN_MODULE_ ${ module } _TOOLS )
list ( APPEND QT_KNOWN_MODULE_ ${ module } _TOOLS "${tool}" )
set ( QT_KNOWN_MODULE_ ${ module } _TOOLS "${QT_KNOWN_MODULE_${module}_TOOLS}"
C A C H E I N T E R N A L " K n o w n Q t m o d u l e $ { m o d u l e } t o o l s " F O R C E )
endif ( )
endmacro ( )
# Reset syncqt cache variable, to make sure it gets recomputed on reconfiguration, otherwise
# it might not get installed.
unset ( QT_SYNCQT CACHE )
2018-10-24 13:20:27 +00:00
# For adjusting variables when running tests, we need to know what
# the correct variable is for separating entries in PATH-alike
# variables.
if ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" )
set ( QT_PATH_SEPARATOR "\\;" )
else ( )
set ( QT_PATH_SEPARATOR ":" )
endif ( )
2019-05-15 11:57:15 +00:00
# This is used to hold extra cmake code that should be put into QtBuildInternalsExtra.cmake file
# at the QtPostProcess stage.
set ( QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "" )
2019-07-26 16:15:41 +00:00
# Save the value of the current first project source dir.
# This will be /path/to/qtbase for qtbase both in a super-build and a non super-build.
# This will be /path/to/qtbase/tests when building standalone tests.
set ( QT_TOP_LEVEL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" )
2019-09-23 11:35:06 +00:00
# Prevent warnings about object files without any symbols. This is a common
# thing in Qt as we tend to build files unconditionally, and then use ifdefs
# to compile out parts that are not relevant.
if ( CMAKE_HOST_APPLE AND APPLE )
foreach ( lang ASM C CXX )
# We have to tell 'ar' to not run ranlib by itself, by passing the 'S' option
set ( CMAKE_ ${ lang } _ARCHIVE_CREATE "<CMAKE_AR> qcS <TARGET> <LINK_FLAGS> <OBJECTS>" )
set ( CMAKE_ ${ lang } _ARCHIVE_APPEND "<CMAKE_AR> qS <TARGET> <LINK_FLAGS> <OBJECTS>" )
set ( CMAKE_ ${ lang } _ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols <TARGET>" )
endforeach ( )
endif ( )
2018-10-24 13:20:27 +00:00
# Functions and macros:
2019-07-18 07:38:37 +00:00
# qt_remove_args can remove arguments from an existing list of function
# arguments in order to pass a filtered list of arguments to a different function.
# Parameters:
# out_var: result of remove all arguments specified by ARGS_TO_REMOVE from ALL_ARGS
# ARGS_TO_REMOVE: Arguments to remove.
# ALL_ARGS: All arguments supplied to cmake_parse_arguments or
# qt_parse_all_arguments
# from which ARGS_TO_REMOVE should be removed from. We require all the
# arguments or we can't properly identify the range of the arguments detailed
# in ARGS_TO_REMOVE.
# ARGS: Arguments passed into the function, usually ${ARGV}
#
# E.g.:
# We want to forward all arguments from foo to bar, execpt ZZZ since it will
# trigger an error in bar.
#
# foo(target BAR .... ZZZ .... WWW ...)
# bar(target BAR.... WWW...)
#
# function(foo target)
# qt_parse_all_arguments(arg "" "" "BAR;ZZZ;WWW ${ARGV})
# qt_remove_args(forward_args
# ARGS_TO_REMOVE ${target} ZZZ
# ALL_ARGS ${target} BAR ZZZ WWW
# ARGS ${ARGV}
# )
# bar(${target} ${forward_args})
# endfunction()
#
function ( qt_remove_args out_var )
cmake_parse_arguments ( arg "" "" "ARGS_TO_REMOVE;ALL_ARGS;ARGS" ${ ARGN } )
set ( result ${ arg_ARGS } )
foreach ( arg IN LISTS arg_ARGS_TO_REMOVE )
# find arg
list ( FIND result ${ arg } find_result )
if ( NOT find_result EQUAL -1 )
# remove arg
list ( REMOVE_AT result ${ find_result } )
list ( LENGTH result result_len )
list ( GET result ${ find_result } arg_current )
# remove values until we hit another arg
while ( NOT ${ arg_current } IN_LIST arg_ALL_ARGS AND find_result LESS result_len )
list ( REMOVE_AT result ${ find_result } )
list ( GET result ${ find_result } arg_current )
list ( LENGTH result result_len )
endwhile ( )
endif ( )
endforeach ( )
set ( ${ out_var } "${result}" PARENT_SCOPE )
endfunction ( )
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
# Wraps install() command. In a prefix build, simply passes along arguments to install().
# In a non-prefix build, handles association of targets to export names, and also calls export().
function ( qt_install )
set ( flags )
set ( options EXPORT DESTINATION NAMESPACE )
set ( multiopts TARGETS )
cmake_parse_arguments ( arg "${flags}" "${options}" "${multiopts}" ${ ARGN } )
if ( arg_TARGETS )
set ( is_install_targets TRUE )
endif ( )
# In a prefix build, always invoke install() without modification.
# In a non-prefix build, pass install(TARGETS) commands to allow
# association of targets to export names, so we can later use the export names
# in export() commands.
if ( QT_WILL_INSTALL OR is_install_targets )
install ( ${ ARGV } )
endif ( )
# Exit early if this is a prefix build.
if ( QT_WILL_INSTALL )
return ( )
endif ( )
# In a non-prefix build, when install(EXPORT) is called,
# also call export(EXPORT) to generate build tree target files.
if ( NOT is_install_targets AND arg_EXPORT )
set ( namespace_option "" )
if ( arg_NAMESPACE )
set ( namespace_option NAMESPACE ${ arg_NAMESPACE } )
endif ( )
export ( EXPORT ${ arg_EXPORT }
$ { n a m e s p a c e _ o p t i o n }
F I L E " $ { a r g _ D E S T I N A T I O N } / $ { a r g _ E X P O R T } . c m a k e " )
endif ( )
endfunction ( )
# Copies files using file(COPY) signature in non-prefix builds.
function ( qt_non_prefix_copy )
if ( NOT QT_WILL_INSTALL )
file ( ${ ARGV } )
endif ( )
endfunction ( )
# Use case is installing files in a prefix build, or copying them to the correct build dir
# in a non-prefix build.
# Pass along arguments as you would pass them to install().
# Only supports FILES, PROGRAMS and DIRECTORY signature, and without fancy things
# like OPTIONAL or RENAME or COMPONENT.
function ( qt_copy_or_install )
set ( flags FILES PROGRAMS DIRECTORY )
set ( options )
set ( multiopts )
cmake_parse_arguments ( arg "${flags}" "${options}" "${multiopts}" ${ ARGN } )
# Remember which option has to be passed to the install command.
set ( argv_copy ${ ARGV } )
if ( arg_FILES )
set ( install_option "FILES" )
elseif ( arg_PROGRAMS )
set ( install_option "PROGRAMS" )
elseif ( arg_DIRECTORY )
set ( install_option "DIRECTORY" )
endif ( )
list ( REMOVE_AT argv_copy 0 )
qt_install ( ${ install_option } ${ argv_copy } )
qt_non_prefix_copy ( COPY ${ argv_copy } )
endfunction ( )
# Hacky way to remove the install target in non-prefix builds.
# We need to associate targets with export names, and that is only possible to do with the
# install(TARGETS) command. But in a non-prefix build, we don't want to install anything.
# To make sure that developers don't accidentally run make install, replace the generated
# cmake_install.cmake file with an empty file. To do this, always create a new temporary file
# at CMake configuration step, and use it as an input to a custom command that replaces the
# cmake_install.cmake file with an empty one. This means we will always replace the file on
# every reconfiguration, but not when doing null builds.
2019-11-13 13:03:20 +00:00
function ( qt_remove_install_target )
2019-11-21 12:33:28 +00:00
# On superbuilds we only do this for qtbase - it will correctly remove the
# cmake_install.cmake at the root of the repository.
if ( QT_SUPERBUILD )
if ( NOT ( PROJECT_NAME STREQUAL "QtBase" ) )
return ( )
endif ( )
endif ( )
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 ( file_in "${CMAKE_BINARY_DIR}/.remove_cmake_install_in.txt" )
set ( file_generated "${CMAKE_BINARY_DIR}/.remove_cmake_install_generated.txt" )
set ( cmake_install_file "${CMAKE_BINARY_DIR}/cmake_install.cmake" )
file ( WRITE ${ file_in } "" )
add_custom_command ( OUTPUT ${ file_generated }
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y $ { f i l e _ i n } $ { f i l e _ g e n e r a t e d }
C O M M A N D $ { C M A K E _ C O M M A N D } - E r e m o v e $ { c m a k e _ i n s t a l l _ f i l e }
C O M M A N D $ { C M A K E _ C O M M A N D } - E t o u c h $ { c m a k e _ i n s t a l l _ f i l e }
C O M M E N T " R e m o v i n g c m a k e _ i n s t a l l . c m a k e "
M A I N _ D E P E N D E N C Y $ { f i l e _ i n } )
add_custom_target ( remove_cmake_install ALL DEPENDS ${ file_generated } )
endfunction ( )
2019-06-25 10:09:10 +00:00
function ( qt_set_up_nonprefix_build )
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
if ( NOT QT_WILL_INSTALL )
2019-11-13 13:03:20 +00:00
qt_remove_install_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
endif ( )
endfunction ( )
2019-07-30 09:15:32 +00:00
function ( qt_is_imported_target target out_var )
if ( NOT TARGET "${target}" )
set ( target "${QT_CMAKE_EXPORT_NAMESPACE}::${target}" )
endif ( )
if ( NOT TARGET "${target}" )
message ( FATAL_ERROR "Invalid target given to qt_is_imported_target: ${target}" )
endif ( )
get_target_property ( is_imported "${target}" IMPORTED )
set ( ${ out_var } "${is_imported}" PARENT_SCOPE )
endfunction ( )
2020-04-22 19:01:32 +00:00
# Creates a regular expression that exactly matches the given string
# Found in https://gitlab.kitware.com/cmake/cmake/issues/18580
function ( qt_re_escape out_var str )
string ( REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${str}" )
set ( ${ out_var } ${ regex } PARENT_SCOPE )
endfunction ( )
2020-06-05 08:10:50 +00:00
# Extracts the 3rdparty libraries for the module ${module_name}
# and stores the information in cmake language in
# ${output_root_dir}/$<CONFIG>/${output_file_name}.
2020-04-22 19:01:32 +00:00
#
# This function "follows" INTERFACE_LIBRARY targets to "real" targets
# and collects defines, include dirs and lib dirs on the way.
2020-06-05 08:10:50 +00:00
function ( qt_generate_qmake_libraries_pri_content module_name output_root_dir output_file_name )
2020-04-22 19:01:32 +00:00
set ( content "" )
# Set up a regular expression that matches all implicit include dirs
set ( implicit_include_dirs_regex "" )
foreach ( dir ${ CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES } )
qt_re_escape ( regex "${dir}" )
list ( APPEND implicit_include_dirs_regex ${ regex } )
endforeach ( )
list ( JOIN implicit_include_dirs_regex "|" implicit_include_dirs_regex )
foreach ( lib ${ QT_QMAKE_LIBS_FOR_${module_name } } )
set ( lib_targets ${ QT_QMAKE_LIB_TARGETS_${lib } } )
string ( TOUPPER ${ lib } uclib )
set ( lib_defines "" )
set ( lib_incdir "" )
set ( lib_libdir "" )
set ( lib_libs "" )
while ( lib_targets )
list ( POP_BACK lib_targets lib_target )
if ( TARGET ${ lib_target } )
get_target_property ( lib_target_type ${ lib_target } TYPE )
if ( lib_target_type STREQUAL "INTERFACE_LIBRARY" )
get_target_property ( iface_libs ${ lib_target } INTERFACE_LINK_LIBRARIES )
if ( iface_libs )
list ( PREPEND lib_targets ${ iface_libs } )
endif ( )
else ( )
list ( APPEND lib_libs "$<TARGET_LINKER_FILE:${lib_target}>" )
endif ( )
list ( APPEND lib_libdir "$<TARGET_PROPERTY:${lib_target},INTERFACE_LINK_DIRECTORIES>" )
list ( APPEND lib_incdir "$<TARGET_PROPERTY:${lib_target},INTERFACE_INCLUDE_DIRECTORIES>" )
list ( APPEND lib_defines "$<TARGET_PROPERTY:${lib_target},INTERFACE_COMPILE_DEFINITIONS>" )
else ( )
list ( APPEND lib_libs "${lib_target}" )
endif ( )
endwhile ( )
# Wrap in $<REMOVE_DUPLICATES:...> but not the libs, because
# we would have to preserve the right order for the linker.
foreach ( sfx libdir incdir defines )
string ( PREPEND lib_ ${ sfx } "$<REMOVE_DUPLICATES:" )
string ( APPEND lib_ ${ sfx } ">" )
endforeach ( )
# Filter out implicit include directories
string ( PREPEND lib_incdir "$<FILTER:" )
string ( APPEND lib_incdir ",EXCLUDE,${implicit_include_dirs_regex}>" )
2020-06-05 08:10:50 +00:00
set ( uccfg $< UPPER_CASE:$<CONFIG > > )
string ( APPEND content " list(APPEND known_libs ${ uclib } )
set ( QMAKE_LIBS_ ${ uclib } _ ${ uccfg } \"${lib_libs}\")
set ( QMAKE_LIBDIR_ ${ uclib } _ ${ uccfg } \"${lib_libdir}\")
set ( QMAKE_INCDIR_ ${ uclib } _ ${ uccfg } \"${lib_incdir}\")
set ( QMAKE_DEFINES_ ${ uclib } _ ${ uccfg } \"${lib_defines}\")
2020-04-22 19:01:32 +00:00
" )
if ( QT_QMAKE_LIB_DEPS_ ${ lib } )
2020-06-05 08:10:50 +00:00
string ( APPEND content " set(QMAKE_DEPENDS_ ${ uclib } _CC, ${ deps } )
set ( QMAKE_DEPENDS_ ${ uclib } _LD, ${ deps } )
2020-04-22 19:01:32 +00:00
" )
endif ( )
endforeach ( )
2020-06-05 08:10:50 +00:00
file ( GENERATE
O U T P U T " $ { o u t p u t _ r o o t _ d i r } / $ < C O N F I G > / $ { o u t p u t _ f i l e _ n a m e } "
C O N T E N T " $ { c o n t e n t } "
)
2020-04-22 19:01:32 +00:00
endfunction ( )
2020-05-28 17:20:09 +00:00
# Retrieves the public Qt module dependencies of the given Qt module or Qt Private module.
2020-05-18 21:09:41 +00:00
function ( qt_get_direct_module_dependencies target out_var )
set ( dependencies "" )
2020-05-28 17:20:09 +00:00
get_target_property ( libs ${ target } INTERFACE_LINK_LIBRARIES )
2020-05-18 21:09:41 +00:00
if ( NOT libs )
set ( libs "" )
endif ( )
get_target_property ( target_type ${ target } TYPE )
while ( libs )
list ( POP_FRONT libs lib )
string ( GENEX_STRIP "${lib}" lib )
if ( NOT lib OR NOT TARGET "${lib}" )
continue ( )
endif ( )
get_target_property ( lib_type ${ lib } TYPE )
2020-05-27 15:36:11 +00:00
get_target_property ( is_versionless_target ${ lib } _qt_is_versionless_target )
if ( lib_type STREQUAL "INTERFACE_LIBRARY" AND is_versionless_target )
2020-05-18 21:09:41 +00:00
# Found a version-less target like Qt::Core outside of qtbase.
# Skip this one and use what this target points to, e.g. Qt6::Core.
2020-05-27 15:36:11 +00:00
# Make sure to process Private interface libraries as-is.
2020-05-18 21:09:41 +00:00
get_target_property ( ifacelibs ${ lib } INTERFACE_LINK_LIBRARIES )
list ( PREPEND libs ${ ifacelibs } )
continue ( )
endif ( )
if ( lib_type STREQUAL "OBJECT_LIBRARY" )
# Skip object libraries, because they're already part of ${target}.
continue ( )
elseif ( lib_type STREQUAL "STATIC_LIBRARY" AND target_type STREQUAL "SHARED_LIBRARY" )
# Skip static libraries if ${target} is a shared library.
continue ( )
endif ( )
get_target_property ( lib_config_module_name ${ lib } "_qt_config_module_name" )
if ( lib_config_module_name )
list ( APPEND dependencies ${ lib_config_module_name } )
endif ( )
endwhile ( )
set ( ${ out_var } ${ dependencies } PARENT_SCOPE )
endfunction ( )
2019-05-29 14:56:49 +00:00
# Generates module .pri files for consumption by qmake
2020-05-18 19:56:12 +00:00
function ( qt_generate_module_pri_file target )
2019-08-19 13:07:22 +00:00
set ( flags INTERNAL_MODULE HEADER_MODULE )
2019-05-29 14:56:49 +00:00
set ( options )
2020-05-18 19:56:12 +00:00
set ( multiopts )
2019-05-29 14:56:49 +00:00
cmake_parse_arguments ( arg "${flags}" "${options}" "${multiopts}" ${ ARGN } )
qt_internal_module_info ( module "${target}" )
2019-06-06 08:11:15 +00:00
set ( pri_files )
2019-05-29 14:56:49 +00:00
2019-08-19 13:07:22 +00:00
set ( property_prefix )
if ( arg_HEADER_MODULE )
2020-05-18 20:28:59 +00:00
set ( property_prefix "INTERFACE_" )
2019-08-19 13:07:22 +00:00
endif ( )
get_target_property ( enabled_features "${target}"
" $ { p r o p e r t y _ p r e f i x } Q T _ E N A B L E D _ P U B L I C _ F E A T U R E S " )
get_target_property ( disabled_features "${target}"
" $ { p r o p e r t y _ p r e f i x } Q T _ D I S A B L E D _ P U B L I C _ F E A T U R E S " )
get_target_property ( enabled_private_features "${target}"
" $ { p r o p e r t y _ p r e f i x } Q T _ E N A B L E D _ P R I V A T E _ F E A T U R E S " )
get_target_property ( disabled_private_features "${target}"
" $ { p r o p e r t y _ p r e f i x } Q T _ D I S A B L E D _ P R I V A T E _ F E A T U R E S " )
2019-08-28 13:15:50 +00:00
qt_correct_features ( enabled_features "${enabled_features}" )
qt_correct_features ( disabled_features "${disabled_features}" )
qt_correct_features ( enabled_private_features "${enabled_private_features}" )
qt_correct_features ( disabled_private_features "${disabled_private_features}" )
2019-06-05 11:49:08 +00:00
foreach ( var enabled_features disabled_features enabled_private_features disabled_private_features )
if ( ${ var } STREQUAL "${var}-NOTFOUND" )
set ( ${ var } "" )
else ( )
string ( REPLACE ";" " " ${ var } "${${var}}" )
endif ( )
endforeach ( )
2019-05-29 14:56:49 +00:00
2019-08-28 13:15:50 +00:00
set ( module_internal_config v2 )
if ( NOT QT_FEATURE_shared )
list ( APPEND module_internal_config staticlib )
endif ( )
if ( arg_INTERNAL_MODULE )
list ( APPEND module_internal_config internal_module )
endif ( )
get_target_property ( target_type ${ target } TYPE )
if ( NOT target_type STREQUAL "INTERFACE_LIBRARY" )
get_target_property ( is_fw ${ target } FRAMEWORK )
if ( is_fw )
list ( APPEND module_internal_config lib_bundle )
endif ( )
endif ( )
# TODO: Add the value 'ltcg' to module_internal_config if LTCG is turned on.
list ( JOIN module_internal_config " " joined_module_internal_config )
2020-05-18 21:09:41 +00:00
get_target_property ( config_module_name ${ target } _qt_config_module_name )
2020-05-18 19:56:12 +00:00
get_target_property ( qmake_module_config ${ target } ${ property_prefix } QT_QMAKE_MODULE_CONFIG )
if ( qmake_module_config )
string ( REPLACE ";" " " module_build_config "${qmake_module_config}" )
2019-08-28 13:15:50 +00:00
set ( module_build_config "\nQT.${config_module_name}.CONFIG = ${module_build_config}" )
2019-05-29 14:56:49 +00:00
else ( )
2019-08-28 13:15:50 +00:00
set ( module_build_config "" )
2019-05-29 14:56:49 +00:00
endif ( )
2020-06-08 19:05:52 +00:00
if ( is_fw )
set ( framework_base_path "$$QT_MODULE_LIB_BASE/${module}.framework/Headers" )
set ( public_module_includes "${framework_base_path}" )
set ( public_module_frameworks "$$QT_MODULE_LIB_BASE" )
set ( private_module_includes "${framework_base_path}/${PROJECT_VERSION} ${framework_base_path}/${PROJECT_VERSION}/${module}" )
set ( module_name_in_pri "${module}" )
else ( )
set ( public_module_includes "$$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/${module}" )
set ( public_module_frameworks "" )
set ( private_module_includes "$$QT_MODULE_INCLUDE_BASE/${module}/${PROJECT_VERSION} $$QT_MODULE_INCLUDE_BASE/${module}/${PROJECT_VERSION}/${module}" )
set ( module_name_in_pri "${module_versioned}" )
endif ( )
2020-05-18 19:56:12 +00:00
qt_path_join ( target_path ${ QT_BUILD_DIR } ${ INSTALL_MKSPECSDIR } /modules )
2020-06-08 19:05:52 +00:00
if ( arg_INTERNAL_MODULE )
string ( PREPEND private_module_includes "${public_module_includes} " )
set ( private_module_frameworks ${ public_module_frameworks } )
else ( )
unset ( private_module_frameworks )
2020-04-30 08:11:40 +00:00
if ( arg_HEADER_MODULE )
set ( module_plugin_types "" )
else ( )
get_target_property ( module_plugin_types ${ target } MODULE_PLUGIN_TYPES )
2020-05-18 15:20:34 +00:00
if ( module_plugin_types )
list ( JOIN module_plugin_types " " module_plugin_types )
else ( )
set ( module_plugin_types "" )
endif ( )
2020-04-30 08:11:40 +00:00
endif ( )
2020-05-28 17:20:09 +00:00
qt_get_direct_module_dependencies ( ${ target } public_module_dependencies )
list ( JOIN public_module_dependencies " " public_module_dependencies )
2020-05-18 21:09:41 +00:00
2020-03-30 12:12:34 +00:00
qt_path_join ( pri_file_name "${target_path}" "qt_lib_${config_module_name}.pri" )
2019-06-06 08:11:15 +00:00
list ( APPEND pri_files "${pri_file_name}" )
2019-06-05 11:49:08 +00:00
file ( GENERATE
O U T P U T " $ { p r i _ f i l e _ n a m e } "
C O N T E N T
2020-03-30 12:12:34 +00:00
" Q T . $ { c o n f i g _ m o d u l e _ n a m e } . V E R S I O N = $ { P R O J E C T _ V E R S I O N }
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . n a m e = $ { m o d u l e }
2020-06-03 16:36:48 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . m o d u l e = $ { m o d u l e _ n a m e _ i n _ p r i }
2020-03-30 12:12:34 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . l i b s = $ $ Q T _ M O D U L E _ L I B _ B A S E
2020-06-03 16:36:48 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . i n c l u d e s = $ { p u b l i c _ m o d u l e _ i n c l u d e s }
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . f r a m e w o r k s = $ { p u b l i c _ m o d u l e _ f r a m e w o r k s }
2020-03-30 12:12:34 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . b i n s = $ $ Q T _ M O D U L E _ B I N _ B A S E
2020-04-30 08:11:40 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . p l u g i n _ t y p e s = $ { m o d u l e _ p l u g i n _ t y p e s }
2020-05-28 17:20:09 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . d e p e n d s = $ { p u b l i c _ m o d u l e _ d e p e n d e n c i e s }
2020-03-30 12:12:34 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . u s e s =
2019-08-28 13:15:50 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . m o d u l e _ c o n f i g = $ { j o i n e d _ m o d u l e _ i n t e r n a l _ c o n f i g }
2020-03-30 12:12:34 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . D E F I N E S = Q T _ $ { m o d u l e _ d e f i n e } _ L I B
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . e n a b l e d _ f e a t u r e s = $ { e n a b l e d _ f e a t u r e s }
2019-08-28 13:15:50 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } . d i s a b l e d _ f e a t u r e s = $ { d i s a b l e d _ f e a t u r e s } $ { m o d u l e _ b u i l d _ c o n f i g }
2020-05-19 09:08:40 +00:00
Q T _ C O N F I G + = $ { e n a b l e d _ f e a t u r e s }
2020-03-30 12:12:34 +00:00
Q T _ M O D U L E S + = $ { c o n f i g _ m o d u l e _ n a m e }
2019-06-05 11:49:08 +00:00
"
)
endif ( )
2020-06-05 08:10:50 +00:00
set ( pri_data_cmake_file "qt_lib_${config_module_name}_private.cmake" )
qt_generate_qmake_libraries_pri_content ( ${ config_module_name } "${CMAKE_CURRENT_BINARY_DIR}"
$ { p r i _ d a t a _ c m a k e _ f i l e } )
2019-06-05 11:49:08 +00:00
2020-06-05 08:10:50 +00:00
set ( private_pri_file_name "qt_lib_${config_module_name}_private.pri" )
2020-04-22 19:01:32 +00:00
2020-05-28 17:20:09 +00:00
set ( private_module_dependencies "" )
2020-05-18 21:09:41 +00:00
if ( NOT arg_HEADER_MODULE )
2020-05-28 17:20:09 +00:00
qt_get_direct_module_dependencies ( ${ target } Private private_module_dependencies )
2020-05-18 21:09:41 +00:00
endif ( )
2020-05-28 17:20:09 +00:00
list ( JOIN private_module_dependencies " " private_module_dependencies )
2020-05-18 21:09:41 +00:00
2020-06-05 08:10:50 +00:00
# Generate a preliminary qt_lib_XXX_private.pri file
2019-06-05 11:49:08 +00:00
file ( GENERATE
2020-06-05 08:10:50 +00:00
O U T P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { p r i v a t e _ p r i _ f i l e _ n a m e } "
2019-06-05 11:49:08 +00:00
C O N T E N T
2020-03-30 12:12:34 +00:00
" Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . V E R S I O N = $ { P R O J E C T _ V E R S I O N }
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . n a m e = $ { m o d u l e }
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . m o d u l e =
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . l i b s = $ $ Q T _ M O D U L E _ L I B _ B A S E
2020-06-03 16:36:48 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . i n c l u d e s = $ { p r i v a t e _ m o d u l e _ i n c l u d e s }
2020-06-08 19:05:52 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . f r a m e w o r k s = $ { p r i v a t e _ m o d u l e _ f r a m e w o r k s }
2020-05-28 17:20:09 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . d e p e n d s = $ { p r i v a t e _ m o d u l e _ d e p e n d e n c i e s }
2020-03-30 12:12:34 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . u s e s =
2019-08-28 13:15:50 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . m o d u l e _ c o n f i g = $ { j o i n e d _ m o d u l e _ i n t e r n a l _ c o n f i g }
2020-03-30 12:12:34 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . e n a b l e d _ f e a t u r e s = $ { e n a b l e d _ p r i v a t e _ f e a t u r e s }
2020-06-05 08:10:50 +00:00
Q T . $ { c o n f i g _ m o d u l e _ n a m e } _ p r i v a t e . d i s a b l e d _ f e a t u r e s = $ { d i s a b l e d _ p r i v a t e _ f e a t u r e s } "
2019-05-29 14:56:49 +00:00
)
2019-06-05 11:49:08 +00:00
2020-06-05 08:10:50 +00:00
if ( QT_GENERATOR_IS_MULTI_CONFIG )
set ( configs ${ CMAKE_CONFIGURATION_TYPES } )
else ( )
set ( configs ${ CMAKE_BUILD_TYPE } )
endif ( )
set ( inputs "${CMAKE_CURRENT_BINARY_DIR}/${private_pri_file_name}" )
foreach ( cfg ${ configs } )
list ( APPEND inputs "${CMAKE_CURRENT_BINARY_DIR}/${cfg}/${pri_data_cmake_file}" )
endforeach ( )
qt_path_join ( private_pri_file_path "${target_path}" "${private_pri_file_name}" )
list ( APPEND pri_files "${private_pri_file_path}" )
add_custom_command (
O U T P U T " $ { p r i v a t e _ p r i _ f i l e _ p a t h } "
D E P E N D S $ { i n p u t s }
C O M M A N D $ { C M A K E _ C O M M A N D } " - D I N _ F I L E S = $ { i n p u t s } " " - D O U T _ F I L E = $ { p r i v a t e _ p r i _ f i l e _ p a t h } "
" - D C O N F I G S = $ { c o n f i g s } "
- P " $ { Q T _ C M A K E _ D I R } / Q t G e n e r a t e L i b P r i . c m a k e "
V E R B A T I M )
add_custom_target ( ${ target } _lib_pri DEPENDS "${private_pri_file_path}" )
if ( arg_HEADER_MODULE )
add_dependencies ( ${ target } _timestamp ${ target } _lib_pri )
else ( )
add_dependencies ( ${ target } ${ target } _lib_pri )
endif ( )
2020-05-18 19:56:12 +00:00
qt_install ( FILES "${pri_files}" DESTINATION ${ INSTALL_MKSPECSDIR } /modules )
2019-05-29 14:56:49 +00:00
endfunction ( )
2020-04-22 19:01:32 +00:00
# Generates qt_ext_XXX.pri files for consumption by qmake
function ( qt_generate_3rdparty_lib_pri_file target lib pri_file_var )
if ( NOT lib )
# Don't write a pri file for projects that don't set QMAKE_LIB_NAME yet.
return ( )
endif ( )
if ( QT_GENERATOR_IS_MULTI_CONFIG )
set ( configs ${ CMAKE_CONFIGURATION_TYPES } )
else ( )
set ( configs ${ CMAKE_BUILD_TYPE } )
endif ( )
file ( GENERATE
O U T P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ < C O N F I G > / q t _ e x t _ $ { l i b } . c m a k e "
C O N T E N T " set ( cfg $< CONFIG > )
set ( incdir $< TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES > )
set ( defines $< TARGET_PROPERTY:${target},INTERFACE_COMPILE_DEFINITIONS > )
set ( libs $< TARGET_FILE:${target} > )
" )
set ( inputs "" )
foreach ( cfg ${ configs } )
list ( APPEND inputs "${CMAKE_CURRENT_BINARY_DIR}/${cfg}/qt_ext_${lib}.cmake" )
endforeach ( )
qt_path_join ( pri_target_path ${ QT_BUILD_DIR } ${ INSTALL_MKSPECSDIR } /modules )
qt_path_join ( pri_file "${pri_target_path}" "qt_ext_${lib}.pri" )
qt_path_join ( qt_build_libdir ${ QT_BUILD_DIR } ${ INSTALL_LIBDIR } )
add_custom_command (
O U T P U T " $ { p r i _ f i l e } "
D E P E N D S $ { i n p u t s }
C O M M A N D $ { C M A K E _ C O M M A N D } " - D I N _ F I L E S = $ { i n p u t s } " " - D O U T _ F I L E = $ { p r i _ f i l e } " - D L I B = $ { l i b }
" - D C O N F I G S = $ { c o n f i g s } "
" - D Q T _ B U I L D _ L I B D I R = $ { q t _ b u i l d _ l i b d i r } "
- P " $ { Q T _ C M A K E _ D I R } / Q t G e n e r a t e E x t P r i . c m a k e "
V E R B A T I M )
add_custom_target ( ${ target } _ext_pri DEPENDS "${pri_file}" )
add_dependencies ( ${ target } ${ target } _ext_pri )
set ( ${ pri_file_var } ${ pri_file } PARENT_SCOPE )
endfunction ( )
2020-05-12 06:21:03 +00:00
# Transforms a CMake Qt module name to a qmake Qt module name.
# Example: Qt6FooPrivate becomes foo_private
function ( qt_get_qmake_module_name result module )
string ( REGEX REPLACE "^Qt6" "" module "${module}" )
string ( REGEX REPLACE "Private$" "_private" module "${module}" )
string ( REGEX REPLACE "Qpa$" "_qpa_lib_private" module "${module}" )
string ( TOLOWER "${module}" module )
set ( ${ result } ${ module } PARENT_SCOPE )
endfunction ( )
# Generates qt_plugin_XXX.pri files for consumption by qmake
#
# QT_PLUGIN.XXX.EXTENDS is set to "-" for the following plugin types:
# - generic
# - platform, if the plugin is not the default QPA plugin
# Otherwise, this variable is empty.
function ( qt_generate_plugin_pri_file target pri_file_var )
get_target_property ( plugin_name ${ target } OUTPUT_NAME )
get_target_property ( plugin_type ${ target } QT_PLUGIN_TYPE )
get_target_property ( default_plugin ${ target } QT_DEFAULT_PLUGIN )
get_target_property ( plugin_class_name ${ target } QT_PLUGIN_CLASS_NAME )
set ( plugin_extends "" )
if ( NOT default_plugin AND ( plugin_type STREQUAL "generic" OR plugin_type STREQUAL "platforms" ) )
set ( plugin_extends "-" )
endif ( )
set ( plugin_deps "" )
get_target_property ( target_deps ${ target } _qt_target_deps )
foreach ( dep ${ target_deps } )
list ( GET dep 0 dep_name )
qt_get_qmake_module_name ( dep_name ${ dep_name } )
list ( APPEND plugin_deps ${ dep_name } )
endforeach ( )
list ( REMOVE_DUPLICATES plugin_deps )
list ( JOIN plugin_deps " " plugin_deps )
qt_path_join ( pri_target_path ${ QT_BUILD_DIR } ${ INSTALL_MKSPECSDIR } /modules )
qt_path_join ( pri_file "${pri_target_path}" "qt_plugin_${plugin_name}.pri" )
qt_configure_file ( OUTPUT "${pri_file}" CONTENT " QT_PLUGIN. ${ plugin_name } .TYPE = ${ plugin_type }
Q T _ P L U G I N . $ { p l u g i n _ n a m e } . E X T E N D S = $ { p l u g i n _ e x t e n d s }
Q T _ P L U G I N . $ { p l u g i n _ n a m e } . D E P E N D S = $ { p l u g i n _ d e p s }
Q T _ P L U G I N . $ { p l u g i n _ n a m e } . C L A S S _ N A M E = $ { p l u g i n _ c l a s s _ n a m e }
Q T _ P L U G I N S + = $ { p l u g i n _ n a m e }
" )
set ( ${ pri_file_var } "${pri_file}" PARENT_SCOPE )
endfunction ( )
2019-08-28 13:15:50 +00:00
function ( qt_cmake_build_type_to_qmake_build_config out_var build_type )
if ( build_type STREQUAL "Debug" )
set ( cfg debug )
else ( )
set ( cfg release )
endif ( )
set ( ${ out_var } ${ cfg } PARENT_SCOPE )
endfunction ( )
function ( qt_guess_qmake_build_config out_var )
if ( QT_GENERATOR_IS_MULTI_CONFIG )
unset ( cfg )
foreach ( config_type ${ CMAKE_CONFIGURATION_TYPES } )
qt_cmake_build_type_to_qmake_build_config ( tmp ${ config_type } )
list ( APPEND cfg ${ tmp } )
endforeach ( )
if ( cfg )
list ( REMOVE_DUPLICATES cfg )
else ( )
set ( cfg debug )
endif ( )
else ( )
qt_cmake_build_type_to_qmake_build_config ( cfg ${ CMAKE_BUILD_TYPE } )
endif ( )
set ( ${ out_var } ${ cfg } PARENT_SCOPE )
endfunction ( )
function ( qt_correct_features out_var features )
set ( corrected_features "" )
foreach ( feature ${ features } )
get_property ( feature_original_name GLOBAL PROPERTY "QT_FEATURE_ORIGINAL_NAME_${feature}" )
list ( APPEND corrected_features "${feature_original_name}" )
endforeach ( )
set ( ${ out_var } ${ corrected_features } PARENT_SCOPE )
endfunction ( )
# Get original names for config values (which correspond to feature names) and use them if they
# exist, otherwise just use the config value (which might be the case when a config value has
# a custom name).
function ( qt_correct_config out_var config )
set ( corrected_config "" )
foreach ( name ${ config } )
2020-04-20 18:31:31 +00:00
# Is the config value a known feature?
2019-08-28 13:15:50 +00:00
get_property ( feature_original_name GLOBAL PROPERTY "QT_FEATURE_ORIGINAL_NAME_${name}" )
if ( feature_original_name )
list ( APPEND corrected_config "${feature_original_name}" )
2020-04-20 18:31:31 +00:00
continue ( )
endif ( )
# Is the config value a negated known feature, e.g. no_foo?
# Then add the config value no-foo.
if ( name MATCHES "^no_(.*)" )
get_property ( feature_original_name GLOBAL PROPERTY
" Q T _ F E A T U R E _ O R I G I N A L _ N A M E _ $ { C M A K E _ M A T C H _ 1 } " )
if ( feature_original_name )
list ( APPEND corrected_config "no-${feature_original_name}" )
continue ( )
endif ( )
2019-08-28 13:15:50 +00:00
endif ( )
2020-04-20 18:31:31 +00:00
# The config value is no known feature. Add the value as is.
list ( APPEND corrected_config "${name}" )
2019-08-28 13:15:50 +00:00
endforeach ( )
set ( ${ out_var } ${ corrected_config } PARENT_SCOPE )
endfunction ( )
# Creates mkspecs/qconfig.pri which contains public global features among other things.
2019-05-29 14:56:49 +00:00
function ( qt_generate_global_config_pri_file )
2020-01-15 22:01:16 +00:00
qt_path_join ( qconfig_pri_target_path ${ PROJECT_BINARY_DIR } ${ INSTALL_MKSPECSDIR } )
2019-05-29 14:56:49 +00:00
qt_path_join ( qconfig_pri_target_path "${qconfig_pri_target_path}" "qconfig.pri" )
get_target_property ( enabled_features GlobalConfig INTERFACE_QT_ENABLED_PUBLIC_FEATURES )
get_target_property ( disabled_features GlobalConfig INTERFACE_QT_DISABLED_PUBLIC_FEATURES )
2019-08-28 13:15:50 +00:00
qt_correct_features ( corrected_enabled_features "${enabled_features}" )
qt_correct_features ( corrected_disabled_features "${disabled_features}" )
string ( REPLACE ";" " " corrected_enabled_features "${corrected_enabled_features}" )
string ( REPLACE ";" " " corrected_disabled_features "${corrected_disabled_features}" )
2019-05-29 14:56:49 +00:00
2019-05-31 14:40:51 +00:00
# Add some required CONFIG entries.
set ( config_entries "" )
if ( CMAKE_BUILD_TYPE STREQUAL Debug )
list ( APPEND config_entries "debug" )
elseif ( CMAKE_BUILD_TYPE STREQUAL Release )
list ( APPEND config_entries "release" )
endif ( )
list ( APPEND config_entries "${qt_build_config_type}" )
string ( REPLACE ";" " " config_entries "${config_entries}" )
2019-08-28 13:15:50 +00:00
get_target_property ( public_config GlobalConfig INTERFACE_QT_QMAKE_PUBLIC_CONFIG )
get_target_property ( qt_public_config GlobalConfig INTERFACE_QT_QMAKE_PUBLIC_QT_CONFIG )
qt_correct_config ( corrected_public_config "${public_config}" )
qt_correct_config ( corrected_qt_public_config "${qt_public_config}" )
qt_guess_qmake_build_config ( qmake_build_config )
list ( APPEND corrected_qt_public_config ${ qmake_build_config } )
list ( JOIN corrected_public_config " " public_config_joined )
list ( JOIN corrected_qt_public_config " " qt_public_config_joined )
2019-05-29 14:56:49 +00:00
file ( GENERATE
O U T P U T " $ { q c o n f i g _ p r i _ t a r g e t _ p a t h } "
C O N T E N T
2019-05-31 08:58:43 +00:00
" Q T _ A R C H = $ { T E S T _ a r c h i t e c t u r e _ a r c h }
Q T _ B U I L D A B I = $ { T E S T _ b u i l d A b i }
2019-08-28 13:15:50 +00:00
Q T . g l o b a l . e n a b l e d _ f e a t u r e s = $ { c o r r e c t e d _ e n a b l e d _ f e a t u r e s }
Q T . g l o b a l . d i s a b l e d _ f e a t u r e s = $ { c o r r e c t e d _ d i s a b l e d _ f e a t u r e s }
Q T . g l o b a l . d i s a b l e d _ f e a t u r e s + = r e l e a s e b u i l d _ a l l
Q T _ C O N F I G + = $ { q t _ p u b l i c _ c o n f i g _ j o i n e d }
C O N F I G + = $ { c o n f i g _ e n t r i e s } $ { p u b l i c _ c o n f i g _ j o i n e d }
2019-05-29 14:56:49 +00:00
Q T _ V E R S I O N = $ { P R O J E C T _ V E R S I O N }
Q T _ M A J O R _ V E R S I O N = $ { P R O J E C T _ V E R S I O N _ M A J O R }
Q T _ M I N O R _ V E R S I O N = $ { P R O J E C T _ V E R S I O N _ M I N O R }
Q T _ P A T C H _ V E R S I O N = $ { P R O J E C T _ V E R S I O N _ P A T C H }
"
)
2020-01-15 22:01:16 +00:00
qt_install ( FILES "${qconfig_pri_target_path}" DESTINATION ${ INSTALL_MKSPECSDIR } )
2019-05-29 14:56:49 +00:00
endfunction ( )
2020-04-06 09:38:26 +00:00
function ( qt_get_build_parts out_var )
set ( parts "libs" )
if ( BUILD_EXAMPLES AND NOT QT_NO_MAKE_EXAMPLES )
list ( APPEND parts "examples" )
endif ( )
if ( BUILD_TESTING AND NOT QT_NO_MAKE_TESTS )
list ( APPEND parts "tests" )
endif ( )
2020-04-27 13:04:57 +00:00
if ( NOT CMAKE_CROSSCOMPILING OR QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
2020-04-06 09:38:26 +00:00
list ( APPEND parts "tools" )
endif ( )
set ( ${ out_var } ${ parts } PARENT_SCOPE )
endfunction ( )
2019-08-28 13:15:50 +00:00
# Creates mkspecs/qmodule.pri which contains private global features among other things.
function ( qt_generate_global_module_pri_file )
2020-04-27 08:24:31 +00:00
qt_path_join ( qmodule_pri_target_path ${ PROJECT_BINARY_DIR } ${ INSTALL_MKSPECSDIR } )
2019-08-28 13:15:50 +00:00
qt_path_join ( qmodule_pri_target_path "${qmodule_pri_target_path}" "qmodule.pri" )
get_target_property ( enabled_features GlobalConfig INTERFACE_QT_ENABLED_PRIVATE_FEATURES )
get_target_property ( disabled_features GlobalConfig INTERFACE_QT_DISABLED_PRIVATE_FEATURES )
qt_correct_features ( corrected_enabled_features "${enabled_features}" )
qt_correct_features ( corrected_disabled_features "${disabled_features}" )
string ( REPLACE ";" " " corrected_enabled_features "${corrected_enabled_features}" )
string ( REPLACE ";" " " corrected_disabled_features "${corrected_disabled_features}" )
set ( corrected_private_config "" )
get_target_property ( private_config GlobalConfig INTERFACE_QT_QMAKE_PRIVATE_CONFIG )
qt_correct_config ( corrected_private_config "${private_config}" )
list ( JOIN corrected_private_config " " private_config_joined )
2020-04-06 09:37:43 +00:00
set ( content " QT.global_private.enabled_features = ${ corrected_enabled_features }
2019-08-28 13:15:50 +00:00
Q T . g l o b a l _ p r i v a t e . d i s a b l e d _ f e a t u r e s = $ { c o r r e c t e d _ d i s a b l e d _ f e a t u r e s }
C O N F I G + = $ { p r i v a t e _ c o n f i g _ j o i n e d }
2020-04-06 09:37:43 +00:00
" )
if ( PKG_CONFIG_FOUND )
string ( APPEND content "PKG_CONFIG_EXECUTABLE = ${PKG_CONFIG_EXECUTABLE}\n" )
endif ( )
# TODO: Write QT_COORD_TYPE once we support setting it.
2020-04-06 09:38:26 +00:00
qt_get_build_parts ( build_parts )
string ( REPLACE ";" " " build_parts "${build_parts}" )
string ( APPEND content "QT_BUILD_PARTS = ${build_parts}\n" )
2020-06-05 08:10:50 +00:00
set ( preliminary_pri_root "${CMAKE_CURRENT_BINARY_DIR}/mkspecs/preliminary" )
set ( pri_data_cmake_file "qmodule.cmake" )
qt_generate_qmake_libraries_pri_content ( global ${ preliminary_pri_root } ${ pri_data_cmake_file } )
2020-04-22 19:01:32 +00:00
2020-06-05 08:10:50 +00:00
# Generate a preliminary qmodule.pri file
set ( preliminary_pri_file_path "${preliminary_pri_root}/qmodule.pri" )
2020-04-06 09:37:43 +00:00
file ( GENERATE
2020-06-05 08:10:50 +00:00
O U T P U T $ { p r e l i m i n a r y _ p r i _ f i l e _ p a t h }
2020-04-06 09:37:43 +00:00
C O N T E N T " $ { c o n t e n t } "
2019-08-28 13:15:50 +00:00
)
2020-06-05 08:10:50 +00:00
if ( QT_GENERATOR_IS_MULTI_CONFIG )
set ( configs ${ CMAKE_CONFIGURATION_TYPES } )
else ( )
set ( configs ${ CMAKE_BUILD_TYPE } )
endif ( )
set ( inputs ${ preliminary_pri_file_path } )
foreach ( cfg ${ configs } )
list ( APPEND inputs "${preliminary_pri_root}/${cfg}/${pri_data_cmake_file}" )
endforeach ( )
add_custom_command (
O U T P U T " $ { q m o d u l e _ p r i _ t a r g e t _ p a t h } "
D E P E N D S $ { i n p u t s }
C O M M A N D $ { C M A K E _ C O M M A N D } " - D I N _ F I L E S = $ { i n p u t s } " " - D O U T _ F I L E = $ { q m o d u l e _ p r i _ t a r g e t _ p a t h } "
" - D C O N F I G S = $ { c o n f i g s } "
- P " $ { Q T _ C M A K E _ D I R } / Q t G e n e r a t e L i b P r i . c m a k e "
V E R B A T I M )
add_custom_target ( qmodule_pri DEPENDS "${qmodule_pri_target_path}" )
2020-04-27 08:24:31 +00:00
qt_install ( FILES "${qmodule_pri_target_path}" DESTINATION ${ INSTALL_MKSPECSDIR } )
2019-08-28 13:15:50 +00:00
endfunction ( )
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
# Takes a list of path components and joins them into one path separated by forward slashes "/",
# and saves the path in out_var.
function ( qt_path_join out_var )
# Remove output variable.
set ( argv ${ ARGV } )
list ( REMOVE_AT argv 0 )
# Join the path components.
string ( JOIN "/" path ${ argv } )
set ( ${ out_var } ${ path } PARENT_SCOPE )
endfunction ( )
2019-05-03 10:30:09 +00:00
function ( qt_internal_export_modern_cmake_config_targets_file )
cmake_parse_arguments ( __arg "" "EXPORT_NAME_PREFIX;CONFIG_INSTALL_DIR" "TARGETS" ${ ARGN } )
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 ( export_name "${__arg_EXPORT_NAME_PREFIX}VersionlessTargets" )
2019-05-03 10:30:09 +00:00
foreach ( target ${ __arg_TARGETS } )
if ( TARGET "${target}Versionless" )
continue ( )
endif ( )
add_library ( "${target}Versionless" INTERFACE )
target_link_libraries ( "${target}Versionless" INTERFACE "${target}" )
2020-05-27 15:36:11 +00:00
set_target_properties ( "${target}Versionless" PROPERTIES
E X P O R T _ N A M E " $ { t a r g e t } "
_ q t _ i s _ v e r s i o n l e s s _ t a r g e t " T R U E " )
set_property ( TARGET "${target}Versionless"
A P P E N D P R O P E R T Y E X P O R T _ P R O P E R T I E S _ q t _ i s _ v e r s i o n l e s s _ t a r g e t )
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
qt_install ( TARGETS "${target}Versionless" EXPORT ${ export_name } )
2019-05-03 10:30:09 +00:00
endforeach ( )
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
qt_install ( EXPORT ${ export_name } NAMESPACE Qt:: DESTINATION "${__arg_CONFIG_INSTALL_DIR}" )
2019-05-03 10:30:09 +00:00
endfunction ( )
2018-10-24 13:20:27 +00:00
# Print all variables defined in the current scope.
macro ( qt_debug_print_variables )
cmake_parse_arguments ( __arg "DEDUP" "" "MATCH;IGNORE" ${ ARGN } )
message ( "Known Variables:" )
get_cmake_property ( __variableNames VARIABLES )
list ( SORT __variableNames )
if ( __arg_DEDUP )
list ( REMOVE_DUPLICATES __variableNames )
endif ( )
foreach ( __var ${ __variableNames } )
set ( __ignore OFF )
foreach ( __i ${ __arg_IGNORE } )
if ( __var MATCHES "${__i}" )
set ( __ignore ON )
break ( )
endif ( )
endforeach ( )
if ( __ignore )
continue ( )
endif ( )
set ( __show OFF )
foreach ( __i ${ __arg_MATCH } )
if ( __var MATCHES "${__i}" )
set ( __show ON )
break ( )
endif ( )
endforeach ( )
if ( __show )
message ( " ${__var}=${${__var}}." )
endif ( )
endforeach ( )
endmacro ( )
macro ( assert )
if ( ${ ARGN } )
else ( )
message ( FATAL_ERROR "ASSERT: ${ARGN}." )
endif ( )
endmacro ( )
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
function ( qt_create_nolink_target target dependee_target )
2019-03-28 14:25:17 +00:00
if ( NOT TARGET "${target}" )
message ( FATAL_ERROR "${target} does not exist when trying to build a nolink target." )
endif ( )
get_target_property ( type "${target}" TYPE )
if ( type STREQUAL EXECUTABLE )
message ( FATAL_ERROR "${target} must be a library of some kind." )
endif ( )
if ( type STREQUAL OBJECT_LIBRARY )
message ( FATAL_ERROR "${target} must not be an object library." )
endif ( )
2019-05-03 13:21:30 +00:00
# Strip off the namespace prefix, so from Vulkan::Vulkan to Vulkan, and then append _nolink.
string ( REGEX REPLACE "^.*::" "" non_prefixed_target ${ target } )
set ( nolink_target "${non_prefixed_target}_nolink" )
# Create the nolink interface target, assign the properties from the original target,
# associate the nolink target with the same export which contains
# the target that uses the _nolink target.
2019-11-07 12:18:21 +00:00
# Also create a namespaced alias of the form ${target}::${target}_nolink which is used by
2019-05-03 13:21:30 +00:00
# our modules.
2019-11-07 12:18:21 +00:00
# Also create a Qt namespaced alias target, because when exporting via install(EXPORT)
# Vulkan::Vulkan_nolink transforms into Qt6::Vulkan_nolink, and the latter needs to be an
# accessible alias for standalone tests.
2019-03-28 14:25:17 +00:00
if ( NOT TARGET "${nolink_target}" )
2019-05-03 13:21:30 +00:00
add_library ( "${nolink_target}" INTERFACE )
set ( prefixed_nolink_target "${target}_nolink" )
2019-04-10 10:12:09 +00:00
set_target_properties ( "${nolink_target}" PROPERTIES
I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S >
I N T E R F A C E _ S Y S T E M _ I N C L U D E _ D I R E C T O R I E S
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ S Y S T E M _ I N C L U D E _ D I R E C T O R I E S >
I N T E R F A C E _ C O M P I L E _ D E F I N I T I O N S
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ C O M P I L E _ D E F I N I T I O N S >
I N T E R F A C E _ C O M P I L E _ O P T I O N S
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ C O M P I L E _ O P T I O N S >
I N T E R F A C E _ C O M P I L E _ F E A T U R E S
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ C O M P I L E _ F E A T U R E S > )
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 13:21:30 +00:00
add_library ( ${ prefixed_nolink_target } ALIAS ${ nolink_target } )
2019-11-07 12:18:21 +00:00
add_library ( "${INSTALL_CMAKE_NAMESPACE}::${nolink_target}" ALIAS ${ nolink_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 ( export_name "${INSTALL_CMAKE_NAMESPACE}${dependee_target}Targets" )
qt_install ( TARGETS ${ nolink_target } EXPORT ${ export_name } )
2019-03-28 14:25:17 +00:00
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
function ( qt_ensure_perl )
if ( DEFINED HOST_PERL )
return ( )
endif ( )
find_program ( HOST_PERL "perl" DOC "Perl binary" )
if ( NOT HOST_PERL )
message ( FATAL_ERROR "Perl needs to be available to build Qt." )
endif ( )
endfunction ( )
2018-12-07 13:04:42 +00:00
function ( qt_ensure_sync_qt )
qt_ensure_perl ( )
2019-02-12 21:39:35 +00:00
if ( DEFINED QT_SYNCQT )
return ( )
2018-12-07 13:04:42 +00:00
endif ( )
2019-02-12 21:39:35 +00:00
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
# When building qtbase, use the source syncqt, otherwise use the installed one.
2019-06-05 14:23:53 +00:00
set ( SYNCQT_FROM_SOURCE "${QtBase_SOURCE_DIR}/bin/syncqt.pl" )
2019-09-18 15:05:56 +00:00
if ( NOT ( "${QtBase_SOURCE_DIR}" STREQUAL "" ) AND EXISTS "${SYNCQT_FROM_SOURCE}" )
2019-06-05 14:23:53 +00:00
set ( QT_SYNCQT "${SYNCQT_FROM_SOURCE}" CACHE FILEPATH "syncqt script" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
message ( STATUS "Using source syncqt found at: ${QT_SYNCQT}" )
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
qt_path_join ( syncqt_install_dir ${ QT_INSTALL_DIR } ${ INSTALL_LIBEXECDIR } )
2019-06-05 14:23:53 +00:00
qt_copy_or_install ( PROGRAMS "${SYNCQT_FROM_SOURCE}"
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
D E S T I N A T I O N " $ { s y n c q t _ i n s t a l l _ d i r } " )
2019-08-28 13:15:50 +00:00
qt_path_join ( syncqt_install_dir ${ QT_INSTALL_DIR } ${ INSTALL_BINDIR } )
qt_copy_or_install ( PROGRAMS "${SYNCQT_FROM_SOURCE}"
D E S T I N A T I O N " $ { s y n c q t _ i n s t a l l _ d i r } " )
2020-01-21 10:45:38 +00:00
elseif ( QT_HOST_PATH )
get_filename_component ( syncqt_absolute_path
" $ { Q T _ H O S T _ P A T H } / $ { I N S T A L L _ L I B E X E C D I R } / s y n c q t . p l "
A B S O L U T E )
set ( QT_SYNCQT "${syncqt_absolute_path}" CACHE FILEPATH "syncqt script" )
message ( STATUS "Using host syncqt found at: ${QT_SYNCQT}" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
else ( )
get_filename_component ( syncqt_absolute_path
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
" $ { Q T _ B U I L D _ I N T E R N A L S _ R E L O C A T A B L E _ I N S T A L L _ P R E F I X } / $ { I N S T A L L _ L I B E X E C D I R } / s y n c q t . p l "
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
A B S O L U T E )
set ( QT_SYNCQT "${syncqt_absolute_path}" CACHE FILEPATH "syncqt script" )
message ( STATUS "Using installed syncqt found at: ${QT_SYNCQT}" )
endif ( )
2018-12-07 13:04:42 +00:00
endfunction ( )
2018-10-24 13:20:27 +00:00
# A version of cmake_parse_arguments that makes sure all arguments are processed and errors out
# with a message about ${type} having received unknown arguments.
macro ( qt_parse_all_arguments result type flags options multiopts )
cmake_parse_arguments ( ${ result } "${flags}" "${options}" "${multiopts}" ${ ARGN } )
if ( DEFINED ${ result } _UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "Unknown arguments were passed to ${type} (${${result}_UNPARSED_ARGUMENTS})." )
endif ( )
endmacro ( )
2019-11-22 16:02:19 +00:00
include ( CheckCXXSourceCompiles )
2018-10-24 13:20:27 +00:00
2019-02-27 12:49:04 +00:00
function ( qt_internal_add_link_flags_no_undefined target )
2019-08-28 13:02:28 +00:00
if ( NOT QT_BUILD_SHARED_LIBS )
return ( )
endif ( )
2019-02-27 12:49:04 +00:00
if ( GCC OR CLANG )
2019-11-22 16:02:19 +00:00
set ( previous_CMAKE_REQUIRED_LINK_OPTIONS ${ CMAKE_REQUIRED_LINK_OPTIONS } )
set ( CMAKE_REQUIRED_LINK_OPTIONS "-Wl,-undefined,error" )
2020-06-10 11:50:10 +00:00
check_cxx_source_compiles ( "int main() {}" HAVE_DASH_UNDEFINED_SYMBOLS )
if ( HAVE_DASH_UNDEFINED_SYMBOLS )
2019-02-27 12:49:04 +00:00
set ( no_undefined_flag "-Wl,-undefined,error" )
2019-11-22 16:02:19 +00:00
endif ( )
set ( CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--no-undefined" )
check_cxx_source_compiles ( "int main() {}" HAVE_DASH_DASH_NO_UNDEFINED )
if ( HAVE_DASH_DASH_NO_UNDEFINED )
2019-02-27 12:49:04 +00:00
set ( no_undefined_flag "-Wl,--no-undefined" )
2019-11-22 16:02:19 +00:00
endif ( )
set ( CMAKE_REQUIRED_LINK_OPTIONS ${ previous_CMAKE_REQUIRED_LINK_OPTIONS } )
2020-06-10 11:50:10 +00:00
if ( NOT HAVE_DASH_UNDEFINED_SYMBOLS AND NOT HAVE_DASH_DASH_NO_UNDEFINED )
2019-02-27 12:49:04 +00:00
message ( FATAL_ERROR "Platform linker doesn't support erroring upon encountering undefined symbols. Target:\" ${ target } \".")
endif ( )
2019-03-04 12:05:54 +00:00
target_link_options ( "${target}" PRIVATE "${no_undefined_flag}" )
endif ( )
endfunction ( )
function ( qt_internal_add_link_flags_gc_sections target visibility )
set ( possible_visibilities PRIVATE INTERFACE PUBLIC )
list ( FIND possible_visibilities "${visibility}" known_visibility )
if ( known_visibility EQUAL "-1" )
message ( FATAL_ERROR "Visibitily setting must be one of PRIVATE, INTERFACE or PUBLIC." )
endif ( )
2019-08-28 13:02:28 +00:00
if ( ( GCC OR CLANG ) AND NOT EMSCRIPTEN )
2019-03-04 12:05:54 +00:00
if ( APPLE )
set ( gc_sections_flag "-Wl,-dead_strip" )
2019-05-29 08:08:56 +00:00
elseif ( LINUX OR BSD OR SOLARIS OR WIN32 OR ANDROID )
2019-03-04 12:05:54 +00:00
set ( gc_sections_flag "-Wl,--gc-sections" )
else ( )
message ( FATAL_ERROR "Platform linker doesn't support gc sections. Target:\" ${ target } \".")
endif ( )
target_link_options ( "${target}" ${ visibility } "${gc_sections_flag}" )
2019-02-27 12:49:04 +00:00
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
function ( qt_internal_add_linker_version_script target )
2018-12-07 12:13:24 +00:00
qt_parse_all_arguments ( arg "qt_internal_add_linker" "INTERNAL" "" "PRIVATE_HEADERS" ${ ARGN } )
2018-10-24 13:20:27 +00:00
if ( TEST_ld_version_script )
2018-12-07 12:13:24 +00:00
if ( arg_INTERNAL )
2018-10-24 13:20:27 +00:00
set ( contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API { *; };" )
else ( )
set ( contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API {\n qt_private_api_tag*;\n" )
2018-12-07 12:13:24 +00:00
foreach ( ph ${ arg_PRIVATE_HEADERS } )
2018-10-24 13:20:27 +00:00
string ( APPEND contents " @FILE:${ph}@\n" )
endforeach ( )
string ( APPEND contents "};\n" )
set ( current "Qt_${PROJECT_VERSION_MAJOR}" )
if ( QT_NAMESPACE STREQUAL "" )
set ( tag_symbol "qt_version_tag" )
else ( )
set ( tag_symbol "qt_version_tag_${QT_NAMESPACE}" )
endif ( )
string ( APPEND contents "${current} { *; };\n" )
foreach ( minor_version RANGE ${ PROJECT_VERSION_MINOR } )
set ( previous "${current}" )
set ( current "Qt_${PROJECT_VERSION_MAJOR}.${minor_version}" )
if ( minor_version EQUAL ${ PROJECT_VERSION_MINOR } )
string ( APPEND contents "${current} { ${tag_symbol}; } ${previous};\n" )
else ( )
string ( APPEND contents "${current} {} ${previous};\n" )
endif ( )
endforeach ( )
set ( infile "${CMAKE_CURRENT_BINARY_DIR}/${target}.version.in" )
set ( outfile "${CMAKE_CURRENT_BINARY_DIR}/${target}.version" )
file ( GENERATE OUTPUT "${infile}" CONTENT "${contents}" )
qt_ensure_perl ( )
add_custom_command ( TARGET "${target}" PRE_LINK
2019-11-21 12:33:28 +00:00
C O M M A N D " $ { H O S T _ P E R L } " " $ { Q T _ M K S P E C S _ D I R } / f e a t u r e s / d a t a / u n i x / f i n d c l a s s l i s t . p l " < " $ { i n f i l e } " > " $ { o u t f i l e } "
2018-10-24 13:20:27 +00:00
B Y P R O D U C T S " $ { o u t f i l e } " D E P E N D S " $ { i n f i l e } "
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
C O M M E N T " G e n e r a t i n g v e r s i o n l i n k e r s c r i p t "
)
2019-03-04 12:05:54 +00:00
target_link_options ( "${target}" PRIVATE "-Wl,--version-script,${outfile}" )
2018-10-24 13:20:27 +00:00
endif ( )
endif ( )
endfunction ( )
2018-12-07 12:30:51 +00:00
# Get a set of Qt module related values based on the target name.
# When doing qt_internal_module_info(foo Core) this method will set
# the following variables in the caller's scope:
# * foo with the value "QtCore"
2019-06-14 10:59:07 +00:00
# * foo_versioned with the value "Qt6Core" (based on major Qt version)
2018-12-07 12:30:51 +00:00
# * foo_upper with the value "CORE"
# * foo_lower with the value "core"
2019-08-08 14:55:48 +00:00
# * foo_repo_include_dir with the module's include directory
# e.g for QtQuick it would be qtdeclarative_build_dir/include for a prefix build or
# qtbase_build_dir/include for a non-prefix build
# * foo_include_dir with the module's include directory
# e.g for QtQuick it would be qtdeclarative_build_dir/include/QtQuick for a prefix build or
# qtbase_build_dir/include/QtQuick for a non-prefix build
2019-06-05 09:31:55 +00:00
# * foo_define same as foo_uper but with - replaced as _
2018-12-07 12:30:51 +00:00
function ( qt_internal_module_info result target )
2018-12-07 13:04:42 +00:00
set ( module "Qt${target}" )
set ( "${result}" "${module}" PARENT_SCOPE )
2018-12-07 12:30:51 +00:00
set ( "${result}_versioned" "Qt${PROJECT_VERSION_MAJOR}${target}" PARENT_SCOPE )
string ( TOUPPER "${target}" upper )
2019-06-05 09:31:55 +00:00
string ( TOLOWER "${target}" lower ) # * foo_upper with the value "CORE"
string ( REPLACE "-" "_" define "${upper}" )
2019-08-12 08:46:50 +00:00
string ( REPLACE "." "_" define "${define}" )
2018-12-07 12:30:51 +00:00
set ( "${result}_upper" "${upper}" PARENT_SCOPE )
set ( "${result}_lower" "${lower}" PARENT_SCOPE )
2020-01-26 11:25:40 +00:00
set ( "${result}_repo_include_dir" "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}" PARENT_SCOPE )
set ( "${result}_include_dir" "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}/${module}" PARENT_SCOPE )
2019-06-05 09:31:55 +00:00
set ( "${result}_define" "${define}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-05-03 14:03:15 +00:00
set ( __default_private_args "SOURCES;LIBRARIES;INCLUDE_DIRECTORIES;DEFINES;DBUS_ADAPTOR_BASENAME;DBUS_ADAPTOR_FLAGS;DBUS_ADAPTOR_SOURCES;DBUS_INTERFACE_BASENAME;DBUS_INTERFACE_FLAGS;DBUS_INTERFACE_SOURCES;FEATURE_DEPENDENCIES;COMPILE_OPTIONS;LINK_OPTIONS;MOC_OPTIONS;DISABLE_AUTOGEN_TOOLS;ENABLE_AUTOGEN_TOOLS;PLUGIN_TYPES" )
2019-01-29 11:07:24 +00:00
set ( __default_public_args "PUBLIC_LIBRARIES;PUBLIC_INCLUDE_DIRECTORIES;PUBLIC_DEFINES;PUBLIC_COMPILE_OPTIONS;PUBLIC_LINK_OPTIONS" )
2020-01-31 21:21:09 +00:00
set ( __default_private_module_args "PRIVATE_MODULE_INTERFACE" )
2020-05-12 09:29:56 +00:00
set ( __default_target_info_args TARGET_VERSION TARGET_PRODUCT TARGET_DESCRIPTION TARGET_COMPANY
T A R G E T _ C O P Y R I G H T )
2018-10-24 13:20:27 +00:00
2019-01-30 15:36:30 +00:00
option ( QT_CMAKE_DEBUG_EXTEND_TARGET "Debug extend_target calls in Qt's build system" OFF )
2019-05-22 13:09:39 +00:00
# Initial autogen setup for a target to specify certain CMake properties which are common
# to all autogen tools. Also enable AUTOMOC by default.
function ( qt_autogen_tools_initial_setup target )
set_property ( TARGET "${target}" PROPERTY INTERFACE_QT_MAJOR_VERSION ${ PROJECT_VERSION_MAJOR } )
set_property ( TARGET "${target}" APPEND PROPERTY COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION )
2019-03-06 12:51:38 +00:00
2019-05-22 13:09:39 +00:00
set_directory_properties ( PROPERTIES
2019-12-11 15:14:22 +00:00
Q T _ V E R S I O N _ M A J O R $ { P R O J E C T _ V E R S I O N _ M A J O R }
Q T _ V E R S I O N _ M I N O R $ { P R O J E C T _ V E R S I O N _ M I N O R }
Q T _ V E R S I O N _ P A T C H $ { P R O J E C T _ V E R S I O N _ P A T C H }
)
2019-03-06 12:51:38 +00:00
2019-05-22 13:09:39 +00:00
qt_enable_autogen_tool ( ${ target } "moc" ON )
endfunction ( )
# Enables or disables an autogen tool like moc, uic or rcc on ${target}.
function ( qt_enable_autogen_tool target tool enable )
string ( TOUPPER "${tool}" captitalAutogenTool )
get_target_property ( tool_enabled ${ target } AUTO ${ captitalAutogenTool } )
get_target_property ( autogen_target_depends ${ target } AUTOGEN_TARGET_DEPENDS )
2019-03-06 12:51:38 +00:00
2019-05-22 13:09:39 +00:00
if ( NOT autogen_target_depends )
set ( autogen_target_depends "" )
endif ( )
set ( tool_executable "$<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::${tool}>" )
set ( tool_target_name ${ QT_CMAKE_EXPORT_NAMESPACE } :: ${ tool } )
if ( enable )
list ( APPEND autogen_target_depends ${ tool_target_name } )
else ( )
list ( REMOVE_ITEM autogen_target_depends ${ tool_target_name } )
endif ( )
2019-03-06 12:51:38 +00:00
2019-07-11 14:23:54 +00:00
# f66c1db16c050c9d685a44a38ad7c5cf9f6fcc96 in qtbase introduced a new macro
# that the moc scanner has to look for. Inform the CMake moc scanner about it.
if ( tool STREQUAL "moc" AND enable )
set_target_properties ( "${target}" PROPERTIES
2019-09-16 15:07:28 +00:00
A U T O M O C _ M A C R O _ N A M E S " Q _ O B J E C T ; Q _ G A D G E T ; Q _ N A M E S P A C E ; Q _ N A M E S P A C E _ E X P O R T ; Q _ E N U M _ N S " )
2019-07-11 14:23:54 +00:00
endif ( )
2019-03-06 12:51:38 +00:00
set_target_properties ( "${target}"
P R O P E R T I E S
2019-05-22 13:09:39 +00:00
A U T O $ { c a p t i t a l A u t o g e n T o o l } " $ { e n a b l e } "
A U T O $ { c a p t i t a l A u t o g e n T o o l } _ E X E C U T A B L E " $ { t o o l _ e x e c u t a b l e } "
A U T O G E N _ T A R G E T _ D E P E N D S " $ { a u t o g e n _ t a r g e t _ d e p e n d s } "
)
endfunction ( )
# This function adds or removes additional AUTOGEN tools to a target: AUTOMOC/UIC/RCC
function ( qt_autogen_tools target )
qt_parse_all_arguments ( arg "qt_autogen_tools" "" "" "${__default_private_args}" ${ ARGN } )
if ( arg_ENABLE_AUTOGEN_TOOLS )
foreach ( tool ${ arg_ENABLE_AUTOGEN_TOOLS } )
qt_enable_autogen_tool ( ${ target } ${ tool } ON )
endforeach ( )
endif ( )
if ( arg_DISABLE_AUTOGEN_TOOLS )
foreach ( tool ${ arg_DISABLE_AUTOGEN_TOOLS } )
qt_enable_autogen_tool ( ${ target } ${ tool } OFF )
endforeach ( )
endif ( )
2019-03-06 12:51:38 +00:00
endfunction ( )
2019-05-03 14:03:15 +00:00
# This function stores the list of Qt modules a library depend on,
# along with their version info, for usage in ${target}Depends.cmake file
function ( qt_register_target_dependencies target public_libs private_libs )
get_target_property ( target_deps "${target}" _qt_target_deps )
if ( NOT target_deps )
set ( target_deps "" )
endif ( )
2020-02-11 15:49:54 +00:00
# Only process private dependencies if target is a static library
get_target_property ( target_type ${ target } TYPE )
set ( lib_list ${ public_libs } )
if ( target_type STREQUAL "STATIC_LIBRARY" )
list ( APPEND lib_list ${ private_libs } )
endif ( )
foreach ( lib IN LISTS lib_list )
2019-05-03 14:03:15 +00:00
if ( "${lib}" MATCHES "^Qt::(.*)" )
set ( lib "${CMAKE_MATCH_1}" )
2019-06-12 15:43:25 +00:00
if ( lib STREQUAL Platform
O R l i b S T R E Q U A L G l o b a l C o n f i g
O R l i b S T R E Q U A L G l o b a l C o n f i g P r i v a t e
2019-06-12 13:08:24 +00:00
O R l i b S T R E Q U A L P l a t f o r m M o d u l e I n t e r n a l
O R l i b S T R E Q U A L P l a t f o r m P l u g i n I n t e r n a l
O R l i b S T R E Q U A L P l a t f o r m T o o l I n t e r n a l )
2019-06-14 10:59:07 +00:00
list ( APPEND target_deps "Qt6\;${PROJECT_VERSION}" )
2019-05-03 14:03:15 +00:00
elseif ( "${lib}" MATCHES "(.*)Private" )
list ( APPEND target_deps "${INSTALL_CMAKE_NAMESPACE}${CMAKE_MATCH_1}\;${PROJECT_VERSION}" )
else ( )
list ( APPEND target_deps "${INSTALL_CMAKE_NAMESPACE}${lib}\;${PROJECT_VERSION}" )
endif ( )
endif ( )
endforeach ( )
set_target_properties ( "${target}" PROPERTIES _qt_target_deps "${target_deps}" )
endfunction ( )
2019-07-05 08:47:26 +00:00
function ( qt_update_precompiled_header target precompiled_header )
if ( precompiled_header AND BUILD_WITH_PCH )
2020-04-03 12:23:18 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY "PRECOMPILE_HEADERS" "$<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>:${precompiled_header}>" )
2019-07-05 08:47:26 +00:00
endif ( )
endfunction ( )
function ( qt_update_precompiled_header_with_library target library )
if ( TARGET "${library}" )
get_target_property ( TARGET_TYPE "${library}" TYPE )
if ( NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY" )
get_target_property ( HEADER "${library}" MODULE_HEADER )
qt_update_precompiled_header ( "${target}" "${HEADER}" )
endif ( )
endif ( )
endfunction ( )
function ( qt_update_ignore_pch_source target sources )
if ( sources )
set_source_files_properties ( ${ sources } PROPERTIES SKIP_PRECOMPILE_HEADERS ON )
endif ( )
endfunction ( )
function ( qt_ignore_pch_obj_c_sources target sources )
2020-04-03 12:23:18 +00:00
# No obj-cxx PCH support for versions lower than 3.16.
if ( CMAKE_VERSION VERSION_LESS 3.16.0 )
list ( FILTER sources INCLUDE REGEX "\\.mm$" )
qt_update_ignore_pch_source ( "${target}" "${sources}" )
endif ( )
2019-07-05 08:47:26 +00:00
endfunction ( )
2018-10-24 13:20:27 +00:00
# This function can be used to add sources/libraries/etc. to the specified CMake target
# if the provided CONDITION evaluates to true.
2019-11-13 13:03:20 +00:00
function ( qt_extend_target target )
2019-07-30 09:15:32 +00:00
# Don't try to extend_target when cross compiling an imported host target (like a tool).
qt_is_imported_target ( "${target}" is_imported )
if ( is_imported )
return ( )
endif ( )
2018-10-24 13:20:27 +00:00
if ( NOT TARGET "${target}" )
message ( FATAL_ERROR "Trying to extend non-existing target \" ${ target } \".")
endif ( )
2019-11-13 13:03:20 +00:00
qt_parse_all_arguments ( arg "qt_extend_target" "HEADER_MODULE" "PRECOMPILED_HEADER"
2020-01-31 21:21:09 +00:00
" C O N D I T I O N ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } ; $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p r i v a t e _ m o d u l e _ a r g s } ; C O M P I L E _ F L A G S ; N O _ P C H _ S O U R C E S " $ { A R G N } )
2018-12-07 12:13:24 +00:00
if ( "x${arg_CONDITION}" STREQUAL x )
set ( arg_CONDITION ON )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-07 12:13:24 +00:00
qt_evaluate_config_expression ( result ${ arg_CONDITION } )
2018-10-24 13:20:27 +00:00
if ( ${ result } )
2019-01-30 15:36:30 +00:00
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
2019-11-13 13:03:20 +00:00
message ( "qt_extend_target(${target} CONDITION ${arg_CONDITION} ...): Evaluated" )
2019-01-30 15:36:30 +00:00
endif ( )
2018-10-29 15:53:51 +00:00
set ( dbus_sources "" )
2018-12-07 12:13:24 +00:00
foreach ( adaptor ${ arg_DBUS_ADAPTOR_SOURCES } )
2019-01-30 13:06:48 +00:00
qt_create_qdbusxml2cpp_command ( "${target}" "${adaptor}" ADAPTOR BASENAME "${arg_DBUS_ADAPTOR_BASENAME}" FLAGS "${arg_DBUS_ADAPTOR_FLAGS}" )
2018-10-29 15:53:51 +00:00
list ( APPEND dbus_sources "${sources}" )
endforeach ( )
2018-12-11 10:38:20 +00:00
2018-12-07 12:13:24 +00:00
foreach ( interface ${ arg_DBUS_INTERFACE_SOURCES } )
2019-01-30 13:06:48 +00:00
qt_create_qdbusxml2cpp_command ( "${target}" "${interface}" INTERFACE BASENAME "${arg_DBUS_INTERFACE_BASENAME}" FLAGS "${arg_DBUS_INTERFACE_FLAGS}" )
2018-10-29 15:53:51 +00:00
list ( APPEND dbus_sources "${sources}" )
endforeach ( )
2018-10-24 13:20:27 +00:00
2019-09-19 15:22:43 +00:00
get_target_property ( target_type ${ target } TYPE )
set ( is_library FALSE )
if ( ${ target_type } STREQUAL "STATIC_LIBRARY" OR ${ target_type } STREQUAL "SHARED_LIBRARY" )
set ( is_library TRUE )
endif ( )
2019-03-28 14:25:17 +00:00
foreach ( lib ${ arg_PUBLIC_LIBRARIES } ${ arg_LIBRARIES } )
2019-09-19 15:22:43 +00:00
# Automatically generate PCH for 'target' using dependencies
# if 'target' is a library/module!
if ( ${ is_library } )
qt_update_precompiled_header_with_library ( "${target}" "${lib}" )
endif ( )
2019-03-28 14:25:17 +00:00
string ( REGEX REPLACE "_nolink$" "" base_lib "${lib}" )
if ( NOT base_lib STREQUAL lib )
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
qt_create_nolink_target ( "${base_lib}" ${ target } )
2019-03-28 14:25:17 +00:00
endif ( )
endforeach ( )
2019-05-03 09:38:41 +00:00
# Set-up the target
2018-12-07 12:13:24 +00:00
target_sources ( "${target}" PRIVATE ${ arg_SOURCES } ${ dbus_sources } )
if ( arg_COMPILE_FLAGS )
set_source_files_properties ( ${ arg_SOURCES } PROPERTIES COMPILE_FLAGS "${arg_COMPILE_FLAGS}" )
2018-10-24 13:20:27 +00:00
endif ( )
2019-05-03 09:38:41 +00:00
2019-08-19 13:07:22 +00:00
set ( public_visibility_option "PUBLIC" )
set ( private_visibility_option "PRIVATE" )
if ( arg_HEADER_MODULE )
set ( public_visibility_option "INTERFACE" )
set ( private_visibility_option "INTERFACE" )
endif ( )
target_include_directories ( "${target}"
$ { p u b l i c _ v i s i b i l i t y _ o p t i o n } $ { a r g _ P U B L I C _ I N C L U D E _ D I R E C T O R I E S }
$ { p r i v a t e _ v i s i b i l i t y _ o p t i o n } $ { a r g _ I N C L U D E _ D I R E C T O R I E S } )
target_compile_definitions ( "${target}"
$ { p u b l i c _ v i s i b i l i t y _ o p t i o n } $ { a r g _ P U B L I C _ D E F I N E S }
$ { p r i v a t e _ v i s i b i l i t y _ o p t i o n } $ { a r g _ D E F I N E S } )
target_link_libraries ( "${target}"
$ { p u b l i c _ v i s i b i l i t y _ o p t i o n } $ { a r g _ P U B L I C _ L I B R A R I E S }
$ { p r i v a t e _ v i s i b i l i t y _ o p t i o n } $ { a r g _ L I B R A R I E S } )
target_compile_options ( "${target}"
$ { p u b l i c _ v i s i b i l i t y _ o p t i o n } $ { a r g _ P U B L I C _ C O M P I L E _ O P T I O N S }
$ { p r i v a t e _ v i s i b i l i t y _ o p t i o n } $ { a r g _ C O M P I L E _ O P T I O N S } )
target_link_options ( "${target}"
$ { p u b l i c _ v i s i b i l i t y _ o p t i o n } $ { a r g _ P U B L I C _ L I N K _ O P T I O N S }
$ { p r i v a t e _ v i s i b i l i t y _ o p t i o n } $ { a r g _ L I N K _ O P T I O N S } )
if ( NOT arg_HEADER_MODULE )
2020-01-29 15:52:29 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY
2019-08-19 13:07:22 +00:00
A U T O M O C _ M O C _ O P T I O N S " $ { a r g _ M O C _ O P T I O N S } "
)
endif ( )
2019-06-05 08:08:44 +00:00
2019-06-05 20:26:12 +00:00
# When computing the private library dependencies, we need to check not only the known
2019-08-20 13:24:14 +00:00
# modules added by this repo's qt_build_repo(), but also all module dependencies that
# were found via find_package().
qt_internal_get_qt_all_known_modules ( known_modules )
2019-06-05 20:26:12 +00:00
# When a public module depends on a private module (Gui on CorePrivate)
# make its private module depend on the other private module (GuiPrivate will depend on
# CorePrivate).
2019-06-05 08:08:44 +00:00
set ( qt_libs_private "" )
2019-06-05 20:26:12 +00:00
foreach ( it ${ known_modules } )
2019-06-05 08:08:44 +00:00
list ( FIND arg_LIBRARIES "Qt::${it}Private" pos )
if ( pos GREATER -1 )
list ( APPEND qt_libs_private "Qt::${it}Private" )
endif ( )
endforeach ( )
set ( target_private "${target}Private" )
if ( TARGET "${target_private}" )
2020-01-31 21:21:09 +00:00
target_link_libraries ( "${target_private}"
2020-03-13 15:51:45 +00:00
I N T E R F A C E $ { a r g _ P R I V A T E _ M O D U L E _ I N T E R F A C E } )
2019-06-05 08:08:44 +00:00
endif ( )
2019-06-12 13:08:24 +00:00
qt_register_target_dependencies ( "${target}"
" $ { a r g _ P U B L I C _ L I B R A R I E S } "
" $ { q t _ l i b s _ p r i v a t e } ; $ { a r g _ L I B R A R I E S } " )
2019-06-05 08:08:44 +00:00
2019-05-22 13:09:39 +00:00
qt_autogen_tools ( ${ target }
E N A B L E _ A U T O G E N _ T O O L S $ { a r g _ E N A B L E _ A U T O G E N _ T O O L S }
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S } )
2019-07-05 08:47:26 +00:00
qt_update_precompiled_header ( "${target}" "${arg_PRECOMPILED_HEADER}" )
qt_update_ignore_pch_source ( "${target}" "${arg_NO_PCH_SOURCES}" )
## Ignore objective-c files for PCH (not supported atm)
qt_ignore_pch_obj_c_sources ( "${target}" "${arg_SOURCES}" )
2019-01-30 15:36:30 +00:00
else ( )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
2019-11-13 13:03:20 +00:00
message ( "qt_extend_target(${target} CONDITION ${arg_CONDITION} ...): Skipped" )
2019-01-30 15:36:30 +00:00
endif ( )
2018-11-08 21:29:55 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
function ( qt_internal_library_deprecation_level result )
if ( WIN32 )
# On Windows, due to the way DLLs work, we need to export all functions,
# including the inlines
2019-10-31 12:56:06 +00:00
list ( APPEND deprecations "QT_DISABLE_DEPRECATED_BEFORE=0x040800" )
2018-10-24 13:20:27 +00:00
else ( )
# On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
2019-10-31 12:56:06 +00:00
list ( APPEND deprecations "QT_DISABLE_DEPRECATED_BEFORE=0x050000" )
2018-10-24 13:20:27 +00:00
endif ( )
2019-10-31 12:56:06 +00:00
list ( APPEND deprecations "QT_DEPRECATED_WARNINGS_SINCE=0x060000" )
set ( "${result}" deprecations PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-12-02 10:10:05 +00:00
function ( qt_install_injections target build_dir install_dir )
2019-02-11 16:09:03 +00:00
set ( injections ${ ARGN } )
2019-12-02 10:10:05 +00:00
set ( module "Qt${target}" )
2020-01-06 12:45:34 +00:00
get_target_property ( target_type ${ target } TYPE )
if ( target_type STREQUAL "INTERFACE_LIBRARY" )
set ( is_framework FALSE )
else ( )
get_target_property ( is_framework ${ target } FRAMEWORK )
endif ( )
2019-02-11 16:09:03 +00:00
# examples:
# SYNCQT.INJECTIONS = src/corelib/global/qconfig.h:qconfig.h:QtConfig src/corelib/global/qconfig_p.h:5.12.0/QtCore/private/qconfig_p.h
# SYNCQT.INJECTIONS = src/gui/vulkan/qvulkanfunctions.h:^qvulkanfunctions.h:QVulkanFunctions:QVulkanDeviceFunctions src/gui/vulkan/qvulkanfunctions_p.h:^5.12.0/QtGui/private/qvulkanfunctions_p.h
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
# The are 3 parts to the assignment, divded by colons ':'.
# The first part contains a path to a generated file in a build folder.
# The second part contains the file name that the forwarding header should have, which points
# to the file in the first part.
# The third part contains multiple UpperCaseFileNames that should be forwarding headers to the
# header specified in the second part.
2019-02-11 16:09:03 +00:00
separate_arguments ( injections UNIX_COMMAND "${injections}" )
foreach ( injection ${ injections } )
string ( REPLACE ":" ";" injection ${ injection } )
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
# Part 1.
2019-02-11 16:09:03 +00:00
list ( GET injection 0 file )
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
# Part 2.
2019-02-11 16:09:03 +00:00
list ( GET injection 1 destination )
string ( REGEX REPLACE "^\\^" "" destination "${destination}" )
list ( REMOVE_AT injection 0 1 )
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
# Part 3.
2019-02-11 16:09:03 +00:00
set ( fwd_hdrs ${ injection } )
get_filename_component ( destinationdir ${ destination } DIRECTORY )
get_filename_component ( destinationname ${ destination } NAME )
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
get_filename_component ( original_file_name ${ file } NAME )
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
# This describes a concrete example for easier comprehension:
# A file 'qtqml-config.h' is generated by qt_internal_feature_write_file into
# ${qtdeclarative_build_dir}/src/{module}/qtqml-config.h (part 1).
#
# Generate a lower case forwarding header (part 2) 'qtqml-config.h' at the following
# location:
# ${some_prefix}/include/${module}/qtqml-config.h.
#
# Inside this file, we #include the originally generated file,
# ${qtdeclarative_build_dir}/src/{module}/qtqml-config.h.
#
# ${some_prefix}'s value depends on the build type.
# If doing a prefix build, it should point to
2019-06-14 13:29:21 +00:00
# ${current_repo_build_dir} which is ${qtdeclarative_build_dir}.
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
# If doing a non-prefix build, it should point to
2019-06-14 13:29:21 +00:00
# ${qtbase_build_dir}.
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
#
# In the code below, ${some_prefix} == ${build_dir}.
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 ( lower_case_forwarding_header_path "${build_dir}/${INSTALL_INCLUDEDIR}/${module}" )
if ( destinationdir )
string ( APPEND lower_case_forwarding_header_path "/${destinationdir}" )
endif ( )
2019-06-14 13:29:21 +00:00
set ( current_repo_build_dir "${PROJECT_BINARY_DIR}" )
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
file ( RELATIVE_PATH relpath
" $ { l o w e r _ c a s e _ f o r w a r d i n g _ h e a d e r _ p a t h } "
2019-06-14 13:29:21 +00:00
" $ { c u r r e n t _ r e p o _ b u i l d _ d i r } / $ { f i l e } " )
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 ( main_contents "#include \" ${ relpath } \"")
2020-03-20 14:07:28 +00:00
qt_configure_file ( OUTPUT "${lower_case_forwarding_header_path}/${original_file_name}"
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
C O N T E N T " $ { m a i n _ c o n t e n t s } " )
2019-12-02 10:10:05 +00:00
if ( is_framework )
if ( file MATCHES "_p\\.h$" )
set ( header_type PRIVATE )
else ( )
set ( header_type PUBLIC )
endif ( )
qt_copy_framework_headers ( ${ target } ${ header_type }
$ { c u r r e n t _ r e p o _ b u i l d _ d i r } / $ { f i l e } )
else ( )
# Copy the actual injected (generated) header file (not the just created forwarding one)
# to its install location when doing a prefix build. In an non-prefix build, the qt_install
# will be a no-op.
qt_path_join ( install_destination
$ { i n s t a l l _ d i r } $ { I N S T A L L _ I N C L U D E D I R } $ { m o d u l e } $ { d e s t i n a t i o n d i r } )
qt_install ( FILES ${ current_repo_build_dir } / ${ file }
D E S T I N A T I O N $ { i n s t a l l _ d e s t i n a t i o n }
R E N A M E $ { d e s t i n a t i o n n a m e } O P T I O N A L )
endif ( )
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
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
# Generate UpperCaseNamed forwarding headers (part 3).
2019-02-11 16:09:03 +00:00
foreach ( fwd_hdr ${ fwd_hdrs } )
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 ( upper_case_forwarding_header_path "${INSTALL_INCLUDEDIR}/${module}" )
if ( destinationdir )
string ( APPEND upper_case_forwarding_header_path "/${destinationdir}" )
endif ( )
# Generate upper case forwarding header like QVulkanFunctions or QtConfig.
2020-03-20 14:07:28 +00:00
qt_configure_file ( OUTPUT "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
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
C O N T E N T " #include \"${destinationname}\"\n")
2019-12-02 10:10:05 +00:00
if ( is_framework )
# Copy the forwarding header to the framework's Headers directory.
qt_copy_framework_headers ( ${ target } PUBLIC
" $ { b u i l d _ d i r } / $ { u p p e r _ c a s e _ f o r w a r d i n g _ h e a d e r _ p a t h } / $ { f w d _ h d r } " )
else ( )
# Install the forwarding header.
qt_path_join ( install_destination
$ { i n s t a l l _ d i r } $ { u p p e r _ c a s e _ f o r w a r d i n g _ h e a d e r _ p a t h } )
qt_install ( FILES "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
D E S T I N A T I O N $ { i n s t a l l _ d e s t i n a t i o n } O P T I O N A L )
endif ( )
2019-02-11 16:09:03 +00:00
endforeach ( )
endforeach ( )
endfunction ( )
2020-05-15 09:37:08 +00:00
function ( qt_read_headers_pri module_include_dir resultVarPrefix )
2018-12-07 13:04:42 +00:00
file ( STRINGS "${module_include_dir}/headers.pri" headers_pri_contents )
2018-10-24 13:20:27 +00:00
foreach ( line ${ headers_pri_contents } )
if ( "${line}" MATCHES "SYNCQT.HEADER_FILES = (.*)" )
set ( public_module_headers "${CMAKE_MATCH_1}" )
separate_arguments ( public_module_headers UNIX_COMMAND "${public_module_headers}" )
elseif ( "${line}" MATCHES "SYNCQT.PRIVATE_HEADER_FILES = (.*)" )
set ( private_module_headers "${CMAKE_MATCH_1}" )
separate_arguments ( private_module_headers UNIX_COMMAND "${private_module_headers}" )
elseif ( "${line}" MATCHES "SYNCQT.GENERATED_HEADER_FILES = (.*)" )
set ( generated_module_headers "${CMAKE_MATCH_1}" )
separate_arguments ( generated_module_headers UNIX_COMMAND "${generated_module_headers}" )
foreach ( generated_header ${ generated_module_headers } )
2018-12-07 13:04:42 +00:00
list ( APPEND public_module_headers "${module_include_dir}/${generated_header}" )
2018-10-24 13:20:27 +00:00
endforeach ( )
2019-02-11 16:09:03 +00:00
elseif ( "${line}" MATCHES "SYNCQT.INJECTIONS = (.*)" )
set ( injections "${CMAKE_MATCH_1}" )
2018-10-24 13:20:27 +00:00
elseif ( "${line}" MATCHES "SYNCQT.([A-Z_]+)_HEADER_FILES = (.+)" )
set ( prefix "${CMAKE_MATCH_1}" )
string ( TOLOWER "${prefix}" prefix )
set ( entries "${CMAKE_MATCH_2}" )
separate_arguments ( entries UNIX_COMMAND "${entries}" )
set ( "${resultVarPrefix}_${prefix}" "${entries}" PARENT_SCOPE )
endif ( )
endforeach ( )
set ( ${ resultVarPrefix } _public "${public_module_headers}" PARENT_SCOPE )
set ( ${ resultVarPrefix } _private "${private_module_headers}" PARENT_SCOPE )
2019-02-11 16:09:03 +00:00
set ( ${ resultVarPrefix } _injections "${injections}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2018-12-07 12:48:36 +00:00
# Add Qt::target and Qt6::target as aliases for the target
function ( qt_internal_add_target_aliases target )
get_target_property ( type "${target}" TYPE )
if ( type STREQUAL EXECUTABLE )
add_executable ( "Qt::${target}" ALIAS "${target}" )
add_executable ( "Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}" )
else ( )
add_library ( "Qt::${target}" ALIAS "${target}" )
add_library ( "Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}" )
endif ( )
endfunction ( )
2019-06-04 13:55:41 +00:00
# Sets the exceptions flags for the given target
function ( qt_internal_set_no_exceptions_flags target )
target_compile_definitions ( "${target}" PRIVATE "QT_NO_EXCEPTIONS" )
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" )
2019-06-06 14:18:37 +00:00
target_compile_options ( "${target}" PRIVATE "/wd4530" "/wd4577" )
2019-06-04 13:55:41 +00:00
elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
target_compile_options ( "${target}" PRIVATE "-fno-exceptions" )
elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" )
target_compile_options ( "${target}" PRIVATE "-fno-exceptions" )
elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
target_compile_options ( "${target}" PRIVATE "-fno-exceptions" )
elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" )
target_compile_options ( "${target}" PRIVATE "-fno-exceptions" )
endif ( )
endfunction ( )
2018-12-07 12:48:36 +00:00
2019-10-15 09:10:08 +00:00
function ( qt_skip_warnings_are_errors target )
2019-11-13 13:46:10 +00:00
get_target_property ( target_type "${target}" TYPE )
if ( target_type STREQUAL "INTERFACE_LIBRARY" )
return ( )
endif ( )
2019-10-15 09:10:08 +00:00
set_target_properties ( "${target}" PROPERTIES QT_SKIP_WARNINGS_ARE_ERRORS ON )
endfunction ( )
function ( qt_skip_warnings_are_errors_when_repo_unclean target )
if ( QT_REPO_NOT_WARNINGS_CLEAN )
qt_skip_warnings_are_errors ( "${target}" )
endif ( )
endfunction ( )
2020-02-24 11:38:55 +00:00
function ( qt_disable_warnings target )
get_target_property ( target_type "${target}" TYPE )
if ( target_type STREQUAL "INTERFACE_LIBRARY" )
return ( )
endif ( )
set_target_properties ( "${target}" PROPERTIES QT_COMPILE_OPTIONS_DISABLE_WARNINGS ON )
endfunction ( )
2020-02-24 11:38:55 +00:00
function ( qt_set_symbol_visibility_preset target value )
get_target_property ( target_type "${target}" TYPE )
if ( target_type STREQUAL "INTERFACE_LIBRARY" )
return ( )
endif ( )
set_target_properties ( "${target}" PROPERTIES C_VISIBILITY_PRESET "${value}" )
set_target_properties ( "${target}" PROPERTIES CXX_VISIBILITY_PRESET "${value}" )
endfunction ( )
function ( qt_set_symbol_visibility_hidden target )
qt_set_symbol_visibility_preset ( "${target}" "hidden" )
endfunction ( )
2019-11-15 14:43:20 +00:00
function ( qt_get_sanitized_plugin_type plugin_type out_var )
# Used to handle some edge cases such as platforms/darwin
string ( REGEX REPLACE "[-/]" "_" plugin_type "${plugin_type}" )
set ( "${out_var}" "${plugin_type}" PARENT_SCOPE )
endfunction ( )
2019-12-02 10:10:05 +00:00
# Copy header files to QtXYZ.framework/Versions/6/Headers/
# Use this function for header files that
# - are not added as source files to the target
# - are not marked as PUBLIC_HEADER
# - or are private and supposed to end up in the 6.7.8/QtXYZ/private subdir.
function ( qt_copy_framework_headers target )
get_target_property ( is_fw ${ target } FRAMEWORK )
if ( NOT "${is_fw}" )
return ( )
endif ( )
set ( options PUBLIC PRIVATE QPA )
set ( oneValueArgs )
set ( multiValueArgs )
cmake_parse_arguments ( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
get_target_property ( fw_version ${ target } FRAMEWORK_VERSION )
get_target_property ( fw_bundle_version ${ target } MACOSX_FRAMEWORK_BUNDLE_VERSION )
get_target_property ( fw_dir ${ target } LIBRARY_OUTPUT_DIRECTORY )
get_target_property ( fw_name ${ target } OUTPUT_NAME )
set ( fw_headers_dir ${ fw_dir } / ${ fw_name } .framework/Versions/ ${ fw_version } /Headers/ )
if ( ARG_PRIVATE )
string ( APPEND fw_headers_dir "${fw_bundle_version}/Qt${target}/private/" )
elseif ( ARG_QPA )
string ( APPEND fw_headers_dir "${fw_bundle_version}/Qt${target}/qpa/" )
endif ( )
set ( out_files )
foreach ( hdr IN LISTS ARG_UNPARSED_ARGUMENTS )
get_filename_component ( in_file_path ${ hdr } ABSOLUTE )
get_filename_component ( in_file_name ${ hdr } NAME )
set ( out_file_path ${ fw_headers_dir } ${ in_file_name } )
add_custom_command (
O U T P U T $ { o u t _ f i l e _ p a t h }
D E P E N D S $ { i n _ f i l e _ p a t h }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y " $ { f w _ h e a d e r s _ d i r } "
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y " $ { i n _ f i l e _ p a t h } " " $ { f w _ h e a d e r s _ d i r } " )
list ( APPEND out_files ${ out_file_path } )
endforeach ( )
get_target_property ( fw_copied_headers ${ target } QT_COPIED_FRAMEWORK_HEADERS )
if ( NOT fw_copied_headers )
set ( fw_copied_headers "" )
endif ( )
list ( APPEND fw_copied_headers ${ out_files } )
set_target_properties ( ${ target } PROPERTIES QT_COPIED_FRAMEWORK_HEADERS "${fw_copied_headers}" )
endfunction ( )
function ( qt_finalize_framework_headers_copy target )
get_target_property ( target_type ${ target } TYPE )
if ( ${ target_type } STREQUAL "INTERFACE_LIBRARY" )
return ( )
endif ( )
get_target_property ( is_fw ${ target } FRAMEWORK )
if ( NOT "${is_fw}" )
return ( )
endif ( )
get_target_property ( headers ${ target } QT_COPIED_FRAMEWORK_HEADERS )
if ( headers )
# Hack to create the "Headers" symlink in the framework:
# Create a fake header file and copy it into the framework by marking it as PUBLIC_HEADER.
# CMake now takes care of creating the symlink.
set ( fake_header ${ target } _fake_header.h )
2019-12-06 14:12:17 +00:00
qt_get_main_cmake_configuration ( main_config )
file ( GENERATE OUTPUT ${ fake_header } CONTENT "// ignore this file\n"
C O N D I T I O N " $ < C O N F I G : $ { m a i n _ c o n f i g } > " )
2019-12-02 10:10:05 +00:00
string ( PREPEND fake_header "${CMAKE_CURRENT_BINARY_DIR}/" )
target_sources ( ${ target } PRIVATE ${ fake_header } )
set_source_files_properties ( ${ fake_header } PROPERTIES GENERATED ON )
set_property ( TARGET ${ target } APPEND PROPERTY PUBLIC_HEADER ${ fake_header } )
# Add a target, e.g. Core_framework_headers, that triggers the header copy.
add_custom_target ( ${ target } _framework_headers DEPENDS ${ headers } )
add_dependencies ( ${ target } ${ target } _framework_headers )
endif ( )
endfunction ( )
2020-05-15 13:21:21 +00:00
function ( qt_get_cmake_configurations out_var )
set ( possible_configs "${CMAKE_BUILD_TYPE}" )
if ( CMAKE_CONFIGURATION_TYPES )
set ( possible_configs "${CMAKE_CONFIGURATION_TYPES}" )
endif ( )
set ( ${ out_var } "${possible_configs}" PARENT_SCOPE )
endfunction ( )
2019-12-06 14:12:17 +00:00
function ( qt_clone_property_for_configs target property configs )
get_target_property ( value "${target}" "${property}" )
foreach ( config ${ configs } )
string ( TOUPPER "${config}" upper_config )
set_property ( TARGET "${target}" PROPERTY "${property}_${upper_config}" "${value}" )
endforeach ( )
endfunction ( )
function ( qt_handle_multi_config_output_dirs target )
2020-05-15 13:21:21 +00:00
qt_get_cmake_configurations ( possible_configs )
2019-12-06 14:12:17 +00:00
qt_clone_property_for_configs ( ${ target } LIBRARY_OUTPUT_DIRECTORY "${possible_configs}" )
qt_clone_property_for_configs ( ${ target } RUNTIME_OUTPUT_DIRECTORY "${possible_configs}" )
qt_clone_property_for_configs ( ${ target } ARCHIVE_OUTPUT_DIRECTORY "${possible_configs}" )
endfunction ( )
2020-03-12 15:16:55 +00:00
# Add a finalizer function for the current CMake list file.
#
# You may add up to nine arguments that are passed to the finalizer.
# A finalizer that is registered with qt_add_list_file_finalizer(foo bar baz)
# will be called with nine arguments: foo(bar baz IGNORE IGNORE IGNORE...),
# because CMake's handling of empty list elements is a cruel joke.
#
# For CMake < 3.18 the function qt_watch_current_list_dir must know about the finalizer.
function ( qt_add_list_file_finalizer func )
set_property ( GLOBAL APPEND
P R O P E R T Y Q T _ L I S T _ F I L E _ F I N A L I Z E R _ F I L E S " $ { C M A K E _ C U R R E N T _ L I S T _ F I L E } " )
set_property ( GLOBAL APPEND
P R O P E R T Y Q T _ L I S T _ F I L E _ F I N A L I Z E R _ F U N C S $ { f u n c } )
foreach ( i RANGE 1 9 )
set ( arg "${ARGV${i}}" )
2020-05-18 19:16:00 +00:00
if ( i GREATER_EQUAL ARGC OR "${arg}" STREQUAL "" )
2020-03-12 15:16:55 +00:00
set ( arg "IGNORE" )
endif ( )
set_property ( GLOBAL APPEND
P R O P E R T Y Q T _ L I S T _ F I L E _ F I N A L I Z E R _ A R G V $ { i } " $ { a r g } " )
endforeach ( )
endfunction ( )
# Watcher function for the variable CMAKE_CURRENT_LIST_DIR.
# This is the driver of the finalizer facility.
function ( qt_watch_current_list_dir variable access value current_list_file stack )
if ( NOT access STREQUAL "MODIFIED_ACCESS" )
# We are only interested in modifications of CMAKE_CURRENT_LIST_DIR.
return ( )
endif ( )
list ( GET stack -1 stack_top )
if ( stack_top STREQUAL current_list_file )
# If the top of the stack equals the current list file then
# we're entering a file. We're not interested in this case.
return ( )
endif ( )
get_property ( files GLOBAL PROPERTY QT_LIST_FILE_FINALIZER_FILES )
if ( NOT files )
return ( )
endif ( )
get_property ( funcs GLOBAL PROPERTY QT_LIST_FILE_FINALIZER_FUNCS )
foreach ( i RANGE 1 9 )
get_property ( args ${ i } GLOBAL PROPERTY QT_LIST_FILE_FINALIZER_ARGV ${ i } )
endforeach ( )
list ( LENGTH files n )
set ( i 0 )
while ( i LESS n )
list ( GET files ${ i } file )
if ( file STREQUAL stack_top )
list ( GET funcs ${ i } func )
foreach ( k RANGE 1 9 )
list ( GET args ${ k } ${ i } a ${ k } )
endforeach ( )
# We've found a file we're looking for. Call the finalizer.
if ( ${ CMAKE_VERSION } VERSION_LESS "3.18.0" )
# Make finalizer known functions here:
2020-05-18 19:56:12 +00:00
if ( func STREQUAL "qt_finalize_module" )
qt_finalize_module ( ${ a1 } ${ a2 } ${ a3 } ${ a4 } ${ a5 } ${ a6 } ${ a7 } ${ a8 } ${ a9 } )
2020-03-12 15:16:55 +00:00
else ( )
message ( FATAL_ERROR "qt_watch_current_list_dir doesn't know about ${func}. Consider adding it." )
endif ( )
else ( )
2020-05-28 14:06:44 +00:00
cmake_language ( CALL ${ func } ${ a1 } ${ a2 } ${ a3 } ${ a4 } ${ a5 } ${ a6 } ${ a7 } ${ a8 } ${ a9 } )
2020-03-12 15:16:55 +00:00
endif ( )
list ( REMOVE_AT files ${ i } )
list ( REMOVE_AT funcs ${ i } )
foreach ( k RANGE 1 9 )
list ( REMOVE_AT args ${ k } ${ i } )
endforeach ( )
math ( EXPR n "${n} - 1" )
else ( )
math ( EXPR i "${i} + 1" )
endif ( )
endwhile ( )
set_property ( GLOBAL PROPERTY QT_LIST_FILE_FINALIZER_FILES ${ files } )
set_property ( GLOBAL PROPERTY QT_LIST_FILE_FINALIZER_FUNCS ${ funcs } )
foreach ( i RANGE 1 9 )
set_property ( GLOBAL PROPERTY QT_LIST_FILE_FINALIZER_ARGV ${ i } "${args${i}}" )
endforeach ( )
endfunction ( )
variable_watch ( CMAKE_CURRENT_LIST_DIR qt_watch_current_list_dir )
2020-04-17 15:12:40 +00:00
# Set target properties that are the same for all modules, plugins, executables
# and 3rdparty libraries.
function ( qt_set_common_target_properties target )
if ( FEATURE_static_runtime )
if ( MSVC )
set_property ( TARGET ${ target } PROPERTY
M S V C _ R U N T I M E _ L I B R A R Y " M u l t i T h r e a d e d $ < $ < C O N F I G : D e b u g > : D e b u g > " )
elseif ( MINGW )
target_link_options ( ${ target } INTERFACE "LINKER:-static" )
endif ( )
endif ( )
endfunction ( )
2020-05-12 09:29:56 +00:00
# Set common, informational target properties.
#
# On Windows, these properties are used to generate the version information resource.
function ( qt_set_target_info_properties target )
cmake_parse_arguments ( arg "" "${__default_target_info_args}" "" ${ ARGN } )
if ( "${arg_TARGET_VERSION}" STREQUAL "" )
set ( arg_TARGET_VERSION "${PROJECT_VERSION}.0" )
endif ( )
if ( "${arg_TARGET_PRODUCT}" STREQUAL "" )
set ( arg_TARGET_PRODUCT "Qt6" )
endif ( )
if ( "${arg_TARGET_DESCRIPTION}" STREQUAL "" )
set ( arg_TARGET_DESCRIPTION "C++ Application Development Framework" )
endif ( )
if ( "${arg_TARGET_COMPANY}" STREQUAL "" )
set ( arg_TARGET_COMPANY "The Qt Company Ltd." )
endif ( )
if ( "${arg_TARGET_COPYRIGHT}" STREQUAL "" )
set ( arg_TARGET_COPYRIGHT "Copyright (C) 2020 The Qt Company Ltd." )
endif ( )
set_target_properties ( ${ target } PROPERTIES
Q T _ T A R G E T _ V E R S I O N " $ { a r g _ T A R G E T _ V E R S I O N } "
Q T _ T A R G E T _ C O M P A N Y _ N A M E " $ { a r g _ T A R G E T _ C O M P A N Y } "
Q T _ T A R G E T _ D E S C R I P T I O N " $ { a r g _ T A R G E T _ D E S C R I P T I O N } "
Q T _ T A R G E T _ C O P Y R I G H T " $ { a r g _ T A R G E T _ C O P Y R I G H T } "
Q T _ T A R G E T _ P R O D U C T _ N A M E " $ { a r g _ T A R G E T _ P R O D U C T } " )
endfunction ( )
2018-10-24 13:20:27 +00:00
# This is the main entry function for creating a Qt module, that typically
# consists of a library, public header files, private header files and configurable
# features.
#
2018-12-07 12:30:51 +00:00
# A CMake target with the specified target parameter is created. If the current source
2018-10-24 13:20:27 +00:00
# directory has a configure.cmake file, then that is also processed for feature definition
# and testing. Any features defined as well as any features coming from dependencies to
# this module are imported into the scope of the calling feature.
2018-12-07 12:30:51 +00:00
#
# Target is without leading "Qt". So e.g. the "QtCore" module has the target "Core".
2019-11-13 13:03:20 +00:00
function ( qt_add_module target )
2018-12-07 13:04:42 +00:00
qt_internal_module_info ( module "${target}" )
# Process arguments:
2019-11-13 13:03:20 +00:00
qt_parse_all_arguments ( arg "qt_add_module"
2020-03-05 13:28:15 +00:00
" N O _ M O D U L E _ H E A D E R S ; S T A T I C ; D I S A B L E _ T O O L S _ E X P O R T ; E X C E P T I O N S ; I N T E R N A L _ M O D U L E ; N O _ S Y N C _ Q T ; N O _ P R I V A T E _ M O D U L E ; H E A D E R _ M O D U L E ; G E N E R A T E _ M E T A T Y P E S ; N O _ C O N F I G _ H E A D E R _ F I L E ; S K I P _ D E P E N D S _ I N C L U D E "
2020-05-15 09:37:08 +00:00
" M O D U L E _ I N C L U D E _ N A M E ; C O N F I G _ M O D U L E _ N A M E ; P R E C O M P I L E D _ H E A D E R ; $ { _ _ d e f a u l t _ t a r g e t _ i n f o _ a r g s } "
2020-01-31 21:21:09 +00:00
" $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } ; $ { _ _ d e f a u l t _ p r i v a t e _ m o d u l e _ a r g s } ; Q M A K E _ M O D U L E _ C O N F I G ; E X T R A _ C M A K E _ F I L E S ; E X T R A _ C M A K E _ I N C L U D E S ; N O _ P C H _ S O U R C E S " $ { A R G N } )
2018-10-24 13:20:27 +00:00
2020-05-18 21:09:41 +00:00
qt_internal_add_qt_repo_known_module ( "${target}" )
2018-12-07 13:04:42 +00:00
if ( NOT DEFINED arg_CONFIG_MODULE_NAME )
set ( arg_CONFIG_MODULE_NAME "${module_lower}" )
endif ( )
2018-10-24 13:20:27 +00:00
### Define Targets:
2019-12-02 10:10:05 +00:00
set ( is_interface_lib 0 )
2020-02-17 13:58:16 +00:00
set ( is_shared_lib 0 )
2019-08-19 13:07:22 +00:00
if ( ${ arg_HEADER_MODULE } )
add_library ( "${target}" INTERFACE )
2019-12-02 10:10:05 +00:00
set ( is_interface_lib 1 )
2019-08-19 13:07:22 +00:00
elseif ( ${ arg_STATIC } )
2018-10-24 13:20:27 +00:00
add_library ( "${target}" STATIC )
elseif ( ${ QT_BUILD_SHARED_LIBS } )
add_library ( "${target}" SHARED )
2020-02-17 13:58:16 +00:00
set ( is_shared_lib 1 )
2018-10-24 13:20:27 +00:00
else ( )
add_library ( "${target}" STATIC )
endif ( )
2019-08-30 09:34:23 +00:00
2020-05-18 19:56:12 +00:00
set ( property_prefix "INTERFACE_" )
2020-05-18 21:09:41 +00:00
if ( NOT arg_HEADER_MODULE )
2020-04-17 15:12:40 +00:00
qt_set_common_target_properties ( ${ target } )
2020-05-18 19:56:12 +00:00
set ( property_prefix "" )
2020-04-17 15:12:40 +00:00
endif ( )
2020-05-18 21:09:41 +00:00
2020-05-18 19:56:12 +00:00
set_target_properties ( ${ target } PROPERTIES
2020-05-18 21:09:41 +00:00
_ q t _ c o n f i g _ m o d u l e _ n a m e " $ { a r g _ C O N F I G _ M O D U L E _ N A M E } "
2020-05-18 19:56:12 +00:00
$ { p r o p e r t y _ p r e f i x } Q T _ Q M A K E _ M O D U L E _ C O N F I G " $ { a r g _ Q M A K E _ M O D U L E _ C O N F I G } " )
2020-05-27 15:36:11 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES _qt_config_module_name )
2020-04-17 15:12:40 +00:00
2019-12-02 10:10:05 +00:00
set ( is_framework 0 )
if ( QT_FEATURE_framework AND NOT ${ arg_HEADER_MODULE } AND NOT ${ arg_STATIC } )
set ( is_framework 1 )
set_target_properties ( ${ target } PROPERTIES
F R A M E W O R K T R U E
F R A M E W O R K _ V E R S I O N $ { P R O J E C T _ V E R S I O N _ M A J O R }
M A C O S X _ F R A M E W O R K _ I D E N T I F I E R o r g . q t - p r o j e c t . Q t $ { t a r g e t }
M A C O S X _ F R A M E W O R K _ B U N D L E _ V E R S I O N $ { P R O J E C T _ V E R S I O N }
M A C O S X _ F R A M E W O R K _ S H O R T _ V E R S I O N _ S T R I N G $ { P R O J E C T _ V E R S I O N _ M A J O R } . $ { P R O J E C T _ V E R S I O N _ M I N O R }
)
endif ( )
2020-02-17 13:58:16 +00:00
if ( QT_FEATURE_reduce_relocations AND UNIX AND NOT is_interface_lib )
# On x86 and x86-64 systems with ELF binaries (especially Linux), due to
# a new optimization in GCC 5.x in combination with a recent version of
# GNU binutils, compiling Qt applications with -fPIE is no longer
# enough.
# Applications now need to be compiled with the -fPIC option if the Qt option
# \"reduce relocations\" is active.
target_compile_options ( ${ target } INTERFACE -fPIC )
if ( GCC AND is_shared_lib )
target_link_options ( ${ target } PRIVATE LINKER:-Bsymbolic-functions )
endif ( )
endif ( )
2020-02-26 10:41:20 +00:00
if ( QT_FEATURE_separate_debug_info AND is_shared_lib AND ( UNIX OR MINGW ) )
qt_enable_separate_debug_info ( ${ target } ${ INSTALL_LIBDIR } )
endif ( )
2019-10-14 13:18:50 +00:00
if ( ANDROID )
2019-08-30 09:34:23 +00:00
qt_android_apply_arch_suffix ( "${target}" )
endif ( )
2018-12-07 12:48:36 +00:00
qt_internal_add_target_aliases ( "${target}" )
2019-10-15 09:10:08 +00:00
qt_skip_warnings_are_errors_when_repo_unclean ( "${target}" )
2018-10-24 13:20:27 +00:00
# Add _private target to link against the private headers:
2019-08-19 13:07:22 +00:00
if ( NOT ${ arg_NO_PRIVATE_MODULE } )
set ( target_private "${target}Private" )
add_library ( "${target_private}" INTERFACE )
qt_internal_add_target_aliases ( "${target_private}" )
2020-05-18 21:09:41 +00:00
set_target_properties ( ${ target_private } PROPERTIES
_ q t _ c o n f i g _ m o d u l e _ n a m e $ { a r g _ C O N F I G _ M O D U L E _ N A M E } _ p r i v a t e )
2020-05-27 15:36:11 +00:00
set_property ( TARGET "${target_private}" APPEND PROPERTY
E X P O R T _ P R O P E R T I E S _ q t _ c o n f i g _ m o d u l e _ n a m e )
2019-08-19 13:07:22 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
2019-12-02 10:10:05 +00:00
if ( NOT arg_HEADER_MODULE )
set_target_properties ( ${ target } PROPERTIES
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ L I B D I R } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ B I N D I R } "
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ L I B D I R } "
V E R S I O N $ { P R O J E C T _ V E R S I O N }
S O V E R S I O N $ { P R O J E C T _ V E R S I O N _ M A J O R }
2020-05-12 09:29:56 +00:00
)
qt_set_target_info_properties ( ${ target } ${ ARGN } )
2019-12-06 14:12:17 +00:00
qt_handle_multi_config_output_dirs ( "${target}" )
2019-12-02 10:10:05 +00:00
2020-06-11 10:44:10 +00:00
if ( NOT BUILD_SHARED_LIBS AND LINUX )
# Horrible workaround for static build failures due to incorrect static library link
# order. By increasing the multiplicity to 3, each library cycle will be repeated
# 3 times on the link line, reducing the probability of undefined symbols at
# link time.
# These failures are only observed on Linux with the ld linker (not sure about
# ld.gold).
# Allow opting out and modifying the value via cache value, in case if we urgently
# need to increase it without waiting for the qtbase change to propagate to
# other dependent repos.
# The proper fix will be to get rid of the cycles in the future.
# See QTBUG-83498 for details.
set ( default_link_cycle_multiplicity "3" )
if ( DEFINED QT_LINK_CYCLE_MULTIPLICITY )
set ( default_link_cycle_multiplicity "${QT_LINK_CYCLE_MULTIPLICITY}" )
endif ( )
if ( default_link_cycle_multiplicity )
set_property ( TARGET "${target}"
P R O P E R T Y
L I N K _ I N T E R F A C E _ M U L T I P L I C I T Y " $ { d e f a u l t _ l i n k _ c y c l e _ m u l t i p l i c i t y } " )
endif ( )
endif ( )
2020-03-05 13:28:15 +00:00
if ( arg_SKIP_DEPENDS_INCLUDE )
set_target_properties ( ${ target } PROPERTIES QT_MODULE_SKIP_DEPENDS_INCLUDE TRUE )
endif ( )
2019-12-02 10:10:05 +00:00
if ( is_framework )
set_target_properties ( ${ target } PROPERTIES
O U T P U T _ N A M E Q t $ { t a r g e t }
)
else ( )
set_target_properties ( ${ target } PROPERTIES
O U T P U T _ N A M E " $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } "
)
endif ( )
2020-02-21 15:32:13 +00:00
if ( WIN32 AND BUILD_SHARED_LIBS )
qt6_generate_win32_rc_file ( ${ target } )
endif ( )
2019-12-02 10:10:05 +00:00
endif ( )
2018-12-11 10:38:20 +00:00
# Module headers:
2019-06-07 08:51:55 +00:00
if ( ${ arg_NO_MODULE_HEADERS } OR ${ arg_NO_SYNC_QT } )
2019-08-19 13:07:22 +00:00
set_target_properties ( "${target}" PROPERTIES INTERFACE_MODULE_HAS_HEADERS OFF )
2018-12-07 12:48:36 +00:00
else ( )
2020-05-15 09:37:08 +00:00
if ( arg_MODULE_INCLUDE_NAME )
set ( module_include_name ${ arg_MODULE_INCLUDE_NAME } )
else ( )
set ( module_include_name ${ module } )
endif ( )
set_target_properties ( "${target}" PROPERTIES INTERFACE_MODULE_INCLUDE_NAME "${module_include_name}" )
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
# Use QT_BUILD_DIR for the syncqt call.
# So we either write the generated files into the qtbase non-prefix build root, or the
# module specific build root.
2018-12-07 13:04:42 +00:00
qt_ensure_sync_qt ( )
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
set ( syncqt_full_command "${HOST_PERL}" -w "${QT_SYNCQT}"
- q u i e t
- c h e c k - i n c l u d e s
2020-05-15 09:37:08 +00:00
- m o d u l e " $ { m o d u l e _ i n c l u d e _ n a m e } "
Fix syncqt call and injected file forwarding and add comments about it
The location of the forwarding headers when not yet installed, depends
on whether we do a prefix or non prefix build.
In a prefix build the /include folder should be in the current repo
build dir.
In a non prefix build, it should be under qtbase/include.
But the actual generated files to which the forwarding headers point,
are always in the current repo build directory.
Also syncqt needs to know both the current repo build directory
specified by -builddir, and the output directory specified by
-outdir.
In a prefix build, both are the same.
In a non-prefix build, builddir should be the current repo build dir,
and outddir should be qtbase's build dir.
Also for non-qtbase repo build directories (like declarative),
examples need to have the current_repo_build_dir/include directory
as an include path, so that framework style includes like
#include <QtQml/QQmlEngine>
work correctly.
Take care of all that, and add a bunch of comments explaining the whole
injected / generated headers interaction.
Change-Id: I612ad7549ce499c4979ee994e998b558716d45ca
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-24 17:19:51 +00:00
- v e r s i o n " $ { P R O J E C T _ V E R S I O N } "
- o u t d i r " $ { Q T _ B U I L D _ D I R } "
- b u i l d d i r " $ { P R O J E C T _ B I N A R Y _ D I R } "
" $ { P R O J E C T _ S O U R C E _ D I R } " )
execute_process ( COMMAND ${ syncqt_full_command } )
2018-10-24 13:20:27 +00:00
2019-08-19 13:07:22 +00:00
set_target_properties ( "${target}" PROPERTIES INTERFACE_MODULE_HAS_HEADERS ON )
2018-12-11 10:38:20 +00:00
### FIXME: Can we replace headers.pri?
2020-05-15 09:37:08 +00:00
set ( module_include_dir "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}/${module_include_name}" )
qt_read_headers_pri ( "${module_include_dir}" "module_headers" )
2020-05-20 14:17:06 +00:00
set ( module_depends_header "${module_include_dir}/${module}Depends" )
2019-12-02 10:10:05 +00:00
if ( is_framework )
if ( NOT is_interface_lib )
set ( public_headers_to_copy "${module_headers_public}" "${module_depends_header}" )
qt_copy_framework_headers ( ${ target } PUBLIC "${public_headers_to_copy}" )
qt_copy_framework_headers ( ${ target } PRIVATE "${module_headers_private}" )
endif ( )
else ( )
set_property ( TARGET ${ target } APPEND PROPERTY PUBLIC_HEADER "${module_headers_public}" )
2020-05-20 14:17:06 +00:00
set_property ( TARGET ${ target } APPEND PROPERTY PUBLIC_HEADER ${ module_depends_header } )
2019-12-02 10:10:05 +00:00
set_property ( TARGET ${ target } APPEND PROPERTY PRIVATE_HEADER "${module_headers_private}" )
endif ( )
2019-09-13 08:35:29 +00:00
if ( NOT ${ arg_HEADER_MODULE } )
2020-05-15 09:37:08 +00:00
set_property ( TARGET "${target}" PROPERTY MODULE_HEADER "${module_include_dir}/${module_include_name}" )
2019-09-13 08:35:29 +00:00
endif ( )
2019-07-05 08:47:26 +00:00
2019-06-20 08:13:22 +00:00
if ( module_headers_qpa )
2019-12-02 10:10:05 +00:00
if ( is_framework )
qt_copy_framework_headers ( ${ target } QPA "${module_headers_qpa}" )
else ( )
qt_install (
F I L E S $ { m o d u l e _ h e a d e r s _ q p a }
2020-05-15 09:37:08 +00:00
D E S T I N A T I O N $ { I N S T A L L _ I N C L U D E D I R } / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e _ i n c l u d e _ n a m e } / q p a )
2019-12-02 10:10:05 +00:00
endif ( )
2019-06-20 08:13:22 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
endif ( )
2019-08-19 13:07:22 +00:00
if ( NOT arg_HEADER_MODULE )
2019-11-21 12:33:28 +00:00
# This property is used for super builds with static libraries. We use
# it in QtPlugins.cmake.in to avoid "polluting" the dependency chain
# for the target in it's project directory.
# E.g: When we process find_package(Qt6 ... Gui) in QtDeclarative, the
# rules in QtPugins.cmake add all the known Gui plugins as interface
# dependencies. This in turn causes circular dependencies on every
# plugin which links against Gui. Plugin A -> GUI -> Plugin A ....
set_target_properties ( ${ target } PROPERTIES QT_BUILD_PROJECT_NAME ${ PROJECT_NAME } )
2019-08-19 13:07:22 +00:00
# Plugin types associated to a module
if ( NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x" )
2019-09-23 14:57:06 +00:00
# Reset the variable containing the list of plugins for the given plugin type
foreach ( plugin_type ${ arg_PLUGIN_TYPES } )
2019-11-15 14:43:20 +00:00
qt_get_sanitized_plugin_type ( "${plugin_type}" plugin_type )
2019-09-23 14:57:06 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY MODULE_PLUGIN_TYPES "${plugin_type}" )
qt_internal_add_qt_repo_known_plugin_types ( "${plugin_type}" )
endforeach ( )
2019-08-19 13:07:22 +00:00
endif ( )
endif ( )
2018-10-24 13:20:27 +00:00
qt_internal_library_deprecation_level ( deprecation_define )
2019-08-19 13:07:22 +00:00
if ( NOT arg_HEADER_MODULE )
qt_autogen_tools_initial_setup ( ${ target } )
endif ( )
2019-03-06 12:51:38 +00:00
2019-08-08 14:55:48 +00:00
set ( private_includes
2019-09-05 13:22:14 +00:00
" $ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } > "
" $ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } > "
2019-08-08 14:55:48 +00:00
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
2019-06-05 08:51:45 +00:00
)
2019-08-08 14:55:48 +00:00
2019-09-02 09:26:12 +00:00
set ( public_includes "" )
2019-12-02 10:10:05 +00:00
set ( public_headers_list "public_includes" )
if ( is_framework )
set ( public_headers_list "private_includes" )
set ( fw_bundle_subdir "${INSTALL_LIBDIR}/Qt${target}.framework" )
set ( fw_headers_subdir "Versions/${PROJECT_VERSION_MAJOR}/Headers" )
list ( APPEND public_includes
# Add the lib/Foo.framework dir as include path to let CMake generate
# the -F compiler flag.
" $ < B U I L D _ I N T E R F A C E : $ { Q T _ B U I L D _ D I R } / $ { f w _ b u n d l e _ s u b d i r } > "
" $ < I N S T A L L _ I N T E R F A C E : $ { f w _ b u n d l e _ s u b d i r } > "
# Add the fully resolved Headers subdir, because the Headers symlink might
# not be there yet.
" $ < B U I L D _ I N T E R F A C E : $ { Q T _ B U I L D _ D I R } / $ { f w _ b u n d l e _ s u b d i r } / $ { f w _ h e a d e r s _ s u b d i r } > "
# After installing, the Headers symlink is guaranteed to exist.
" $ < I N S T A L L _ I N T E R F A C E : $ { f w _ b u n d l e _ s u b d i r } / H e a d e r s > "
)
endif ( )
2019-09-02 09:26:12 +00:00
# Handle cases like QmlDevTools which do not have their own headers, but rather borrow them
# from another module.
2019-10-14 13:47:53 +00:00
if ( NOT arg_NO_SYNC_QT AND NOT arg_NO_MODULE_HEADERS )
2019-12-03 15:07:44 +00:00
# Don't include private headers unless they exist, aka syncqt created them.
if ( module_headers_private )
list ( APPEND private_includes
" $ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } > "
" $ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } > " )
endif ( )
2019-09-02 09:26:12 +00:00
2019-12-02 10:10:05 +00:00
list ( APPEND ${ public_headers_list }
2019-09-02 09:26:12 +00:00
# For the syncqt headers
" $ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ r e p o _ i n c l u d e _ d i r } > "
" $ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } > " )
endif ( )
2019-08-08 14:55:48 +00:00
2019-09-10 12:02:15 +00:00
if ( NOT arg_NO_MODULE_HEADERS AND NOT arg_NO_SYNC_QT )
2019-08-08 14:55:48 +00:00
# For the syncqt headers
2020-01-26 11:25:40 +00:00
list ( APPEND ${ public_headers_list } "$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/${module}>" )
2019-06-05 08:51:45 +00:00
endif ( )
2019-12-02 10:10:05 +00:00
list ( APPEND ${ public_headers_list } ${ arg_PUBLIC_INCLUDE_DIRECTORIES } )
2019-06-05 08:51:45 +00:00
2019-08-19 13:07:22 +00:00
set ( header_module )
if ( arg_HEADER_MODULE )
set ( header_module "HEADER_MODULE" )
2020-06-05 08:10:50 +00:00
# Provide a *_timestamp target that can be used to trigger the build of custom_commands.
set ( timestamp_file "${CMAKE_CURRENT_BINARY_DIR}/timestamp" )
add_custom_command ( OUTPUT "${timestamp_file}"
C O M M A N D $ { C M A K E _ C O M M A N D } - E t o u c h " $ { t i m e s t a m p _ f i l e } "
D E P E N D S $ { m o d u l e _ h e a d e r s _ p u b l i c }
V E R B A T I M )
add_custom_target ( ${ target } _timestamp ALL DEPENDS "${timestamp_file}" )
2019-08-19 13:07:22 +00:00
endif ( )
2019-11-13 13:03:20 +00:00
qt_extend_target ( "${target}"
2019-08-19 13:07:22 +00:00
$ { h e a d e r _ m o d u l e }
2018-12-07 12:13:24 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
2019-08-08 14:55:48 +00:00
$ { p r i v a t e _ i n c l u d e s }
P U B L I C _ I N C L U D E _ D I R E C T O R I E S
$ { p u b l i c _ i n c l u d e s }
2018-10-24 13:20:27 +00:00
P U B L I C _ D E F I N E S
2018-12-07 12:13:24 +00:00
$ { a r g _ P U B L I C _ D E F I N E S }
2019-06-05 09:31:55 +00:00
Q T _ $ { m o d u l e _ d e f i n e } _ L I B
2018-10-24 13:20:27 +00:00
D E F I N E S
2018-12-07 12:13:24 +00:00
$ { a r g _ D E F I N E S }
2018-10-24 13:20:27 +00:00
Q T _ N O _ C A S T _ T O _ A S C I I Q T _ A S C I I _ C A S T _ W A R N I N G S
Q T _ M O C _ C O M P A T #we don't need warnings from calling moc code in our generated code
Q T _ U S E _ Q S T R I N G B U I L D E R
Q T _ D E P R E C A T E D _ W A R N I N G S
Q T _ B U I L D I N G _ Q T
2019-06-05 09:31:55 +00:00
Q T _ B U I L D _ $ { m o d u l e _ d e f i n e } _ L I B ### FIXME: use QT_BUILD_ADDON for Add-ons or remove if we don't have add-ons anymore
2018-10-24 13:20:27 +00:00
" $ { d e p r e c a t i o n _ d e f i n e } "
2018-12-11 10:38:20 +00:00
P U B L I C _ L I B R A R I E S $ { a r g _ P U B L I C _ L I B R A R I E S }
2019-06-05 14:05:50 +00:00
L I B R A R I E S $ { a r g _ L I B R A R I E S } Q t : : P l a t f o r m M o d u l e I n t e r n a l
2020-01-31 21:21:09 +00:00
P R I V A T E _ M O D U L E _ I N T E R F A C E $ { a r g _ P R I V A T E _ M O D U L E _ I N T E R F A C E }
2018-12-11 10:38:20 +00:00
F E A T U R E _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
D B U S _ A D A P T O R _ S O U R C E S $ { a r g _ D B U S _ A D A P T O R _ S O U R C E S }
D B U S _ A D A P T O R _ F L A G S $ { a r g _ D B U S _ A D A P T O R _ F L A G S }
D B U S _ I N T E R F A C E _ S O U R C E S $ { a r g _ D B U S _ I N T E R F A C E _ S O U R C E S }
D B U S _ I N T E R F A C E _ F L A G S $ { a r g _ D B U S _ I N T E R F A C E _ F L A G S }
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
P U B L I C _ C O M P I L E _ O P T I O N S $ { a r g _ P U B L I C _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
P U B L I C _ L I N K _ O P T I O N S $ { a r g _ P U B L I C _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2019-05-22 13:09:39 +00:00
E N A B L E _ A U T O G E N _ T O O L S $ { a r g _ E N A B L E _ A U T O G E N _ T O O L S }
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
2019-07-05 08:47:26 +00:00
P R E C O M P I L E D _ H E A D E R $ { a r g _ P R E C O M P I L E D _ H E A D E R }
N O _ P C H _ S O U R C E S $ { a r g _ N O _ P C H _ S O U R C E S }
2018-10-24 13:20:27 +00:00
)
2019-08-19 13:07:22 +00:00
if ( NOT ${ arg_EXCEPTIONS } AND NOT ${ arg_HEADER_MODULE } )
2019-06-04 13:55:41 +00:00
qt_internal_set_no_exceptions_flags ( "${target}" )
endif ( )
2019-06-03 15:41:45 +00:00
2018-12-11 10:38:20 +00:00
set ( configureFile "${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake" )
2020-02-24 13:10:08 +00:00
if ( EXISTS "${configureFile}" AND NOT arg_NO_CONFIG_HEADER_FILE )
2018-12-11 10:38:20 +00:00
qt_feature_module_begin (
L I B R A R Y " $ { t a r g e t } "
P U B L I C _ F I L E " q t $ { a r g _ C O N F I G _ M O D U L E _ N A M E } - c o n f i g . h "
P R I V A T E _ F I L E " q t $ { a r g _ C O N F I G _ M O D U L E _ N A M E } - c o n f i g _ p . h "
P U B L I C _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
P R I V A T E _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
)
include ( ${ configureFile } )
qt_feature_module_end ( "${target}" )
set_property ( TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qt${arg_CONFIG_MODULE_NAME}-config.h" )
set_property ( TARGET "${target}" APPEND PROPERTY PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qt${arg_CONFIG_MODULE_NAME}-config_p.h" )
2018-10-24 13:20:27 +00:00
endif ( )
2019-11-04 12:53:35 +00:00
if ( NOT arg_HEADER_MODULE )
if ( DEFINED module_headers_private )
qt_internal_add_linker_version_script ( "${target}" PRIVATE_HEADERS ${ module_headers_private } ${ module_headers_qpa } )
else ( )
qt_internal_add_linker_version_script ( "${target}" )
endif ( )
2018-10-24 13:20:27 +00:00
endif ( )
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
# Handle injections. Aka create forwarding headers for certain headers that have been
# automatically generated in the build dir (for example qconfig.h, qtcore-config.h,
# qvulkanfunctions.h, etc)
# module_headers_injections come from the qt_read_headers_pri() call.
# extra_library_injections come from the qt_feature_module_end() call.
set ( final_injections "" )
if ( module_headers_injections )
string ( APPEND final_injections "${module_headers_injections} " )
endif ( )
if ( extra_library_injections )
string ( APPEND final_injections "${extra_library_injections} " )
endif ( )
2018-10-24 13:20:27 +00:00
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
if ( final_injections )
2019-12-02 10:10:05 +00:00
qt_install_injections ( ${ target } "${QT_BUILD_DIR}" "${QT_INSTALL_DIR}" ${ final_injections } )
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
endif ( )
# Handle creation of cmake files for consumers of find_package().
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 } )
2019-05-03 10:30:09 +00:00
2019-02-12 11:21:56 +00:00
set ( extra_cmake_files )
set ( extra_cmake_includes )
if ( EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake" )
list ( APPEND extra_cmake_files "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake" )
list ( APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake" )
endif ( )
if ( EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in" )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in"
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
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g E x t r a s . c m a k e "
2019-02-12 11:21:56 +00:00
@ O N L Y )
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
list ( APPEND extra_cmake_files "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake" )
2019-02-12 11:21:56 +00:00
list ( APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake" )
endif ( )
2019-08-19 14:19:08 +00:00
foreach ( cmake_file IN LISTS arg_EXTRA_CMAKE_FILES )
get_filename_component ( basename ${ cmake_file } NAME )
file ( COPY ${ cmake_file } DESTINATION ${ config_build_dir } )
list ( APPEND extra_cmake_files "${config_build_dir}/${basename}" )
endforeach ( )
list ( APPEND extra_cmake_includes ${ arg_EXTRA_CMAKE_INCLUDES } )
2019-05-03 14:03:15 +00:00
set ( extra_cmake_code "" )
2019-05-16 09:34:06 +00:00
2019-05-03 14:03:15 +00:00
if ( target STREQUAL Core )
# Propagate non-build related variables that are needed for consuming Qt packages.
2019-06-14 10:59:07 +00:00
# Do this in CoreConfig instead of Qt6Config, so that consumers can also use
# find_package(Qt6Core) instead of find_package(Qt6 COMPONENTS Core)
2019-05-03 14:03:15 +00:00
string ( APPEND extra_cmake_code "
2019-05-16 09:34:06 +00:00
set ( QT_CMAKE_EXPORT_NAMESPACE ${ QT_CMAKE_EXPORT_NAMESPACE } ) " )
2019-05-03 14:03:15 +00:00
endif ( )
2019-05-16 09:34:06 +00:00
2020-01-27 13:56:40 +00:00
# Generate metatypes
set ( QT_MODULE_HAS_META_TYPES_FILE FALSE )
if ( ${ arg_GENERATE_METATYPES } )
set ( QT_MODULE_HAS_META_TYPES_FILE TRUE )
set ( metatypes_install_dir ${ INSTALL_LIBDIR } /metatypes )
set ( args )
if ( NOT QT_WILL_INSTALL )
set ( args COPY_OVER_INSTALL INSTALL_DIR "${QT_BUILD_DIR}/${metatypes_install_dir}" )
else ( )
set ( args INSTALL_DIR "${metatypes_install_dir}" )
endif ( )
qt6_generate_meta_types_json_file ( ${ target } ${ args } )
endif ( )
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
configure_package_config_file (
" $ { Q T _ C M A K E _ D I R } / Q t M o d u l e C o n f i g . c m a k e . i n "
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
I N S T A L L _ D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
)
2020-02-05 16:35:49 +00:00
if ( EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}BuildInternals.cmake" )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}BuildInternals.cmake"
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } B u i l d I n t e r n a l s . c m a k e "
@ O N L Y )
list ( APPEND extra_cmake_files "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}BuildInternals.cmake" )
endif ( )
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
write_basic_package_version_file (
2019-05-03 14:03:15 +00:00
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
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
V E R S I O N $ { P R O J E C T _ V E R S I O N }
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n
)
qt_install ( FILES
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
$ { e x t r a _ c m a k e _ f i l e s }
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
C O M P O N E N T D e v e l
)
2019-06-06 12:29:31 +00:00
file ( COPY ${ extra_cmake_files } DESTINATION "${config_build_dir}" )
2019-08-19 13:07:22 +00:00
set ( exported_targets ${ target } )
if ( NOT ${ arg_NO_PRIVATE_MODULE } )
list ( APPEND exported_targets ${ target_private } )
endif ( )
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 ( export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets" )
qt_install ( TARGETS ${ exported_targets }
E X P O R T $ { e x p o r t _ n a m e }
2019-06-04 11:40:57 +00:00
R U N T I M E D E S T I N A T I O N $ { I N S T A L L _ B I N D I R }
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
L I B R A R Y D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
A R C H I V E D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
2019-12-02 10:10:05 +00:00
F R A M E W O R K D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
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
P U B L I C _ H E A D E R D E S T I N A T I O N $ { I N S T A L L _ I N C L U D E D I R } / $ { m o d u l e }
P R I V A T E _ H E A D E R D E S T I N A T I O N $ { I N S T A L L _ I N C L U D E D I R } / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } / p r i v a t e
)
2019-06-24 12:54:40 +00:00
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
qt_apply_rpaths ( TARGET "${target}" INSTALL_PATH "${INSTALL_LIBDIR}" RELATIVE_RPATH )
2019-11-04 13:42:59 +00:00
if ( ANDROID AND NOT arg_HEADER_MODULE )
2019-06-24 12:54:40 +00:00
# Record install library location so it can be accessed by
# qt_android_dependencies without having to specify it again.
set_target_properties ( ${ target } PROPERTIES
Q T _ A N D R O I D _ M O D U L E _ I N S T A L L _ D I R $ { I N S T A L L _ L I B D I R } )
endif ( )
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
qt_install ( EXPORT ${ export_name }
N A M E S P A C E $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : :
D E S T I N A T I O N $ { c o n f i g _ i n s t a l l _ d i r } )
qt_internal_export_modern_cmake_config_targets_file (
T A R G E T S $ { e x p o r t e d _ t a r g e t s }
E X P O R T _ N A M E _ P R E F I X $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t }
C O N F I G _ I N S T A L L _ D I R " $ { c o n f i g _ i n s t a l l _ d i r } " )
2019-06-05 11:49:08 +00:00
if ( ${ arg_INTERNAL_MODULE } )
set ( arg_INTERNAL_MODULE "INTERNAL_MODULE" )
else ( )
unset ( arg_INTERNAL_MODULE )
endif ( )
2018-10-24 13:20:27 +00:00
### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
# that belong to Qt.
2019-08-19 13:07:22 +00:00
if ( NOT arg_HEADER_MODULE )
qt_internal_add_link_flags_no_undefined ( "${target}" )
endif ( )
2018-10-24 13:20:27 +00:00
2019-09-02 09:26:12 +00:00
set ( interface_includes "" )
2019-02-12 19:17:57 +00:00
2019-09-02 09:26:12 +00:00
# Handle cases like QmlDevTools which do not have their own headers, but rather borrow them
# from another module.
if ( NOT arg_NO_SYNC_QT )
2020-02-06 12:04:45 +00:00
list ( APPEND interface_includes "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>" )
2019-09-02 09:26:12 +00:00
2020-02-24 15:52:36 +00:00
# syncqt.pl does not create a private header directory like 'include/6.0/QtFoo' unless
# the module has foo_p.h header files. For QtZlib, there are no such private headers, so we
# need to make sure not to add such include paths unless the directory exists, otherwise
# consumers of the module will fail at CMake generation time stating that
# INTERFACE_INCLUDE_DIRECTORIES contains a non-existent path.
if ( NOT arg_NO_MODULE_HEADERS
A N D E X I S T S " $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } " )
2020-02-06 12:04:45 +00:00
list ( APPEND interface_includes
" $ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } > "
" $ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } > " )
2019-12-02 10:10:05 +00:00
if ( is_framework )
set ( fw_headers_dir
" $ { I N S T A L L _ L I B D I R } / $ { m o d u l e } . f r a m e w o r k / H e a d e r s / " )
list ( APPEND interface_includes
" $ < I N S T A L L _ I N T E R F A C E : $ { f w _ h e a d e r s _ d i r } $ { P R O J E C T _ V E R S I O N } > "
" $ < I N S T A L L _ I N T E R F A C E : $ { f w _ h e a d e r s _ d i r } $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } > " )
else ( )
list ( APPEND interface_includes
2020-01-26 11:25:40 +00:00
" $ < I N S T A L L _ I N T E R F A C E : $ { I N S T A L L _ I N C L U D E D I R } / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } > "
" $ < I N S T A L L _ I N T E R F A C E : $ { I N S T A L L _ I N C L U D E D I R } / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } > " )
2019-12-02 10:10:05 +00:00
endif ( )
2019-09-02 09:26:12 +00:00
endif ( )
2019-06-05 08:51:45 +00:00
endif ( )
2019-08-19 13:07:22 +00:00
if ( NOT ${ arg_NO_PRIVATE_MODULE } )
target_include_directories ( "${target_private}" INTERFACE ${ interface_includes } )
2020-03-13 15:51:45 +00:00
target_link_libraries ( "${target_private}" INTERFACE "${target}" )
2019-08-19 13:07:22 +00:00
endif ( )
2019-09-24 09:42:15 +00:00
2019-12-02 10:10:05 +00:00
if ( is_framework AND NOT is_interface_lib )
qt_finalize_framework_headers_copy ( ${ target } )
endif ( )
2019-09-24 09:42:15 +00:00
qt_describe_module ( ${ target } )
2020-05-18 19:56:12 +00:00
qt_add_list_file_finalizer ( qt_finalize_module ${ target } ${ arg_INTERNAL_MODULE } ${ header_module } )
endfunction ( )
function ( qt_finalize_module target )
2020-06-10 11:04:13 +00:00
# Workaround to allow successful configuration of static top-level Qt builds.
# See QTBUG-84874.
if ( QT_SUPERBUILD AND NOT BUILD_SHARED_LIBS )
# Do nothing.
else ( )
qt_generate_prl_file ( ${ target } )
endif ( )
2020-05-18 19:56:12 +00:00
qt_generate_module_pri_file ( "${target}" ${ ARGN } )
2020-03-12 15:16:55 +00:00
endfunction ( )
# Add libraries to variable ${out_libs_var} in a way that duplicates
# are added at the end. This ensures the library order needed for the
# linker.
function ( qt_merge_libs out_libs_var )
foreach ( dep ${ ARGN } )
list ( REMOVE_ITEM ${ out_libs_var } ${ dep } )
list ( APPEND ${ out_libs_var } ${ dep } )
endforeach ( )
set ( ${ out_libs_var } ${ ${out_libs_var } } PARENT_SCOPE )
endfunction ( )
# Collects the library dependencies of a target.
# This takes into account transitive usage requirements.
function ( qt_collect_libs target out_var )
set ( collected ${ ARGN } )
if ( target IN_LIST collected )
return ( )
endif ( )
list ( APPEND collected ${ target } )
if ( NOT TARGET qt_collect_libs_dict )
add_library ( qt_collect_libs_dict INTERFACE IMPORTED GLOBAL )
endif ( )
get_target_property ( libs qt_collect_libs_dict INTERFACE_ ${ target } )
if ( NOT libs )
unset ( libs )
get_target_property ( target_libs ${ target } INTERFACE_LINK_LIBRARIES )
if ( NOT target_libs )
unset ( target_libs )
endif ( )
get_target_property ( target_type ${ target } TYPE )
if ( target_type STREQUAL "STATIC_LIBRARY" )
get_target_property ( link_libs ${ target } LINK_LIBRARIES )
if ( link_libs )
list ( APPEND target_libs ${ link_libs } )
endif ( )
endif ( )
foreach ( lib ${ target_libs } )
# Cannot use $<TARGET_POLICY:...> in add_custom_command.
# Check the policy now, and replace the generator expression with the value.
while ( lib MATCHES "\\$<TARGET_POLICY:([^>]+)>" )
cmake_policy ( GET ${ CMAKE_MATCH_1 } value )
if ( value STREQUAL "NEW" )
set ( value "TRUE" )
else ( )
set ( value "FALSE" )
endif ( )
string ( REPLACE "${CMAKE_MATCH_0}" "${value}" lib "${lib}" )
endwhile ( )
# Fix up $<TARGET_PROPERTY:FOO> expressions that refer to the "current" target.
# Those cannot be used with add_custom_command.
while ( lib MATCHES "\\$<TARGET_PROPERTY:([^,>]+)>" )
string ( REPLACE "${CMAKE_MATCH_0}" "$<TARGET_PROPERTY:${target},${CMAKE_MATCH_1}>"
l i b " $ { l i b } " )
endwhile ( )
if ( lib MATCHES "^\\$<TARGET_OBJECTS:" )
# Skip object files.
continue ( )
elseif ( lib MATCHES "^\\$<LINK_ONLY:(.*)>$" )
set ( lib_target ${ CMAKE_MATCH_1 } )
else ( )
set ( lib_target ${ lib } )
endif ( )
if ( TARGET ${ lib_target } )
if ( "${lib_target}" MATCHES "^Qt::(.*)" )
# If both, Qt::Foo and Foo targets exist, prefer the target name without
# namespace. Which one is preferred doesn't really matter. This code exists to
# avoid ending up with both, Qt::Foo and Foo in our dependencies.
set ( namespaceless_lib_target "${CMAKE_MATCH_1}" )
if ( TARGET namespaceless_lib_target )
set ( lib_target ${ namespaceless_lib_target } )
endif ( )
endif ( )
get_target_property ( lib_target_type ${ lib_target } TYPE )
if ( lib_target_type STREQUAL "INTERFACE_LIBRARY" )
qt_collect_libs ( ${ lib_target } lib_libs ${ collected } )
if ( lib_libs )
qt_merge_libs ( libs ${ lib_libs } )
set ( is_module 0 )
endif ( )
else ( )
qt_merge_libs ( libs "$<TARGET_FILE:${lib_target}>" )
qt_collect_libs ( ${ lib_target } lib_libs ${ collected } )
if ( lib_libs )
qt_merge_libs ( libs ${ lib_libs } )
endif ( )
endif ( )
else ( )
2020-06-03 16:36:48 +00:00
set ( final_lib_name_to_merge "${lib_target}" )
if ( lib_target MATCHES "/([^/]+).framework$" )
set ( final_lib_name_to_merge "-framework ${CMAKE_MATCH_1}" )
endif ( )
qt_merge_libs ( libs "${final_lib_name_to_merge}" )
2020-03-12 15:16:55 +00:00
endif ( )
endforeach ( )
set_target_properties ( qt_collect_libs_dict PROPERTIES INTERFACE_ ${ target } "${libs}" )
endif ( )
set ( ${ out_var } ${ libs } PARENT_SCOPE )
endfunction ( )
# Generate a qmake .prl file for the given target
function ( qt_generate_prl_file target )
get_target_property ( target_type ${ target } TYPE )
if ( target_type STREQUAL "INTERFACE_LIBRARY" )
return ( )
endif ( )
unset ( prl_libs )
qt_collect_libs ( ${ target } prl_libs )
unset ( prl_config )
if ( target_type STREQUAL "STATIC_LIBRARY" )
list ( APPEND prl_config static )
elseif ( target_type STREQUAL "SHARED_LIBRARY" )
list ( APPEND prl_config shared )
endif ( )
if ( NOT target_type STREQUAL "INTERFACE_LIBRARY" )
get_target_property ( is_fw ${ target } FRAMEWORK )
if ( is_fw )
list ( APPEND prl_config lib_bundle )
endif ( )
endif ( )
list ( JOIN prl_config " " prl_config )
# Generate a preliminary .prl file that contains absolute paths to all libraries
set ( prl_file_name "$<TARGET_FILE_PREFIX:${target}>$<TARGET_FILE_BASE_NAME:${target}>.prl" )
file ( GENERATE
O U T P U T " $ { p r l _ f i l e _ n a m e } "
C O N T E N T
" Q M A K E _ P R L _ B U I L D _ D I R = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
Q M A K E _ P R L _ T A R G E T = $ < T A R G E T _ F I L E _ N A M E : $ { t a r g e t } >
Q M A K E _ P R L _ C O N F I G = $ { p r l _ c o n f i g }
Q M A K E _ P R L _ V E R S I O N = $ { P R O J E C T _ V E R S I O N }
Q M A K E _ P R L _ L I B S _ F O R _ C M A K E = $ { p r l _ l i b s }
"
)
# Add a custom command that prepares the .prl file for installation
qt_path_join ( qt_build_libdir ${ QT_BUILD_DIR } ${ INSTALL_LIBDIR } )
qt_path_join ( prl_file_path "${qt_build_libdir}" "${prl_file_name}" )
set ( library_suffixes ${ CMAKE_SHARED_LIBRARY_SUFFIX } ${ CMAKE_STATIC_LIBRARY_SUFFIX } )
add_custom_command (
T A R G E T $ { t a r g e t } P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D } - D I N _ F I L E = $ { p r l _ f i l e _ n a m e } - D O U T _ F I L E = $ { p r l _ f i l e _ p a t h }
" - D L I B R A R Y _ S U F F I X E S = $ { l i b r a r y _ s u f f i x e s } "
- D Q T _ B U I L D _ L I B D I R = $ { q t _ b u i l d _ l i b d i r }
- P " $ { Q T _ C M A K E _ D I R } / Q t F i n i s h P r l F i l e . c m a k e "
V E R B A T I M
)
2019-11-26 09:10:55 +00:00
2020-03-12 15:16:55 +00:00
# Installation of the .prl file happens globally elsewhere,
# because we have no clue here what the actual file name is.
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
endfunction ( )
function ( qt_export_tools module_name )
2020-04-27 13:04:57 +00:00
# Bail out when cross-compiling, unless QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is on.
if ( CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
return ( )
endif ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
2020-04-27 13:04:57 +00:00
# If no tools were defined belonging to this module, don't create a config and targets file.
if ( NOT "${module_name}" IN_LIST QT_KNOWN_MODULES_WITH_TOOLS )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
return ( )
endif ( )
# The tools target name. For example: CoreTools
set ( target "${module_name}Tools" )
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 ( 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 } )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
# Add the extra cmake statements to make the tool targets global, so it doesn't matter where
# find_package is called.
# Also assemble a list of tool targets to expose in the config file for informational purposes.
set ( extra_cmake_statements "" )
set ( tool_targets "" )
2019-12-05 12:54:07 +00:00
set ( tool_targets_non_prefixed "" )
2019-11-15 15:28:17 +00:00
# List of package dependencies that need be find_package'd when using the Tools package.
set ( package_deps "" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
foreach ( tool_name ${ QT_KNOWN_MODULE_${module_name } _TOOLS} )
2019-11-15 15:28:17 +00:00
# Specific tools can have package dependencies.
# e.g. qtwaylandscanner depends on WaylandScanner (non-qt package).
get_target_property ( extra_packages "${tool_name}" QT_EXTRA_PACKAGE_DEPENDENCIES )
if ( extra_packages )
list ( APPEND package_deps "${extra_packages}" )
endif ( )
2020-04-27 13:04:57 +00:00
if ( CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
string ( REGEX REPLACE "_native$" "" tool_name ${ tool_name } )
endif ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
set ( extra_cmake_statements " ${ extra_cmake_statements }
2019-06-11 13:46:31 +00:00
if ( NOT QT_NO_CREATE_TARGETS )
get_property ( is_global TARGET ${ INSTALL_CMAKE_NAMESPACE } :: ${ tool_name } PROPERTY IMPORTED_GLOBAL )
if ( NOT is_global )
set_property ( TARGET ${ INSTALL_CMAKE_NAMESPACE } :: ${ tool_name } PROPERTY IMPORTED_GLOBAL TRUE )
endif ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
endif ( )
" )
list ( APPEND tool_targets "${QT_CMAKE_EXPORT_NAMESPACE}::${tool_name}" )
2019-12-05 12:54:07 +00:00
list ( APPEND tool_targets_non_prefixed "${tool_name}" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
endforeach ( )
string ( APPEND extra_cmake_statements
" set ( ${ QT_CMAKE_EXPORT_NAMESPACE } ${ module_name } Tools_TARGETS \"${tool_targets}\")")
2019-11-15 15:28:17 +00:00
# Extract package dependencies that were determined in QtPostProcess, but only if ${module_name}
# is an actual target.
# module_name can be a non-existent target, if the tool doesn't have an existing associated
# module, e.g. qtwaylandscanner.
if ( TARGET "${module_name}" )
get_target_property ( module_package_deps "${module_name}" _qt_tools_package_deps )
if ( module_package_deps )
list ( APPEND package_deps "${module_package_deps}" )
endif ( )
endif ( )
# Configure and install dependencies file for the ${module_name}Tools package.
configure_file (
" $ { Q T _ C M A K E _ D I R } / Q t M o d u l e T o o l s D e p e n d e n c i e s . c m a k e . i n "
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } D e p e n d e n c i e s . c m a k e "
@ O N L Y
)
qt_install ( FILES
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } D e p e n d e n c i e s . c m a k e "
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
C O M P O N E N T D e v e l
)
# Configure and install the ${module_name}Tools package Config file.
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
configure_package_config_file (
" $ { Q T _ C M A K E _ D I R } / Q t M o d u l e T o o l s C o n f i g . c m a k e . i n "
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
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
I N S T A L L _ D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
)
write_basic_package_version_file (
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
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
V E R S I O N $ { P R O J E C T _ V E R S I O N }
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n
)
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
qt_install ( FILES
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
C O M P O N E N T D e v e l
)
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 ( export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets" )
qt_install ( EXPORT "${export_name}"
N A M E S P A C E " $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : "
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } " )
2019-12-05 12:54:07 +00:00
# Create versionless targets file.
configure_file (
" $ { Q T _ C M A K E _ D I R } / Q t M o d u l e T o o l s V e r s i o n l e s s T a r g e t s . c m a k e . i n "
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } V e r s i o n l e s s T a r g e t s . c m a k e "
@ O N L Y
)
qt_install ( FILES
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } V e r s i o n l e s s T a r g e t s . c m a k e "
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
C O M P O N E N T D e v e l
)
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-11-15 15:28:17 +00:00
# This function records a dependency between ${target_name} and ${dep_package_name}.
# at the CMake package level.
# E.g. The Tools package that provides the qtwaylandscanner target
# needs to call find_package(WaylandScanner) (non-qt-package).
# main_target_name = qtwaylandscanner
# dep_package_name = WaylandScanner
function ( qt_record_extra_package_dependency main_target_name dep_package_name dep_package_version )
2020-04-02 12:56:37 +00:00
if ( TARGET "${main_target_name}" )
get_target_property ( extra_packages "${main_target_name}" QT_EXTRA_PACKAGE_DEPENDENCIES )
if ( NOT extra_packages )
set ( extra_packages "" )
endif ( )
2019-11-15 15:28:17 +00:00
2020-04-02 12:56:37 +00:00
list ( APPEND extra_packages "${dep_package_name}\;${dep_package_version}" )
set_target_properties ( "${main_target_name}" PROPERTIES QT_EXTRA_PACKAGE_DEPENDENCIES
" $ { e x t r a _ p a c k a g e s } " )
endif ( )
2019-11-15 15:28:17 +00:00
endfunction ( )
# This function records a dependency between ${main_target_name} and ${dep_target_name}
# at the CMake package level.
# E.g. Qt6CoreConfig.cmake needs to find_package(Qt6WinMain).
# main_target_name = Core
# dep_target_name = WinMain
# This is just a convenience function that deals with Qt targets and their associated packages
# instead of raw package names.
function ( qt_record_extra_qt_package_dependency main_target_name dep_target_name
d e p _ p a c k a g e _ v e r s i o n )
# WinMain -> Qt6WinMain.
qt_internal_module_info ( qtfied_target_name "${dep_target_name}" )
qt_record_extra_package_dependency ( "${main_target_name}" "${qtfied_target_name_versioned}"
" $ { d e p _ p a c k a g e _ v e r s i o n } " )
endfunction ( )
2019-03-26 12:32:34 +00:00
function ( qt_internal_check_directory_or_type name dir type default result_var )
if ( "x${dir}" STREQUAL x )
if ( "x${type}" STREQUAL x )
2020-04-21 11:28:57 +00:00
message ( FATAL_ERROR "qt_internal_add_plugin called without setting either TYPE or ${name}." )
2019-03-26 12:32:34 +00:00
endif ( )
set ( ${ result_var } "${default}" PARENT_SCOPE )
else ( )
set ( ${ result_var } "${dir}" PARENT_SCOPE )
endif ( )
endfunction ( )
2019-05-03 14:03:15 +00:00
# Utility function to find the module to which a plug-in belongs.
# This will set the QT_MODULE target property on the plug-in - e.g. "Gui", "Sql"...
function ( qt_get_module_for_plugin target target_type )
2019-08-20 13:24:14 +00:00
qt_internal_get_qt_all_known_modules ( known_modules )
2019-11-15 14:43:20 +00:00
qt_get_sanitized_plugin_type ( "${target_type}" target_type )
2019-08-15 17:12:31 +00:00
foreach ( qt_module ${ known_modules } )
2019-08-28 09:54:25 +00:00
get_target_property ( module_type "${QT_CMAKE_EXPORT_NAMESPACE}::${qt_module}" TYPE )
# Assuming interface libraries can't have plugins. Otherwise we'll need to fix the property
# name, because the current one would be invalid for interface libraries.
if ( module_type STREQUAL "INTERFACE_LIBRARY" )
continue ( )
endif ( )
2019-08-15 17:12:31 +00:00
get_target_property ( plugin_types
" $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : $ { q t _ m o d u l e } "
M O D U L E _ P L U G I N _ T Y P E S )
2019-05-03 14:03:15 +00:00
if ( plugin_types )
foreach ( plugin_type ${ plugin_types } )
if ( "${target_type}" STREQUAL "${plugin_type}" )
set_target_properties ( "${target}" PROPERTIES QT_MODULE "${qt_module}" )
return ( )
endif ( )
endforeach ( )
endif ( )
endforeach ( )
message ( AUTHOR_WARNING "The plug-in '${target}' does not belong to any Qt module." )
endfunction ( )
2019-07-18 07:38:37 +00:00
2019-11-13 13:03:20 +00:00
# Collection of qt_add_plugin arguments so they can be shared across different
2019-07-18 07:38:37 +00:00
# plugin type wrappers
2019-11-13 13:03:20 +00:00
set ( __qt_add_plugin_optional_args
2019-10-21 09:31:28 +00:00
" S T A T I C ; E X C E P T I O N S ; A L L O W _ U N D E F I N E D _ S Y M B O L S "
2019-07-18 07:38:37 +00:00
)
2019-11-13 13:03:20 +00:00
set ( __qt_add_plugin_single_args
2020-01-22 13:22:19 +00:00
" T Y P E ; C L A S S _ N A M E ; O U T P U T _ D I R E C T O R Y ; I N S T A L L _ D I R E C T O R Y ; A R C H I V E _ I N S T A L L _ D I R E C T O R Y ; Q M L _ T A R G E T _ P A T H ; O U T P U T _ N A M E "
2020-05-12 09:29:56 +00:00
$ { _ _ d e f a u l t _ t a r g e t _ i n f o _ a r g s }
2019-07-18 07:38:37 +00:00
)
2019-11-13 13:03:20 +00:00
set ( __qt_add_plugin_multi_args
2019-07-18 07:38:37 +00:00
" $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } ; D E F A U L T _ I F "
)
2018-10-24 13:20:27 +00:00
# This is the main entry point for defining Qt plugins.
2018-12-11 10:38:20 +00:00
# A CMake target is created with the given target. The TYPE parameter is needed to place the
2018-10-24 13:20:27 +00:00
# plugin into the correct plugins/ sub-directory.
2020-04-21 11:28:57 +00:00
function ( qt_internal_add_plugin target )
2018-12-11 10:38:20 +00:00
qt_internal_module_info ( module "${target}" )
2018-10-24 13:20:27 +00:00
2019-05-03 14:03:15 +00:00
qt_internal_set_qt_known_plugins ( "${QT_KNOWN_PLUGINS}" "${target}" )
2020-04-21 11:28:57 +00:00
qt_parse_all_arguments ( arg "qt_internal_add_plugin"
2019-11-13 13:03:20 +00:00
" $ { _ _ q t _ a d d _ p l u g i n _ o p t i o n a l _ a r g s } ; S K I P _ I N S T A L L "
" $ { _ _ q t _ a d d _ p l u g i n _ s i n g l e _ a r g s } "
" $ { _ _ q t _ a d d _ p l u g i n _ m u l t i _ a r g s } "
2019-07-18 07:38:37 +00:00
" $ { A R G N } "
)
2019-03-26 12:32:34 +00:00
2020-04-01 16:14:15 +00:00
qt_get_sanitized_plugin_type ( "${arg_TYPE}" plugin_type_escaped )
2019-04-08 15:23:57 +00:00
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 ( output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${arg_TYPE}" )
2019-06-05 11:39:41 +00:00
set ( install_directory_default "${INSTALL_PLUGINSDIR}/${arg_TYPE}" )
if ( arg_QML_TARGET_PATH )
set ( target_path "${arg_QML_TARGET_PATH}" )
set ( output_directory_default "${QT_BUILD_DIR}/${INSTALL_QMLDIR}/${target_path}" )
set ( install_directory_default "${INSTALL_QMLDIR}/${target_path}" )
endif ( )
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
2020-01-22 13:22:19 +00:00
# Derive the class name from the target name if it's not explicitly specified.
# Don't set it for qml plugins though.
set ( plugin_class_name "" )
2020-04-28 12:07:29 +00:00
if ( NOT "${plugin_type_escaped}" STREQUAL "qml_plugin" )
if ( NOT arg_CLASS_NAME )
set ( plugin_class_name "${target}" )
else ( )
set ( plugin_class_name "${arg_CLASS_NAME}" )
endif ( )
2019-05-03 14:03:15 +00:00
endif ( )
2019-03-26 12:32:34 +00:00
qt_internal_check_directory_or_type ( OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" "${arg_TYPE}"
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
" $ { o u t p u t _ d i r e c t o r y _ d e f a u l t } " o u t p u t _ d i r e c t o r y )
2019-10-10 15:02:59 +00:00
if ( NOT arg_SKIP_INSTALL )
qt_internal_check_directory_or_type ( INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" "${arg_TYPE}"
" $ { i n s t a l l _ d i r e c t o r y _ d e f a u l t } " i n s t a l l _ d i r e c t o r y )
2020-06-10 12:24:53 +00:00
set ( archive_install_directory ${ arg_ARCHIVE_INSTALL_DIRECTORY } )
if ( NOT archive_install_directory AND install_directory )
set ( archive_install_directory "${install_directory}" )
2019-10-10 15:02:59 +00:00
endif ( )
2019-10-10 12:21:02 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
2019-06-07 07:13:31 +00:00
if ( arg_STATIC OR NOT BUILD_SHARED_LIBS )
2019-03-26 12:32:34 +00:00
add_library ( "${target}" STATIC )
else ( )
2019-06-04 12:38:24 +00:00
add_library ( "${target}" MODULE )
2019-06-24 13:07:07 +00:00
if ( APPLE )
# CMake defaults to using .so extensions for loadable modules, aka plugins,
# but Qt plugins are actually suffixed with .dylib.
set_property ( TARGET "${target}" PROPERTY SUFFIX ".dylib" )
endif ( )
2020-05-29 10:08:01 +00:00
if ( WIN32 )
# CMake sets for Windows-GNU platforms the suffix "lib"
set_property ( TARGET "${target}" PROPERTY PREFIX "" )
endif ( )
2019-03-26 12:32:34 +00:00
endif ( )
2019-08-30 09:34:23 +00:00
2020-04-17 15:12:40 +00:00
qt_set_common_target_properties ( ${ target } )
2020-05-12 09:29:56 +00:00
qt_set_target_info_properties ( ${ target } ${ ARGN } TARGET_VERSION "${arg_VERSION}" )
2020-04-17 15:12:40 +00:00
2020-01-22 13:22:19 +00:00
# Make sure the Qt6 plugin library names are like they were in Qt5 qmake land.
# Whereas the Qt6 CMake target names are like the Qt5 CMake target names.
set ( output_name "${target}" )
if ( arg_OUTPUT_NAME )
set ( output_name "${arg_OUTPUT_NAME}" )
endif ( )
set_property ( TARGET "${target}" PROPERTY OUTPUT_NAME "${output_name}" )
# Add a custom target with the Qt5 qmake name for a more user friendly ninja experience.
2020-01-27 14:03:08 +00:00
if ( arg_OUTPUT_NAME AND NOT TARGET "${output_name}" )
2020-01-22 13:22:19 +00:00
add_custom_target ( "${output_name}" )
add_dependencies ( "${output_name}" "${target}" )
endif ( )
2019-08-30 09:34:23 +00:00
if ( ANDROID )
qt_android_apply_arch_suffix ( "${target}" )
2019-10-22 14:19:13 +00:00
set_target_properties ( ${ target }
P R O P E R T I E S
2020-01-22 13:22:19 +00:00
L I B R A R Y _ O U T P U T _ N A M E " p l u g i n s _ $ { a r g _ T Y P E } _ $ { o u t p u t _ n a m e } "
2019-10-22 14:19:13 +00:00
)
2019-08-30 09:34:23 +00:00
endif ( )
2018-12-11 10:38:20 +00:00
qt_internal_add_target_aliases ( "${target}" )
2019-10-15 09:10:08 +00:00
qt_skip_warnings_are_errors_when_repo_unclean ( "${target}" )
2018-10-24 13:20:27 +00:00
2019-11-21 12:33:28 +00:00
# Disable linking of plugins against other plugins during static regular and
# super builds. The latter causes cyclic dependencies otherwise.
set_target_properties ( ${ target } PROPERTIES QT_DEFAULT_PLUGINS 0 )
2018-12-11 10:38:20 +00:00
set_target_properties ( "${target}" PROPERTIES
2019-03-26 12:32:34 +00:00
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { o u t p u t _ d i r e c t o r y } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { o u t p u t _ d i r e c t o r y } "
2019-05-03 14:03:15 +00:00
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { o u t p u t _ d i r e c t o r y } "
2020-05-12 06:21:03 +00:00
Q T _ P L U G I N _ T Y P E " $ { p l u g i n _ t y p e _ e s c a p e d } "
2020-01-22 13:22:19 +00:00
Q T _ P L U G I N _ C L A S S _ N A M E " $ { p l u g i n _ c l a s s _ n a m e } " )
2019-12-06 14:12:17 +00:00
qt_handle_multi_config_output_dirs ( "${target}" )
2018-10-24 13:20:27 +00:00
qt_internal_library_deprecation_level ( deprecation_define )
2019-05-22 13:09:39 +00:00
qt_autogen_tools_initial_setup ( ${ target } )
2019-03-06 12:51:38 +00:00
2019-03-26 12:39:43 +00:00
set ( static_plugin_define "" )
if ( arg_STATIC OR NOT QT_BUILD_SHARED_LIBS )
set ( static_plugin_define "QT_STATICPLUGIN" )
endif ( )
2019-05-03 14:03:15 +00:00
# Save the Qt module in the plug-in's properties
2020-04-01 16:14:15 +00:00
if ( NOT plugin_type_escaped STREQUAL "qml_plugin" )
qt_get_module_for_plugin ( "${target}" "${plugin_type_escaped}" )
2019-07-22 15:44:55 +00:00
get_target_property ( qt_module "${target}" QT_MODULE )
endif ( )
2019-05-03 14:03:15 +00:00
# Add the plug-in to the list of plug-ins of this module
if ( TARGET "${qt_module}" )
set_property ( TARGET "${qt_module}" APPEND PROPERTY QT_PLUGINS "${target}" )
endif ( )
2019-07-05 09:55:05 +00:00
set ( _default_plugin 1 )
if ( DEFINED arg_DEFAULT_IF )
if ( NOT ${ arg_DEFAULT_IF } )
set ( _default_plugin 0 )
endif ( )
endif ( )
set_property ( TARGET "${target}" PROPERTY QT_DEFAULT_PLUGIN "${_default_plugin}" )
2019-09-23 14:57:06 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_PLUGIN_CLASS_NAME;QT_PLUGIN_TYPE;QT_MODULE;QT_DEFAULT_PLUGIN" )
2019-06-05 08:08:44 +00:00
2019-08-08 14:55:48 +00:00
set ( private_includes
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
# For the syncqt headers
" $ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ r e p o _ i n c l u d e _ d i r } > "
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
)
set ( public_includes
$ { a r g _ P U B L I C _ I N C L U D E _ D I R E C T O R I E S }
)
2019-11-13 13:03:20 +00:00
qt_extend_target ( "${target}"
2018-12-07 12:13:24 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
2019-08-08 14:55:48 +00:00
$ { p r i v a t e _ i n c l u d e s }
P U B L I C _ I N C L U D E _ D I R E C T O R I E S
$ { p u b l i c _ i n c l u d e s }
2019-06-05 14:05:50 +00:00
L I B R A R I E S $ { a r g _ L I B R A R I E S } Q t : : P l a t f o r m P l u g i n I n t e r n a l
2018-12-07 12:13:24 +00:00
P U B L I C _ L I B R A R I E S $ { a r g _ P U B L I C _ L I B R A R I E S }
2018-10-24 13:20:27 +00:00
D E F I N E S
2018-12-07 12:13:24 +00:00
$ { a r g _ D E F I N E S }
2018-10-24 13:20:27 +00:00
Q T _ D E P R E C A T E D _ W A R N I N G S
" $ { d e p r e c a t i o n _ d e f i n e } "
2019-03-26 12:39:43 +00:00
" $ { s t a t i c _ p l u g i n _ d e f i n e } "
2019-03-11 11:34:52 +00:00
Q T _ P L U G I N
2018-10-24 13:20:27 +00:00
P U B L I C _ D E F I N E S
2019-06-05 09:31:55 +00:00
Q T _ $ { m o d u l e _ d e f i n e } _ L I B
2018-12-07 12:13:24 +00:00
$ { a r g _ P U B L I C _ D E F I N E S }
2018-12-11 10:38:20 +00:00
F E A T U R E _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
2018-12-07 12:13:24 +00:00
D B U S _ A D A P T O R _ S O U R C E S " $ { a r g _ D B U S _ A D A P T O R _ S O U R C E S } "
D B U S _ A D A P T O R _ F L A G S " $ { a r g _ D B U S _ A D A P T O R _ F L A G S } "
D B U S _ I N T E R F A C E _ S O U R C E S " $ { a r g _ D B U S _ I N T E R F A C E _ S O U R C E S } "
D B U S _ I N T E R F A C E _ F L A G S " $ { a r g _ D B U S _ I N T E R F A C E _ F L A G S } "
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
P U B L I C _ C O M P I L E _ O P T I O N S $ { a r g _ P U B L I C _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
P U B L I C _ L I N K _ O P T I O N S $ { a r g _ P U B L I C _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2019-05-22 13:09:39 +00:00
E N A B L E _ A U T O G E N _ T O O L S $ { a r g _ E N A B L E _ A U T O G E N _ T O O L S }
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
2018-10-24 13:20:27 +00:00
)
2019-06-04 13:55:41 +00:00
if ( NOT ${ arg_EXCEPTIONS } )
qt_internal_set_no_exceptions_flags ( "${target}" )
endif ( )
2019-06-04 15:09:14 +00:00
2018-10-24 13:20:27 +00:00
2019-05-03 14:03:15 +00:00
set ( qt_libs_private "" )
2019-08-20 13:24:14 +00:00
qt_internal_get_qt_all_known_modules ( known_modules )
foreach ( it ${ known_modules } )
2019-05-03 14:03:15 +00:00
list ( FIND arg_LIBRARIES "Qt::${it}Private" pos )
if ( pos GREATER -1 )
list ( APPEND qt_libs_private "Qt::${it}Private" )
endif ( )
endforeach ( )
qt_register_target_dependencies ( "${target}" "${arg_PUBLIC_LIBRARIES}" "${qt_libs_private}" )
2020-05-12 06:21:03 +00:00
qt_generate_plugin_pri_file ( "${target}" pri_file )
2019-05-03 14:03:15 +00:00
2019-10-10 15:02:59 +00:00
if ( NOT arg_SKIP_INSTALL )
# Handle creation of cmake files for consumers of find_package().
# If we are part of a Qt module, the plugin cmake files are installed as part of that module.
if ( qt_module )
set ( path_suffix "${INSTALL_CMAKE_NAMESPACE}${qt_module}" )
else ( )
set ( path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}" )
endif ( )
2019-05-03 14:03:15 +00:00
2019-10-10 15:02:59 +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 } )
2019-05-03 14:03:15 +00:00
2019-10-10 15:02:59 +00:00
configure_package_config_file (
" $ { Q T _ C M A K E _ D I R } / Q t P l u g i n C o n f i g . c m a k e . i n "
" $ { c o n f i g _ b u i l d _ d i r } / $ { t a r g e t } C o n f i g . c m a k e "
I N S T A L L _ D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
)
write_basic_package_version_file (
" $ { c o n f i g _ b u i l d _ d i r } / $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
V E R S I O N $ { P R O J E C T _ V E R S I O N }
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n
)
2019-05-03 14:03:15 +00:00
2019-10-10 15:02:59 +00:00
qt_install ( FILES
" $ { c o n f i g _ b u i l d _ d i r } / $ { t a r g e t } C o n f i g . c m a k e "
" $ { c o n f i g _ b u i l d _ d i r } / $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
C O M P O N E N T D e v e l
)
2020-05-12 06:21:03 +00:00
qt_install ( FILES
" $ { p r i _ f i l e } "
D E S T I N A T I O N " $ { I N S T A L L _ M K S P E C S D I R } / m o d u l e s "
)
2019-05-03 14:03:15 +00:00
2019-10-10 15:02:59 +00:00
# Make the export name of plugins be consistent with modules, so that
2019-11-13 13:03:20 +00:00
# qt_add_resource adds its additional targets to the same export set in a static Qt build.
2019-10-10 15:02:59 +00:00
set ( export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets" )
qt_install ( TARGETS "${target}"
E X P O R T $ { e x p o r t _ n a m e }
R U N T I M E D E S T I N A T I O N " $ { i n s t a l l _ d i r e c t o r y } "
L I B R A R Y D E S T I N A T I O N " $ { i n s t a l l _ d i r e c t o r y } "
A R C H I V E D E S T I N A T I O N " $ { a r c h i v e _ i n s t a l l _ d i r e c t o r y } "
)
qt_install ( EXPORT ${ export_name }
N A M E S P A C E $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : :
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
)
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
qt_apply_rpaths ( TARGET "${target}" INSTALL_PATH "${install_directory}" RELATIVE_RPATH )
2019-10-10 15:02:59 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
2019-10-21 09:31:28 +00:00
if ( NOT arg_ALLOW_UNDEFINED_SYMBOLS )
### fixme: cmake is missing a built-in variable for this. We want to apply it only to
# modules and plugins that belong to Qt.
qt_internal_add_link_flags_no_undefined ( "${target}" )
endif ( )
2018-10-24 13:20:27 +00:00
2018-12-11 10:38:20 +00:00
qt_internal_add_linker_version_script ( ${ target } )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-08-01 13:43:36 +00:00
function ( qt_install_qml_files target )
qt_parse_all_arguments ( arg "qt_install_qml_files"
" " " " " F I L E S " $ { A R G N }
)
if ( NOT arg_FILES )
message ( FATAL_ERROR "No files specified for qt_install_qml_files. Please specify them using the FILES parameter." )
endif ( )
get_target_property ( target_path ${ target } QT_QML_MODULE_TARGET_PATH )
if ( NOT target_path )
message ( FATAL_ERROR "Target ${target} is not a qml module." )
endif ( )
qt_path_join ( qml_module_install_dir ${ QT_INSTALL_DIR } "${INSTALL_QMLDIR}/${target_path}" )
qt_copy_or_install ( FILES ${ arg_FILES }
D E S T I N A T I O N $ { q m l _ m o d u l e _ i n s t a l l _ d i r }
)
endfunction ( )
2019-08-19 14:19:08 +00:00
2019-11-13 13:03:20 +00:00
function ( qt_add_resource target resourceName )
2019-08-19 14:19:08 +00:00
# Don't try to add resources when cross compiling, and the target is actually a host target
# (like a tool).
qt_is_imported_target ( "${target}" is_imported )
if ( is_imported )
return ( )
endif ( )
2019-11-13 13:03:20 +00:00
qt_parse_all_arguments ( arg "qt_add_resource" "" "PREFIX;LANG;BASE" "FILES" ${ ARGN } )
2019-08-19 14:19:08 +00:00
QT6_PROCESS_RESOURCE ( ${ target } ${ resourceName }
P R E F I X " $ { a r g _ P R E F I X } "
L A N G " $ { a r g _ L A N G } "
B A S E " $ { a r g _ B A S E } "
F I L E S $ { a r g _ F I L E S }
2019-09-16 07:49:40 +00:00
O U T P U T _ T A R G E T S o u t _ t a r g e t s
2019-08-19 14:19:08 +00:00
)
2019-09-16 07:49:40 +00:00
if ( out_targets )
2019-09-18 14:18:32 +00:00
qt_install ( TARGETS ${ out_targets }
E X P O R T " $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } T a r g e t s "
D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
)
2019-08-19 14:19:08 +00:00
endif ( )
endfunction ( )
2019-11-13 13:03:20 +00:00
# Collection of qt_add_executable arguments so they can be shared across qt_add_executable
# and qt_add_test_helper.
set ( __qt_add_executable_optional_args
2019-08-12 13:51:17 +00:00
" G U I ; B O O T S T R A P ; N O _ Q T ; N O _ I N S T A L L ; E X C E P T I O N S "
)
2019-11-13 13:03:20 +00:00
set ( __qt_add_executable_single_args
2020-02-21 15:32:13 +00:00
" O U T P U T _ D I R E C T O R Y ; I N S T A L L _ D I R E C T O R Y ; V E R S I O N "
2020-05-12 09:29:56 +00:00
$ { _ _ d e f a u l t _ t a r g e t _ i n f o _ a r g s }
2019-08-12 13:51:17 +00:00
)
2019-11-13 13:03:20 +00:00
set ( __qt_add_executable_multi_args
2019-08-12 13:51:17 +00:00
" E X E _ F L A G S ; $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } "
)
2018-10-24 13:20:27 +00:00
# This function creates a CMake target for a generic console or GUI binary.
# Please consider to use a more specific version target like the one created
2019-11-13 13:03:20 +00:00
# by qt_add_test or qt_add_tool below.
function ( qt_add_executable name )
qt_parse_all_arguments ( arg "qt_add_executable"
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ o p t i o n a l _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ s i n g l e _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ m u l t i _ a r g s } "
2019-08-12 13:51:17 +00:00
$ { A R G N } )
2018-10-24 13:20:27 +00:00
2018-12-07 12:13:24 +00:00
if ( "x${arg_OUTPUT_DIRECTORY}" STREQUAL "x" )
2019-11-21 12:33:28 +00:00
set ( arg_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}" )
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-18 17:49:04 +00:00
get_filename_component ( arg_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
2019-11-21 12:33:28 +00:00
A B S O L U T E B A S E _ D I R " $ { Q T _ B U I L D _ D I R } " )
2019-03-18 17:49:04 +00:00
2019-03-18 18:09:27 +00:00
if ( "x${arg_INSTALL_DIRECTORY}" STREQUAL "x" )
set ( arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}" )
endif ( )
2019-10-24 08:50:06 +00:00
if ( ANDROID )
add_library ( "${name}" MODULE )
qt_android_apply_arch_suffix ( "${name}" )
qt_android_generate_deployment_settings ( "${name}" )
qt_android_add_apk_target ( "${name}" )
# On our qmake builds we don't compile the executables with
# visibility=hidden. Not having this flag set will cause the
# executable to have main() hidden and can then no longer be loaded
# through dlopen()
set_property ( TARGET ${ name } PROPERTY C_VISIBILITY_PRESET default )
set_property ( TARGET ${ name } PROPERTY CXX_VISIBILITY_PRESET default )
else ( )
add_executable ( "${name}" ${ arg_EXE_FLAGS } )
endif ( )
2019-03-06 12:51:38 +00:00
2020-02-21 15:32:13 +00:00
if ( arg_VERSION )
if ( arg_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" )
# nothing to do
elseif ( arg_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+" )
set ( arg_VERSION "${arg_VERSION}.0" )
elseif ( arg_VERSION MATCHES "[0-9]+\\.[0-9]+" )
set ( arg_VERSION "${arg_VERSION}.0.0" )
elseif ( arg_VERSION MATCHES "[0-9]+" )
set ( arg_VERSION "${arg_VERSION}.0.0.0" )
else ( )
message ( FATAL_ERROR "Invalid version format" )
endif ( )
endif ( )
2020-06-11 16:45:04 +00:00
if ( "${arg_TARGET_DESCRIPTION}" STREQUAL "" )
set ( arg_TARGET_DESCRIPTION "Qt ${name}" )
endif ( )
qt_set_target_info_properties ( ${ name } ${ ARGN }
T A R G E T _ D E S C R I P T I O N " $ { a r g _ T A R G E T _ D E S C R I P T I O N } "
T A R G E T _ V E R S I O N " $ { a r g _ V E R S I O N } " )
2020-02-21 15:32:13 +00:00
if ( WIN32 )
qt6_generate_win32_rc_file ( ${ name } )
endif ( )
2020-04-17 15:12:40 +00:00
qt_set_common_target_properties ( ${ name } )
2019-05-22 13:09:39 +00:00
qt_autogen_tools_initial_setup ( ${ name } )
2019-11-13 09:09:17 +00:00
qt_skip_warnings_are_errors_when_repo_unclean ( "${name}" )
2019-03-06 12:51:38 +00:00
2019-03-20 11:09:12 +00:00
set ( extra_libraries "" )
2019-04-29 14:32:21 +00:00
if ( NOT arg_BOOTSTRAP AND NOT arg_NO_QT )
2019-03-20 11:09:12 +00:00
set ( extra_libraries "Qt::Core" )
endif ( )
2019-08-08 14:55:48 +00:00
set ( private_includes
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
)
2019-11-13 13:03:20 +00:00
qt_extend_target ( "${name}"
2018-12-07 12:13:24 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2019-08-08 14:55:48 +00:00
I N C L U D E _ D I R E C T O R I E S $ { p r i v a t e _ i n c l u d e s }
2018-12-07 12:13:24 +00:00
D E F I N E S $ { a r g _ D E F I N E S }
2020-02-19 15:22:42 +00:00
L I B R A R I E S $ { a r g _ L I B R A R I E S } Q t : : P l a t f o r m C o m m o n I n t e r n a l
2019-08-02 12:14:16 +00:00
P U B L I C _ L I B R A R I E S $ { e x t r a _ l i b r a r i e s } $ { a r g _ P U B L I C _ L I B R A R I E S }
2018-12-07 12:13:24 +00:00
D B U S _ A D A P T O R _ S O U R C E S " $ { a r g _ D B U S _ A D A P T O R _ S O U R C E S } "
D B U S _ A D A P T O R _ F L A G S " $ { a r g _ D B U S _ A D A P T O R _ F L A G S } "
D B U S _ I N T E R F A C E _ S O U R C E S " $ { a r g _ D B U S _ I N T E R F A C E _ S O U R C E S } "
D B U S _ I N T E R F A C E _ F L A G S " $ { a r g _ D B U S _ I N T E R F A C E _ F L A G S } "
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2019-05-22 13:09:39 +00:00
E N A B L E _ A U T O G E N _ T O O L S $ { a r g _ E N A B L E _ A U T O G E N _ T O O L S }
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
2018-10-24 13:20:27 +00:00
)
set_target_properties ( "${name}" PROPERTIES
2018-12-07 12:13:24 +00:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { a r g _ O U T P U T _ D I R E C T O R Y } "
2019-10-24 08:50:06 +00:00
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { a r g _ O U T P U T _ D I R E C T O R Y } "
2018-12-07 12:13:24 +00:00
W I N 3 2 _ E X E C U T A B L E " $ { a r g _ G U I } "
M A C O S X _ B U N D L E " $ { a r g _ G U I } "
2018-10-24 13:20:27 +00:00
)
2019-06-04 13:55:41 +00:00
if ( NOT ${ arg_EXCEPTIONS } )
qt_internal_set_no_exceptions_flags ( "${name}" )
endif ( )
2019-06-04 15:09:14 +00:00
2020-04-06 16:45:19 +00:00
# Check if target needs to be excluded from all target. Also affects qt_install.
# Set by qt_exclude_tool_directories_from_default_target.
set ( exclude_from_all FALSE )
if ( __qt_exclude_tool_directories )
foreach ( absolute_dir ${ __qt_exclude_tool_directories } )
string ( FIND "${CMAKE_CURRENT_SOURCE_DIR}" "${absolute_dir}" dir_starting_pos )
if ( dir_starting_pos EQUAL 0 )
set ( exclude_from_all TRUE )
set_target_properties ( "${name}" PROPERTIES EXCLUDE_FROM_ALL TRUE )
break ( )
endif ( )
endforeach ( )
endif ( )
2019-03-18 18:09:27 +00:00
2019-04-03 09:33:28 +00:00
if ( NOT arg_NO_INSTALL )
2020-04-06 16:45:19 +00:00
set ( additional_install_args "" )
if ( exclude_from_all )
list ( APPEND additional_install_args EXCLUDE_FROM_ALL COMPONENT "ExcludedExecutables" )
endif ( )
2020-05-15 13:21:21 +00:00
qt_get_cmake_configurations ( cmake_configs )
foreach ( cmake_config ${ cmake_configs } )
qt_get_install_target_default_args (
O U T _ V A R i n s t a l l _ t a r g e t s _ d e f a u l t _ a r g s
C M A K E _ C O N F I G " $ { c m a k e _ c o n f i g } "
A L L _ C M A K E _ C O N F I G S " $ { c m a k e _ c o n f i g s } "
R U N T I M E " $ { a r g _ I N S T A L L _ D I R E C T O R Y } "
L I B R A R Y " $ { a r g _ I N S T A L L _ D I R E C T O R Y } "
B U N D L E " $ { a r g _ I N S T A L L _ D I R E C T O R Y } " )
qt_install ( TARGETS "${name}"
$ { a d d i t i o n a l _ i n s t a l l _ a r g s } # Needs to be before the DESTINATIONS.
C O N F I G U R A T I O N S $ { c m a k e _ c o n f i g }
$ { i n s t a l l _ t a r g e t s _ d e f a u l t _ a r g s } )
endforeach ( )
2019-04-03 09:33:28 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-11-13 13:03:20 +00:00
# Simple wrapper around qt_add_executable for benchmarks which insure that
2019-10-28 14:35:47 +00:00
# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
2019-11-13 13:03:20 +00:00
# See qt_add_executable() for more details.
function ( qt_add_benchmark target )
2019-10-28 14:35:47 +00:00
2019-11-13 13:03:20 +00:00
qt_parse_all_arguments ( arg "qt_add_benchmark"
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ o p t i o n a l _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ s i n g l e _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ m u l t i _ a r g s } "
2019-10-28 14:35:47 +00:00
$ { A R G N }
)
qt_remove_args ( exec_args
A R G S _ T O _ R E M O V E
$ { t a r g e t }
O U T P U T _ D I R E C T O R Y
I N S T A L L _ D I R E C T O R Y
A L L _ A R G S
2019-11-13 13:03:20 +00:00
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ o p t i o n a l _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ s i n g l e _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ m u l t i _ a r g s } "
2019-10-28 14:35:47 +00:00
A R G S
$ { A R G V }
)
2020-05-19 16:39:24 +00:00
if ( NOT arg_OUTPUT_DIRECTORY )
set ( arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
endif ( )
2019-11-13 13:03:20 +00:00
qt_add_executable ( ${ target }
2019-10-28 14:35:47 +00:00
N O _ I N S T A L L # we don't install benchmarks
2020-05-19 16:39:24 +00:00
O U T P U T _ D I R E C T O R Y " $ { a r g _ O U T P U T _ D I R E C T O R Y } " # avoid polluting bin directory
2019-10-28 14:35:47 +00:00
$ { e x e c _ a r g s }
)
endfunction ( )
2018-10-24 13:20:27 +00:00
2019-11-13 13:03:20 +00:00
# Simple wrapper around qt_add_executable for manual tests which insure that
2019-11-12 14:31:34 +00:00
# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
2019-11-13 13:03:20 +00:00
# See qt_add_executable() for more details.
function ( qt_add_manual_test target )
2019-11-12 14:31:34 +00:00
2019-11-13 13:03:20 +00:00
qt_parse_all_arguments ( arg "qt_add_manual_test"
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ o p t i o n a l _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ s i n g l e _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ m u l t i _ a r g s } "
2019-11-12 14:31:34 +00:00
$ { A R G N }
)
qt_remove_args ( exec_args
A R G S _ T O _ R E M O V E
$ { t a r g e t }
O U T P U T _ D I R E C T O R Y
I N S T A L L _ D I R E C T O R Y
A L L _ A R G S
2019-11-13 13:03:20 +00:00
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ o p t i o n a l _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ s i n g l e _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ m u l t i _ a r g s } "
2019-11-12 14:31:34 +00:00
A R G S
$ { A R G V }
)
2020-05-19 16:39:24 +00:00
if ( NOT arg_OUTPUT_DIRECTORY )
set ( arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
endif ( )
2019-11-13 13:03:20 +00:00
qt_add_executable ( ${ target }
2019-11-12 14:31:34 +00:00
N O _ I N S T A L L # we don't install benchmarks
2020-05-19 16:39:24 +00:00
O U T P U T _ D I R E C T O R Y " $ { a r g _ O U T P U T _ D I R E C T O R Y } " # avoid polluting bin directory
2019-11-12 14:31:34 +00:00
$ { e x e c _ a r g s }
)
endfunction ( )
2018-10-24 13:20:27 +00:00
# This function creates a CMake test target with the specified name for use with CTest.
2019-11-13 13:03:20 +00:00
function ( qt_add_test name )
qt_parse_all_arguments ( arg "qt_add_test"
2019-07-22 10:55:48 +00:00
" R U N _ S E R I A L ; E X C E P T I O N S ; G U I ; Q M L T E S T "
2020-02-21 15:32:13 +00:00
" O U T P U T _ D I R E C T O R Y ; W O R K I N G _ D I R E C T O R Y ; T I M E O U T ; V E R S I O N "
2019-12-10 13:21:36 +00:00
" Q M L _ I M P O R T P A T H ; T E S T D A T A ; $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } " $ { A R G N }
)
2019-08-26 09:08:52 +00:00
if ( NOT arg_OUTPUT_DIRECTORY )
set ( arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
endif ( )
2018-10-24 13:20:27 +00:00
2019-06-04 13:55:41 +00:00
if ( ${ arg_EXCEPTIONS } )
2019-07-22 10:55:48 +00:00
set ( exceptions_text "EXCEPTIONS" )
endif ( )
if ( ${ arg_GUI } )
set ( gui_text "GUI" )
2019-06-04 13:55:41 +00:00
endif ( )
2020-02-21 15:32:13 +00:00
if ( arg_VERSION )
set ( version_arg VERSION "${arg_VERSION}" )
endif ( )
2019-08-08 14:46:05 +00:00
# Handle cases where we have a qml test without source files
if ( arg_SOURCES )
set ( private_includes
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
2020-01-26 11:25:40 +00:00
" $ < B U I L D _ I N T E R F A C E : $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ I N C L U D E D I R } > "
2019-08-08 14:46:05 +00:00
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
)
2019-08-08 14:55:48 +00:00
2019-11-13 13:03:20 +00:00
qt_add_executable ( "${name}"
2019-08-08 14:46:05 +00:00
$ { e x c e p t i o n s _ t e x t }
$ { g u i _ t e x t }
2020-02-21 15:32:13 +00:00
$ { v e r s i o n _ a r g }
2019-08-08 14:46:05 +00:00
N O _ I N S T A L L
2019-08-26 09:08:52 +00:00
O U T P U T _ D I R E C T O R Y " $ { a r g _ O U T P U T _ D I R E C T O R Y } "
2019-08-08 14:46:05 +00:00
S O U R C E S " $ { a r g _ S O U R C E S } "
I N C L U D E _ D I R E C T O R I E S
$ { p r i v a t e _ i n c l u d e s }
D E F I N E S
Q T _ T E S T C A S E _ B U I L D D I R = " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
Q T _ T E S T C A S E _ S O U R C E D I R = " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
$ { a r g _ D E F I N E S }
P U B L I C _ L I B R A R I E S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : C o r e $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : T e s t $ { a r g _ P U B L I C _ L I B R A R I E S }
L I B R A R I E S $ { a r g _ L I B R A R I E S }
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
E N A B L E _ A U T O G E N _ T O O L S $ { a r g _ E N A B L E _ A U T O G E N _ T O O L S }
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
)
2018-10-24 13:20:27 +00:00
2019-08-12 13:51:17 +00:00
# Tests should not be bundles on macOS even if arg_GUI is true, because some tests make
# assumptions about the location of helper processes, and those paths would be different
# if a test is built as a bundle.
set_property ( TARGET "${name}" PROPERTY MACOSX_BUNDLE FALSE )
2019-09-16 10:41:43 +00:00
# The same goes for WIN32_EXECUTABLE, but because it will detach from the console window
# and not print anything.
set_property ( TARGET "${name}" PROPERTY WIN32_EXECUTABLE FALSE )
2019-08-12 13:51:17 +00:00
2019-08-08 14:46:05 +00:00
# QMLTest specifics
2019-07-22 10:55:48 +00:00
2019-11-13 13:03:20 +00:00
qt_extend_target ( "${name}" CONDITION arg_QMLTEST
2019-08-08 14:46:05 +00:00
P U B L I C _ L I B R A R I E S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : Q u i c k T e s t
)
2019-07-22 10:55:48 +00:00
2019-11-13 13:03:20 +00:00
qt_extend_target ( "${name}" CONDITION arg_QMLTEST AND NOT ANDROID
2019-08-08 14:46:05 +00:00
D E F I N E S
Q U I C K _ T E S T _ S O U R C E _ D I R = " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
)
2019-07-22 10:55:48 +00:00
2019-11-13 13:03:20 +00:00
qt_extend_target ( "${name}" CONDITION arg_QMLTEST AND ANDROID
2019-08-08 14:46:05 +00:00
D E F I N E S
Q U I C K _ T E S T _ S O U R C E _ D I R = " : / "
)
endif ( )
2019-07-22 10:55:48 +00:00
2019-09-17 09:27:47 +00:00
foreach ( path IN LISTS arg_QML_IMPORTPATH )
list ( APPEND extra_test_args "-import" "${path}" )
endforeach ( )
2019-07-22 10:55:48 +00:00
2019-06-25 08:57:20 +00:00
# Generate a label in the form tests/auto/foo/bar/tst_baz
# and use it also for XML output
file ( RELATIVE_PATH label "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${name}" )
2018-10-24 13:20:27 +00:00
2019-10-24 08:50:06 +00:00
if ( ANDROID )
qt_android_add_test ( "${name}" )
2019-07-22 10:55:48 +00:00
else ( )
2019-10-24 08:50:06 +00:00
if ( arg_QMLTEST AND NOT arg_SOURCES )
set ( test_working_dir "${CMAKE_CURRENT_SOURCE_DIR}" )
set ( test_executable ${ QT_CMAKE_EXPORT_NAMESPACE } ::qmltestrunner )
else ( )
2019-12-10 13:21:36 +00:00
if ( arg_WORKING_DIRECTORY )
set ( test_working_dir "${arg_WORKING_DIRECTORY}" )
2020-02-12 16:19:17 +00:00
elseif ( arg_OUTPUT_DIRECTORY )
set ( test_working_dir "${arg_OUTPUT_DIRECTORY}" )
2019-12-10 13:21:36 +00:00
else ( )
set ( test_working_dir "${CMAKE_CURRENT_BINARY_DIR}" )
endif ( )
2019-10-24 08:50:06 +00:00
set ( test_executable "${name}" )
endif ( )
2019-06-25 08:57:20 +00:00
2019-10-24 08:50:06 +00:00
add_test ( NAME "${name}" COMMAND ${ test_executable } ${ extra_test_args } -o ${ name } .xml,xml -o -,txt WORKING_DIRECTORY "${test_working_dir}" )
endif ( )
2019-06-25 08:57:20 +00:00
set_tests_properties ( "${name}" PROPERTIES RUN_SERIAL "${arg_RUN_SERIAL}" LABELS "${label}" )
2020-01-13 09:19:13 +00:00
if ( arg_TIMEOUT )
set_tests_properties ( ${ name } PROPERTIES TIMEOUT ${ arg_TIMEOUT } )
endif ( )
2020-04-30 15:00:13 +00:00
2020-05-29 17:50:06 +00:00
# Add a ${target}/check makefile target, to more easily test one test.
2020-06-03 09:58:17 +00:00
if ( TEST "${name}" )
add_custom_target ( "${name}_check"
V E R B A T I M
C O M M E N T " R u n n i n g $ { C M A K E _ C T E S T _ C O M M A N D } - V - R \ " ^ $ { n a m e } $ \ " "
C O M M A N D " $ { C M A K E _ C T E S T _ C O M M A N D } " - V - R " ^ $ { n a m e } $ "
)
if ( TARGET "${name}" )
add_dependencies ( "${name}_check" "${name}" )
endif ( )
endif ( )
2020-05-29 17:50:06 +00:00
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
# Get path to <qt_relocatable_install_prefix>/bin, as well as CMAKE_INSTALL_PREFIX/bin, then
2020-04-30 15:00:13 +00:00
# prepend them to the PATH environment variable.
# It's needed on Windows to find the shared libraries and plugins.
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_relocatable_install_prefix is dynamically computed from the location of where the Qt CMake
# package is found.
2020-04-30 15:00:13 +00:00
# The regular CMAKE_INSTALL_PREFIX can be different for example when building standalone tests.
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
# Any given CMAKE_INSTALL_PREFIX takes priority over qt_relocatable_install_prefix for the
# PATH environment variable.
2020-04-30 15:00:13 +00:00
set ( install_prefixes "${CMAKE_INSTALL_PREFIX}" )
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
if ( QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX )
list ( APPEND install_prefixes "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}" )
2020-04-30 15:00:13 +00:00
endif ( )
set ( test_env_path "PATH=${CMAKE_CURRENT_BINARY_DIR}" )
foreach ( install_prefix ${ install_prefixes } )
set ( test_env_path "${test_env_path}${QT_PATH_SEPARATOR}${install_prefix}/${INSTALL_BINDIR}" )
endforeach ( )
set ( test_env_path "${test_env_path}${QT_PATH_SEPARATOR}$ENV{PATH}" )
2020-02-19 12:24:22 +00:00
string ( REPLACE ";" "\;" test_env_path "${test_env_path}" )
set_property ( TEST "${name}" APPEND PROPERTY ENVIRONMENT "${test_env_path}" )
2020-01-13 12:56:04 +00:00
set_property ( TEST "${name}" APPEND PROPERTY ENVIRONMENT "QT_TEST_RUNNING_IN_CTEST=1" )
2019-07-12 14:54:26 +00:00
2019-07-22 10:55:48 +00:00
# Add the install prefix to list of plugin paths when doing a prefix build
if ( NOT QT_INSTALL_DIR )
2020-04-30 15:00:13 +00:00
foreach ( install_prefix ${ install_prefixes } )
list ( APPEND plugin_paths "${install_prefix}/${INSTALL_PLUGINSDIR}" )
endforeach ( )
2019-07-22 10:55:48 +00:00
endif ( )
2020-04-30 15:00:13 +00:00
2019-07-22 10:55:48 +00:00
#TODO: Collect all paths from known repositories when performing a super
# build.
list ( APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}" )
list ( JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined )
set_property ( TEST "${name}" APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}" )
2019-07-12 14:54:26 +00:00
if ( ANDROID OR IOS OR WINRT )
set ( builtin_testdata TRUE )
endif ( )
if ( builtin_testdata )
2019-08-22 14:20:03 +00:00
# Safe guard against qml only tests, no source files == no target
if ( TARGET "${name}" )
target_compile_definitions ( "${name}" PRIVATE BUILTIN_TESTDATA )
2019-07-12 14:54:26 +00:00
2019-08-22 14:20:03 +00:00
foreach ( testdata IN LISTS arg_TESTDATA )
list ( APPEND builtin_files ${ testdata } )
endforeach ( )
2019-07-12 14:54:26 +00:00
2019-08-22 14:20:03 +00:00
set ( blacklist_path "BLACKLIST" )
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}" )
list ( APPEND builtin_files ${ blacklist_path } )
endif ( )
2019-07-12 14:54:26 +00:00
2019-08-22 14:20:03 +00:00
list ( REMOVE_DUPLICATES builtin_files )
2019-07-12 14:54:26 +00:00
2019-08-23 13:43:55 +00:00
# Skip Qt quick compiler when embedding test resources
foreach ( file IN LISTS builtin_files )
set_source_files_properties ( ${ file }
P R O P E R T I E S Q T _ S K I P _ Q U I C K C O M P I L E R T R U E
)
endforeach ( )
2019-08-22 14:20:03 +00:00
if ( builtin_files )
2019-11-13 13:03:20 +00:00
qt_add_resource ( ${ name } "${name}_testdata_builtin"
2019-08-22 14:20:03 +00:00
P R E F I X " / "
F I L E S $ { b u i l t i n _ f i l e s }
B A S E $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } )
endif ( )
2019-07-12 14:54:26 +00:00
endif ( )
else ( )
# Install test data
2019-07-26 16:15:41 +00:00
file ( RELATIVE_PATH relative_path_to_test_project
" $ { Q T _ T O P _ L E V E L _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } " )
qt_path_join ( testdata_install_dir ${ QT_INSTALL_DIR }
2019-08-12 14:29:58 +00:00
" $ { r e l a t i v e _ p a t h _ t o _ t e s t _ p r o j e c t } " )
2019-07-12 14:54:26 +00:00
foreach ( testdata IN LISTS arg_TESTDATA )
set ( testdata "${CMAKE_CURRENT_SOURCE_DIR}/${testdata}" )
if ( IS_DIRECTORY "${testdata}" )
2020-02-12 14:37:12 +00:00
qt_install (
2019-07-12 14:54:26 +00:00
D I R E C T O R Y " $ { t e s t d a t a } "
2019-07-23 07:13:47 +00:00
D E S T I N A T I O N " $ { t e s t d a t a _ i n s t a l l _ d i r } " )
2019-07-12 14:54:26 +00:00
else ( )
2020-02-12 14:37:12 +00:00
qt_install (
2019-07-12 14:54:26 +00:00
F I L E S " $ { t e s t d a t a } "
2019-07-23 07:13:47 +00:00
D E S T I N A T I O N " $ { t e s t d a t a _ i n s t a l l _ d i r } " )
2019-07-12 14:54:26 +00:00
endif ( )
endforeach ( )
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-08-12 13:51:17 +00:00
# This function creates an executable for use as a helper program with tests. Some
# tests launch separate programs to test certain input/output behavior.
# Specify OVERRIDE_OUTPUT_DIRECTORY if you dont' want to place the helper in the parent directory,
# in which case you should specify OUTPUT_DIRECTORY "/foo/bar" manually.
2019-11-13 13:03:20 +00:00
function ( qt_add_test_helper name )
2019-08-12 13:51:17 +00:00
2019-11-13 13:03:20 +00:00
set ( qt_add_test_helper_optional_args
2019-08-12 13:51:17 +00:00
" O V E R R I D E _ O U T P U T _ D I R E C T O R Y "
)
2019-11-13 13:03:20 +00:00
qt_parse_all_arguments ( arg "qt_add_test_helper"
" $ { q t _ a d d _ t e s t _ h e l p e r _ o p t i o n a l _ a r g s } ; $ { _ _ q t _ a d d _ e x e c u t a b l e _ o p t i o n a l _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ s i n g l e _ a r g s } "
" $ { _ _ q t _ a d d _ e x e c u t a b l e _ m u l t i _ a r g s } "
2019-08-12 13:51:17 +00:00
$ { A R G N } )
qt_remove_args ( forward_args
A R G S _ T O _ R E M O V E
" $ { n a m e } "
2019-11-13 13:03:20 +00:00
$ { q t _ a d d _ t e s t _ h e l p e r _ o p t i o n a l _ a r g s }
2019-08-12 13:51:17 +00:00
A L L _ A R G S
2019-11-13 13:03:20 +00:00
$ { q t _ a d d _ t e s t _ h e l p e r _ o p t i o n a l _ a r g s }
$ { _ _ q t _ a d d _ e x e c u t a b l e _ o p t i o n a l _ a r g s }
$ { _ _ q t _ a d d _ e x e c u t a b l e _ s i n g l e _ a r g s }
$ { _ _ q t _ a d d _ e x e c u t a b l e _ m u l t i _ a r g s }
2019-08-12 13:51:17 +00:00
A R G S
$ { A R G V }
)
set ( extra_args_to_pass )
if ( NOT arg_OVERRIDE_OUTPUT_DIRECTORY )
set ( extra_args_to_pass OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." )
endif ( )
2019-11-13 13:03:20 +00:00
qt_add_executable ( "${name}" NO_INSTALL ${ extra_args_to_pass } ${ forward_args } )
2018-10-24 13:20:27 +00:00
endfunction ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
# Sets QT_WILL_BUILD_TOOLS if tools will be built.
function ( qt_check_if_tools_will_be_built )
2020-04-27 13:04:57 +00:00
if ( QT_FORCE_FIND_TOOLS OR ( CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING ) )
2019-08-16 10:57:31 +00:00
set ( will_build_tools FALSE )
2020-04-27 13:04:57 +00:00
else ( )
set ( will_build_tools TRUE )
2019-08-16 10:57:31 +00:00
endif ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
set ( QT_WILL_BUILD_TOOLS ${ will_build_tools } CACHE INTERNAL "Are tools going to be built" FORCE )
endfunction ( )
2018-10-24 13:20:27 +00:00
2019-10-10 13:40:38 +00:00
# Wrapper function to create a regular cmake target and forward all the
# arguments collected by the conversion script. This is only meant for tests!
2019-11-13 13:03:20 +00:00
function ( qt_add_cmake_library target )
2019-10-10 13:40:38 +00:00
# Process arguments:
2019-11-13 13:03:20 +00:00
qt_parse_all_arguments ( arg "qt_add_cmake_library"
2019-10-10 13:40:38 +00:00
" S H A R E D ; M O D U L E ; S T A T I C ; I N T E R F A C E "
" O U T P U T _ D I R E C T O R Y ; A R C H I V E _ I N S T A L L _ D I R E C T O R Y ; I N S T A L L _ D I R E C T O R Y "
2019-10-11 11:55:59 +00:00
" $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } "
2019-10-10 13:40:38 +00:00
$ { A R G N }
)
### Define Targets:
if ( ${ arg_INTERFACE } )
add_library ( "${target}" INTERFACE )
2019-04-08 15:23:57 +00:00
elseif ( ${ arg_STATIC } OR ( ${ arg_MODULE } AND NOT BUILD_SHARED_LIBS ) )
2019-10-10 13:40:38 +00:00
add_library ( "${target}" STATIC )
elseif ( ${ arg_SHARED } )
add_library ( "${target}" SHARED )
2019-10-23 12:45:20 +00:00
elseif ( ${ arg_MODULE } )
add_library ( "${target}" MODULE )
set_property ( TARGET ${ name } PROPERTY C_VISIBILITY_PRESET default )
set_property ( TARGET ${ name } PROPERTY CXX_VISIBILITY_PRESET default )
2019-11-14 10:24:14 +00:00
if ( APPLE )
# CMake defaults to using .so extensions for loadable modules, aka plugins,
# but Qt plugins are actually suffixed with .dylib.
set_property ( TARGET "${target}" PROPERTY SUFFIX ".dylib" )
endif ( )
2020-06-08 16:21:18 +00:00
if ( WIN32 )
# CMake sets for Windows-GNU platforms the suffix "lib"
set_property ( TARGET "${target}" PROPERTY PREFIX "" )
endif ( )
2019-10-10 13:40:38 +00:00
else ( )
add_library ( "${target}" )
endif ( )
if ( NOT arg_ARCHIVE_INSTALL_DIRECTORY AND arg_INSTALL_DIRECTORY )
set ( arg_ARCHIVE_INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" )
endif ( )
2019-10-14 13:18:50 +00:00
if ( ANDROID )
2019-10-10 13:40:38 +00:00
qt_android_apply_arch_suffix ( "${target}" )
endif ( )
2019-10-15 09:10:08 +00:00
qt_skip_warnings_are_errors_when_repo_unclean ( "${target}" )
2019-10-10 13:40:38 +00:00
if ( arg_INSTALL_DIRECTORY )
set ( install_arguments
A R C H I V E _ I N S T A L L _ D I R E C T O R Y $ { a r g _ A R C H I V E _ I N S T A L L _ D I R E C T O R Y }
I N S T A L L _ D I R E C T O R Y $ { a r g _ I N S T A L L _ D I R E C T O R Y }
)
endif ( )
2019-10-11 11:55:59 +00:00
if ( arg_OUTPUT_DIRECTORY )
set_target_properties ( ${ target } PROPERTIES
2019-10-15 12:54:25 +00:00
A R C H I V E _ O U T P U T _ D I R E C T O R Y $ { a r g _ O U T P U T _ D I R E C T O R Y }
R U N T I M E _ O U T P U T _ D I R E C T O R Y $ { a r g _ O U T P U T _ D I R E C T O R Y }
L I B R A R Y _ O U T P U T _ D I R E C T O R Y $ { a r g _ O U T P U T _ D I R E C T O R Y }
2019-10-11 11:55:59 +00:00
)
endif ( )
2019-11-13 13:03:20 +00:00
qt_extend_target ( "${target}"
2019-10-10 13:40:38 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
I N C L U D E _ D I R E C T O R I E S
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
P U B L I C _ I N C L U D E _ D I R E C T O R I E S
$ { a r g _ P U B L I C _ I N C L U D E _ D I R E C T O R I E S }
P U B L I C _ D E F I N E S
$ { a r g _ P U B L I C _ D E F I N E S }
D E F I N E S
$ { a r g _ D E F I N E S }
P U B L I C _ L I B R A R I E S $ { a r g _ P U B L I C _ L I B R A R I E S }
L I B R A R I E S $ { a r g _ L I B R A R I E S } Q t : : P l a t f o r m M o d u l e I n t e r n a l
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
P U B L I C _ C O M P I L E _ O P T I O N S $ { a r g _ P U B L I C _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
P U B L I C _ L I N K _ O P T I O N S $ { a r g _ P U B L I C _ L I N K _ O P T I O N S }
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
E N A B L E _ A U T O G E N _ T O O L S $ { a r g _ E N A B L E _ A U T O G E N _ T O O L S }
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
$ { i n s t a l l _ a r g u m e n t s }
)
endfunction ( )
2020-02-11 14:38:47 +00:00
#
# This function replaces qmake's qt_helper_lib feature. It is intended to
# compile 3rdparty libraries as part of the build.
#
function ( qt_add_3rdparty_library target )
# Process arguments:
qt_parse_all_arguments ( arg "qt_add_3rdparty_library"
2020-04-28 14:26:54 +00:00
" S H A R E D ; M O D U L E ; S T A T I C ; I N T E R F A C E ; E X C E P T I O N S ; I N S T A L L ; S K I P _ A U T O M O C "
2020-04-22 19:01:32 +00:00
" O U T P U T _ D I R E C T O R Y ; Q M A K E _ L I B _ N A M E "
2020-02-11 14:38:47 +00:00
" $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } "
$ { A R G N }
)
### Define Targets:
if ( ${ arg_INTERFACE } )
add_library ( "${target}" INTERFACE )
elseif ( ${ arg_STATIC } OR ( ${ arg_MODULE } AND NOT BUILD_SHARED_LIBS ) )
add_library ( "${target}" STATIC )
elseif ( ${ arg_SHARED } )
add_library ( "${target}" SHARED )
elseif ( ${ arg_MODULE } )
add_library ( "${target}" MODULE )
set_property ( TARGET ${ name } PROPERTY C_VISIBILITY_PRESET default )
set_property ( TARGET ${ name } PROPERTY CXX_VISIBILITY_PRESET default )
if ( APPLE )
# CMake defaults to using .so extensions for loadable modules, aka plugins,
# but Qt plugins are actually suffixed with .dylib.
set_property ( TARGET "${target}" PROPERTY SUFFIX ".dylib" )
endif ( )
else ( )
add_library ( "${target}" )
endif ( )
2020-04-17 15:12:40 +00:00
if ( NOT arg_INTERFACE )
qt_set_common_target_properties ( ${ target } )
endif ( )
2020-02-11 14:38:47 +00:00
if ( NOT arg_ARCHIVE_INSTALL_DIRECTORY AND arg_INSTALL_DIRECTORY )
set ( arg_ARCHIVE_INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" )
endif ( )
qt_internal_add_qt_repo_known_module ( ${ target } )
qt_internal_add_target_aliases ( ${ target } )
if ( ANDROID )
qt_android_apply_arch_suffix ( "${target}" )
endif ( )
qt_skip_warnings_are_errors_when_repo_unclean ( "${target}" )
2020-04-02 07:53:02 +00:00
set_target_properties ( ${ target } PROPERTIES
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ L I B D I R } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ B I N D I R } "
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ L I B D I R } "
V E R S I O N $ { P R O J E C T _ V E R S I O N }
S O V E R S I O N $ { P R O J E C T _ V E R S I O N _ M A J O R }
Q T _ M O D U L E _ I S _ 3 R D P A R T Y _ L I B R A R Y T R U E
Q T _ M O D U L E _ S K I P _ D E P E N D S _ I N C L U D E T R U E
)
qt_handle_multi_config_output_dirs ( "${target}" )
2020-02-11 14:38:47 +00:00
2020-04-02 07:53:02 +00:00
set_target_properties ( ${ target } PROPERTIES
O U T P U T _ N A M E " $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } "
)
2020-02-11 14:38:47 +00:00
2020-04-28 14:26:54 +00:00
if ( NOT arg_SKIP_AUTOMOC )
qt_autogen_tools_initial_setup ( ${ target } )
endif ( )
2020-04-14 10:29:05 +00:00
2020-02-11 14:38:47 +00:00
if ( NOT arg_INTERFACE )
# This property is used for super builds with static libraries. We use
# it in QtPlugins.cmake.in to avoid "polluting" the dependency chain
# for the target in it's project directory.
# E.g: When we process find_package(Qt6 ... Gui) in QtDeclarative, the
# rules in QtPugins.cmake add all the known Gui plugins as interface
# dependencies. This in turn causes circular dependencies on every
# plugin which links against Gui. Plugin A -> GUI -> Plugin A ....
set_target_properties ( ${ target } PROPERTIES QT_BUILD_PROJECT_NAME ${ PROJECT_NAME } )
endif ( )
if ( NOT arg_EXCEPTIONS AND NOT arg_INTERFACE )
qt_internal_set_no_exceptions_flags ( "${target}" )
endif ( )
2020-04-22 19:01:32 +00:00
qt_generate_3rdparty_lib_pri_file ( "${target}" "${arg_QMAKE_LIB_NAME}" pri_file )
if ( pri_file )
qt_install ( FILES "${pri_file}" DESTINATION "${INSTALL_MKSPECSDIR}/modules" )
endif ( )
2020-02-11 14:38:47 +00:00
qt_extend_target ( "${target}"
S O U R C E S $ { a r g _ S O U R C E S }
I N C L U D E _ D I R E C T O R I E S
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
P U B L I C _ I N C L U D E _ D I R E C T O R I E S
$ { a r g _ P U B L I C _ I N C L U D E _ D I R E C T O R I E S }
P U B L I C _ D E F I N E S
$ { a r g _ P U B L I C _ D E F I N E S }
D E F I N E S
$ { a r g _ D E F I N E S }
P U B L I C _ L I B R A R I E S $ { a r g _ P U B L I C _ L I B R A R I E S }
L I B R A R I E S $ { a r g _ L I B R A R I E S }
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
P U B L I C _ C O M P I L E _ O P T I O N S $ { a r g _ P U B L I C _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
P U B L I C _ L I N K _ O P T I O N S $ { a r g _ P U B L I C _ L I N K _ O P T I O N S }
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
E N A B L E _ A U T O G E N _ T O O L S $ { a r g _ E N A B L E _ A U T O G E N _ T O O L S }
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
$ { i n s t a l l _ a r g u m e n t s }
)
2020-02-24 13:12:46 +00:00
if ( NOT BUILD_SHARED_LIBS OR arg_INSTALL )
2020-02-11 14:38:47 +00:00
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 } )
set ( export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets" )
configure_package_config_file (
" $ { Q T _ C M A K E _ D I R } / Q t 3 r d P a r t y L i b r a r y C o n f i g . c m a k e . i n "
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
I N S T A L L _ D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
)
write_basic_package_version_file (
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
V E R S I O N $ { P R O J E C T _ V E R S I O N }
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n
)
2020-02-24 13:12:46 +00:00
qt_install ( FILES
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
" $ { c o n f i g _ b u i l d _ d i r } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
C O M P O N E N T D e v e l
)
2020-02-11 14:38:47 +00:00
qt_install ( TARGETS ${ target }
E X P O R T " $ { e x p o r t _ n a m e } "
2020-02-24 13:12:46 +00:00
R U N T I M E D E S T I N A T I O N $ { I N S T A L L _ B I N D I R }
L I B R A R Y D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
A R C H I V E D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
2020-02-11 14:38:47 +00:00
)
qt_install ( EXPORT ${ export_name }
N A M E S P A C E " $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : "
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
)
qt_internal_export_modern_cmake_config_targets_file (
T A R G E T S $ { t a r g e t }
E X P O R T _ N A M E _ P R E F I X $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t }
C O N F I G _ I N S T A L L _ D I R " $ { c o n f i g _ i n s t a l l _ d i r } "
)
endif ( )
endfunction ( )
2020-03-05 12:15:34 +00:00
function ( qt_install_3rdparty_library_wrap_config_extra_file target )
if ( TARGET "${target}" )
set ( use_bundled "ON" )
else ( )
set ( use_bundled "OFF" )
endif ( )
set ( QT_USE_BUNDLED_ ${ target } "${use_bundled}" CACHE BOOL "" FORCE )
set ( extra_cmake_code "set(QT_USE_BUNDLED_${target} ${use_bundled} CACHE BOOL \" \" FORCE ) " )
configure_file (
" $ { Q T _ C M A K E _ D I R } / Q t F i n d W r a p C o n f i g E x t r a . c m a k e . i n "
" $ { Q T _ C O N F I G _ B U I L D _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } / F i n d W r a p $ { t a r g e t } C o n f i g E x t r a . c m a k e "
@ O N L Y
)
qt_install ( FILES
" $ { Q T _ C O N F I G _ B U I L D _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } / F i n d W r a p $ { t a r g e t } C o n f i g E x t r a . c m a k e "
D E S T I N A T I O N " $ { Q T _ C O N F I G _ I N S T A L L _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } "
C O M P O N E N T D e v e l
)
endfunction ( )
2019-12-06 14:12:17 +00:00
function ( qt_get_tool_cmake_configuration out_var )
qt_get_main_cmake_configuration ( "${out_var}" )
string ( TOUPPER "${${out_var}}" upper_config )
set ( "${out_var}" "${upper_config}" PARENT_SCOPE )
endfunction ( )
function ( qt_get_main_cmake_configuration out_var )
if ( CMAKE_BUILD_TYPE )
set ( config "${CMAKE_BUILD_TYPE}" )
elseif ( QT_MULTI_CONFIG_FIRST_CONFIG )
set ( config "${QT_MULTI_CONFIG_FIRST_CONFIG}" )
endif ( )
set ( "${out_var}" "${config}" PARENT_SCOPE )
endfunction ( )
2020-04-27 13:04:57 +00:00
# Returns the target name for the tool with the given name.
#
# In most cases, the target name is the same as the tool name.
# If the user specifies to build tools when cross-compiling, then the
# suffix "_native" is appended.
function ( qt_get_tool_target_name out_var name )
if ( CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
set ( ${ out_var } ${ name } _native PARENT_SCOPE )
else ( )
set ( ${ out_var } ${ name } PARENT_SCOPE )
endif ( )
endfunction ( )
# Returns the tool name for a given tool target.
# This is the inverse of qt_get_tool_target_name.
function ( qt_tool_target_to_name out_var target )
set ( name ${ target } )
if ( CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
string ( REGEX REPLACE "_native$" "" name ${ target } )
endif ( )
set ( ${ out_var } ${ name } PARENT_SCOPE )
endfunction ( )
2018-10-24 13:20:27 +00:00
# This function is used to define a "Qt tool", such as moc, uic or rcc.
# The BOOTSTRAP option allows building it as standalone program, otherwise
# it will be linked against QtCore.
2020-04-27 13:04:57 +00:00
#
# We must pass this function a target name obtained from
# qt_get_tool_target_name like this:
# qt_get_tool_target_name(target_name my_tool)
# qt_add_tool(${target_name})
#
function ( qt_add_tool target_name )
qt_tool_target_to_name ( name ${ target_name } )
2020-05-12 09:29:56 +00:00
qt_parse_all_arguments ( arg "qt_add_tool" "BOOTSTRAP;NO_QT;NO_INSTALL"
" T O O L S _ T A R G E T ; $ { _ _ d e f a u l t _ t a r g e t _ i n f o _ a r g s } "
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
" $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } " $ { A R G N } )
# Handle case when a tool does not belong to a module and it can't be built either (like
# during a cross-compile).
if ( NOT arg_TOOLS_TARGET AND NOT QT_WILL_BUILD_TOOLS )
message ( FATAL_ERROR "The tool \" ${ name } \" has not been assigned to a module via "
" TOOLS_TARGET ( so it can't be found ) a n d i t c a n ' t b e b u i l t "
" ( Q T _ W I L L _ B U I L D _ T O O L S i s $ { Q T _ W I L L _ B U I L D _ T O O L S } ) . " )
endif ( )
2020-04-27 13:04:57 +00:00
if ( CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING AND ( name STREQUAL target_name ) )
message ( FATAL_ERROR
" q t _ a d d _ t o o l m u s t b e p a s s e d a t a r g e t o b t a i n e d f r o m q t _ g e t _ t o o l _ t a r g e t _ n a m e . " )
endif ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
set ( full_name "${QT_CMAKE_EXPORT_NAMESPACE}::${name}" )
2020-04-27 13:04:57 +00:00
set ( imported_tool_target_found FALSE )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
if ( TARGET ${ full_name } )
get_property ( path TARGET ${ full_name } PROPERTY LOCATION )
message ( STATUS "Tool '${full_name}' was found at ${path}." )
2020-04-27 13:04:57 +00:00
set ( imported_tool_target_found TRUE )
if ( CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
return ( )
endif ( )
2019-02-11 14:50:17 +00:00
endif ( )
2020-04-27 13:04:57 +00:00
if ( arg_TOOLS_TARGET AND ( NOT QT_WILL_BUILD_TOOLS OR QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
A N D N O T i m p o r t e d _ t o o l _ t a r g e t _ f o u n d )
2019-06-14 10:59:07 +00:00
set ( tools_package_name "Qt6${arg_TOOLS_TARGET}Tools" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
message ( STATUS "Searching for tool '${full_name}' in package ${tools_package_name}." )
# Only search in path provided by QT_HOST_PATH. We need to do it with CMAKE_PREFIX_PATH
# instead of PATHS option, because any find_dependency call inside a Tools package would
# not get the proper prefix when using PATHS.
set ( BACKUP_CMAKE_PREFIX_PATH ${ CMAKE_PREFIX_PATH } )
set ( CMAKE_PREFIX_PATH "${QT_HOST_PATH}" )
2019-05-03 10:07:37 +00:00
# Search both with sysroots prepended as well as in the host system. When cross compiling
2019-06-14 10:59:07 +00:00
# the mode_package might be set to ONLY only, and the Qt6 tools packages are actually
2019-05-03 10:07:37 +00:00
# in the host system.
set ( BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${ CMAKE_FIND_ROOT_PATH_MODE_PACKAGE } )
set ( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH" )
set ( BACKUP_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}" )
set ( CMAKE_SIZEOF_VOID_P "" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
find_package (
$ { t o o l s _ p a c k a g e _ n a m e }
$ { P R O J E C T _ V E R S I O N }
N O _ P A C K A G E _ R O O T _ P A T H
N O _ C M A K E _ E N V I R O N M E N T _ P A T H
N O _ S Y S T E M _ E N V I R O N M E N T _ P A T H
N O _ C M A K E _ P A C K A G E _ R E G I S T R Y
N O _ C M A K E _ S Y S T E M _ P A T H
N O _ C M A K E _ S Y S T E M _ P A C K A G E _ R E G I S T R Y )
2019-05-03 10:07:37 +00:00
set ( CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}" )
set ( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}" )
set ( CMAKE_PREFIX_PATH "${BACKUP_CMAKE_PREFIX_PATH}" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
if ( ${ ${tools_package_name } _FOUND} AND TARGET ${ full_name } )
2019-06-24 13:01:53 +00:00
# Even if the tool is already visible, make sure that our modules remain associated
# with the tools.
qt_internal_append_known_modules_with_tools ( "${arg_TOOLS_TARGET}" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
get_property ( path TARGET ${ full_name } PROPERTY LOCATION )
message ( STATUS "${full_name} was found at ${path} using package ${tools_package_name}." )
2020-04-27 13:04:57 +00:00
if ( NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
return ( )
endif ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
endif ( )
endif ( )
if ( NOT QT_WILL_BUILD_TOOLS )
message ( FATAL_ERROR "The tool \" ${ full_name } \" was not found in the "
" $ { t o o l s _ p a c k a g e _ n a m e } p a c k a g e . "
" P a c k a g e f o u n d : $ { $ { t o o l s _ p a c k a g e _ n a m e } _ F O U N D } " )
else ( )
2020-04-27 13:04:57 +00:00
if ( QT_BUILD_TOOLS_WHEN_CROSSCOMPILING )
message ( STATUS "Tool '${target_name}' will be cross-built from source." )
else ( )
message ( STATUS "Tool '${full_name}' will be built from source." )
endif ( )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
2019-03-06 12:51:38 +00:00
set ( disable_autogen_tools "${arg_DISABLE_AUTOGEN_TOOLS}" )
2019-04-29 11:14:22 +00:00
if ( arg_NO_QT )
# FIXME: Remove NO_QT again once qmake can use a "normal" Qt!
if ( arg_BOOTSTRAP )
message ( FATAL_ERROR "Tool can not be NO_QT and BOOTSTRAP at the same time!" )
endif ( )
set ( corelib "" )
2018-10-24 13:20:27 +00:00
else ( )
2019-04-29 11:14:22 +00:00
if ( arg_BOOTSTRAP )
set ( corelib ${ QT_CMAKE_EXPORT_NAMESPACE } ::Bootstrap )
list ( APPEND disable_autogen_tools "uic" "moc" "rcc" )
else ( )
set ( corelib ${ QT_CMAKE_EXPORT_NAMESPACE } ::Core )
endif ( )
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-20 11:09:12 +00:00
set ( bootstrap "" )
if ( arg_BOOTSTRAP )
set ( bootstrap BOOTSTRAP )
endif ( )
2019-04-29 14:32:21 +00:00
set ( no_qt "" )
if ( arg_NO_QT )
set ( no_qt NO_QT )
endif ( )
2020-04-27 13:04:57 +00:00
qt_add_executable ( "${target_name}" OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
2019-03-20 11:09:12 +00:00
$ { b o o t s t r a p }
2019-04-29 14:32:21 +00:00
$ { n o _ q t }
2020-05-15 13:21:21 +00:00
N O _ I N S T A L L
2018-12-12 09:55:20 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
2018-12-07 12:13:24 +00:00
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
D E F I N E S $ { a r g _ D E F I N E S }
2019-05-09 08:02:37 +00:00
P U B L I C _ L I B R A R I E S $ { c o r e l i b }
2019-06-05 14:05:50 +00:00
L I B R A R I E S $ { a r g _ L I B R A R I E S } Q t : : P l a t f o r m T o o l I n t e r n a l
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2019-03-06 12:51:38 +00:00
D I S A B L E _ A U T O G E N _ T O O L S $ { d i s a b l e _ a u t o g e n _ t o o l s }
2020-05-12 09:29:56 +00:00
T A R G E T _ V E R S I O N " $ { a r g _ T A R G E T _ V E R S I O N } "
T A R G E T _ P R O D U C T " $ { a r g _ T A R G E T _ P R O D U C T } "
T A R G E T _ D E S C R I P T I O N " $ { a r g _ T A R G E T _ D E S C R I P T I O N } "
T A R G E T _ C O M P A N Y " $ { a r g _ T A R G E T _ C O M P A N Y } "
T A R G E T _ C O P Y R I G H T " $ { a r g _ T A R G E T _ C O P Y R I G H T } "
2018-10-24 13:20:27 +00:00
)
2020-04-27 13:04:57 +00:00
qt_internal_add_target_aliases ( "${target_name}" )
if ( NOT target_name STREQUAL name )
set_target_properties ( ${ target_name } PROPERTIES
O U T P U T _ N A M E $ { n a m e }
E X P O R T _ N A M E $ { n a m e }
)
endif ( )
2018-10-24 13:20:27 +00:00
2019-12-06 14:12:17 +00:00
# If building with a multi-config configuration, the main configuration tool will be placed in
# ./bin, while the rest will be in <CONFIG> specific subdirectories.
qt_get_tool_cmake_configuration ( tool_cmake_configuration )
2020-04-27 13:04:57 +00:00
set_target_properties ( "${target_name}" PROPERTIES
2019-12-06 14:12:17 +00:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y _ $ { t o o l _ c m a k e _ c o n f i g u r a t i o n } " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ B I N D I R } "
2019-06-20 08:56:19 +00:00
)
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
if ( NOT arg_NO_INSTALL AND arg_TOOLS_TARGET )
# Assign a tool to an export set, and mark the module to which the tool belongs.
qt_internal_append_known_modules_with_tools ( "${arg_TOOLS_TARGET}" )
# Also append the tool to the module list.
2020-04-27 13:04:57 +00:00
qt_internal_append_known_module_tool ( "${arg_TOOLS_TARGET}" "${target_name}" )
Export tool config and target files for each relevant module
CMake will now generate config and target files for each module that
provides tools. As a result, namespaced global targets such as
Qt5::moc or Qt5::rcc can be made available.
Third party projects that require just these tools, and not the Qt
modules themselves, should specify CMAKE_PREFIX_PATH pointing to the
installed Qt location, and call find_package(Qt5CoreTools),
find_package(Qt5GuiTools), etc.
It is also possible to call
find_package(Qt5Tools REQUIRED Core Widgets) where the last option
is a list of modules whose tools should be imported.
Note that all the tools are in the Qt5::
namespace and not in the Qt5CoreTools:: or Qt5WidgetsTools::
namespace.
This commit also changes the behavior regarding when to build tools
while building Qt itself.
When cross compiling Qt (checked via CMAKE_CROSSCOMPILING) or when
-DQT_FORCE_FIND_TOOLS=TRUE is passed, tools added by add_qt_tool will
always be searched for and not built.
In this case the user has to specify the CMake variable QT_HOST_PATH
pointing to an installed host Qt location.
When not cross compiling, tools added by add_qt_tool are built from
source.
When building leaf modules (like qtsvg) that require some tool that was
built in qtbase (like moc), the module project should contain a
find_package(Qt5ToolsCore) call and specify an appropriate
CMAKE_PREFIX_PATH so that the tool package is found.
Note that because HOST_QT_TOOLS_DIRECTORY was replaced by QT_HOST_PATH,
the ensure syncqt code was changed to make it work properly with
both qtbase and qtsvg.
Here's a list of tools and their module associations:
qmake, moc, rcc, tracegen, qfloat16-tables, qlalr -> CoreTools
qvkgen -> GuiTools
uic -> WidgetTools
dbus related tools -> DBusTools
Task-number: QTBUG-74134
Change-Id: Ie67d1e2f8de46102b48eca008f0b50caf4fbe3ed
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-04-10 17:21:22 +00:00
2020-05-15 13:21:21 +00:00
qt_get_cmake_configurations ( cmake_configs )
set ( install_initial_call_args
E X P O R T " $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { a r g _ T O O L S _ T A R G E T } T o o l s T a r g e t s " )
foreach ( cmake_config ${ cmake_configs } )
qt_get_install_target_default_args (
O U T _ V A R i n s t a l l _ t a r g e t s _ d e f a u l t _ a r g s
C M A K E _ C O N F I G " $ { c m a k e _ c o n f i g } "
A L L _ C M A K E _ C O N F I G S " $ { c m a k e _ c o n f i g s } " )
2020-04-27 13:04:57 +00:00
qt_install ( TARGETS "${target_name}"
2020-05-15 13:21:21 +00:00
$ { i n s t a l l _ i n i t i a l _ c a l l _ a r g s }
C O N F I G U R A T I O N S $ { c m a k e _ c o n f i g }
$ { i n s t a l l _ t a r g e t s _ d e f a u l t _ a r g s } )
unset ( install_initial_call_args )
endforeach ( )
2020-04-27 13:04:57 +00:00
qt_apply_rpaths ( TARGET "${target_name}" INSTALL_PATH "${INSTALL_BINDIR}" RELATIVE_RPATH )
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
2019-04-03 09:33:28 +00:00
endif ( )
2020-02-26 10:41:20 +00:00
if ( QT_FEATURE_separate_debug_info AND ( UNIX OR MINGW ) )
2020-04-27 13:04:57 +00:00
qt_enable_separate_debug_info ( ${ target_name } ${ INSTALL_BINDIR } )
2020-02-26 10:41:20 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
function ( qt_create_tracepoints name tracePointsFile )
#### TODO
string ( TOLOWER "${name}" name )
file ( GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/qt${name}_tracepoints_p.h" CONTENT
" #include <private/qtrace_p.h>")
endfunction ( )
2019-03-11 14:09:33 +00:00
# Handle files that need special SIMD-related flags.
# This creates an object library and makes target link
# to it (privately).
2019-11-13 13:03:20 +00:00
function ( qt_add_simd_part target )
qt_parse_all_arguments ( arg "qt_add_simd_part" "" ""
2019-03-11 14:09:33 +00:00
" N A M E ; S I M D ; $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; C O M P I L E _ F L A G S " $ { A R G N } )
if ( "x${arg_SIMD}" STREQUAL x )
2019-11-13 13:03:20 +00:00
message ( FATAL_ERROR "qt_add_simd_part needs a SIMD type to be set." )
2019-03-11 14:09:33 +00:00
endif ( )
set ( condition "QT_FEATURE_${arg_SIMD}" )
if ( "${arg_SIMD}" STREQUAL arch_haswell )
set ( condition "TEST_subarch_avx2 AND TEST_subarch_bmi AND TEST_subarch_bmi2 AND TEST_subarch_f16c AND TEST_subarch_fma AND TEST_subarch_lzcnt AND TEST_subarch_popcnt" )
elseif ( "${arg_SIMD}" STREQUAL avx512common )
set ( condition "TEST_subarch_avx512cd" )
elseif ( "${arg_SIMD}" STREQUAL avx512core )
set ( condition "TEST_subarch_avx512cd AND TEST_subarch_avx512bw AND TEST_subarch_avx512dq AND TEST_subarch_avx512vl" )
endif ( )
set ( name "${arg_NAME}" )
if ( "x${name}" STREQUAL x )
set ( name "${target}_simd_${arg_SIMD}" )
endif ( )
qt_evaluate_config_expression ( result ${ condition } )
if ( ${ result } )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
2019-11-13 13:03:20 +00:00
message ( "qt_add_simd_part(${target} SIMD ${arg_SIMD} ...): Evaluated" )
2019-03-11 14:09:33 +00:00
endif ( )
string ( TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags )
2020-03-12 10:01:35 +00:00
foreach ( source IN LISTS arg_SOURCES )
set_property ( SOURCE "${source}" APPEND
P R O P E R T Y C O M P I L E _ O P T I O N S
$ { $ { s i m d _ f l a g s } }
$ { a r g _ C O M P I L E _ F L A G S }
2019-02-11 11:12:07 +00:00
)
2020-03-12 10:01:35 +00:00
endforeach ( )
set_source_files_properties ( ${ arg_SOURCES } PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE )
target_sources ( ${ target } PRIVATE ${ arg_SOURCES } )
2019-03-11 14:09:33 +00:00
else ( )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
2019-11-13 13:03:20 +00:00
message ( "qt_add_simd_part(${target} SIMD ${arg_SIMD} ...): Skipped" )
2019-03-11 14:09:33 +00:00
endif ( )
endif ( )
endfunction ( )
2019-06-14 10:59:07 +00:00
# From Qt6CoreMacros
2018-10-24 13:20:27 +00:00
# Function used to create the names of output files preserving relative dirs
2018-11-08 21:29:27 +00:00
function ( qt_make_output_file infile prefix suffix source_dir binary_dir result )
get_filename_component ( outfilename "${infile}" NAME_WE )
set ( base_dir "${source_dir}" )
string ( FIND "${infile}" "${binary_dir}/" in_binary )
if ( in_binary EQUAL 0 )
set ( base_dir "${binary_dir}" )
2018-10-24 13:20:27 +00:00
endif ( )
2018-11-08 21:29:27 +00:00
get_filename_component ( abs_infile "${infile}" ABSOLUTE BASE_DIR "${base_dir}" )
file ( RELATIVE_PATH rel_infile "${base_dir}" "${abs_infile}" )
string ( REPLACE "../" "__/" mapped_infile "${rel_infile}" )
get_filename_component ( abs_mapped_infile "${mapped_infile}" ABSOLUTE BASE_DIR "${binary_dir}" )
get_filename_component ( outpath "${abs_mapped_infile}" PATH )
2018-10-24 13:20:27 +00:00
file ( MAKE_DIRECTORY "${outpath}" )
2018-12-07 12:13:24 +00:00
set ( "${result}" "${outpath}/${prefix}${outfilename}${suffix}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2018-11-08 21:29:27 +00:00
2018-12-12 09:55:20 +00:00
# Complete manual moc invocation with full control.
# Use AUTOMOC whenever possible.
function ( qt_manual_moc result )
2020-02-03 15:52:18 +00:00
cmake_parse_arguments ( arg "" "OUTPUT_MOC_JSON_FILES" "FLAGS" ${ ARGN } )
2018-12-12 09:55:20 +00:00
set ( moc_files )
2020-02-03 15:52:18 +00:00
set ( metatypes_json_list )
2018-12-12 09:55:20 +00:00
foreach ( infile ${ arg_UNPARSED_ARGUMENTS } )
qt_make_output_file ( "${infile}" "moc_" ".cpp"
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } " " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } " o u t f i l e )
list ( APPEND moc_files "${outfile}" )
2018-10-24 13:20:27 +00:00
2018-12-12 09:55:20 +00:00
set ( moc_parameters_file "${outfile}_parameters$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>" )
set ( moc_parameters ${ arg_FLAGS } -o "${outfile}" "${infile}" )
2020-02-03 15:52:18 +00:00
set ( metatypes_byproducts )
if ( arg_OUTPUT_MOC_JSON_FILES )
set ( moc_json_file "${outfile}.json" )
list ( APPEND moc_parameters --output-json )
list ( APPEND metatypes_json_list "${outfile}.json" )
set ( metatypes_byproducts "${outfile}.json" )
endif ( )
2018-12-12 09:55:20 +00:00
string ( REPLACE ";" "\n" moc_parameters "${moc_parameters}" )
2018-10-24 13:20:27 +00:00
2018-12-12 09:55:20 +00:00
file ( GENERATE OUTPUT "${moc_parameters_file}" CONTENT "${moc_parameters}\n" )
2018-10-24 13:20:27 +00:00
2020-02-03 15:52:18 +00:00
add_custom_command ( OUTPUT "${outfile}" ${ metatypes_byproducts }
2019-02-12 09:02:15 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : m o c " @ $ { m o c _ p a r a m e t e r s _ f i l e } "
D E P E N D S " $ { i n f i l e } " $ { m o c _ d e p e n d s } $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : m o c
2018-12-12 09:55:20 +00:00
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } " V E R B A T I M )
2018-10-24 13:20:27 +00:00
endforeach ( )
2018-12-12 09:55:20 +00:00
set ( "${result}" ${ moc_files } PARENT_SCOPE )
2020-02-03 15:52:18 +00:00
# Register generated json files
if ( arg_OUTPUT_MOC_JSON_FILES )
set ( ${ arg_OUTPUT_MOC_JSON_FILES } "${metatypes_json_list}" PARENT_SCOPE )
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
2018-10-29 15:53:51 +00:00
# helper to set up a qdbusxml2cpp rule
function ( qt_create_qdbusxml2cpp_command target infile )
2019-01-30 13:06:48 +00:00
qt_parse_all_arguments ( arg "qt_create_qdbusxml2cpp_command" "ADAPTOR;INTERFACE" "BASENAME" "FLAGS" ${ ARGN } )
2018-12-07 12:13:24 +00:00
if ( ( arg_ADAPTOR AND arg_INTERFACE ) OR ( NOT arg_ADAPTOR AND NOT arg_INTERFACE ) )
2018-10-29 15:53:51 +00:00
message ( FATAL_ERROR "qt_create_dbusxml2cpp_command needs either ADAPTOR or INTERFACE." )
endif ( )
2018-12-07 12:13:24 +00:00
set ( option "-a" )
set ( type "adaptor" )
if ( arg_INTERFACE )
set ( option "-p" )
set ( type "interface" )
2018-10-29 15:53:51 +00:00
endif ( )
2019-01-30 13:06:48 +00:00
if ( "${arg_BASENAME}" STREQUAL "" )
2019-03-18 18:10:28 +00:00
get_filename_component ( file_dir "${infile}" DIRECTORY )
get_filename_component ( file_name "${infile}" NAME_WLE )
get_filename_component ( file_ext "${infile}" LAST_EXT )
if ( "${file_ext}" STREQUAL ".xml" )
else ( )
message ( FATAL_ERROR "DBUS ${type} input file is not xml." )
endif ( )
# use last part of io.qt.something.xml!
get_filename_component ( file_ext "${file_name}" LAST_EXT )
if ( "x${file_ext}" STREQUAL "x" )
else ( )
string ( SUBSTRING "${file_ext}" 1 -1 file_name ) # cut of leading '.'
endif ( )
2019-01-30 13:06:48 +00:00
string ( TOLOWER "${file_name}" file_name )
set ( file_name "${file_name}_${type}" )
else ( )
set ( file_name ${ arg_BASENAME } )
endif ( )
2019-04-16 10:53:24 +00:00
# Use absolute file path for the source file and set the current working directory to the
# current binary directory, because setting an absolute path for the header:source combo option
# does not work. Splitting on ":" breaks inside the dbus tool when running on Windows
# due to ":" being contained in the drive path (e.g C:\foo.h:C:\foo.cpp).
get_filename_component ( absolute_in_file_path "${infile}" ABSOLUTE )
2018-10-29 15:53:51 +00:00
2019-04-16 10:53:24 +00:00
set ( header_file "${file_name}.h" )
set ( source_file "${file_name}.cpp" )
2018-10-29 15:53:51 +00:00
add_custom_command ( OUTPUT "${header_file}" "${source_file}"
2019-04-16 10:53:24 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : q d b u s x m l 2 c p p $ { a r g _ F L A G S } " $ { o p t i o n } "
" $ { h e a d e r _ f i l e } : $ { s o u r c e _ f i l e } " " $ { a b s o l u t e _ i n _ f i l e _ p a t h } "
2020-01-31 13:44:52 +00:00
D E P E N D S " $ { a b s o l u t e _ i n _ f i l e _ p a t h } " $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : q d b u s x m l 2 c p p
2019-04-16 10:53:24 +00:00
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
2018-10-29 15:53:51 +00:00
V E R B A T I M )
2018-12-12 09:55:20 +00:00
target_sources ( "${target}" PRIVATE "${header_file}" "${source_file}" )
2018-10-29 15:53:51 +00:00
endfunction ( )
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
function ( qt_compute_injection_forwarding_header target )
qt_parse_all_arguments ( arg "qt_compute_injection_forwarding_header"
" P R I V A T E " " S O U R C E ; O U T _ V A R " " " $ { A R G N } )
2018-12-07 13:04:42 +00:00
qt_internal_module_info ( module "${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
get_filename_component ( file_name "${arg_SOURCE}" NAME )
2018-10-24 13:20:27 +00:00
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 ( source_absolute_path "${CMAKE_CURRENT_BINARY_DIR}/${arg_SOURCE}" )
2019-11-21 12:33:28 +00:00
file ( RELATIVE_PATH relpath "${PROJECT_BINARY_DIR}" "${source_absolute_path}" )
2018-10-24 13:20:27 +00:00
2018-12-07 12:13:24 +00:00
if ( arg_PRIVATE )
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 ( fwd "${PROJECT_VERSION}/${module}/private/${file_name}" )
2018-10-24 13:20:27 +00:00
else ( )
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 ( fwd "${file_name}" )
2018-10-24 13:20:27 +00:00
endif ( )
2019-06-14 13:29:21 +00:00
string ( APPEND ${ arg_OUT_VAR } " ${relpath}:${fwd}" )
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 ( ${ arg_OUT_VAR } ${ ${arg_OUT_VAR } } PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-11-13 13:03:20 +00:00
function ( qt_add_docs )
2019-09-18 07:27:22 +00:00
if ( ${ ARGC } EQUAL 1 )
# Function called from old generated CMakeLists.txt that was missing the target parameter
return ( )
endif ( )
if ( NOT ${ ARGC } EQUAL 2 )
2019-11-13 13:03:20 +00:00
message ( FATAL_ERROR "qt_add_docs called with the wrong number of arguments. Should be qt_add_docs(target path_to_project.qdocconf)." )
2019-09-18 07:27:22 +00:00
return ( )
endif ( )
set ( target ${ ARGV0 } )
set ( doc_project ${ ARGV1 } )
2019-09-19 07:38:09 +00:00
2020-03-26 13:19:21 +00:00
# If a target is not built (which can happen for tools when crosscompiling, we shouldn't try
# to generate docs.
if ( NOT TARGET "${target}" )
return ( )
endif ( )
2019-11-21 12:33:28 +00:00
if ( NOT QT_SUPERBUILD OR QT_WILL_INSTALL )
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
set ( qdoc_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qdoc" )
set ( qtattributionsscanner_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qtattributionsscanner" )
set ( qhelpgenerator_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qhelpgenerator" )
2019-11-21 12:33:28 +00:00
else ( )
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
set ( qdoc_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/qtbase/${INSTALL_BINDIR}/qdoc" )
set ( qtattributionsscanner_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/qtbase/${INSTALL_BINDIR}/qtattributionsscanner" )
set ( qhelpgenerator_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/qtbase/${INSTALL_BINDIR}/qhelpgenerator" )
2019-11-21 12:33:28 +00:00
endif ( )
2019-09-19 07:38:09 +00:00
get_target_property ( target_type ${ target } TYPE )
if ( NOT target_type STREQUAL "INTERFACE_LIBRARY" )
get_target_property ( target_bin_dir ${ target } BINARY_DIR )
get_target_property ( target_source_dir ${ target } SOURCE_DIR )
else ( )
set ( target_bin_dir ${ CMAKE_CURRENT_BINARY_DIR } )
set ( target_source_dir ${ CMAKE_CURRENT_SOURCE_DIR } )
endif ( )
set ( doc_ouput_dir "${target_bin_dir}/.doc" )
# Generate include dir list
2019-12-06 14:12:17 +00:00
set ( target_include_dirs_file "${doc_ouput_dir}/$<CONFIG>/includes.txt" )
2019-09-19 07:38:09 +00:00
set ( include_paths_property "$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>" )
if ( NOT target_type STREQUAL "INTERFACE_LIBRARY" )
file ( GENERATE
O U T P U T $ { t a r g e t _ i n c l u d e _ d i r s _ f i l e }
C O N T E N T " - I $ < J O I N : $ { i n c l u d e _ p a t h s _ p r o p e r t y } , \ n - I > "
)
set ( include_path_args "@${target_include_dirs_file}" )
else ( )
set ( include_path_args "" )
endif ( )
get_filename_component ( doc_target "${doc_project}" NAME_WLE )
if ( QT_WILL_INSTALL )
2020-02-07 16:02:27 +00:00
set ( qdoc_output_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}/${doc_target}" )
set ( index_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}" )
2019-11-21 12:33:28 +00:00
elseif ( QT_SUPERBUILD )
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
set ( qdoc_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/qtbase/${INSTALL_DOCDIR}/${doc_target}" )
set ( index_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/qtbase/${INSTALL_DOCDIR}" )
2019-09-19 07:38:09 +00:00
else ( )
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
set ( qdoc_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}/${doc_target}" )
set ( index_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}" )
2019-09-19 07:38:09 +00:00
endif ( )
# qtattributionsscanner
add_custom_target ( qattributionsscanner_ ${ target }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { q a t t r i b u t i o n s s c a n n e r _ b i n }
2019-09-19 07:38:09 +00:00
C O M M A N D $ { q t a t t r i b u t i o n s s c a n n e r _ b i n }
$ { P R O J E C T _ S O U R C E _ D I R }
- - f i l t e r " Q D o c M o d u l e = $ { q d o c _ t a r g e t } "
- o " $ { t a r g e t _ b i n _ d i r } / c o d e a t t r i b u t i o n s . q d o c "
)
# prepare docs target
set ( prepare_qdoc_args
- o u t p u t d i r " $ { q d o c _ o u t p u t _ d i r } "
2020-02-07 16:02:27 +00:00
- i n s t a l l d i r " $ { Q T _ I N S T A L L _ D I R } / $ { I N S T A L L _ D O C D I R } "
2019-09-19 07:38:09 +00:00
" $ { t a r g e t _ s o u r c e _ d i r } / $ { d o c _ p r o j e c t } "
- p r e p a r e
- i n d e x d i r " $ { i n d e x _ d i r } "
- n o - l i n k - e r r o r s
" $ { i n c l u d e _ p a t h _ a r g s } "
)
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
if ( QT_WILL_INSTALL )
2020-02-07 16:02:27 +00:00
set ( qt_install_docs_env "${CMAKE_INSTALL_PREFIX}/${INSTALL_DOCDIR}" )
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
elseif ( QT_SUPERBUILD )
set ( qt_install_docs_env "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/qtbase/${INSTALL_DOCDIR}" )
else ( )
set ( qt_install_docs_env "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}" )
2019-11-21 12:33:28 +00:00
endif ( )
2019-09-19 07:38:09 +00:00
set ( qdoc_env_args
2019-11-21 12:33:28 +00:00
" Q T _ I N S T A L L _ D O C S = \ " $ { q t _ i n s t a l l _ d o c s _ e n v } \ " "
2019-09-19 07:38:09 +00:00
" Q T _ V E R S I O N = $ { P R O J E C T _ V E R S I O N _ M A J O R } . $ { P R O J E C T _ V E R S I O N _ M I N O R } . $ { P R O J E C T _ V E R S I O N _ P A T C H } "
" Q T _ V E R = $ { P R O J E C T _ V E R S I O N _ M A J O R } . $ { P R O J E C T _ V E R S I O N _ M I N O R } "
" Q T _ V E R S I O N _ T A G = $ { P R O J E C T _ V E R S I O N _ M A J O R } $ { P R O J E C T _ V E R S I O N _ M I N O R } $ { P R O J E C T _ V E R S I O N _ P A T C H } "
" B U I L D D I R = $ { t a r g e t _ b i n _ d i r } "
)
add_custom_target ( prepare_docs_ ${ target }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { q d o c _ b i n }
2019-09-19 07:38:09 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E e n v $ { q d o c _ e n v _ a r g s }
$ { q d o c _ b i n }
$ { p r e p a r e _ q d o c _ a r g s }
)
add_dependencies ( prepare_docs_ ${ target } qattributionsscanner_ ${ target } )
# generate docs target
set ( generate_qdocs_args
- o u t p u t d i r " $ { q d o c _ o u t p u t _ d i r } "
- i n s t a l l d i r " $ { I N S T A L L _ D O C D I R } "
" $ { t a r g e t _ s o u r c e _ d i r } / $ { d o c _ p r o j e c t } "
- g e n e r a t e
- i n d e x d i r " $ { i n d e x _ d i r } "
" $ { i n c l u d e _ p a t h _ a r g s } "
)
add_custom_target ( generate_docs_ ${ target }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { q d o c _ b i n }
2019-09-19 07:38:09 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E e n v $ { q d o c _ e n v _ a r g s }
$ { q d o c _ b i n }
$ { g e n e r a t e _ q d o c s _ a r g s }
)
add_dependencies ( generate_docs_ ${ target } prepare_docs_ ${ target } )
# generate html
set ( html_qdocs_args
- o u t p u t d i r " $ { q d o c _ o u t p u t _ d i r } "
- i n s t a l l d i r " $ { I N S T A L L _ D O C D I R } "
" $ { t a r g e t _ s o u r c e _ d i r } / $ { d o c _ p r o j e c t } "
- i n d e x d i r " $ { i n d e x _ d i r } "
" $ { i n c l u d e _ p a t h _ a r g s } "
)
add_custom_target ( html_docs_ ${ target }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { q d o c _ b i n }
2019-09-19 07:38:09 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E e n v $ { q d o c _ e n v _ a r g s }
$ { q d o c _ b i n }
$ { h t m l _ q d o c s _ a r g s }
)
add_dependencies ( html_docs_ ${ target } generate_docs_ ${ target } )
# generate .qch
set ( qch_file_name ${ doc_target } .qch )
set ( qch_file_path ${ qdoc_output_dir } / ${ qch_file_name } )
add_custom_target ( qch_docs_ ${ target }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { q h e l p g e n e r a t o r _ b i n }
2019-09-19 07:38:09 +00:00
C O M M A N D $ { q h e l p g e n e r a t o r _ b i n }
" $ { q d o c _ o u t p u t _ d i r } / $ { d o c _ t a r g e t } . q h p "
- o " $ { q c h _ f i l e _ p a t h } "
)
add_dependencies ( qch_docs_ ${ target } generate_docs_ ${ target } )
if ( QT_WILL_INSTALL )
add_custom_target ( install_html_docs_ ${ target }
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
" $ { q d o c _ o u t p u t _ d i r } "
" $ { C M A K E _ I N S T A L L _ P R E F I X } / $ { I N S T A L L _ D O C D I R } / $ { d o c _ t a r g e t } "
2020-02-07 16:02:27 +00:00
C O M M E N T " I n s t a l l i n g h t m l d o c s f o r t a r g e t $ { t a r g e t } "
2019-09-19 07:38:09 +00:00
)
add_custom_target ( install_qch_docs_ ${ target }
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ i f _ d i f f e r e n t
" $ { q c h _ f i l e _ p a t h } "
" $ { C M A K E _ I N S T A L L _ P R E F I X } / $ { I N S T A L L _ D O C D I R } / $ { q c h _ f i l e _ n a m e } "
C O M M E N T " I n s t a l l i n g q c h d o c s f o r t a r g e t $ { t a r g e t } "
)
else ( )
# Don't need to do anything when not installing
add_custom_target ( install_html_docs_ ${ target } )
add_custom_target ( install_qch_docs_ ${ target } )
endif ( )
add_dependencies ( install_html_docs_ ${ target } html_docs_ ${ target } )
add_dependencies ( install_qch_docs_ ${ target } qch_docs_ ${ target } )
add_custom_target ( install_docs_ ${ target } )
add_dependencies ( install_docs_ ${ target } install_html_docs_ ${ target } install_qch_docs_ ${ target } )
2020-03-18 15:07:44 +00:00
add_custom_target ( docs_ ${ target } )
add_dependencies ( docs_ ${ target } html_docs_ ${ target } )
add_dependencies ( docs_ ${ target } qch_docs_ ${ target } )
2019-09-19 07:38:09 +00:00
add_dependencies ( ${ qt_docs_prepare_target_name } prepare_docs_ ${ target } )
add_dependencies ( ${ qt_docs_generate_target_name } generate_docs_ ${ target } )
add_dependencies ( ${ qt_docs_html_target_name } html_docs_ ${ target } )
add_dependencies ( ${ qt_docs_qch_target_name } qch_docs_ ${ target } )
2020-03-18 15:07:44 +00:00
add_dependencies ( ${ qt_docs_target_name } docs_ ${ target } )
2019-09-19 07:38:09 +00:00
add_dependencies ( ${ qt_docs_install_html_target_name } install_html_docs_ ${ target } )
add_dependencies ( ${ qt_docs_install_qch_target_name } install_qch_docs_ ${ target } )
add_dependencies ( ${ qt_docs_install_target_name } install_docs_ ${ target } )
2018-10-24 13:20:27 +00:00
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
macro ( qt_find_package )
# Get the target names we expect to be provided by the package.
2019-05-03 13:46:02 +00:00
set ( options CONFIG NO_MODULE MODULE REQUIRED )
2020-04-22 19:01:32 +00:00
set ( oneValueArgs MODULE_NAME QMAKE_LIB )
2019-05-03 13:46:02 +00:00
set ( multiValueArgs PROVIDED_TARGETS COMPONENTS )
cmake_parse_arguments ( arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
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-10-01 13:22:27 +00:00
# If some Qt internal project calls qt_find_package(WrapFreeType), but WrapFreeType was already
# found as part of a find_dependency() call from a ModuleDependencies.cmake file (or similar),
# and the provided target is also found, that means this might have been an unnecessary
# qt_find_package() call, because the dependency was already found via some other transitive
# dependency. Return early, so that CMake doesn't fail wiht an error with trying to promote the
# targets to be global. This behavior is not enabled by default, because there are cases
# when a regular find_package() (non qt_) can find a package (Freetype -> PNG), and a subsequent
# qt_find_package(PNG PROVIDED_TARGET PNG::PNG) still needs to succeed and register the provided
2020-04-29 08:46:53 +00:00
# targets. To enable the debugging behavior, set QT_DEBUG_QT_FIND_PACKAGE to 1.
2019-10-01 13:22:27 +00:00
set ( _qt_find_package_skip_find_package FALSE )
2020-04-29 08:46:53 +00:00
if ( QT_DEBUG_QT_FIND_PACKAGE AND ${ ARGV0 } _FOUND AND arg_PROVIDED_TARGETS )
2019-10-01 13:22:27 +00:00
set ( _qt_find_package_skip_find_package TRUE )
foreach ( qt_find_package_target_name ${ arg_PROVIDED_TARGETS } )
if ( NOT TARGET ${ qt_find_package_target_name } )
set ( _qt_find_package_skip_find_package FALSE )
endif ( )
endforeach ( )
if ( _qt_find_package_skip_find_package )
message ( AUTHOR_WARNING "qt_find_package(${ARGV0}) called even though the package "
" w a s a l r e a d y f o u n d . C o n s i d e r r e m o v i n g t h e c a l l . " )
endif ( )
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
# Get the version if specified.
set ( package_version "" )
if ( ${ ARGC } GREATER_EQUAL 2 )
if ( ${ ARGV1 } MATCHES "^[0-9\.]+$" )
set ( package_version "${ARGV1}" )
endif ( )
endif ( )
if ( arg_COMPONENTS )
# Re-append components to forward them.
list ( APPEND arg_UNPARSED_ARGUMENTS "COMPONENTS;${arg_COMPONENTS}" )
endif ( )
2019-10-01 13:22:27 +00:00
if ( NOT ( arg_CONFIG OR arg_NO_MODULE OR arg_MODULE ) AND NOT _qt_find_package_skip_find_package )
2019-05-03 13:46:02 +00:00
# Try to find a config package first in quiet mode
set ( config_package_arg ${ arg_UNPARSED_ARGUMENTS } )
list ( APPEND config_package_arg "CONFIG;QUIET" )
find_package ( ${ config_package_arg } )
2019-06-03 09:06:07 +00:00
# Double check that in config mode the targets become visible. Sometimes
# only the module mode creates the targets. For example with vcpkg, the sqlite
# package provides sqlite3-config.cmake, which offers multi-config targets but
# in their own way. CMake has FindSQLite3.cmake and with the original
# qt_find_package(SQLite3) call it is our intention to use the cmake package
# in module mode.
if ( ${ ARGV0 } _FOUND AND arg_PROVIDED_TARGETS )
2019-06-05 09:45:23 +00:00
unset ( any_target_found )
2019-06-03 09:06:07 +00:00
foreach ( expected_target ${ arg_PROVIDED_TARGETS } )
if ( TARGET ${ expected_target } )
set ( any_target_found TRUE )
break ( )
endif ( )
endforeach ( )
if ( NOT any_target_found )
2019-06-05 09:45:23 +00:00
unset ( ${ ARGV0 } _FOUND )
2019-06-03 09:06:07 +00:00
endif ( )
endif ( )
2019-05-03 13:46:02 +00:00
endif ( )
# Ensure the options are back in the original unparsed arguments
foreach ( opt IN LISTS options )
if ( arg_ ${ opt } )
list ( APPEND arg_UNPARSED_ARGUMENTS ${ opt } )
endif ( )
endforeach ( )
2019-10-01 13:22:27 +00:00
if ( NOT ${ ARGV0 } _FOUND AND NOT _qt_find_package_skip_find_package )
2019-09-27 11:29:47 +00:00
# Unset the NOTFOUND ${package}_DIR var that might have been set by the previous
# find_package call, to get rid of "not found" messagees in the feature summary
# if the package is found by the next find_package call.
if ( DEFINED CACHE{ ${ ARGV0 } _DIR} AND NOT ${ ARGV0 } _DIR )
unset ( ${ ARGV0 } _DIR CACHE )
endif ( )
2019-05-03 13:46:02 +00:00
# Call original function without our custom arguments.
find_package ( ${ arg_UNPARSED_ARGUMENTS } )
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-10-01 13:22:27 +00:00
if ( ${ ARGV0 } _FOUND AND arg_PROVIDED_TARGETS AND NOT _qt_find_package_skip_find_package )
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
# If package was found, associate each target with its package name. This will be used
# later when creating Config files for Qt libraries, to generate correct find_dependency()
# calls. Also make the provided targets global, so that the properties can be read in
# all scopes.
foreach ( qt_find_package_target_name ${ arg_PROVIDED_TARGETS } )
if ( TARGET ${ qt_find_package_target_name } )
2019-06-04 10:02:14 +00:00
# Allow usage of aliased targets by setting properties on the actual target
get_target_property ( aliased_target ${ qt_find_package_target_name } ALIASED_TARGET )
if ( aliased_target )
set ( qt_find_package_target_name ${ aliased_target } )
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
set_target_properties ( ${ qt_find_package_target_name }
P R O P E R T I E S I N T E R F A C E _ Q T _ P A C K A G E _ N A M E $ { A R G V 0 } )
if ( package_version )
set_target_properties ( ${ qt_find_package_target_name }
P R O P E R T I E S I N T E R F A C E _ Q T _ P A C K A G E _ V E R S I O N $ { A R G V 1 } )
endif ( )
if ( arg_COMPONENTS )
2019-06-25 12:44:29 +00:00
string ( REPLACE ";" " " components_as_string "${arg_COMPONENTS}" )
set_property ( TARGET ${ qt_find_package_target_name }
P R O P E R T Y I N T E R F A C E _ Q T _ P A C K A G E _ C O M P O N E N T S $ { c o m p o n e n t s _ a s _ s t r i n g } )
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 ( )
get_property ( is_global TARGET ${ qt_find_package_target_name } PROPERTY
I M P O R T E D _ G L O B A L )
if ( NOT is_global )
set_property ( TARGET ${ qt_find_package_target_name } PROPERTY
I M P O R T E D _ G L O B A L T R U E )
endif ( )
endif ( )
endforeach ( )
2020-04-22 19:01:32 +00:00
if ( arg_MODULE_NAME AND arg_QMAKE_LIB
AND ( NOT arg_QMAKE_LIB IN_LIST QT_QMAKE_LIBS_FOR_ ${ arg_MODULE_NAME } ) )
set ( QT_QMAKE_LIBS_FOR_ ${ arg_MODULE_NAME }
$ { Q T _ Q M A K E _ L I B S _ F O R _ $ { a r g _ M O D U L E _ N A M E } } ; $ { a r g _ Q M A K E _ L I B } C A C H E I N T E R N A L " " )
set ( QT_QMAKE_LIB_TARGETS_ ${ arg_QMAKE_LIB } ${ arg_PROVIDED_TARGETS } CACHE INTERNAL "" )
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
endif ( )
endmacro ( )
2019-02-11 11:12:07 +00:00
2020-04-22 19:01:32 +00:00
macro ( qt_add_qmake_lib_dependency lib dep )
string ( REPLACE "-" "_" dep ${ dep } )
string ( TOUPPER "${dep}" ucdep )
list ( APPEND QT_QMAKE_LIB_DEPS_ ${ lib } ${ ucdep } )
endmacro ( )
Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.
Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.
Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
have a .git subdir and thus defaults to be built in Release
mode, even though qtbase might have been built in Debug, so to
avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
the tests project doesn't specify a major version, and if we
override the values, the moc / uic targets don't get the correct
major version prefix and configuration fails
Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 08:22:08 +00:00
macro ( qt_find_apple_system_frameworks )
if ( APPLE )
find_library ( FWAppKit AppKit )
2019-04-08 15:23:57 +00:00
find_library ( FWAssetsLibrary AssetsLibrary )
find_library ( FWAudioToolbox AudioToolbox )
Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.
Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.
Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
have a .git subdir and thus defaults to be built in Release
mode, even though qtbase might have been built in Debug, so to
avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
the tests project doesn't specify a major version, and if we
override the values, the moc / uic targets don't get the correct
major version prefix and configuration fails
Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 08:22:08 +00:00
find_library ( FWApplicationServices ApplicationServices )
find_library ( FWCarbon Carbon )
find_library ( FWCoreFoundation CoreFoundation )
find_library ( FWCoreServices CoreServices )
2019-04-08 15:23:57 +00:00
find_library ( FWCoreGraphics CoreGraphics )
find_library ( FWCoreText CoreText )
Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.
Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.
Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
have a .git subdir and thus defaults to be built in Release
mode, even though qtbase might have been built in Debug, so to
avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
the tests project doesn't specify a major version, and if we
override the values, the moc / uic targets don't get the correct
major version prefix and configuration fails
Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 08:22:08 +00:00
find_library ( FWCoreVideo CoreVideo )
find_library ( FWcups cups )
find_library ( FWDiskArbitration DiskArbitration )
find_library ( FWFoundation Foundation )
2019-10-01 09:01:26 +00:00
find_library ( FWIOBluetooth IOBluetooth )
Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.
Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.
Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
have a .git subdir and thus defaults to be built in Release
mode, even though qtbase might have been built in Debug, so to
avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
the tests project doesn't specify a major version, and if we
override the values, the moc / uic targets don't get the correct
major version prefix and configuration fails
Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 08:22:08 +00:00
find_library ( FWIOKit IOKit )
find_library ( FWIOSurface IOSurface )
find_library ( FWImageIO ImageIO )
find_library ( FWMetal Metal )
find_library ( FWMobileCoreServices MobileCoreServices )
find_library ( FWQuartzCore QuartzCore )
find_library ( FWSecurity Security )
find_library ( FWSystemConfiguration SystemConfiguration )
find_library ( FWUIKit UIKit )
find_library ( FWWatchKit WatchKit )
2019-10-01 08:36:51 +00:00
find_library ( FWGameController GameController )
Allow building the tests directory as a standalone CMake project
At the moment, Coin builds tests as a separate qmake invocation
against an installed Qt. We need to support the same with CMake.
Change the tests subdirectory to be a standalone CMake project when
CMake does not detect an existing QtTest target while processing the
subdirectory. If the target exists, it means we are building the whole
repo, if the target does not exist, we need to call find_package
to find the installed Qt.
Refactor and move around a few things to make standalone tests build
successfully:
- add a new macro to set up paths to find QtSetup
- add a new macro to find all macOS frameworks
- add a new macro to set up building tests
- add a new macro that actually builds the tests
- export the INSTALL_CMAKE_NAMESPACE value into the BuildInternals
Config file
- export the CMAKE_BUILD_TYPE value, because a test project doesn't
have a .git subdir and thus defaults to be built in Release
mode, even though qtbase might have been built in Debug, so to
avoid the mixing, the propagate the build type
- stop overriding INSTALL_CMAKE_NAMESPACE and
QT_CMAKE_EXPORT_NAMESPACE inside QtSetup if they are set, because
the tests project doesn't specify a major version, and if we
override the values, the moc / uic targets don't get the correct
major version prefix and configuration fails
Change-Id: Ibdb03687302567fe325a15f6d1cb922c76240675
Fixes: QTBUG-75090
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-22 08:22:08 +00:00
endif ( )
endmacro ( )
2019-05-28 12:13:27 +00:00
# Match the pattern 'regex' in 'input_line', replace the match with 'replacement'
# and set that result in 'out_var' in the parent scope.
function ( qt_regex_match_and_get input_line regex replacement out_var )
string ( REGEX MATCH "${regex}" match "${input_line}" )
if ( match )
string ( REGEX REPLACE "${regex}" "${replacement}" match "${input_line}" )
string ( STRIP ${ match } match )
set ( ${ out_var } "${match}" PARENT_SCOPE )
endif ( )
endfunction ( )
# Match 'regex' in a list of lines. When found, set the value to 'out_var' and break early.
function ( qt_qlalr_find_option_in_list input_list regex out_var )
foreach ( line ${ input_list } )
qt_regex_match_and_get ( "${line}" "${regex}" "\\1" option )
if ( option )
string ( TOLOWER ${ option } option )
set ( ${ out_var } "${option}" PARENT_SCOPE )
return ( )
endif ( )
endforeach ( )
message ( FATAL_ERROR "qt_qlalr_find_option_in_list: Could not extract ${out_var}" )
endfunction ( )
# Generate a few output files using qlalr, and assign those to 'consuming_target'.
# 'input_file_list' is a list of 'foo.g' file paths.
# 'flags' are extra flags to be passed to qlalr.
2019-10-11 11:42:06 +00:00
function ( qt_process_qlalr consuming_target input_file_list flags )
2019-05-28 12:13:27 +00:00
foreach ( input_file ${ input_file_list } )
file ( STRINGS ${ input_file } input_file_lines )
qt_qlalr_find_option_in_list ( "${input_file_lines}" "^%parser(.+)" "parser" )
qt_qlalr_find_option_in_list ( "${input_file_lines}" "^%decl(.+)" "decl" )
qt_qlalr_find_option_in_list ( "${input_file_lines}" "^%impl(.+)" "impl" )
get_filename_component ( base_file_name ${ input_file } NAME_WE )
set ( cpp_file "${parser}.cpp" )
set ( private_file "${parser}_p.h" )
set ( decl_file "${decl}" )
set ( impl_file "${impl}" )
add_custom_command (
O U T P U T $ { c p p _ f i l e } $ { p r i v a t e _ f i l e } $ { d e c l _ f i l e } $ { i m p l _ f i l e }
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : q l a l r $ { f l a g s } $ { i n p u t _ f i l e }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : q l a l r
2019-05-28 12:13:27 +00:00
M A I N _ D E P E N D E N C Y $ { i n p u t _ f i l e }
)
target_sources ( ${ consuming_target } PRIVATE ${ cpp_file } ${ impl_file } )
endforeach ( )
endfunction ( )
CMake: Introduce qt_configure_file
It has the same kind of signature as file(GENERATE) but
creates the files at configure time rather than generation time.
CMake provides a few ways to generate files
file(WRITE) -> always overrides content
configure_file() -> only overrides if content changes, creates file
at configure time, can only take a file as input
file(GENERATE) -> only overrides if content changes, creats file
at generation time, can take a string or file
as input
Because dealing with an input file is a hassle (need to create one,
make sure it's installed, make sure it's used correctly in the
various build types like super-build, non-prefix-build, etc)
people tend to use file(GENERATE) instead, which can take a string
argument, and is thus easier to use.
Unfortunately that introduces subtle bugs because the
file is created at generation time, but there are existence
checks which are done at configuration time.
Thus qt_configure_file allows creation of files at configure time,
without having to provide an input file. Underneath it uses
configure_file(). Once CMake 3.18 is released, the implementation
can be switched to use file(CONFIGURE).
Change-Id: Ic8f8d88541ef0b25d01af143352c8c9ba390ad5f
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-20 14:03:54 +00:00
# qt_configure_file(OUTPUT output-file <INPUT input-file | CONTENT content>)
# input-file is relative to ${CMAKE_CURRENT_SOURCE_DIR}
# output-file is relative to ${CMAKE_CURRENT_BINARY_DIR}
#
# This function is similar to file(GENERATE OUTPUT) except it writes the content
# to the file at configure time, rather than at generate time. Once CMake 3.18 is released, it can use file(CONFIGURE) in its implmenetation. Until then, it
# uses configure_file() with a generic input file as source, when used with the CONTENT signature.
function ( qt_configure_file )
qt_parse_all_arguments ( arg "qt_configure_file" "" "OUTPUT;INPUT;CONTENT" "" ${ ARGN } )
if ( NOT arg_OUTPUT )
message ( FATAL_ERROR "No output file provided to qt_configure_file." )
endif ( )
if ( arg_CONTENT )
set ( template_name "QtFileConfigure.txt.in" )
# When building qtbase, use the source template file.
# Otherwise use the installed file.
# This should work for non-prefix and superbuilds as well.
if ( QtBase_SOURCE_DIR )
set ( input_file "${QtBase_SOURCE_DIR}/cmake/${template_name}" )
else ( )
set ( input_file "${Qt6_DIR}/${template_name}" )
endif ( )
set ( __qt_file_configure_content "${arg_CONTENT}" )
elseif ( arg_INPUT )
set ( input_file "${arg_INPUT}" )
else ( )
message ( FATAL_ERROR "No input value provided to qt_configure_file." )
endif ( )
configure_file ( "${input_file}" "${arg_OUTPUT}" @ONLY )
endfunction ( )
2019-05-31 14:30:09 +00:00
macro ( qt_add_string_to_qconfig_cpp str )
string ( LENGTH "${str}" length )
string ( APPEND QT_CONFIG_STRS " \" ${ str } \\0\"\n")
string ( APPEND QT_CONFIG_STR_OFFSETS " ${QT_CONFIG_STR_OFFSET},\n" )
math ( EXPR QT_CONFIG_STR_OFFSET "${QT_CONFIG_STR_OFFSET}+${length}+1" )
endmacro ( )
function ( qt_generate_qconfig_cpp )
set ( QT_CONFIG_STR_OFFSET "0" )
set ( QT_CONFIG_STR_OFFSETS "" )
set ( QT_CONFIG_STRS "" )
# Start first part.
2020-03-06 16:06:45 +00:00
qt_add_string_to_qconfig_cpp ( "${INSTALL_DOCDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_INCLUDEDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_LIBDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_LIBEXECDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_BINDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_PLUGINSDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_QMLDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_ARCHDATADIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_DATADIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_TRANSLATIONSDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_EXAMPLESDIR}" )
qt_add_string_to_qconfig_cpp ( "${INSTALL_TESTSDIR}" )
2019-05-31 14:30:09 +00:00
# Save first part.
set ( QT_CONFIG_STR_OFFSETS_FIRST "${QT_CONFIG_STR_OFFSETS}" )
set ( QT_CONFIG_STRS_FIRST "${QT_CONFIG_STRS}" )
# Start second part.
set ( QT_CONFIG_STR_OFFSETS "" )
set ( QT_CONFIG_STRS "" )
2020-03-06 16:06:45 +00:00
qt_add_string_to_qconfig_cpp ( "" ) # config.input.sysroot
qt_add_string_to_qconfig_cpp ( "false" ) # qmake_sysrootify
qt_add_string_to_qconfig_cpp ( "${INSTALL_BINDIR}" ) # TODO: Host-specific
qt_add_string_to_qconfig_cpp ( "${INSTALL_LIBDIR}" ) # TODO: Host-specific
qt_add_string_to_qconfig_cpp ( "${INSTALL_DATADIR}" ) # TODO: Host-specific
2019-05-31 14:30:09 +00:00
qt_add_string_to_qconfig_cpp ( "${QT_QMAKE_TARGET_MKSPEC}" )
qt_add_string_to_qconfig_cpp ( "${QT_QMAKE_HOST_MKSPEC}" )
# Save second part.
set ( QT_CONFIG_STR_OFFSETS_SECOND "${QT_CONFIG_STR_OFFSETS}" )
set ( QT_CONFIG_STRS_SECOND "${QT_CONFIG_STRS}" )
2019-10-11 14:55:55 +00:00
# Settings path / sysconf dir.
if ( APPLE )
set ( QT_DEFAULT_SYS_CONF_DIR "/Library/Preferences/Qt" )
else ( )
set ( QT_DEFAULT_SYS_CONF_DIR "etc/xdg" )
endif ( )
# Compute and set relocation prefixes.
# TODO: Clean this up, there's a bunch of unrealistic assumptions here.
# See qtConfOutput_preparePaths in qtbase/configure.pri.
if ( WIN32 )
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
set ( lib_location_absolute_path
" $ { Q T _ B U I L D _ I N T E R N A L S _ R E L O C A T A B L E _ I N S T A L L _ P R E F I X } / $ { I N S T A L L _ B I N D I R } " )
2019-10-11 14:55:55 +00:00
else ( )
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
set ( lib_location_absolute_path
" $ { Q T _ B U I L D _ I N T E R N A L S _ R E L O C A T A B L E _ I N S T A L L _ P R E F I X } / $ { I N S T A L L _ L I B D I R } " )
2019-10-11 14:55:55 +00:00
endif ( )
file ( RELATIVE_PATH from_lib_location_to_prefix
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
" $ { l i b _ l o c a t i o n _ a b s o l u t e _ p a t h } " " $ { Q T _ B U I L D _ I N T E R N A L S _ R E L O C A T A B L E _ I N S T A L L _ P R E F I X } " )
2019-10-11 14:55:55 +00:00
if ( QT_HOST_PATH )
set ( host_prefix "${QT_HOST_PATH}" )
2020-01-21 14:02:58 +00:00
set ( host_bin_dir_absolute_path "${QT_HOST_PATH}/${INSTALL_BINDIR}" )
2019-10-11 14:55:55 +00:00
else ( )
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
set ( host_prefix "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}" )
set ( host_bin_dir_absolute_path
" $ { Q T _ B U I L D _ I N T E R N A L S _ R E L O C A T A B L E _ I N S T A L L _ P R E F I X } / $ { I N S T A L L _ B I N D I R } " )
2019-10-11 14:55:55 +00:00
endif ( )
file ( RELATIVE_PATH from_host_bin_dir_to_host_prefix
" $ { h o s t _ b i n _ d i r _ a b s o l u t e _ p a t h } " " $ { h o s t _ p r e f i x } " )
# TODO: Fix this to use the equivalent of extprefix on CMake (CMAKE_STAGING_PREFIX?)
# For now just assume ext prefix is same as regular prefix.
file ( RELATIVE_PATH from_host_bin_dir_to_ext_prefix
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
" $ { h o s t _ b i n _ d i r _ a b s o l u t e _ p a t h } " " $ { Q T _ B U I L D _ I N T E R N A L S _ R E L O C A T A B L E _ I N S T A L L _ P R E F I X } " )
2019-10-11 14:55:55 +00:00
set ( QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "${from_lib_location_to_prefix}" )
set ( QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_host_bin_dir_to_host_prefix}" )
set ( QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_host_bin_dir_to_ext_prefix}" )
2019-05-31 14:30:09 +00:00
configure_file ( global/qconfig.cpp.in global/qconfig.cpp @ONLY )
endfunction ( )
2019-10-17 08:14:09 +00:00
function ( qt_set_language_standards )
## Use the latest standard the compiler supports (same as qt_common.prf)
if ( QT_FEATURE_cxx2a )
set ( CMAKE_CXX_STANDARD 20 PARENT_SCOPE )
2020-02-13 12:39:38 +00:00
else ( )
2019-10-17 08:14:09 +00:00
set ( CMAKE_CXX_STANDARD 17 PARENT_SCOPE )
endif ( )
if ( c_std_11 IN_LIST CMAKE_C_COMPILE_FEATURES )
set ( CMAKE_C_STANDARD 11 PARENT_SCOPE )
elseif ( c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES )
set ( CMAKE_C_STANDARD 99 PARENT_SCOPE )
endif ( )
endfunction ( )
2019-11-13 13:03:20 +00:00
2020-03-11 13:44:12 +00:00
function ( qt_set_language_standards_interface_compile_features target )
# Regardless of which C++ standard is used to build Qt itself, require C++17 when building
# Qt applications using CMake (because the Qt header files use C++17 features).
set ( cpp_feature "cxx_std_17" )
target_compile_features ( "${target}" INTERFACE ${ cpp_feature } )
endfunction ( )
2020-02-17 08:54:59 +00:00
function ( qt_enable_msvc_cplusplus_define target visibility )
# For MSVC we need to explicitly pass -Zc:__cplusplus to get correct __cplusplus.
# Check qt_config_compile_test for more info.
if ( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913 )
target_compile_options ( "${target}" ${ visibility } "-Zc:__cplusplus" )
endif ( )
endfunction ( )
2020-05-12 12:57:23 +00:00
function ( qt_enable_utf8_sources target )
set ( utf8_flags "" )
if ( MSVC )
list ( APPEND utf8_flags "-utf-8" )
elseif ( WIN32 AND ICC )
list ( APPEND utf8_flags "-Qoption,cpp,--unicode_source_kind,UTF-8" )
endif ( )
if ( utf8_flags )
# Allow opting out by specifying the QT_NO_UTF8_SOURCE target property.
set ( genex_condition "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_UTF8_SOURCE>>>" )
set ( utf8_flags "$<${genex_condition}:${utf8_flags}>" )
target_compile_options ( "${target}" INTERFACE "${utf8_flags}" )
endif ( )
endfunction ( )
2020-03-26 16:42:48 +00:00
# Equivalent of qmake's qtNomakeTools(directory1 directory2).
2020-04-06 16:45:19 +00:00
# If QT_NO_MAKE_TOOLS is true, then targets within the given directories will be excluded from the
# default 'all' target, as well as from install phase.
# The private variable is checked by qt_add_executable.
2020-03-26 16:42:48 +00:00
function ( qt_exclude_tool_directories_from_default_target )
if ( QT_NO_MAKE_TOOLS )
set ( absolute_path_directories "" )
foreach ( directory ${ ARGV } )
list ( APPEND absolute_path_directories "${CMAKE_CURRENT_SOURCE_DIR}/${directory}" )
endforeach ( )
2020-04-06 16:45:19 +00:00
set ( __qt_exclude_tool_directories "${absolute_path_directories}" PARENT_SCOPE )
2020-03-26 16:42:48 +00:00
endif ( )
endfunction ( )
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
function ( qt_compute_relative_rpath_base rpath install_location out_var )
set ( install_lib_dir_absolute "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" )
get_filename_component ( rpath_absolute "${rpath}"
A B S O L U T E B A S E _ D I R " $ { i n s t a l l _ l i b _ d i r _ a b s o l u t e } " )
if ( NOT IS_ABSOLUTE )
set ( install_location_absolute "${CMAKE_INSTALL_PREFIX}/${install_location}" )
endif ( )
# Compute relative rpath from where the target will be installed, to the place where libraries
# will be placed (INSTALL_LIBDIR).
file ( RELATIVE_PATH rpath_relative "${install_location_absolute}" "${rpath_absolute}" )
if ( "${rpath_relative}" STREQUAL "" )
# file(RELATIVE_PATH) returns an empty string if the given absolute paths are equal
set ( rpath_relative "." )
endif ( )
# Prepend $ORIGIN / @loader_path style tokens (qmake's QMAKE_REL_RPATH_BASE), to make the
# relative rpaths work. qmake does this automatically when generating a project, so it wasn't
# needed in the .prf files, but for CMake we need to prepend them ourselves.
if ( APPLE )
set ( rpath_rel_base "@loader_path" )
elseif ( LINUX )
set ( rpath_rel_base "$ORIGIN" )
else ( )
message ( WARNING "No known RPATH_REL_BASE for target platform." )
set ( rpath_rel_base "NO_KNOWN_RPATH_REL_BASE" )
endif ( )
if ( rpath_relative STREQUAL "." )
set ( rpath_relative "${rpath_rel_base}" )
else ( )
set ( rpath_relative "${rpath_rel_base}/${rpath_relative}" )
endif ( )
set ( "${out_var}" "${rpath_relative}" PARENT_SCOPE )
endfunction ( )
# Applies necessary rpaths to a target upon target installation.
# No-op when targeting Windows, Android, or non-prefix builds.
#
# If no RELATIVE_RPATH option is given, embeds an absolute path rpath to ${INSTALL_LIBDIR}.
# If RELATIVE_RPATH is given, the INSTALL_PATH value is to compute the relative path from
# ${INSTALL_LIBDIR} to wherever the target will be installed (the value of INSTALL_PATH).
# It's the equivalent of qmake's relative_qt_rpath.
# INSTALL_PATH is used to implement the equivalent of qmake's $$qtRelativeRPathBase().
#
# A cache variable QT_DISABLE_RPATH can be set to disable embedding any rpaths when installing.
function ( qt_apply_rpaths )
# No rpath support for win32 and android. Also no need to apply rpaths when doing a non-prefix
# build.
if ( NOT QT_WILL_INSTALL OR WIN32 OR ANDROID )
return ( )
endif ( )
# Rpaths xplicitly disabled (like for uikit), equivalent to qmake's no_qt_rpath.
if ( QT_DISABLE_RPATH )
return ( )
endif ( )
qt_parse_all_arguments ( arg "qt_apply_rpaths" "RELATIVE_RPATH" "TARGET;INSTALL_PATH" "" ${ ARGN } )
if ( NOT arg_TARGET )
message ( FATAL_ERRO "No target given to qt_apply_rpaths." )
else ( )
set ( target "${arg_TARGET}" )
endif ( )
# If a target is not built (which can happen for tools when crosscompiling, we shouldn't try
# to apply properties.
if ( NOT TARGET "${target}" )
return ( )
endif ( )
# Protect against interface libraries.
get_target_property ( target_type "${target}" TYPE )
if ( target_type STREQUAL "INTERFACE_LIBRARY" )
return ( )
endif ( )
if ( NOT arg_INSTALL_PATH )
message ( FATAL_ERROR "No INSTALL_PATH given to qt_apply_rpaths." )
endif ( )
set ( rpaths "" )
# Modify the install path to contain the nested structure of a framework.
get_target_property ( is_framework "${target}" FRAMEWORK )
if ( is_framework )
if ( UIKIT )
# Shallow framework
string ( APPEND arg_INSTALL_PATH "/Qt${target}.framework" )
else ( )
# Full framework
string ( APPEND arg_INSTALL_PATH "/Qt${target}.framework/Versions/Current" )
endif ( )
endif ( )
# Same but for an app bundle.
get_target_property ( is_bundle "${target}" MACOSX_BUNDLE )
if ( is_bundle AND NOT is_framework )
if ( UIKIT )
# Shallow bundle
string ( APPEND arg_INSTALL_PATH "/${target}.app" )
else ( )
# Full bundle
string ( APPEND arg_INSTALL_PATH "/${target}.app/Contents/MacOS" )
endif ( )
endif ( )
# Somewhat similar to mkspecs/features/qt.prf
if ( arg_RELATIVE_RPATH )
qt_compute_relative_rpath_base (
" $ { _ d e f a u l t _ i n s t a l l _ r p a t h } " " $ { a r g _ I N S T A L L _ P A T H } " r e l a t i v e _ r p a t h )
list ( APPEND rpaths "${relative_rpath}" )
else ( )
list ( APPEND rpaths "${_default_install_rpath}" )
endif ( )
# Somewhat similar to mkspecs/features/qt_build_extra.prf.
foreach ( rpath ${ QT_EXTRA_RPATHS } )
if ( IS_ABSOLUTE )
list ( APPEND rpaths "${rpath}" )
else ( )
qt_compute_relative_rpath_base ( "${rpath}" "${arg_INSTALL_PATH}" relative_rpath )
list ( APPEND rpaths "${relative_rpath}" )
endif ( )
endforeach ( )
if ( rpaths )
list ( REMOVE_DUPLICATES rpaths )
set_property ( TARGET "${target}" APPEND PROPERTY INSTALL_RPATH ${ rpaths } )
endif ( )
endfunction ( )
2019-11-13 13:03:20 +00:00
# Compatibility macros that should be removed once all their usages are removed.
function ( extend_target )
qt_extend_target ( ${ ARGV } )
endfunction ( )
function ( add_qt_module )
qt_add_module ( ${ ARGV } )
endfunction ( )
function ( add_qt_plugin )
qt_add_plugin ( ${ ARGV } )
endfunction ( )
function ( add_qt_tool )
qt_add_tool ( ${ ARGV } )
endfunction ( )
function ( add_qt_test )
qt_add_test ( ${ ARGV } )
endfunction ( )
function ( add_qt_test_helper )
qt_add_test_helper ( ${ ARGV } )
endfunction ( )
function ( add_qt_manual_test )
qt_add_manual_test ( ${ ARGV } )
endfunction ( )
function ( add_qt_benchmark )
qt_add_benchmark ( ${ ARGV } )
endfunction ( )
function ( add_qt_executable )
qt_add_executable ( ${ ARGV } )
endfunction ( )
function ( add_qt_simd_part )
qt_add_simd_part ( ${ ARGV } )
endfunction ( )
function ( add_qt_docs )
qt_add_docs ( ${ ARGV } )
endfunction ( )
function ( add_qt_resource )
qt_add_resource ( ${ ARGV } )
endfunction ( )
function ( add_cmake_library )
qt_add_cmake_library ( ${ ARGV } )
endfunction ( )