summaryrefslogtreecommitdiffstats
path: root/cmake/QtTargetHelpers.cmake
Commit message (Collapse)AuthorAgeFilesLines
* CMake: Fix dbus headers not being added in qt_internal_extend_targetAlexandru Croitor2022-01-181-2/+2
| | | | | | | | | | The generated dbus headers would not appear in IDE source lists because of incorrectly named variables. Pick-to: 6.2 6.3 Change-Id: I276d4284eb94b98cc75f791de62ca332ad947004 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Update copyright year to 2022Kai Köhne2022-01-041-1/+1
| | | | | | | Pick-to: 5.15 6.2 6.3 Change-Id: If6f1d6f9f82a601f8e2b6d36650d6e737518aa60 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Exclude sources from HEADER_MODULE if cmake version is less than 3.19Alexey Edelev2022-01-031-3/+12
| | | | | | | | | | | | | CMake versions less than 3.19 don't support adding the source files to the PRIVATE scope of the INTERFACE libraries. It looks like these PRIVATE sources are only used by IDEs to display them in a project tree. Skip them to avoid configuring issues. Fixes: QTBUG-99316 Pick-to: 6.3 Change-Id: Id03f540ac9c94e920adfae5de4f364bd7aba4613 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Install MSVC debug information for resource object librariesJoerg Bornemann2021-12-021-1/+14
| | | | | | | | | | | | | | | | Building against a static debug MSVC Qt produced LNK4099 warnings (PDB was not found with object file). This was because we did not install the .pdb files for the object libraries that are created for Qt resources. Now, these .pdb files are named like the object library targets and are installed next to the object files. Pick-to: 6.2 Fixes: QTBUG-97699 Change-Id: I7e23f8392b7ac657be1d2fb3b33e051ae2e4d407 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add PRIVATE_MODULE_INTERFACE to the module dependency setAlexey Edelev2021-10-151-1/+1
| | | | | | | | | | | | | | PRIVATE_MODULE_INTERFACE libraries are linked as interface libraries to the module's Private target and exported as the dependencies of package targets. We need to register these modules as public package dependencies to call find_package when resolving module dependencies in user projects. Pick-to: 6.2 Fixes: QTBUG-96558 Change-Id: I4eef550aab306eaf357539ef7a0f76d69873f856 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Don't export Qt6::ATSPI2_nolink target in Qt6GuiTargets.cmakeJoerg Bornemann2021-10-011-9/+21
| | | | | | | | | | | | | | We don't have any APSPI2 includes in our public headers and should therefore not export the target that provides ATSPI2 include paths for consumers. Link against PkgConfig::ATSPI2 instead of the _nolink target. The former will not be exported. Pick-to: 6.2 Fixes: QTBUG-97023 Change-Id: I4b12e0c2230917feeb963c02565e6db24f757bd3 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Warn when PRIVATE_MODULE_INTERFACE is provided with no targetAlexandru Croitor2021-08-261-2/+10
| | | | | | | | | | | | Warn if the PRIVATE_MODULE_INTERFACE option is provided a value, but there is no ${target}Private target to set the interface dependencies on. Pick-to: 6.2 Task-number: QTBUG-95921 Change-Id: I7d4df9cb3aa9b7746d836b82019ecdd9c8f50fdc Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add missing PRIVATE_MODULE_INTERFACEs to INTERNAL_MODULEsAlexey Edelev2021-08-241-0/+6
| | | | | | | | | | | | | | To detect the internal module ouside the qt_internal_add_module function need to mark it with the property. This adds _qt_is_internal_module property to the Qt internal modules. Since PRIVATE_MODULE_INTERFACE only was applicable to pure Private modules, INTERNAL_MODULEs is missing those dependencies if they were specified. Add extra condition to qt_internal_extend_target to link PRIVATE_MODULE_INTERFACE libraries to internal modules as well. Pick-to: 6.2 6.1 Change-Id: I9c32fa5bad3aff365f5d7663349e5365d5f1d72d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix excessive size of precompiled header filesJoerg Bornemann2021-08-241-3/+3
| | | | | | | | | | | | | | | Do not add catch-all header files like QtCore, QtGui, etc. to precompiled headers for targets that already define their own set of precompiled header files. This reduces the size of the precompiled headers and brings the pch file sizes down into the region of the qmake build. Pick-to: 6.2 Task-number: QTBUG-89122 Change-Id: I8e4d17aa6829c7d7b1aa01a01a61b6677e22c460 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Rename qt6_add_plugin TYPE option to PLUGIN_TYPEAlexandru Croitor2021-08-061-1/+2
| | | | | | | | | | | | | The intention is to remove TYPE as a keyword completely before 6.2.0 release, but in case if that's not possible due to the large amount of repositories and examples, just print a deprecation warning for now and handle both TYPE and PLUGIN_TYPE. Task-number: QTBUG-95170 Pick-to: 6.2 Change-Id: If0c18345483b9254b0fc21120229fcc2a2fbfbf5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Avoid to call _qt_internal_set_up_static_runtime_library() twiceLi Xinwei2021-08-031-1/+0
| | | | | | Pick-to: 6.2 Change-Id: I28985470b3e0b88befbbd2d62a027670d7d6c822 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Make WrapVulkanHeaders target optional for QtGui consumersAlexandru Croitor2021-07-291-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If Vulkan headers are present on the system when qtbase is configured, QtGui and QtOpenGL should be compiled with Vulkan support. If a user project uses a Qt built with Vulkan support, but their system is missing Vulkan headers, the project configuration needs to succeed. The project will get compilation errors if it uses Vulkan headers, but that's intended. This use case was broken when fixing Vulkan to be found when building Qt for Android. Fix the regression with a combination of things 1) Mark the WrapVulkanHeaders package as optional (already the case) 2) Use the include directories directly when compiling Gui and OpenGL 3) Propagate WrapVulkanHeaders::WrapVulkanHeaders link requirement to consumers only if the target exists. It won't exist if Vulkan include dirs are not found This also requires some changes in pri and prl file generation. For prl file generation, we don't want to link to the WrapVulkanHeaders target, so we filter out all dependencies that use TARGET_NAME_IF_EXISTS for anything that calls __qt_internal_walk_libs which includes qt_collect_libs. For pri files, we make sure to generate a uses=vulkan/nolink clause by inspecting a new _qt_is_nolink_target property on the target. We also don't add include dirs to the pri file if the new _qt_skip_include_dir_for_pri property is set. This is intended for Vulkan, because there is separate qmake logic to try and find the include dirs when configuring a user project. As a drive-by, fix nolink handling for WrapOpenSSLHeaders. Amends bb25536a3db657b41ae31e1690d230ef8722b57d Amends 7b9904849fe1a43f0db8216076a9e974ebca5c78 Pick-to: 6.2 Fixes: QTBUG-95391 Change-Id: I21e2f4be5c386f9e40033e4691f4786a91ba0e2d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Apply bitcode flags to internal plugin object lib initializersAlexandru Croitor2021-07-161-0/+10
| | | | | | | | | | | | | | | | | | | | | | All internal libraries, plugins, object libraries (resources, plugin initializers) need to be built with bitcode flags when targeting iOS. Internal here means all libraries added by qt_internal_add_X functions or associated with internal libraries. We didn't do that for plugin initializers, which were added not too long ago. Extract the logic that links to Qt::PlatformModuleInternal into a separate function to be used for object libraries. Use it for resources and plugin initializers. It will also be used in qtdeclarative for qml plugin initializers. Pick-to: 6.2 Task-number: QTBUG-95208 Change-Id: I366996078f5e9d1c2d2797f6b81c522ee99529e3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't propagate -fapplication-extension to user projectsAlexandru Croitor2021-07-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Both the compiler and linker -fapplication-extension flag should only be applied when building Qt's libraries (not executables). It's up to the user project whether their code will be restricted with application-extension-only APIs. In qmake that can be achieved by adding to the qmake project CONFIG += app_extension_api_only In CMake it can be achieved by either adding the compiler and link flags in the project directly (using target_X_options) or by setting the appropriate setting in the Xcode project when using the Xcode generator. Amends e189126f1ae1d2fa2ad0f95ee2c4aa72c770a97b Pick-to: 6.2 Task-number: QTBUG-95199 Change-Id: Ie7a764d460a89c7650391abff0fcc5abfcabef64 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix IMPORTED_IMPLIB to be set for shared libraries on WindowsAlexandru Croitor2021-07-141-1/+1
| | | | | | | | | | The correct variable to check is WIN32, not WINDOWS. Amends 85e25d93b3b99fbeae8541586252df2cb099081d Pick-to: 6.2 Change-Id: I4570eb5a124bcaa0bd38135dd7c7f48345c40c9d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* CMake: Use correct MSVC runtime library for Qt object librariesAlexandru Croitor2021-07-091-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | If Qt was configured with -static-runtime which implies MultiThreaded -MT flag, the plugin initializer object libraries were still compiled with the default -MD flag. When an application linked to Qt, that caused linking to fail with mismatched symbol errors between the application symbols and the plugin initializer object library symbols. Make sure to set the MSVC_RUNTIME_LIBRARY property on both plugin initializer and resource object libraries, depending on the value of QT_FEATURE_static_runtime. We did set the property for resources added by qt_internal_add_resource, but not for the resource created by the public qt6_add_resources counterpart. Pick-to: 6.2 Fixes: QTBUG-95043 Change-Id: Ia543cd0241db94a12080be2655ad420fe9ad3f24 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Place internal apps in the correct output directoryAlexandru Croitor2021-07-091-0/+24
| | | | | | | | | | | | | | In a -debug-and-release build, apps were placed under bin/Release rather than just bin. Apply the logic we use for tools for apps as well. Rename and move the common functions into QtTargetHelpers.cmake. Pick-to: 6.2 Fixes: QTBUG-95028 Change-Id: I5a9082ea50c9238c8fcf0c6dd099708fbc571bf8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Set IMPORTED_{SONAME|IMPLIB} for shared libs onlyJoerg Bornemann2021-07-081-9/+32
| | | | | | | | | | | | In our *AdditionalTargetInfo.cmake we now set above target properties for shared libs only, not executables. IMPORTED_IMPLIB is only set for Windows. IMPORTED_SONAME is only set for non-Windows platforms. Pick-to: 6.2 Change-Id: If7f01e6bf5183cca0ac90f9afffd57c41b34dccd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix build of Debug projects against debug-and-release non-prefix QtJoerg Bornemann2021-07-081-2/+21
| | | | | | | | | | | | | | | | | | | Building a CMake project with CMAKE_BUILD_CONFIG=Debug was broken for non-prefix debug-and-release builds of Qt. In debug-and-release builds we set EXCLUDE_FROM_ALL on tools in the Debug configuration. In non-prefix builds we export(EXPORT) targets, and that also contains the non-existent Debug variants of the tools. In prefix builds, we install(EXPORT) instead, which only exports what is built and installed. Consequently, we now remove the DEBUG-related import information if the debug variant if the target binary does not exist. Pick-to: 6.2 Fixes: QTBUG-95027 Change-Id: I37766d5ab1e2795bcb91a348e7e72150e8a00f82 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Promote all targets to global within a scope when possibleAlexandru Croitor2021-06-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | CMake 3.21 introduced a new IMPORTED_TARGETS directory property which we can use to promote all imported targets within a scope to be global. This would cover transitive non-Qt imported targets which the Qt build system does not know about and is thus a more complete solution compared to promoting only Qt targets. Run a finalizer at the end of the directory scope where find_package(Qt6) is called to promote all imported targets within that scope to global (when requested). The old promotion method is disabled when the CMake version is new enough. Pick-to: 6.2 Task-number: QTBUG-92878 Task-number: QTBUG-94528 Change-Id: I533a3bd4186eba652f878ddd72c76118c2fd8bae Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Allow promoting the Qt libraries to be global targetsAlexandru Croitor2021-06-161-7/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User projects can set the QT_PROMOTE_TO_GLOBAL_TARGETS variable to true so that the various imported targets created by find_package(Qt6) are promoted to global targets. This would allow a project to find Qt packages in a subdirectory scope while using those Qt targets from a different scope. E.g. it fixes errors like CMake Error at CMakeLists.txt:5 (target_link_libraries): Error evaluating generator expression: $<TARGET_OBJECTS:Qt6::Widgets_resources_1> Objects of target "Qt6::Widgets_resources_1" referenced but no such target exists. when trying to use a static Qt from a sibling scope. Various 3rd party dependency targets (like Atomic or ZLIB) are not made global due to limitations in CMake, but as long as those targets are not mentioned directly, it shouldn't cause issues. The targets are made global in the generated QtFooAdditionalTargetInfo.cmake file. To ensure that resource object libraries promoted, the generation of the file has to be done at the end of the defining scope where qt_internal_export_additional_targets_file is called, which is achieved with a deferred finalizer. Replaced all occurrences of target promotion with a helper function which allows tracing of all promoted targets by specifying --log-level=debug to CMake. Pick-to: 6.2 Fixes: QTBUG-92878 Change-Id: Ic4ec03b0bc383d7e591a58c520c3974fbea746d2 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Make qt_internal_walk_libs available in public projectsAlexandru Croitor2021-05-111-17/+0
| | | | | | | | | | | | | | | | | | Needed for the upcoming static plugin mechanism, where we have to extract the list of Qt module dependencies of a target and then extract the plugins associated with those modules. To do that we need to recursively collect the dependencies of a given target. Rename the moved functions to contain the __qt_internal prefix. Also rename the existing QtPublicTargetsHelpers.cmake into QtPlatformTargetHelpers.cmake to avoid confusion with the newly introduced QtPublicTargetHelpers.cmake. Task-number: QTBUG-92933 Change-Id: I48b5b6a8718a3424f59ca60f11fc9e97a809765d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Do not use qt_internal_module_info for non-module targetsAlexey Edelev2021-04-301-0/+6
| | | | | | | | | | | | The qt_internal_module_info function suppose to provide the information only about the Qt modules. Avoid using it for the tool and extra package dependencies, since some targets do not always exist, when function is called. Add the qt_internal_qtfy_target function to make the prefixed target names. Change-Id: Ifa8c61064d9c6c430889f00a4ead304029da711b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Allow enabling Apple app extension API in other reposAlexandru Croitor2021-04-231-0/+4
| | | | | | | | | | | | | | It's needed in qtconnectivity, but currently the qt_disable_apple_app_extension_api_only function is defined in QtInternalTargets.cmake which is loaded only in qtbase. Move the function to cmake/QtTargetHelpers.cmake. Amends e189126f1ae1d2fa2ad0f95ee2c4aa72c770a97b Pick-to: 6.1 Change-Id: Ia2470e48a91385239394368780f5bbb223000113 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix building multi-arch universal macOS QtAlexandru Croitor2021-04-011-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the same approach we use for iOS, which is to set multiple CMAKE_OSX_ARCHITECTURES values and let the clang front end deal with lipo-ing the final libraries. For now, Qt can be configured to build universal macOS libraries by passing 2 architectures to CMake, either via: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" or -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" Currently we recommend specifying the intel x86_64 arch as the first one, to get an intel slice configuration that is comparable to a non-universal intel build. Specifying the arm64 slice first could pessimize optimizations and reduce the feature set for the intel slice due to the limitation that we run configure tests only once. The first specified architecture is the one used to do all the configure tests. It 'mostly' defines the common feature set of both architecture slices, with the excepion of some special handling for sse2 and neon instructions. In the future we might want to run at least the Qt architecture config test for all specified architectures, so that we can extract all the supported sub-arches and instruction sets in a reliable way. For now, we use the same sse2 hack as for iOS simulator_and_device builds, otherwise QtGui fails to link due to missing qt_memfill32_sse2 and other symbols. The hack is somewhat augmented to ensure that reconfiguration still succeeds (same issue happened with iOS). Previously the sse2 feature condition was broken due to force setting the feature to be ON. Now the condition also checks for a special QT_FORCE_FEATURE_sse2 variable which we set internally. Note that we shouldn't build for arm64e, because the binaries get killed when running on AS with the following message: kernel: exec_mach_imgact: not running binary built against preview arm64e ABI. Aslo, by default, we disable the arm64 slice for qt sql plugins, mostly because the CI provisioned sql libraries that we depend on only contain x86_64 slices, and trying to build the sql plugins for both slices will fail with linker errors. This behavior can be disabled for all targets marked by qt_internal_force_macos_intel_arch, by setting the QT_FORCE_MACOS_ALL_ARCHES CMake option to ON. To disble it per-target one can set QT_FORCE_MACOS_ALL_ARCHES_${target} to ON. Task-number: QTBUG-85447 Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Refactor qt_internal_add_plugin() and qt6_add_plugin()Craig Scott2021-03-291-37/+0
| | | | | | | | | | | | | | | | | | | | | | Remove code duplication by calling qt6_add_plugin() from qt_internal_add_plugin(). Separate out the public and internal arguments for the variables defined in QtBuild.cmake for these functions. Provide them via commands instead for greater robustness. This separation allows other Qt repos to access the appropriate set of keywords where they define commands that forward on to *_add_plugin() in their implementations. Retain the old variables for now to simplify the integration steps for updating other repos. The old variables can be removed once there are no more references left to them in any repo. Task-number: QTBUG-88763 Pick-to: 6.1 Change-Id: I0105523afd95995923bd20fc963d245bbb15d34d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Move build tools to libexec instead of the bin dirJoerg Bornemann2021-02-231-1/+1
| | | | | | | | | | | | | | [ChangeLog][Build System] Tools that are called by the build system and are unlikely to be called by the user are now installed to the libexec directory. This is a step towards easier co-installability of different Qt versions. Pick-to: 6.1 Task-number: QTBUG-88791 Change-Id: Id19575b5ba27795f7715e4ea6a09391b26dd4942 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Bump copyright year to 2021Kai Köhne2021-01-251-1/+1
| | | | | | Change-Id: I18a9c2de391ca51655148b2e3cc9abdfbb8ddbcf Reviewed-by: Tarja Sundqvist <tarja.sundqvist@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Use host variables instead of hardcoded directoriesAlexey Edelev2020-12-211-1/+1
| | | | | | | | | | | | | | | | | | | 'QT_HOST_PATH' indicates that we use crosscompilation toolchain to build project. In this case 'Qt6Config.cmake' loads 'Qt6HostInfoConfig.cmake' from host QT_HOST_PATH, that defines correct paths to host tools. Replace hardcoded paths for host tools by paths recorded in Qt6HostInfoConfig.cmake. Correct conditions for QT_HOST_PATH, evaluate it explicitly as string, but not as boolean expression. Fixes: QTBUG-86557 Pick-to: 6.0 Change-Id: Ib52bbd32478051d019a932dcb1f735e2d4aacfbf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Fix module separate build error when -DFEATURE_static_runtime=ONLi Xinwei2020-12-171-9/+9
| | | | | | | | | | | | | | | | | | Build qtbase with -DFEATURE_static_runtime=ON, and then separately build another module, following build error occurs: error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'. That's because all the sources in this module are compiled with 'MD'. When separately building a module except qtbase, FEATURE_static_runtime is not exist in cmake cache. So we should use QT_FEATURE_static_runtime instead of FEATURE_static_runtime in qt_set_common_target_properties. Additionally, adjust the indentation. Pick-to: 6.0 Change-Id: I2cf4737db9d3e8533570039a66c7d277d62a8d14 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Refactor parts of qt_internal_walk_libsAlexandru Croitor2020-11-191-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | Refactor the function in preparation of processing rcc object files. Introduce 2 new functions to get and set values in the memoization dictionary used by qt_internal_walk_libs. Modify qt_internal_add_target_aliases to assign the alias names it creates as properties on the target. Extract these aliases when available to assign memoized values not only for the initial library name, but also for its aliases. When recursively calling qt_internal_walk_libs, make sure to provide a unique out_var name based on the outer target name, and not just lib_libs. Otherwise the out_var values would be polluted from previous recursion runs. Make sure to check for -NOTFOUND in if() checks so that we reuse memoized values that are the empty string. Change-Id: I8fd8e2b0ae14d0ba8f502bc5a764d6e01095001a Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Install pdb files to proper directories in multi-config buildLi Xinwei2020-11-141-2/+16
| | | | | | | | | | | | | | In multi-config build, for different configs, the pdb files of EXEs should have different installation directories. For example, when CMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug, <build_dir>/bin/moc.pdb will be installed to <install_dir>/bin/moc.pdb. <build_dir>/bin/Debug/moc.pdb should be installed to <install_dir>/bin/Debug/moc.pdb, not <install_dir>/bin/moc.pdb. Fixes: QTBUG-88268 Change-Id: Idc7c92ca8d44bb81d990656af2b309306a4f5c6b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix additional target info filesJoerg Bornemann2020-10-201-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | ...for QT_BUILD_TOOLS_WHEN_CROSSCOMPILING. qt_internal_export_additional_targets_file now gets two lists of target names when run from qt_export_tools: - TARGETS containing actually existing targets, and - TARGET_EXPORT_NAMES containing the target names as they appear in the additional target info file. Operations that require actual targets are run on the TARGETS, in the additional target info file only TARGET_EXPORT_NAMES are written. This distinction is required for the case where the host Qt lacks a tool that is built in the target Qt. Example: host Qt is built with DEVELOPER_BUILD=OFF, target Qt is built with DEVELOPER_BUILD=ON. Then the host Qt lacks qmljs, but it is built in the target Qt. TARGETS contains qmljs_native, and TARGET_EXPORT_NAMES contains qmljs. Fixes: QTBUG-87693 Change-Id: I615aed996bfcbe654274defcda8c1cb2cc4b7b4e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Install PDB debug info for MSVC buildsAlexandru Croitor2020-10-061-0/+62
| | | | | | | | | | | | | | | Supports installing linker generated debug info for shared libraries and executables, as well as compiler generated debug info for static libraries. Works with Ninja Multi-Config as well, with the caveat that the files are installed optionally, aka the install rule will not error out if a pdb file is not present. This is necessary, because it's not possible to create per-config install rules properly. Fixes: QTBUG-87006 Change-Id: I95e91a6557eb0ee0f882103be54cd38795c349f7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Implement configure -reduce-exportsJoerg Bornemann2020-10-051-0/+8
| | | | | | | | | | | | | | | | | This option maps to FEATURE_reduce_exports. The feature is on by default, except for MSVC. The reduce_exports configure test is not used in the CMake build. The <LANG>_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN target properties are now explicitly initialized in the qt_set_common_target_properties function, because we don't have access to the feature in QtSetup.cmake where the CMAKE_<LANG>_VISIBILITY_PRESET variables were set before. Task-number: QTBUG-85373 Change-Id: I378453f0e0665731970016170302871e20ceb4e2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Generate *AdditionalTargetInfo.cmake for toolsJoerg Bornemann2020-09-281-1/+4
| | | | | | | | | | This ensures that we have the configuration-independent IMPORTED_* properties set on tools. Fixes: QTBUG-86893 Change-Id: I2b772c21341e6e4631379d4a5a99580ec96909ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Write proper *AdditionalTargetInfo file in debug-only buildJoerg Bornemann2020-09-281-25/+29
| | | | | | | | | | To provide the IMPORTED_LOCATION target property we must write the *AdditionalTargetInfo.cmake file for all debug-only builds, not only the ones containing a release configuration. Task-number: QTBUG-86893 Change-Id: I9ecd01483660f434a3f1ea12fa2af756cdcf9932 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix build of Release user projects against RelWithDebInfo QtJoerg Bornemann2020-09-251-0/+97
| | | | | | | | | | | | | | | | | | | | | Building a user project in Release configuration against a Qt built with CMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug led to the user project being linked against the Debug Qt libraries. This is especially painful with MSVC where debug and release runtimes are incompatible. We now create *AdditionalTargetInfo.cmake files along the exported *Targets.cmake files that set the IMPORT_*_<CONFIG> properties to the values of the release config Qt was built with. User projects built with an unknown configuration (CMAKE_BUILD_TYPE=ArbitraryName) will link against a release Qt. This can be controlled by setting the variable QT_DEFAULT_IMPORT_CONFIGURATION to, for example, DEBUG in the user project. Fixes: QTBUG-86743 Change-Id: I12c4b065a9845c7317f6acddab46b649f2732c9e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Rename internal functions to contain qt_internalAlexandru Croitor2020-09-231-2/+2
| | | | | | | | | | Offer compatibility wrapper functions until we update all of the Qt repos to use the new names. Task-number: QTBUG-86815 Change-Id: I5826a4116f52a8509db32601ef7c200f9bd331de Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* CMake: Fix generation of XXX_tracepoints.cppJoerg Bornemann2020-09-101-1/+1
| | | | | | | | The include directive was incorrectly written. This amends 5c092c2b401. Change-Id: Ia72ca3a5d5e1486ade4d71a764550d36979640f6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix call to tracegen when cross-compiling toolsJoerg Bornemann2020-09-101-2/+10
| | | | | | | | | | We need to use the imported host tracegen target to generate files, not the one we're going to cross-build. This amends 5c092c2b401. Change-Id: Ib74dd2d87110383c31216872eb55bebf5d90df37 Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* CMake: Implement configure -traceJoerg Bornemann2020-09-011-5/+31
| | | | | | Task-number: QTBUG-85373 Change-Id: Ib9ac35ec98dd5b6c272f58f8a61a124d1d262ec0 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* CMake: Split QtBuild.cmake into smaller filesAlexandru Croitor2020-08-141-0/+335
QtBuild.cmake is huge. Split it. Move module, plugin, tools, executables and test related functions out of QtBuild.cmake into separate files. Do the same for many other things too. An additional requirement is that all the new Helpers files only define functions and macros. No global variable definitions are allowed, nor execution of commands with side effects. Some notes: qt_install_qml_files is removed because it's dead code. Some functions still need to be figured out, because they are interspersed and depend on various global state assignments. Task-number: QTBUG-86035 Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>