2018-10-24 13:20:27 +00:00
include ( CMakePackageConfigHelpers )
# Install locations:
set ( INSTALL_BINDIR "bin" CACHE PATH "Executables [PREFIX/bin]" )
set ( INSTALL_INCLUDEDIR "include" CACHE PATH "Header files [PREFIX/include]" )
set ( INSTALL_LIBDIR "lib" CACHE PATH "Libraries [PREFIX/lib]" )
set ( INSTALL_ARCHDATADIR "." CACHE PATH "Arch-dependent data [PREFIX]" )
set ( INSTALL_PLUGINSDIR "${INSTALL_ARCHDATADIR}/plugins" CACHE PATH
" 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 ] " )
set ( INSTALL_TARGETS_DEFAULT_ARGS
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 } " C O M P O N E N T D e v e l
I N C L U D E S 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 } "
)
if ( WIN32 )
set ( _default_libexec "${INSTALL_ARCHDATADIR}/bin" )
else ( )
set ( _default_libexec "${INSTALL_ARCHDATADIR}/libexec" )
endif ( )
set ( INSTALL_LIBEXECDIR "${_default_libexec}" CACHE PATH
" 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 ] " )
set ( INSTALL_IMPORTDIR "${INSTALL_ARCHDATADIR}/imports" CACHE PATH
" Q M L 1 i m p o r t s [ A R C H D A T A D I R / i m p o r t s ] " )
set ( INSTALL_QMLDIR "${INSTALL_ARCHDATADIR}/qml" CACHE PATH
" 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 ] " )
set ( INSTALL_DATADIR "." CACHE PATH "Arch-independent data [PREFIX]" )
set ( INSTALL_DOCDIR "${INSTALL_DATADIR}/doc" CACHE PATH "Documentation [DATADIR/doc]" )
set ( INSTALL_TRANSLATIONSDIR "${INSTALL_DATADIR}/translations" CACHE PATH
" 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 ] " )
set ( INSTALL_SYSCONFDIR "etc/xdg" CACHE PATH
" 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 ] " )
set ( INSTALL_EXAMPLESDIR "examples" CACHE PATH "Examples [PREFIX/examples]" )
set ( INSTALL_TESTSDIR "tests" CACHE PATH "Tests [PREFIX/tests]" )
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-02-11 14:45:56 +00:00
# the default RPATH to be used when installing, but only if it's not a system directory
LIST ( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir )
IF ( "${isSystemDir}" STREQUAL "-1" )
SET ( _default_install_rpath "${CMAKE_INSTALL_PREFIX}/lib" )
ENDIF ( "${isSystemDir}" STREQUAL "-1" )
# Default rpath settings: Use rpath for build tree as well as a full path for the installed binaries.
# For origin builds, one needs to override CMAKE_INSTALL_RPATH for example with $ORIGIN/../lib
SET ( CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE PATH "RPATH for installed binaries" )
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
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 )
2018-10-24 13:20:27 +00:00
elseif ( CLANG )
2019-05-31 14:30:09 +00:00
set ( QT_QMAKE_TARGET_MKSPEC win32-clang )
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-05-03 13:46:02 +00:00
list ( APPEND QT_DEFAULT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0601 )
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 )
endif ( )
# TODO: Fixme to be correct.
set ( QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}" )
if ( QT_QMAKE_TARGET_MKSPEC )
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/ ${ 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 " )
set ( QT_PLATFORM_DEFINITION_DIR ${ QT_DEFAULT_PLATFORM_DEFINITION_DIR }
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 " )
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
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
macro ( qt_internal_set_qt_known_modules )
set ( QT_KNOWN_MODULES ${ ARGN } CACHE INTERNAL "Known Qt modules" FORCE )
2018-11-08 21:29:54 +00:00
endmacro ( )
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
2018-11-08 21:29:54 +00:00
# Reset:
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
qt_internal_set_qt_known_modules ( "" )
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 )
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 ( )
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
# 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.
#
# 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_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 ( )
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 } )
unset ( __config_path_part )
2018-10-24 13:20:27 +00:00
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}" )
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.
function ( remove_install_target )
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 )
remove_install_target ( )
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 ( )
2019-05-29 14:56:49 +00:00
# Generates module .pri files for consumption by qmake
2019-06-05 11:49:08 +00:00
function ( qt_generate_module_pri_file target target_path pri_files_var )
set ( flags INTERNAL_MODULE )
2019-05-29 14:56:49 +00:00
set ( options )
set ( multiopts QMAKE_MODULE_CONFIG )
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
get_target_property ( enabled_features "${target}" QT_ENABLED_PUBLIC_FEATURES )
get_target_property ( disabled_features "${target}" QT_DISABLED_PUBLIC_FEATURES )
2019-06-05 11:49:08 +00:00
get_target_property ( enabled_private_features "${target}" QT_ENABLED_PRIVATE_FEATURES )
get_target_property ( disabled_private_features "${target}" QT_DISABLED_PRIVATE_FEATURES )
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
if ( arg_QMAKE_MODULE_CONFIG )
string ( REPLACE ";" " " module_config "${arg_QMAKE_MODULE_CONFIG}" )
set ( module_config "\nQT.${module_lower}.CONFIG = ${module_config}" )
else ( )
set ( module_config "" )
endif ( )
2019-06-05 11:49:08 +00:00
if ( NOT ${ arg_INTERNAL_MODULE } )
2019-06-06 08:11:15 +00:00
qt_path_join ( pri_file_name "${target_path}" "qt_lib_${module_lower}.pri" )
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
2019-05-29 14:56:49 +00:00
" Q T . $ { m o d u l e _ l o w e r } . V E R S I O N = $ { P R O J E C T _ V E R S I O N }
Q T . $ { m o d u l e _ l o w e r } . n a m e = $ { m o d u l e }
Q T . $ { m o d u l e _ l o w e r } . m o d u l e = $ { m o d u l e _ v e r s i o n e d }
Q T . $ { m o d u l e _ l o w e r } . l i b s = $ $ Q T _ M O D U L E _ L I B _ B A S E
Q T . $ { m o d u l e _ l o w e r } . i n c l u d e s = $ $ Q T _ M O D U L E _ I N C L U D E _ B A S E $ $ Q T _ M O D U L E _ I N C L U D E _ B A S E / $ { m o d u l e }
Q T . $ { m o d u l e _ l o w e r } . f r a m e w o r k s =
Q T . $ { m o d u l e _ l o w e r } . b i n s = $ $ Q T _ M O D U L E _ B I N _ B A S E
Q T . $ { m o d u l e _ l o w e r } . d e p e n d s =
Q T . $ { m o d u l e _ l o w e r } . u s e s =
Q T . $ { m o d u l e _ l o w e r } . m o d u l e _ c o n f i g = v 2
2019-06-05 09:31:55 +00:00
Q T . $ { m o d u l e _ l o w e r } . D E F I N E S = Q T _ $ { m o d u l e _ d e f i n e } _ L I B
2019-05-29 14:56:49 +00:00
Q T . $ { m o d u l e _ l o w e r } . 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 }
Q T . $ { m o d u l e _ l o w e r } . 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 _ c o n f i g }
Q T _ M O D U L E S + = $ { m o d u l e _ l o w e r }
2019-06-05 11:49:08 +00:00
"
)
endif ( )
qt_path_join ( private_pri_file "${target_path}" "qt_lib_${module_lower}_private.pri" )
list ( APPEND pri_files "${private_pri_file}" )
file ( GENERATE
O U T P U T " $ { p r i v a t e _ p r i _ f i l e } "
C O N T E N T
" Q T . $ { m o d u l e _ l o w e r } _ 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 . $ { m o d u l e _ l o w e r } _ p r i v a t e . n a m e = $ { m o d u l e }
Q T . $ { m o d u l e _ l o w e r } _ p r i v a t e . m o d u l e =
Q T . $ { m o d u l e _ l o w e r } _ 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
Q T . $ { m o d u l e _ l o w e r } _ p r i v a t e . i n c l u d e s = $ $ Q T _ M O D U L E _ I N C L U D E _ B A S E / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } $ $ Q T _ M O D U L E _ I N C L U D E _ B A S E / $ { 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 }
Q T . $ { m o d u l e _ l o w e r } _ p r i v a t e . f r a m e w o r k s =
Q T . $ { m o d u l e _ l o w e r } _ p r i v a t e . d e p e n d s = $ { m o d u l e _ l o w e r }
Q T . $ { m o d u l e _ l o w e r } _ p r i v a t e . u s e s =
Q T . $ { m o d u l e _ l o w e r } _ p r i v a t e . m o d u l e _ c o n f i g = v 2
Q T . $ { m o d u l e _ l o w e r } _ 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 }
Q T . $ { m o d u l e _ l o w e r } _ 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
set ( "${pri_files_var}" "${pri_files}" PARENT_SCOPE )
2019-05-29 14:56:49 +00:00
endfunction ( )
function ( qt_generate_global_config_pri_file )
qt_path_join ( qconfig_pri_target_path ${ PROJECT_BINARY_DIR } mkspecs )
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 )
# configure2cmake skips the "static" feature, so emulate it here for qmake support:
2019-05-31 14:40:51 +00:00
if ( QT_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS )
2019-05-29 14:56:49 +00:00
list ( APPEND enabled_features shared )
list ( APPEND disabled_features static )
2019-05-31 14:40:51 +00:00
set ( qt_build_config_type "shared" )
2019-05-29 14:56:49 +00:00
else ( )
list ( APPEND enabled_features static )
list ( APPEND disabled_features shared )
2019-05-31 14:40:51 +00:00
set ( qt_build_config_type "static" )
2019-05-29 14:56:49 +00:00
endif ( )
# configure2cmake skips the "rpath" feature, so emulate it here for qmake support:
if ( CMAKE_SKIP_RPATH )
list ( APPEND disabled_features rpath )
elseif ( LINUX OR APPLE )
list ( APPEND enabled_features rpath )
endif ( )
string ( REPLACE ";" " " enabled_features "${enabled_features}" )
string ( REPLACE ";" " " disabled_features "${disabled_features}" )
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-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 }
Q T . g l o b a l . 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-05-29 14:56:49 +00:00
Q T . g l o b a l . 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 }
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 }
C O N F I G - = l i n k _ p r l # we do not create prl files right now
2019-05-31 14:40:51 +00:00
C O N F I G + = $ { c o n f i g _ e n t r i e s }
2019-05-29 14:56:49 +00:00
"
)
qt_install ( FILES "${qconfig_pri_target_path}" DESTINATION mkspecs )
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}" )
set_target_properties ( "${target}Versionless" PROPERTIES EXPORT_NAME "${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
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.
# Also create a namespaced alias of the form {$target}::${target}_nolink which is used by
# our modules.
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 } )
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" )
if ( EXISTS "${SYNCQT_FROM_SOURCE}" )
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 } " )
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
" $ { 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 _ 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 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-02-27 12:49:04 +00:00
function ( qt_internal_add_link_flags_no_undefined target )
if ( GCC OR CLANG )
if ( APPLE )
set ( no_undefined_flag "-Wl,-undefined,error" )
2019-05-29 08:08:56 +00:00
elseif ( LINUX OR MINGW OR ANDROID )
2019-02-27 12:49:04 +00:00
set ( no_undefined_flag "-Wl,--no-undefined" )
else ( )
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 ( )
if ( GCC OR CLANG )
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
C O M M A N D " $ { H O S T _ P E R L } " " $ { P R O J E C T _ S O U R C E _ D I R } / m k s p e c s / 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 } "
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}" )
2018-12-07 12:30:51 +00:00
set ( "${result}_upper" "${upper}" PARENT_SCOPE )
set ( "${result}_lower" "${lower}" PARENT_SCOPE )
2019-08-08 14:55:48 +00:00
set ( "${result}_repo_include_dir" "${QT_BUILD_DIR}/include" PARENT_SCOPE )
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 ( "${result}_include_dir" "${QT_BUILD_DIR}/include/${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" )
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
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 } )
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
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 " )
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 ( )
foreach ( lib IN LISTS public_libs private_libs )
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 ( )
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.
function ( 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 ( )
2018-12-07 12:13:24 +00:00
qt_parse_all_arguments ( arg "extend_target" "" ""
2018-10-24 13:20:27 +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 } ; C O M P I L E _ F L A G 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 )
message ( "extend_target(${target} CONDITION ${arg_CONDITION} ...): Evaluated" )
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-03-28 14:25:17 +00:00
foreach ( lib ${ arg_PUBLIC_LIBRARIES } ${ arg_LIBRARIES } )
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
# Find dependencies to internal libraries
get_target_property ( target_deps "${target}" _qt_target_deps )
if ( NOT target_deps )
set ( target_deps "" )
endif ( )
foreach ( lib ${ arg_LIBRARIES } )
if ( TARGET "${lib}" )
get_target_property ( _is_exported "${lib}" INTERFACE_QT_EXPORTED_LIBRARY )
if ( "${_is_exported}" )
list ( APPEND target_deps "${lib}\;${PROJECT_VERSION}" )
endif ( )
endif ( )
endforeach ( )
# 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 ( )
2018-12-07 12:13:24 +00:00
target_include_directories ( "${target}" PUBLIC ${ arg_PUBLIC_INCLUDE_DIRECTORIES } PRIVATE ${ arg_INCLUDE_DIRECTORIES } )
target_compile_definitions ( "${target}" PUBLIC ${ arg_PUBLIC_DEFINES } PRIVATE ${ arg_DEFINES } )
target_link_libraries ( "${target}" PUBLIC ${ arg_PUBLIC_LIBRARIES } PRIVATE ${ arg_LIBRARIES } )
2019-01-29 11:07:24 +00:00
target_compile_options ( "${target}" PUBLIC ${ arg_PUBLIC_COMPILE_OPTIONS } PRIVATE ${ arg_COMPILE_OPTIONS } )
target_link_options ( "${target}" PUBLIC ${ arg_PUBLIC_LINK_OPTIONS } PRIVATE ${ arg_LINK_OPTIONS } )
2019-05-03 09:38:41 +00:00
set_target_properties ( "${target}" PROPERTIES
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 } "
_ q t _ t a r g e t _ d e p s " $ { t a r g e t _ d e p s } "
)
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
# modules added by this repo's qt_build_repo() (which are stored in QT_KNOWN_MODULES), but
# also all module dependencies that were found via find_package() (which are stored in
# QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE).
set ( known_modules ${ QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE } ${ QT_KNOWN_MODULES } )
list ( REMOVE_DUPLICATES known_modules )
# 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}" )
target_link_libraries ( "${target_private}" INTERFACE "${target}" "${qt_libs_private}" )
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-01-30 15:36:30 +00:00
else ( )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
message ( "extend_target(${target} CONDITION ${arg_CONDITION} ...): Skipped" )
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
set ( "${result}" "QT_DISABLE_DEPRECATED_BEFORE=0x040800" PARENT_SCOPE )
else ( )
# On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
set ( "${result}" "QT_DISABLE_DEPRECATED_BEFORE=0x050000" PARENT_SCOPE )
endif ( )
2019-06-05 09:26:39 +00:00
set ( "${result}" "QT_DEPRECATED_WARNINGS_SINCE=0x060000" PARENT_SCOPE )
2018-10-24 13:20:27 +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_install_injections module build_dir install_dir )
2019-02-11 16:09:03 +00:00
set ( injections ${ ARGN } )
# 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 } \"")
file ( GENERATE OUTPUT "${lower_case_forwarding_header_path}/${original_file_name}"
C O N T E N T " $ { m a i n _ c o n t e n t s } " )
# Copy the actual injected (generated) header file (not the just created forwarding one)
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
# to its install location when doing a prefix build. In an non-prefix build, the qt_install
# will be a no-op.
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 ( 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 } )
2019-06-14 13:29:21 +00:00
qt_install ( FILES ${ current_repo_build_dir } / ${ 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
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 )
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.
file ( GENERATE OUTPUT "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
C O N T E N T " #include \"${destinationname}\"\n")
# 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 )
2019-02-11 16:09:03 +00:00
endforeach ( )
endforeach ( )
endfunction ( )
2018-12-07 13:04:42 +00:00
function ( qt_read_headers_pri target resultVarPrefix )
qt_internal_module_info ( module "${target}" )
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
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".
function ( add_qt_module target )
2018-12-07 13:04:42 +00:00
qt_internal_module_info ( module "${target}" )
# Process arguments:
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
qt_parse_all_arguments ( arg "add_qt_module"
2019-06-07 08:51:55 +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 "
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
" C O N F I G _ M O D U L E _ N A M E "
2019-05-29 14:56:49 +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 } ; Q M A K E _ M O D U L E _ C O N F I G " $ { A R G N } )
2018-10-24 13:20:27 +00:00
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
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
qt_internal_set_qt_known_modules ( "${QT_KNOWN_MODULES}" "${target}" )
2018-10-24 13:20:27 +00:00
### Define Targets:
2018-12-07 12:13:24 +00:00
if ( ${ arg_STATIC } )
2018-10-24 13:20:27 +00:00
add_library ( "${target}" STATIC )
elseif ( ${ QT_BUILD_SHARED_LIBS } )
add_library ( "${target}" SHARED )
else ( )
add_library ( "${target}" STATIC )
endif ( )
2018-12-07 12:48:36 +00:00
qt_internal_add_target_aliases ( "${target}" )
2018-10-24 13:20:27 +00:00
# Add _private target to link against the private headers:
set ( target_private "${target}Private" )
add_library ( "${target_private}" INTERFACE )
2018-12-07 12:48:36 +00:00
qt_internal_add_target_aliases ( "${target_private}" )
2018-10-24 13:20:27 +00:00
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 } )
2018-12-07 12:48:36 +00:00
set_target_properties ( "${target}" PROPERTIES MODULE_HAS_HEADERS OFF )
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
# 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
- m o d u l e " $ { m o d u l e } "
- 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
set_target_properties ( "${target}" PROPERTIES MODULE_HAS_HEADERS ON )
2018-12-11 10:38:20 +00:00
### FIXME: Can we replace headers.pri?
qt_read_headers_pri ( "${target}" "module_headers" )
set_property ( TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${module_headers_public}" )
set_property ( TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${module_include_dir}/${module}Depends" )
set_property ( TARGET "${target}" APPEND PROPERTY PRIVATE_HEADER "${module_headers_private}" )
2019-06-20 08:13:22 +00:00
if ( module_headers_qpa )
qt_install ( FILES ${ module_headers_qpa } DESTINATION ${ INSTALL_INCLUDEDIR } / ${ module } / ${ PROJECT_VERSION } / ${ module } /qpa )
endif ( )
2018-10-24 13:20:27 +00:00
endif ( )
2019-05-03 14:03:15 +00:00
# Plugin types associated to a module
if ( NOT "x${arg_PLUGIN_TYPES}" STREQUAL "x" )
set_target_properties ( "${target}" PROPERTIES MODULE_PLUGIN_TYPES "${arg_PLUGIN_TYPES}" )
endif ( )
2018-12-07 12:48:36 +00:00
set_target_properties ( "${target}" PROPERTIES
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 _ 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 } "
2019-06-20 08:56:19 +00:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y _ R E L E A S E " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ B I N 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 _ D E B U G " $ { Q T _ B U I L D _ D I R } / $ { 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
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 } "
2019-02-12 10:20:22 +00:00
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 }
2019-06-05 08:08:44 +00:00
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 } "
)
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-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 } "
" $ { 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 _ 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 } "
$ { 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
set ( public_includes
# 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 } > "
)
2019-06-05 08:51:45 +00:00
if ( NOT arg_NO_MODULE_HEADERS )
2019-08-08 14:55:48 +00:00
# For the syncqt headers
list ( APPEND public_includes "$<INSTALL_INTERFACE:include/${module}>" )
2019-06-05 08:51:45 +00:00
endif ( )
2019-08-08 14:55:48 +00:00
list ( APPEND public_includes ${ arg_PUBLIC_INCLUDE_DIRECTORIES } )
2019-06-05 08:51:45 +00:00
2018-10-24 13:20:27 +00:00
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 }
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
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 }
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-03 15:41:45 +00:00
2018-12-11 10:38:20 +00:00
set ( configureFile "${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake" )
if ( EXISTS "${configureFile}" )
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 ( )
if ( DEFINED module_headers_private )
qt_internal_add_linker_version_script ( "${target}" PRIVATE_HEADERS ${ module_headers_private } )
else ( )
qt_internal_add_linker_version_script ( "${target}" )
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 )
qt_install_injections ( "${module}" "${QT_BUILD_DIR}" "${QT_INSTALL_DIR}" ${ final_injections } )
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-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
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 } "
)
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}" )
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 ( exported_targets ${ target } ${ target_private } )
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 }
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
if ( ANDROID )
# 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 ( )
2019-05-29 14:56:49 +00:00
qt_path_join ( pri_target_path ${ PROJECT_BINARY_DIR } mkspecs/modules )
2019-06-05 11:49:08 +00:00
qt_generate_module_pri_file ( "${target}" "${pri_target_path}" module_pri_files
$ { a r g _ I N T E R N A L _ M O D U L E }
2019-05-29 14:56:49 +00:00
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 }
)
2019-06-05 11:49:08 +00:00
qt_install ( FILES "${module_pri_files}" DESTINATION mkspecs/modules )
2019-05-29 14:56:49 +00:00
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-02-27 12:49:04 +00:00
qt_internal_add_link_flags_no_undefined ( "${target}" )
2018-10-24 13:20:27 +00:00
2019-08-08 14:55:48 +00:00
set ( interface_includes
" $ < 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 } > "
" $ < 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 } > "
2018-10-24 13:20:27 +00:00
)
2019-02-12 19:17:57 +00:00
2019-06-05 08:51:45 +00:00
if ( NOT arg_NO_MODULE_HEADERS )
2019-08-08 14:55:48 +00:00
list ( APPEND interface_includes
" $ < I N S T A L L _ I N T E R F A C E : i n c l u d e / $ { 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 c l u d e / $ { 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-06-05 08:51:45 +00:00
)
endif ( )
2019-08-08 14:55:48 +00:00
target_include_directories ( "${target_private}" INTERFACE
$ { i n t e r f a c e _ i n c l u d e 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
if ( NOT ${ arg_DISABLE_TOOLS_EXPORT } )
qt_export_tools ( ${ target } )
endif ( )
endfunction ( )
function ( qt_export_tools module_name )
# If no tools were defined belonging to this module, don't create a config and targets file.
# Guards against the case when doing a cross-build and the function is called manually and not
# by add_qt_module.
2019-06-24 13:01:53 +00:00
if ( NOT "${module_name}" IN_LIST QT_KNOWN_MODULES_WITH_TOOLS OR CMAKE_CROSSCOMPILING )
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 "" )
foreach ( tool_name ${ QT_KNOWN_MODULE_${module_name } _TOOLS} )
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}" )
endforeach ( )
string ( APPEND extra_cmake_statements
" set ( ${ QT_CMAKE_EXPORT_NAMESPACE } ${ module_name } Tools_TARGETS \"${tool_targets}\")")
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-05-03 10:30:09 +00:00
qt_internal_export_modern_cmake_config_targets_file ( TARGETS ${ QT_KNOWN_MODULE_${module_name } _TOOLS}
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 } )
2018-10-24 13:20:27 +00:00
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 )
message ( FATAL_ERROR "add_qt_plugin called without setting either TYPE or ${name}." )
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 )
foreach ( qt_module ${ QT_KNOWN_MODULES } )
get_target_property ( plugin_types "${qt_module}" MODULE_PLUGIN_TYPES )
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
# Collection of add_qt_plugin arguments so they can be shared across different
# plugin type wrappers
set ( __add_qt_plugin_optional_args
" S T A T I C ; E X C E P T I O N S "
)
set ( __add_qt_plugin_single_args
" 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 "
)
set ( __add_qt_plugin_multi_args
" $ { _ _ 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.
2018-12-11 10:38:20 +00:00
function ( add_qt_plugin target )
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}" )
2019-07-18 07:38:37 +00:00
qt_parse_all_arguments ( arg "add_qt_plugin"
" $ { _ _ a d d _ q t _ p l u g i n _ o p t i o n a l _ a r g s } "
" $ { _ _ a d d _ q t _ p l u g i n _ s i n g l e _ a r g s } "
" $ { _ _ a d d _ q t _ p l u g i n _ m u l t i _ a r g s } "
" $ { A R G N } "
)
2019-03-26 12:32:34 +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}" )
set ( archive_install_directory_default "${INSTALL_LIBDIR}/${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}" )
set ( archive_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
2019-07-22 15:44:55 +00:00
if ( "x${arg_CLASS_NAME}" STREQUAL "x" AND NOT "${arg_TYPE}" STREQUAL "qml_plugin" )
2019-05-03 14:03:15 +00:00
message ( AUTHOR_WARNING "add_qt_plugin called without setting CLASS_NAME." )
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-03-26 12:32:34 +00:00
qt_internal_check_directory_or_type ( INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" "${arg_TYPE}"
2019-06-05 11:39:41 +00:00
" $ { 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 )
2019-03-26 12:32:34 +00:00
qt_internal_check_directory_or_type ( ARCHIVE_INSTALL_DIRECTORY
" $ { 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 } " " $ { a r g _ T Y P E } "
2019-06-05 11:39:41 +00:00
" $ { a r c h i v e _ i n s t a l l _ d i r e c t o r y _ d e f a u l t } " a r c h i v e _ i n s t a l l _ d i r e c t o r y )
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 ( )
2019-03-26 12:32:34 +00:00
endif ( )
2018-12-11 10:38:20 +00:00
qt_internal_add_target_aliases ( "${target}" )
2018-10-24 13:20:27 +00:00
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 } "
Q T _ P L U G I N _ C L A S S _ N A M E " $ { a r g _ C L A S S _ N A M E } " )
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
2019-07-22 15:44:55 +00:00
if ( NOT arg_TYPE STREQUAL "qml_plugin" )
qt_get_module_for_plugin ( "${target}" "${arg_TYPE}" )
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}" )
set_property ( TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_PLUGIN_CLASS_NAME;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 }
)
2018-12-11 10:38:20 +00:00
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 "" )
foreach ( it ${ QT_KNOWN_MODULES } )
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}" )
# 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 ( )
qt_path_join ( config_build_dir ${ QT_CONFIG_BUILD_DIR } ${ path_suffix } )
qt_path_join ( config_install_dir ${ QT_CONFIG_INSTALL_DIR } ${ path_suffix } )
configure_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
)
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
)
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 "${target}Targets" )
qt_install ( TARGETS "${target}"
E X P O R T $ { e x p o r t _ n a m e }
2019-06-04 12:25:18 +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 _ d i r e c t o r 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
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 } "
2019-05-03 14:03:15 +00:00
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 } "
)
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 } : :
2019-05-03 14:03:15 +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 } "
)
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-02-27 12:49:04 +00:00
qt_internal_add_link_flags_no_undefined ( "${target}" )
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-06-05 11:39:41 +00:00
# Generate custom ${target}_qmltypes target for Qml Plugins
function ( qt_add_qmltypes_target target )
# Do nothing when cross compiling
if ( CMAKE_CROSSCOMPILING )
return ( )
endif ( )
qt_parse_all_arguments ( arg "qt_generate_qmltypes"
" "
2019-07-18 07:38:37 +00:00
" T A R G E T _ P A T H ; I M P O R T _ V E R S I O N ; I M P O R T _ N A M E ; Q M L _ P L U G I N D U M P _ D E P E N D E N C I E S "
2019-06-05 11:39:41 +00:00
" "
$ { A R G N } )
# scan repos for qml repositories
foreach ( repo IN LISTS QT_REPOS )
if ( IS_DIRECTORY "${repo}/qml" )
list ( APPEND import_paths "${repo}/qml" )
endif ( )
endforeach ( )
list ( REMOVE_DUPLICATES import_paths )
if ( UNIX )
list ( JOIN import_paths ":" import_paths_env )
else ( )
list ( JOIN import_paths "\;" import_paths_env )
endif ( )
if ( NOT arg_IMPORT_NAME )
string ( REGEX REPLACE "\\.\\d+$" "" import_name ${ arg_TARGET_PATH } )
else ( )
set ( import_name ${ arg_IMPORT_NAME } )
endif ( )
if ( NOT arg_IMPORT_VERSION )
2019-07-18 07:38:37 +00:00
message ( FATAL_ERROR "Import version parameter was not specified. Specify the import version using the IMPORT_VERSION." )
2019-06-05 11:39:41 +00:00
endif ( )
get_target_property ( source_dir ${ target } SOURCE_DIR )
# qml1_target check is no longer required
set ( qmltypes_command_args "-nonrelocatable" )
2019-07-18 07:38:37 +00:00
if ( NOT arg_QML_PLUGINDUMP_DEPENDENCIES AND EXISTS "${source_dir}/dependencies.json" )
2019-06-05 11:39:41 +00:00
list ( APPEND qmltypes_command_args "-dependencies" "${source_dir}/dependencies.json" )
2019-07-18 07:38:37 +00:00
elseif ( arg_QML_PLUGINDUMP_DEPENDENCIES )
list ( APPEND qmltypes_command_args "-dependencies" "${arg_QML_PLUGINDUMP_DEPENDENCIES}" )
2019-06-05 11:39:41 +00:00
endif ( )
string ( REPLACE "/" "." import_name_arg ${ import_name } )
2019-07-18 07:38:37 +00:00
list ( APPEND qmltypes_command_args "${import_name_arg}" "${arg_IMPORT_VERSION}" )
set ( qml_plugindump_target ${ QT_CMAKE_EXPORT_NAMESPACE } ::qmlplugindump )
2019-06-05 11:39:41 +00:00
2019-07-18 07:38:37 +00:00
# Manually set dependency on plugindump target since CMake will not add
# this rule because it's not the main executable argument to the COMMAND
# parameter.
2019-06-05 11:39:41 +00:00
add_custom_target (
" $ { t a r g e t } _ q m l t y p e s "
2019-07-18 07:38:37 +00:00
D E P E N D S $ { q m l _ p l u g i n d u m p _ t a r g e t }
2019-06-05 11:39:41 +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 M L 2 _ I M P O R T P A T H = $ { i m p o r t _ p a t h s _ e n v } "
2019-07-18 07:38:37 +00:00
$ < T A R G E T _ F I L E : $ { q m l _ p l u g i n d u m p _ t a r g e t } > $ { q m l t y p e s _ c o m m a n d _ a r g s } > " $ { s o u r c e _ d i r } / p l u g i n s . q m l t y p e s "
2019-06-05 11:39:41 +00:00
)
endfunction ( )
2019-07-24 14:00:48 +00:00
# Create a custom target that will ensure all js and qml files are processed
# by the qmlcachegen tool during build. The generated jsc/qmlc files will
# also be added to list of files to be installed.
#
# TARGET_PATH: QML target path
# QML_FILES: List of QML Files
#
# Note: This will only run on non static builds.
#
function ( add_qmlcachegen_target target )
if ( NOT QT_BUILD_SHARED_LIBS )
# Do nothing for static builds since the QML files are embedded into
# the executable.
return ( )
endif ( )
if ( NOT TARGET ${ QT_CMAKE_EXPORT_NAMESPACE } ::qmlcachegen )
message ( FATAL_ERROR " Could not locate qmlcachegen tool. \
P l e a s e a d d Q m l T o o l s t o y o u r f i n d _ p a c k a g e c o m m a n d . "
)
endif ( )
qt_parse_all_arguments ( arg "add_qmlcachegen_target"
" " " T A R G E T _ P A T H " " Q M L _ F I L E S " $ { A R G N }
)
set ( cache_dir "${QT_BUILD_DIR}/${INSTALL_QMLDIR}/${arg_TARGET_PATH}" )
foreach ( qml_file IN LISTS arg_QML_FILES )
if ( "${qml_file}" MATCHES "\.m?js$" OR "${qml_file}" MATCHES "\.qml$" )
if ( NOT IS_ABSOLUTE ${ qml_file } )
get_filename_component ( qml_file ${ qml_file } ABSOLUTE )
endif ( )
file ( RELATIVE_PATH qmlc_file "${CMAKE_CURRENT_SOURCE_DIR}" "${qml_file}" )
set ( qmlc_file "${cache_dir}/${qmlc_file}c" )
list ( APPEND qmlc_files ${ qmlc_file } )
add_custom_command ( OUTPUT "${qmlc_file}"
D E P E N D S
$ { q m 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 m l c a c h e g e n - o $ { q m l c _ f i l e } $ { q m l _ f i l e }
C O M M E N T
" G e n e r a t i n g Q M L C a c h e f o r $ { q m l _ f i l e } "
)
endif ( )
endforeach ( )
if ( qmlc_files )
set ( qmlcachegen_target "${target}_qmlcachegen" )
# Add custom target which depends on all the qmlc files and then add
# that target as a dependency of ${target}. This will guarantee
# that the qmlc file get generated.
add_custom_target ( ${ qmlcachegen_target }
D E P E N D S $ { q m l c _ f i l e s }
)
add_dependencies ( ${ target } ${ qmlcachegen_target } )
if ( QT_WILL_INSTALL )
# Only install on non-prefix builds, since the file does not exist
# at configuration time. Furthermore, the cached qml files are
# generated in the destination location for non-prefix builds.
qt_copy_or_install (
F I L E S $ { q m l c _ f i l e s }
D E S T I N A T I O N $ { I N S T A L L _ Q M L D I R } / $ { a r g _ T A R G E T _ P A T H }
)
endif ( )
endif ( )
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-07-18 07:38:37 +00:00
# This function creates a CMake target for qml modules. It will also make
# sure that if no C++ source are present, that qml files show up in the project
# in an IDE. Finally, it will also create a custom ${target}_qmltypes which
# can be used to generate the respective plugin.qmltypes file.
#
2019-08-01 13:43:36 +00:00
# CPP_PLUGIN: Whether this qml module has any c++ source files.
# URI: Module's uri.
2019-07-18 07:38:37 +00:00
# TARGET_PATH: Expected installation path for the Qml Module. Equivalent
2019-08-01 13:43:36 +00:00
# to the module's URI where '.' is replaced with '/'. Use this to override the
# default substitution pattern.
# VERSION: Version of the qml module
# RESOURCE_PREFIX: Resource import prefix to be prepended to the module's
# target path.
2019-07-18 07:38:37 +00:00
# QML_PLUGINDUMP_DEPENDENCIES: Path to a dependencies.json file to be consumed
# with the ${target}_qmltypes target (optional)
#
2019-06-05 11:39:41 +00:00
function ( add_qml_module target )
2019-08-01 13:43:36 +00:00
2019-07-25 09:22:52 +00:00
set ( qml_module_optional_args
2019-08-01 13:43:36 +00:00
C P P _ P L U G I N
2019-07-25 09:22:52 +00:00
)
2019-07-18 07:38:37 +00:00
set ( qml_module_single_args
2019-08-01 13:43:36 +00:00
U R I
2019-07-18 07:38:37 +00:00
T A R G E T _ P A T H
2019-08-01 13:43:36 +00:00
V E R S I O N
R E S O U R C E _ P R E F I X
2019-07-18 07:38:37 +00:00
Q M L _ P L U G I N D U M P _ D E P E N D E N C I E S
)
2019-06-05 11:39:41 +00:00
qt_parse_all_arguments ( arg "add_qml_module"
2019-07-25 09:22:52 +00:00
" $ { _ _ a d d _ q t _ p l u g i n _ o p t i o n a l _ a r g s } ; $ { q m l _ m o d u l e _ o p t i o n a l _ a r g s } "
2019-07-18 07:38:37 +00:00
" $ { _ _ a d d _ q t _ p l u g i n _ s i n g l e _ a r g s } ; $ { q m l _ m o d u l e _ s i n g l e _ a r g s } "
2019-08-01 13:43:36 +00:00
" $ { _ _ a d d _ q t _ p l u g i n _ m u l t i _ a r g s } " $ { A R G N } )
2019-06-05 11:39:41 +00:00
2019-08-01 13:43:36 +00:00
if ( NOT arg_URI )
message ( FATAL_ERROR "add_qml_module called without specifying the module's uri. Please specify one using the URI parameter." )
2019-07-18 07:38:37 +00:00
endif ( )
set ( target_path ${ arg_TARGET_PATH } )
2019-08-01 13:43:36 +00:00
if ( NOT arg_VERSION )
message ( FATAL_ERROR "add_qml_module called without specifying the module's import version. Please specify one using the VERSION parameter." )
endif ( )
if ( NOT arg_RESOURCE_PREFIX )
message ( FATAL_ERROR "add_qml_module called without specifying the module's import prefix. Prease specify one using the RESOURCE_PREFIX parameter." )
2019-07-18 07:38:37 +00:00
endif ( )
2019-08-01 13:43:36 +00:00
if ( NOT arg_TARGET_PATH )
string ( REPLACE "." "/" arg_TARGET_PATH ${ arg_URI } )
2019-07-25 14:45:11 +00:00
endif ( )
2019-07-18 07:38:37 +00:00
qt_remove_args ( plugin_args
A R G S _ T O _ R E M O V E
$ { t a r g e t }
$ { q m l _ m o d u l e _ m u l t i _ a r g s }
$ { q m l _ m o d u l e _ s i n g l e _ a r g s }
A L L _ A R G S
$ { _ _ a d d _ q t _ p l u g i n _ o p t i o n a l _ a r g s }
$ { _ _ a d d _ q t _ p l u g i n _ s i n g l e _ a r g s }
$ { q m l _ m o d u l e _ s i n g l e _ a r g s }
$ { _ _ a d d _ q t _ p l u g i n _ m u l t i _ a r g s }
$ { q m l _ m o d u l e _ m u l t i _ a r g s }
A R G S
$ { A R G V }
)
# If we have no sources, but qml files, create a custom target so the
# qml file will be visibile in an IDE.
2019-08-01 13:43:36 +00:00
if ( NOT arg_CPP_PLUGIN )
2019-07-18 07:38:37 +00:00
add_custom_target ( ${ target }
S O U R C E S $ { a r g _ Q M L _ F I L E S }
)
else ( )
add_qt_plugin ( ${ target }
T Y P E
q m l _ p l u g i n
Q M L _ T A R G E T _ P A T H
2019-08-01 13:43:36 +00:00
" $ { a r g _ T A R G E T _ P A T H } "
$ { p l u g i n _ a r g s }
2019-07-18 07:38:37 +00:00
)
2019-06-05 11:39:41 +00:00
endif ( )
2019-08-01 13:43:36 +00:00
# Set target properties
set_target_properties ( ${ target }
P R O P E R T I E S
Q T _ Q M L _ M O D U L E _ T A R G E T _ P A T H $ { a r g _ T A R G E T _ P A T H }
Q T _ Q M L _ M O D U L E _ U R I $ { a r g _ U R I }
Q T _ Q M L _ M O D U L E _ R E S O U R C E _ P R E F I X $ { a r g _ R E S O U R C E _ P R E F I X }
Q T _ Q M L _ M O D U L E _ V E R S I O N $ { a r g _ V E R S I O N }
)
2019-07-24 14:00:48 +00:00
2019-06-05 11:39:41 +00:00
qt_add_qmltypes_target ( ${ target }
2019-08-01 13:43:36 +00:00
T A R G E T _ P A T H " $ { a r g _ T A R G E T _ P A T H } "
I M P O R T _ V E R S I O N " $ { a r g _ V E R S I O N } "
2019-08-06 12:06:47 +00:00
I M P O R T _ N A M E " $ { a r g _ U R I } "
2019-07-18 07:38:37 +00:00
Q M L _ P L U G I N D U M P _ D E P E N D E N C I E S " $ { a r g _ Q M L _ P L U G I N D U M P _ D E P E N D E N C I E S } " )
2019-06-05 11:39:41 +00:00
2019-08-01 13:43:36 +00:00
qt_path_join ( qml_module_install_dir ${ QT_INSTALL_DIR } "${INSTALL_QMLDIR}/${arg_TARGET_PATH}" )
2019-06-05 11:39:41 +00:00
set ( plugin_types "${CMAKE_CURRENT_SOURCE_DIR}/plugins.qmltypes" )
if ( EXISTS ${ plugin_types } )
qt_copy_or_install ( FILES ${ plugin_types }
2019-07-23 07:13:47 +00:00
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 } "
2019-06-05 11:39:41 +00:00
)
2019-07-23 07:13:47 +00:00
if ( QT_WILL_INSTALL )
# plugin.qmltypes when present should also be copied to the
# cmake binary dir when doing prefix builds
file ( COPY ${ plugin_types }
2019-08-01 13:43:36 +00:00
D E S T I N A T I O N " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ Q M L D I R } / $ { a r g _ T A R G E T _ P A T H } "
2019-07-23 07:13:47 +00:00
)
endif ( )
2019-06-05 11:39:41 +00:00
endif ( )
2019-08-01 13:43:36 +00:00
if ( NOT QT_BUILD_SHARED_LIBS )
# only embed qmldir on static builds. Some qml modules may request
# their qml files to be embedded into their binary
2019-08-06 12:06:47 +00:00
string ( REPLACE "." "_" qmldir_resource_name ${ arg_TARGET_PATH } )
string ( REPLACE "/" "_" qmldir_resource_name ${ qmldir_resource_name } )
2019-08-01 13:43:36 +00:00
set ( qmldir_resource_name "${qmldir_resource_name}_qmldir" )
add_qt_resource ( ${ target } ${ uri_target }
F I L E S " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / q m l d i r "
P R E F I X " $ { a r g _ R E S O U R C E _ P R E F I X } / $ { a r g _ T A R G E T _ P A T H } "
)
endif ( )
2019-06-05 11:39:41 +00:00
qt_copy_or_install (
F I L E S
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / q m l d i r "
D E S T I N A T I O N
2019-07-23 07:13:47 +00:00
" $ { q m l _ m o d u l e _ i n s t a l l _ d i r } "
2019-06-05 11:39:41 +00:00
)
2019-08-01 13:43:36 +00:00
2019-07-23 07:13:47 +00:00
if ( QT_WILL_INSTALL )
# qmldir should also be copied to the cmake binary dir when doing
# prefix builds
file ( COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
2019-08-01 13:43:36 +00:00
D E S T I N A T I O N " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ Q M L D I R } / $ { a r g _ T A R G E T _ P A T H } "
2019-07-25 09:22:52 +00:00
)
2019-06-05 11:39:41 +00:00
endif ( )
endfunction ( )
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
# by add_qt_test or add_qt_tool below.
function ( add_qt_executable name )
2019-08-02 12:14:16 +00:00
qt_parse_all_arguments ( arg "add_qt_executable" "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS" "OUTPUT_DIRECTORY;INSTALL_DIRECTORY" "EXE_FLAGS;${__default_private_args};${__default_public_args}" ${ ARGN } )
2018-10-24 13:20:27 +00:00
2018-12-07 12:13:24 +00:00
if ( "x${arg_OUTPUT_DIRECTORY}" STREQUAL "x" )
set ( arg_OUTPUT_DIRECTORY "${CMAKE_BINARY_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}"
A B S O L U T E B A S E _ D I R " $ { C M A K E _ B I N A R Y _ D I R } " )
2019-03-18 18:09:27 +00:00
if ( "x${arg_INSTALL_DIRECTORY}" STREQUAL "x" )
set ( arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}" )
endif ( )
2018-12-07 12:13:24 +00:00
add_executable ( "${name}" ${ arg_EXE_FLAGS } )
2019-03-06 12:51:38 +00:00
2019-05-22 13:09:39 +00:00
qt_autogen_tools_initial_setup ( ${ 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 }
)
2018-10-24 13:20:27 +00:00
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 }
2019-05-09 08:02:37 +00:00
L I B R A R I E S $ { a r g _ L I B R A R I E S }
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 } "
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
2019-03-18 18:09:27 +00:00
2019-04-03 09:33:28 +00:00
if ( NOT arg_NO_INSTALL )
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 "${name}"
2019-04-03 09:33:28 +00:00
R U N T I M E D E S T I N A T I O N " $ { 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 D E S T I N A T I O N " $ { a r g _ I N S T A L L _ D I R E C T O R Y } " )
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
# This function creates a CMake test target with the specified name for use with CTest.
function ( add_qt_test name )
2019-07-12 14:54:26 +00:00
qt_parse_all_arguments ( arg "add_qt_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 "
2019-08-02 12:14:16 +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 } )
2018-12-07 12:13:24 +00:00
set ( path "${CMAKE_CURRENT_BINARY_DIR}" )
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 ( )
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 } "
" $ < 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 c l u d e > "
$ { 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-08-08 14:46:05 +00:00
add_qt_executable ( "${name}"
$ { e x c e p t i o n s _ t e x t }
$ { g u i _ t e x t }
N O _ I N S T A L L
O U T P U T _ D I R E C T O R Y " $ { p a t h } "
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-08 14:46:05 +00:00
# QMLTest specifics
2019-07-22 10:55:48 +00:00
2019-08-08 14:46:05 +00:00
extend_target ( "${name}" CONDITION arg_QMLTEST
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-08-08 14:46:05 +00:00
extend_target ( "${name}" CONDITION arg_QMLTEST AND NOT ANDROID
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-08-08 14:46:05 +00:00
extend_target ( "${name}" CONDITION arg_QMLTEST AND ANDROID
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
if ( arg_QML_IMPORTPATH )
set ( extra_test_args "-import" "${arg_QML_IMPORTPATH}" )
endif ( )
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-07-22 10:55:48 +00:00
if ( arg_QMLTEST AND NOT arg_SOURCES )
2019-08-08 14:46:05 +00:00
set ( test_working_dir "${CMAKE_CURRENT_SOURCE_DIR}" )
set ( test_executable ${ QT_CMAKE_EXPORT_NAMESPACE } ::qmltestrunner )
2019-07-22 10:55:48 +00:00
else ( )
2019-08-08 14:46:05 +00:00
set ( test_working_dir "${CMAKE_CURRENT_BINARY_DIR}" )
2019-07-22 10:55:48 +00:00
set ( test_executable "${name}" )
endif ( )
2019-06-25 08:57:20 +00:00
2019-08-08 14:46:05 +00:00
add_test ( NAME "${name}" COMMAND ${ test_executable } ${ extra_test_args } -o ${ name } .xml,xml -o -,txt WORKING_DIRECTORY "${test_working_dir}" )
2019-06-25 08:57:20 +00:00
set_tests_properties ( "${name}" PROPERTIES RUN_SERIAL "${arg_RUN_SERIAL}" LABELS "${label}" )
2018-12-07 12:13:24 +00:00
set_property ( TEST "${name}" APPEND PROPERTY ENVIRONMENT "PATH=${path}${QT_PATH_SEPARATOR}${CMAKE_CURRENT_BINARY_DIR}${QT_PATH_SEPARATOR}$ENV{PATH}" )
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 )
list ( APPEND plugin_paths "${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINSDIR}" )
endif ( )
#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 )
target_compile_definitions ( "${name}" PRIVATE BUILTIN_TESTDATA )
foreach ( testdata IN LISTS arg_TESTDATA )
list ( APPEND builtin_files ${ testdata } )
endforeach ( )
set ( blacklist_path "BLACKLIST" )
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}" )
list ( APPEND builtin_files ${ blacklist_path } )
endif ( )
list ( REMOVE_DUPLICATES builtin_files )
if ( builtin_files )
add_qt_resource ( ${ name } "testdata"
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 ( )
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 }
" $ { 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 } / t e s t d a t a " )
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}" )
qt_copy_or_install (
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 ( )
qt_copy_or_install (
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 ( )
# This function creates an executable for use as helper program with tests. Some
# tests launch separate programs to test certainly input/output behavior.
function ( add_qt_test_helper name )
2019-04-05 09:17:24 +00:00
add_qt_executable ( "${name}" NO_INSTALL OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." ${ ARGN } )
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 )
2019-08-07 07:32:51 +00:00
set ( will_build_tools NOT CMAKE_CROSSCOMPILING AND NOT QT_FORCE_FIND_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
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
# 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.
function ( add_qt_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
qt_parse_all_arguments ( arg "add_qt_tool" "BOOTSTRAP;NO_QT;NO_INSTALL" "TOOLS_TARGET"
" $ { _ _ 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 ( )
set ( full_name "${QT_CMAKE_EXPORT_NAMESPACE}::${name}" )
if ( TARGET ${ full_name } )
get_property ( path TARGET ${ full_name } PROPERTY LOCATION )
message ( STATUS "Tool '${full_name}' was found at ${path}." )
2019-02-11 14:50:17 +00:00
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
if ( arg_TOOLS_TARGET AND NOT QT_WILL_BUILD_TOOLS )
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}." )
return ( )
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 ( )
message ( STATUS "Tool '${full_name}' will be built from source." )
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 ( )
2019-04-03 09:33:28 +00:00
set ( no_install "" )
if ( arg_NO_INSTALL )
set ( no_install NO_INSTALL )
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
add_qt_executable ( "${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 }
2019-04-03 09:33:28 +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 }
2018-10-24 13:20:27 +00:00
)
2018-12-07 12:48:36 +00:00
qt_internal_add_target_aliases ( "${name}" )
2018-10-24 13:20:27 +00:00
2019-06-20 08:56:19 +00:00
set_target_properties ( "${name}" PROPERTIES
R U N T I M E _ O U T P U T _ D I R E C T O R Y _ R E L E A S E " $ { Q T _ B U I L D _ D I R } / $ { I N S T A L L _ B I N D I R } "
)
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.
qt_internal_append_known_module_tool ( "${arg_TOOLS_TARGET}" "${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
qt_install ( TARGETS "${name}"
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 "
D E S T I N A T I O N $ { 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 } )
2019-04-03 09:33:28 +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-07-25 14:45:11 +00:00
function ( qt_get_relative_resource_path_for_file output_alias file )
get_property ( alias SOURCE ${ file } PROPERTY alias )
if ( NOT alias )
set ( alias "${file}" )
endif ( )
set ( ${ output_alias } ${ alias } PARENT_SCOPE )
endfunction ( )
2019-08-02 09:25:59 +00:00
# Inspect all files passed to a call to add_qt_resource. If there are any
# files present, invoke the quick compiler and return the remaining resource
# files that have not been prossed in REMAING_RESOURCES as well as the new
# name for the resource in OUTPUT_RESOURCE_NAME.
function ( qt_quick_compiler_process_resources target resource_name )
qt_parse_all_arguments ( arg "qt_qtuick_compiler_process_resources"
" " " P R E F I X ; O U T P U T _ R E M A I N I N G _ R E S O U R C E S ; O U T P U T _ R E S O U R C E _ N A M E " " F I L E S " $ { A R G N }
)
set ( qml_files )
# scan for qml files
foreach ( file IN LISTS arg_FILES )
# check whether this resource should not be processed by the qt quick
# compiler
2019-08-09 09:01:41 +00:00
get_source_file_property ( skip_compiler_check ${ file } QT_SKIP_QUICKCOMPILER )
2019-08-02 09:25:59 +00:00
if ( skip_compiler_check )
list ( APPEND resource_files ${ file } )
continue ( )
endif ( )
if ( ${ file } MATCHES "\.js$"
O R $ { f i l e } M A T C H E S " \ . m j s $ "
O R $ { f i l e } M A T C H E S " \ . q m l $ " )
list ( APPEND qml_files ${ file } )
else ( )
list ( APPEND resource_files ${ file } )
endif ( )
endforeach ( )
if ( NOT TARGET ${ QT_CMAKE_EXPORT_NAMESPACE } ::qmlcachegen AND qml_files )
message ( WARNING "add_qt_resource: Qml files were detected but the qmlcachgen target is not defined. Consider adding QmlTools to your find_package command." )
endif ( )
if ( TARGET ${ QT_CMAKE_EXPORT_NAMESPACE } ::qmlcachegen AND qml_files )
# Enable qt quick compiler support
set ( qml_resource_file "${CMAKE_CURRENT_BINARY_DIR}/${resource_name}.qrc" )
if ( resource_files )
set ( chained_resource_name "${resource_name}_qmlcache" )
endif ( )
foreach ( file IN LISTS qml_files )
get_filename_component ( file_absolute ${ file } ABSOLUTE )
file ( RELATIVE_PATH file_relative ${ CMAKE_CURRENT_SOURCE_DIR } ${ file_absolute } )
2019-08-09 07:39:42 +00:00
qt_get_relative_resource_path_for_file ( file_resource_path ${ file } )
set ( file_resource_path "${arg_PREFIX}/${file_resource_path}" )
2019-08-02 09:25:59 +00:00
file ( TO_CMAKE_PATH ${ file_resource_path } file_resource_path )
list ( APPEND file_resource_paths ${ file_resource_path } )
string ( REGEX REPLACE "\.js$" "_js" compiled_file ${ file_relative } )
string ( REGEX REPLACE "\.mjs$" "_mjs" compiled_file ${ compiled_file } )
string ( REGEX REPLACE "\.qml$" "_qml" compiled_file ${ compiled_file } )
set ( compiled_file "${CMAKE_CURRENT_BINARY_DIR}/qmlcache/${compiled_file}.cpp" )
add_custom_command (
O U T P U T $ { c o m p i l e d _ f i l e }
D E P E N D S $ { f i l e _ a b s o l u t 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 m l c a c h e g e n
- - r e s o u r c e - p a t h $ { f i l e _ r e s o u r c e _ p a t h }
- o $ { c o m p i l e d _ f i l e }
$ { f i l e _ a b s o l u t e }
)
target_sources ( ${ target } PRIVATE ${ compiled_file } )
endforeach ( )
set ( qmlcache_loader_list "${CMAKE_CURRENT_BINARY_DIR}/qmlcache/${resource_name}_qml_loader_file_list.rsp" )
file ( GENERATE
O U T P U T $ { q m l c a c h e _ l o a d e r _ l i s t }
C O N T E N T " $ < J O I N : $ { f i l e _ r e s o u r c e _ p a t h s } , \ n > "
)
set ( qmlcache_loader_file "${CMAKE_CURRENT_BINARY_DIR}/qmlcache/${resource_name}_qmlcache_loader.cpp" )
set ( resource_name_arg "${resource_name}.qrc" )
if ( chained_resource_name )
set ( resource_name_arg "${resource_name_arg}=${chained_resource_name}" )
endif ( )
add_custom_command (
O U T P U T $ { q m l c a c h e _ l o a d e r _ f i l e }
D E P E N D S $ { q m l c a c h e _ l o a d e r _ l i s t }
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 m l c a c h e g e n
- - r e s o u r c e - n a m e " $ { r e s o u r c e _ n a m e _ a r g } "
- o $ { q m l c a c h e _ l o a d e r _ f i l e }
" @ $ { q m l c a c h e _ l o a d e r _ l i s t } "
)
qt_propagate_generated_resource ( ${ target } ${ resource_name } ${ qmlcache_loader_file } )
if ( resource_files )
set ( resource_name ${ chained_resource_name } )
endif ( )
else ( )
set ( resource_files ${ arg_FILES } )
endif ( )
set ( ${ arg_OUTPUT_REMAINING_RESOURCES } ${ resource_files } PARENT_SCOPE )
set ( ${ arg_OUTPUT_RESOURCE_NAME } ${ resource_name } PARENT_SCOPE )
endfunction ( )
function ( qt_propagate_generated_resource target resource_name generated_source_code )
get_target_property ( type ${ target } TYPE )
if ( type STREQUAL STATIC_LIBRARY )
set ( resource_target "${target}_resources_${resourceName}" )
add_library ( "${resource_target}" OBJECT "${generated_source_code}" )
qt_internal_add_target_aliases ( "${resource_target}" )
qt_install ( TARGETS "${resource_target}"
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 }
)
target_link_libraries ( ${ target } INTERFACE "$<TARGET_OBJECTS:${INSTALL_CMAKE_NAMESPACE}::${resource_target}>" )
else ( )
target_sources ( ${ target } PRIVATE ${ generated_source_code } )
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
function ( add_qt_resource target resourceName )
2019-07-30 09:15:32 +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-03-07 09:05:10 +00:00
qt_parse_all_arguments ( rcc "add_qt_resource" "" "PREFIX;LANG;BASE" "FILES" ${ ARGN } )
2018-10-24 13:20:27 +00:00
2019-08-02 09:25:59 +00:00
string ( REPLACE "/" "_" resourceName ${ resourceName } )
string ( REPLACE "." "_" resourceName ${ resourceName } )
# Apply base to all files
if ( rcc_BASE )
foreach ( file IN LISTS rcc_FILES )
set ( resource_file "${rcc_BASE}/${file}" )
file ( TO_CMAKE_PATH ${ resource_file } resource_file )
list ( APPEND resource_files ${ resource_file } )
endforeach ( )
else ( )
set ( resource_files ${ rcc_FILES } )
endif ( )
# Apply quick compiler pass
qt_quick_compiler_process_resources ( ${ target } ${ resourceName }
F I L E S $ { r e s o u r c e _ f i l e s }
P R E F I X $ { r c c _ P R E F I X }
O U T P U T _ R E M A I N I N G _ R E S O U R C E S r e s o u r c e s
O U T P U T _ R E S O U R C E _ N A M E n e w R e s o u r c e N a m e
)
if ( NOT resources )
return ( )
endif ( )
set ( generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/generated_${newResourceName}.qrc" )
set ( generatedSourceCode "${CMAKE_CURRENT_BINARY_DIR}/qrc_${newResourceName}.cpp" )
2019-03-07 09:05:10 +00:00
# Generate .qrc file:
# <RCC><qresource ...>
set ( qrcContents "<RCC>\n <qresource" )
if ( rcc_PREFIX )
string ( APPEND qrcContents " prefix=\" ${ rcc_PREFIX } \"")
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-07 09:05:10 +00:00
if ( rcc_LANG )
string ( APPEND qrcContents " lang=\" ${ rcc_LANG } \"")
endif ( )
string ( APPEND qrcContents ">\n" )
2018-10-24 13:20:27 +00:00
2019-08-02 09:25:59 +00:00
foreach ( file IN LISTS resources )
2019-08-09 07:39:42 +00:00
qt_get_relative_resource_path_for_file ( file_resource_path ${ file } )
2019-07-12 14:54:26 +00:00
2019-08-02 09:25:59 +00:00
if ( NOT IS_ABSOLUTE ${ file } )
set ( file "${CMAKE_CURRENT_SOURCE_DIR}/${file}" )
2019-07-12 14:54:26 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
### FIXME: escape file paths to be XML conform
2019-03-07 09:05:10 +00:00
# <file ...>...</file>
2019-08-09 07:39:42 +00:00
string ( APPEND qrcContents " <file alias=\" ${ file_resource_path } \">")
2019-08-02 09:25:59 +00:00
string ( APPEND qrcContents "${file}</file>\n" )
list ( APPEND files "${file}" )
2018-10-24 13:20:27 +00:00
endforeach ( )
2019-03-07 09:05:10 +00:00
# </qresource></RCC>
2018-10-24 13:20:27 +00:00
string ( APPEND qrcContents " </qresource>\n</RCC>\n" )
2019-03-07 09:05:10 +00:00
2018-10-24 13:20:27 +00:00
file ( GENERATE OUTPUT "${generatedResourceFile}" CONTENT "${qrcContents}" )
2019-03-07 09:05:10 +00:00
# Process .qrc file:
2018-10-24 13:20:27 +00:00
add_custom_command ( OUTPUT "${generatedSourceCode}"
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 } : : r c c "
2019-08-02 09:25:59 +00:00
A R G S - - n a m e " $ { n e w R e s o u r c e N a m e } "
2018-10-24 13:20:27 +00:00
- - o u t p u t " $ { g e n e r a t e d S o u r c e C o d e } " " $ { g e n e r a t e d R e s o u r c e F i l e } "
2019-08-09 11:20:34 +00:00
D E P E N D S $ { r e s o u r c e s } $ { g e n e r a t e d R e s o u r c e F i l e }
2019-08-02 09:25:59 +00:00
C O M M E N T " R C C $ { n e w R e s o u r c e N a m e } "
2018-10-24 13:20:27 +00:00
V E R B A T I M )
2019-08-02 10:01:00 +00:00
get_target_property ( type "${target}" TYPE )
2019-08-02 09:25:59 +00:00
# Only do this if newResourceName is the same as resourceName, since
# the resource will be chainloaded by the qt quickcompiler
# qml cache loader
if ( newResourceName STREQUAL resourceName )
qt_propagate_generated_resource ( ${ target } ${ resourceName } "${generatedSourceCode}" )
2019-08-02 10:01:00 +00:00
else ( )
target_sources ( ${ target } PRIVATE "${generatedSourceCode}" )
endif ( )
2018-10-24 13:20:27 +00:00
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).
function ( add_qt_simd_part target )
qt_parse_all_arguments ( arg "add_qt_simd_part" "" ""
" 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 )
message ( FATAL_ERROR "add_qt_simd_part needs a SIMD type to be set." )
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 )
message ( "add_qt_simd_part(${target} SIMD ${arg_SIMD} ...): Evaluated" )
endif ( )
string ( TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags )
add_library ( "${name}" OBJECT )
target_sources ( "${name}" PRIVATE ${ arg_SOURCES } )
target_include_directories ( "${name}" PRIVATE
$ { a r g _ 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 C L U D E _ D I R E C T O R I E S > )
target_compile_options ( "${name}" PRIVATE
$ { $ { s i m d _ f l a g s } }
$ { a r g _ C O M P I L E _ F L A G S }
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , C O M P I L E _ O P T I O N S > )
target_compile_definitions ( "${name}" PRIVATE
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , C O M P I L E _ D E F I N I T I O N S > )
target_link_libraries ( "${target}" PRIVATE "${name}" )
2019-02-11 11:12:07 +00:00
if ( NOT BUILD_SHARED_LIBS )
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 (
2019-02-11 11:12:07 +00:00
T A R G E T S $ { n a m e }
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 s "
)
endif ( )
2019-03-11 14:09:33 +00:00
else ( )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
message ( "add_qt_simd_part(${target} SIMD ${arg_SIMD} ...): Skipped" )
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 )
cmake_parse_arguments ( arg "" "" "FLAGS" ${ ARGN } )
set ( moc_files )
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}" )
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
2018-12-12 09:55:20 +00:00
add_custom_command ( OUTPUT "${outfile}"
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 )
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 } "
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 } "
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-06-14 13:29:21 +00:00
file ( RELATIVE_PATH relpath "${CMAKE_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 ( )
function ( add_qt_docs qdocFile )
# TODO
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 )
set ( oneValueArgs )
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
# 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-05-03 13:46:02 +00:00
if ( NOT ( arg_CONFIG OR arg_NO_MODULE OR arg_MODULE ) )
# 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 ( )
if ( NOT ${ ARGV0 } _FOUND )
# 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
if ( ${ ARGV0 } _FOUND AND arg_PROVIDED_TARGETS )
# 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 ( )
endif ( )
endmacro ( )
2019-02-11 11:12:07 +00:00
# Creates a simple export set for the various Find* dependencies
# which are needed when creating a static build of Qt.
# This introduces a custom target property: INTERFACE_QT_EXPORTED_LIBRARY
# This target property indicates that Qt modules / plugins using this 3rd party library
# must add it to their list of dependencies when creating their own ${qtmodule}Config.cmake
function ( qt_install_static_target_export target )
if ( BUILD_SHARED_LIBS )
return ( )
endif ( )
qt_parse_all_arguments ( arg "qt_install_3rdparty_config_files" "" "EXPORT" "" ${ ARGN } )
# TODO mark EXPORT as required
set_target_properties ( ${ target }
P R O P E R T I E S
I N T E R F A C E _ Q T _ E X P O R T E D _ L I B R A R Y 1 )
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 ( config_install_dir ${ QT_CONFIG_INSTALL_DIR } ${ arg_EXPORT } )
set ( export_name "${arg_EXPORT}Targets" )
qt_install (
2019-02-11 11:12:07 +00:00
T A R G E T 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
E X P O R T $ { e x p o r t _ n a m e }
2019-02-11 11:12:07 +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 } )
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 (
E X P O R T $ { e x p o r t _ n a m e }
2019-02-11 11:12:07 +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 } "
)
endfunction ( )
# Create a set of ${target}Config.cmake and ${target}Version.cmake for a
# third-party library so that it can be found by client code linking statically.
function ( qt_install_3rdparty_config_files target )
if ( BUILD_SHARED_LIBS )
return ( )
endif ( )
qt_parse_all_arguments ( arg "qt_install_3rdparty_config_files" "" "EXPORT" "PACKAGES;ADDITIONAL_FILES" ${ ARGN } )
# TODO mark EXPORT as required
set ( 3RDPARTY_ADDITIONAL_SETUP_CODE )
foreach ( package ${ arg_PACKAGES } )
list ( APPEND 3RDPARTY_ADDITIONAL_SETUP_CODE "find_package(${package})\n" )
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
set ( path_suffix "${arg_EXPORT}" )
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-02-11 11:12:07 +00:00
configure_package_config_file (
" $ { P R O J E C T _ S O U R C E _ D I R } / c m a k e / 3 r d p a r t y 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 } / $ { t a r g e t } C o n f i g . c m a k e "
2019-02-11 11:12:07 +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 } / $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
2019-02-11 11:12:07 +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 } / $ { 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 "
2019-02-11 11:12:07 +00:00
$ { a r g _ A D D I T I O N A L _ 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
)
endfunction ( )
# Call this function in 3rdparty find modules that ought to be installed alongside
# Qt modules and must be found when linking statically.
function ( qt_install_3rdparty_library target )
qt_install_static_target_export ( ${ target } EXPORT ${ target } )
qt_install_3rdparty_config_files ( ${ target } EXPORT ${ target } ${ ARGN } )
endfunction ( )
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 )
find_library ( FWApplicationServices ApplicationServices )
find_library ( FWCarbon Carbon )
find_library ( FWCoreFoundation CoreFoundation )
find_library ( FWCoreServices CoreServices )
find_library ( FWCoreVideo CoreVideo )
find_library ( FWcups cups )
find_library ( FWDiskArbitration DiskArbitration )
find_library ( FWFoundation Foundation )
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 )
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.
function ( qt_process_qlalr input_file_list consuming_target flags )
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 }
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 ( )
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.
qt_add_string_to_qconfig_cpp ( "doc" )
qt_add_string_to_qconfig_cpp ( "include" )
qt_add_string_to_qconfig_cpp ( "lib" )
qt_add_string_to_qconfig_cpp ( "libexec" )
qt_add_string_to_qconfig_cpp ( "bin" )
qt_add_string_to_qconfig_cpp ( "plugins" )
qt_add_string_to_qconfig_cpp ( "imports" )
qt_add_string_to_qconfig_cpp ( "qml" )
qt_add_string_to_qconfig_cpp ( "." )
qt_add_string_to_qconfig_cpp ( "." )
qt_add_string_to_qconfig_cpp ( "translations" )
qt_add_string_to_qconfig_cpp ( "examples" )
qt_add_string_to_qconfig_cpp ( "tests" )
# 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 "" )
qt_add_string_to_qconfig_cpp ( "" )
qt_add_string_to_qconfig_cpp ( "false" )
qt_add_string_to_qconfig_cpp ( "bin" )
qt_add_string_to_qconfig_cpp ( "lib" )
qt_add_string_to_qconfig_cpp ( "." )
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}" )
configure_file ( global/qconfig.cpp.in global/qconfig.cpp @ONLY )
endfunction ( )