qt5base-lts/util/cmake
Alexandru Croitor c5b61d2e90 pro2cmake: Handle QT += core-private correctly for modules
If a module project (Quick) contains QT += core-private, the
qmake semantics translated to CMake would mean the following:

target_link_libraries(Quick PUBLIC Core)
target_link_libraries(Quick PRIVATE CorePrivate)
target_link_libraries(QuickPrivate INTERFACE CorePrivate)

Whereas a QT_PRIVATE += core-private only means
target_link_libraries(Quick PRIVATE CorePrivate)

without adding any public dependencies to QuickPrivate.

To achieve that, we need a few modifications to both pro2cmake and
QtBuild.cmake

- pro2cmake doesn't automagically add public and private dependencies
  to targets when encountering a private module assigned to QT.
  Instead it generates the logic described above by passing correct
  LIBRARIES, PUBLIC_LIBRARIES, and PRIVATE_MODULE_INTERFACE values.

- pro2cmake doesn't do any dependency magic for non-module targets
  anymore, like executables, plugins, internal_modules. This means
  that QT assignments are now regular public dependencies.

- qt_add_module and qt_extend_target now accept a new
  PRIVATE_MODULE_INTERFACE option.

- qt_extend_target does not automagically make private modules be
   public dependencies on other private modules.

- qt_extend_target correctly assigns PRIVATE_MODULE_INTERFACE values
  to Private module only. For other target types, it's a no-op.

The change requires regeneration of all projects.

When we fix pro2cmake and QtBuild.cmake to properly handle
internal_modules (create only Private modules without creating
a non-Private counter part), we will need another project regeneration
to correctly assign dependencies.

Change-Id: I4c21f26b3ef3b2a4ed208b58bccb65a5b7312f81
Task-number: QTBUG-81780
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-02-05 14:36:16 +00:00
..
tests pro2cmake: Handle operation evaluation order when including children 2019-11-12 11:47:42 +00:00
cmakeconversionrate.py Improve styling of util/cmake scripts 2019-09-18 12:00:26 +00:00
condition_simplifier_cache.py Fix message about missing portalocker 2019-10-15 12:23:46 +00:00
condition_simplifier.py cmake scripts: fix type issues 2019-10-09 09:13:44 +00:00
configurejson2cmake.py Add special condition replacement for libclang in qttools 2019-12-10 12:37:22 +00:00
generate_module_map.sh Begin port of qtbase to CMake 2018-11-01 11:48:46 +00:00
helper.py Run make format 2020-01-16 08:41:08 +00:00
json_parser.py cmake scripts: more type cleanup 2019-10-09 09:14:19 +00:00
Makefile cmake scripts: format with black 2019-10-11 08:13:54 +00:00
Pipfile cmake scripts: add portalocker as dependency for Pipenv 2019-10-10 13:58:26 +00:00
pro2cmake.py pro2cmake: Handle QT += core-private correctly for modules 2020-02-05 14:36:16 +00:00
pro_conversion_rate.py cmake scripts: make pro_conversion_rate.py mypy clean 2019-10-10 14:59:55 +00:00
qmake_parser.py pro2cmake: Handle operation evaluation order when including children 2019-11-12 11:47:42 +00:00
README.md Improve styling of util/cmake scripts 2019-09-18 12:00:26 +00:00
requirements.txt cmake scripts: format with black 2019-10-11 08:13:54 +00:00
run_pro2cmake.py Fix pro2cmake formatting 2019-11-23 07:07:45 +00:00
special_case_helper.py pro2cmake: Clean up debug messages 2019-11-12 10:12:35 +00:00

CMake Utils

This directory holds scripts to help the porting process from qmake to cmake for Qt6.

Requirements

  • Python 3.7,
  • pipenv or pip to manage the modules.

Python modules

Since Python has many ways of handling projects, you have a couple of options to install the dependencies of the scripts:

Using pipenv

The dependencies are specified on the Pipfile, so you just need to run pipenv install and that will automatically create a virtual environment that you can activate with a pipenv shell.

Using pip

It's highly recommended to use a virtualenvironment to avoid conflict with other packages that are already installed: pip install virtualenv.

  • Create an environment: virtualenv env,
  • Activate the environment: source env/bin/activate (on Windows: source env\Scripts\activate.bat)
  • Install the requirements: pip install -r requirements.txt

Contributing to the scripts

You can verify if the styling of a script complaint with PEP8, with a couple of exceptions:

Install flake8 (pip install flake8) and run it on the script you want to test:

flake8 <file>.py --ignore=E501,E266,W503
  • E501: Line too long (82>79 characters),
  • E266: Too many leading '#' for block comment,
  • W503: Line break occurred before a binary operator)

You can also modify the file with an automatic formatter, like black (pip install black), and execute it:

black -l 100 <file>.py

Using Qt's maximum line length, 100.