qmake Integration

Qt IVI Generator is fully integrated in qmake to generate all or part of a project.

In it's simplest form, qmake can generate all the source code and the project only needs to configure the type of project to build.

For complex setups, you can combine generated code with application specific code to extend and use the generated code.

Example:

CONFIG += ivigenerator

QT_FOR_CONFIG += ivicore
!qtConfig(ivigenerator): error("No ivigenerator available")

QFACE_FORMAT = frontend
QFACE_SOURCES = example.qface
QFACE_MODULE_NAME = myModule
QFACE_OUTPUT_DIR = myOutputDir
QFACE_ANNOTATIONS = annotation.yaml

The following qmake variables are available:

QFACE_FORMATfrontend (default), simulator_backend
QFACE_SOURCESA single .qface input file.
QFACE_MODULE_NAMEOptional. The name of the module that is using the generated code.
QFACE_OUTPUT_DIRThe output folder where the generated code is placed. The default location is the current build folder.
QFACE_ANNOTATIONSA list of additional annotation files in YAML format. For more information, see the Annotations Option.
QFACE_IMPORT_PATHA list of import paths, which are considered when an IDL file uses an import statement. For more information, see the Import Option.

For more details on the generator's command line arguments, see Use the Generator.

Note: Since the ivigenerator has specific system dependencies, it may not be available in all QtIviCore installation. In this case, the ivigenerator qmake feature is also not available and this can result in build errors.

In this case, use the following code snippet that makes sure the build stops and provides a meaningful error message:

QT_FOR_CONFIG += ivicore
!qtConfig(ivigenerator): error("No ivigenerator available")

QtModule Support

The qmake integration also supports generating code that you can subsequently compile into a Qt module. Since this module needs to work more closely with Qt's module building system, it shouldn't be loaded using the CONFIG variable, but using the load() function instead. The ivigenerator_qt_module feature replaces the load(qt_module) call.

The following shows how you can integrate the QtIviVehicleFunctions module:

TARGET = QtIviVehicleFunctions
QT = core core-private ivicore ivicore-private
CONFIG += c++11 ivigenerator

QT_FOR_CONFIG += ivicore
!qtConfig(ivigenerator): error("No ivigenerator available")

...

QFACE_MODULE_NAME = QtIviVehicleFunctions
QFACE_SOURCES += ivivehiclefunctions.qface

load(ivigenerator_qt_module)

In addition to the project file for the module library, the sync.profile also needs to be changed, as it's used to call the syncqt.pl script that generates the forwarding headers. Usually, the sync.profile is setup to search for these headers in the source folders. Using $out_basedir, you can also extend the script to search in the build folder.

...
%modules = ( # path to module name map
    "QtIviVehicleFunctions" => "$basedir/src/ivivehiclefunctions;$out_basedir/src/ivivehiclefunctions"
);
...

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.