summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-05-03 15:02:32 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-05-03 13:42:25 +0000
commit7874ce780130cdecd6188662f03703ff49387ab0 (patch)
tree81fe8f5c09d7c60ae6889c537439dba17064a39c /util
parent9618434de56644fb61a76d4a3eb2176d629023fc (diff)
CMake: Improve mapping of libraries
Merge all data related to mapping libraries into one data structure in helper.py. Use that data for everything related to library mapping. This change enables way more features now like e.g. adding find_package calls into generated files. Change-Id: Ibbd2a1063cbeb65277582d434a6a672d62fc170b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/configurejson2cmake.py125
-rw-r--r--util/cmake/helper.py427
-rwxr-xr-xutil/cmake/pro2cmake.py2
3 files changed, 272 insertions, 282 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index fc6f9845a6..b9ec0f9449 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -33,7 +33,7 @@ import re
import sys
from typing import Set, Union, List, Dict
-from helper import map_qt_library, featureName, substitute_platform, qmake_library_to_cmake_target_mapping
+from helper import map_qt_library, featureName, substitute_platform, find_library_mapping
knownTests = set() # type: Set[str]
@@ -44,70 +44,6 @@ class LibraryMapping:
self.resultVariable = resultVariable
self.appendFoundSuffix = appendFoundSuffix
-
-def map_library(lib: str) -> Union[str, LibraryMapping, List[str]]:
- libmap = {
- 'atspi': 'ATSPI2',
- 'corewlan': None, # Framework
- 'cups': 'Cups',
- 'double-conversion': None,
- 'drm': 'Libdrm',
- 'egl': 'EGL',
- 'fontconfig': LibraryMapping(package='Fontconfig', resultVariable="FONTCONFIG"),
- 'freetype': ['Freetype', 'REQUIRED'],
- 'gbm': 'gbm',
- 'glib': 'GLIB2',
- 'gnu_iconv': None,
- 'gtk3': 'GTK3',
- 'harfbuzz': 'harfbuzz',
- 'host_dbus': None,
- 'icu': ['ICU', 'COMPONENTS', 'i18n', 'uc', 'data'],
- 'journald': 'Libsystemd',
- 'libatomic': 'Atomic',
- 'libdl': None, # handled by CMAKE_DL_LIBS
- 'libinput': 'Libinput',
- 'libjpeg': 'JPEG',
- 'libpng': 'PNG',
- 'libproxy': 'Libproxy',
- 'librt': 'WrapRt',
- 'libudev': 'Libudev',
- 'lttng-ust': LibraryMapping(package='LTTngUST', resultVariable="LTTNGUST"),
- 'mtdev': 'Mtdev',
- 'odbc': 'ODBC',
- 'opengl': LibraryMapping(package="OpenGL", resultVariable="OpenGL_OpenGL"),
- 'openssl': 'OpenSSL',
- 'openssl_headers': LibraryMapping(package="OpenSSL", resultVariable="OPENSSL_INCLUDE_DIR", appendFoundSuffix=False),
- 'pcre2': ['PCRE2', 'REQUIRED'],
- 'posix_iconv': None,
- 'pps': 'PPS',
- 'psql': 'PostgreSQL',
- 'slog2': 'Slog2',
- 'sqlite3': 'SQLite3',
- 'sun_iconv': None,
- 'tslib': 'Tslib',
- 'udev': 'Libudev',
- 'vulkan': 'Vulkan',
- 'wayland_server': 'Wayland',
- 'x11sm': LibraryMapping(package="X11", resultVariable="X11_SM"),
- 'xcb_glx': LibraryMapping(package="XCB", resultVariable="XCB_GLX"),
- 'xcb_render': LibraryMapping(package="XCB", resultVariable="XCB_RENDER"),
- 'xcb': ['XCB', '1.9'],
- 'xcb_xinput': LibraryMapping(package="XCB", resultVariable="XCB_XINPUT"),
- 'xcb_xkb': LibraryMapping(package="XCB", resultVariable="XCB_XKB"),
- 'xcb_xlib': 'X11_XCB',
- 'xkbcommon': ['XKB', '0.4.1'],
- 'xlib': 'X11',
- 'xrender': LibraryMapping(package="XCB", resultVariable="XCB_RENDER"),
- 'zlib': 'ZLIB',
- 'zstd': 'ZSTD',
- 'opengl_es2': 'GLESv2',
- } # type: Dict[str, Union[str, List[str], LibraryMapping]]
- if lib not in libmap:
- raise Exception(' XXXX Unknown library "{}".'.format(lib))
-
- return libmap[lib]
-
-
def map_tests(test: str) -> str:
testmap = {
'c++11': '$<COMPILE_FEATURES:cxx_std_11>',
@@ -229,49 +165,48 @@ def processFiles(ctx, data):
return ctx
def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
- extra = []
- try:
- newlib = map_library(lib)
- if isinstance(newlib, list):
- extra = newlib[1:]
- newlib = newlib[0]
- elif isinstance(newlib, LibraryMapping):
- newlib = newlib.package
- except Exception:
- return ctx
-
- if newlib is None:
+ newlib = find_library_mapping(lib)
+ if not newlib:
+ print(' XXXX Unknown library "{}".'.format(lib))
+ return
+
+ if newlib.packageName is None:
print(' **** Skipping library "{}" -- was masked.'.format(lib))
return
print(' mapped library {} to {}.'.format(lib, newlib))
# Avoid duplicate find_package calls.
- if newlib in cmake_find_packages_set:
+ if newlib.targetName in cmake_find_packages_set:
return
- cmake_find_packages_set.add(newlib)
+ cmake_find_packages_set.add(newlib.targetName)
isRequired = False
+ extra = newlib.extra.copy()
+
if extra:
if "REQUIRED" in extra:
isRequired = True
extra.remove("REQUIRED")
- # If we have a mapping from a qmake library to a CMake target name,
- # encode that in the qt_find_package call().
- cmake_target_name = qmake_library_to_cmake_target_mapping.get(lib, None)
+ cmake_target_name = newlib.targetName
+
+ # _nolink or not does not matter at this point:
+ if cmake_target_name.endswith('_nolink') or cmake_target_name.endswith('/nolink'):
+ cmake_target_name = cmake_target_name[:-7]
+
if cmake_target_name:
extra += ['PROVIDED_TARGETS', cmake_target_name]
if extra:
- cm_fh.write('qt_find_package({} {})\n'.format(newlib, ' '.join(extra)))
+ cm_fh.write('qt_find_package({} {})\n'.format(newlib.packageName, ' '.join(extra)))
else:
- cm_fh.write('qt_find_package({})\n'.format(newlib))
+ cm_fh.write('qt_find_package({})\n'.format(newlib.packageName))
if isRequired:
- cm_fh.write('set_package_properties({} PROPERTIES TYPE REQUIRED)\n'.format(newlib))
+ cm_fh.write('set_package_properties({} PROPERTIES TYPE REQUIRED)\n'.format(newlib.packageName))
def lineify(label, value, quote=True):
if value:
@@ -316,18 +251,14 @@ def map_condition(condition):
substitution = None
appendFoundSuffix = True
if match.group(1) == 'libs':
- try:
- substitution = map_library(match.group(2))
- if isinstance(substitution, list):
- substitution = substitution[0]
- elif isinstance(substitution, LibraryMapping):
- appendFoundSuffix = substitution.appendFoundSuffix
- substitution = substitution.resultVariable
- except Exception:
- substitution = None
-
- if substitution is not None and appendFoundSuffix:
- substitution += '_FOUND'
+ libmapping = find_library_mapping(match.group(2))
+
+ if libmapping and libmapping.packageName:
+ substitution = libmapping.packageName
+ if libmapping.resultVariable:
+ substitution = libmapping.resultVariable
+ if libmapping.appendFoundSuffix:
+ substitution += '_FOUND'
elif match.group(1) == 'features':
feature = match.group(2)
diff --git a/util/cmake/helper.py b/util/cmake/helper.py
index eb30aa02dd..99a518bf0c 100644
--- a/util/cmake/helper.py
+++ b/util/cmake/helper.py
@@ -27,136 +27,241 @@
#############################################################################
import re
+import typing
+class LibraryMapping:
+ def __init__(self, soName: typing.Optional[str],
+ packageName: str, targetName: str, *,
+ resultVariable: typing.Optional[str] = None,
+ extra: typing.List[str] = [],
+ appendFoundSuffix: bool = True) -> None:
+ self.soName = soName
+ self.packageName = packageName
+ self.resultVariable = resultVariable
+ self.appendFoundSuffix = appendFoundSuffix
+ self.extra = extra
+ self.targetName = targetName
-def featureName(input: str) -> str:
- return re.sub(r'[^a-zA-Z0-9_]', '_', input)
+ def is_qt() -> bool:
+ return self.packageName == 'Qt' \
+ or self.packageName == 'Qt5' \
+ or self.packageName == 'Qt6'
+
+_qt_library_map = [
+ # Qt:
+ LibraryMapping('accessibility_support', 'Qt5', 'Qt::AccessibilitySupport', extra = ['COMPONENTS', 'AccessibilitySupport']),
+ LibraryMapping('androidextras', 'Qt5', 'Qt::AndroidExtras', extra = ['COMPONENTS', 'AndroidExtras']),
+ LibraryMapping('animation', 'Qt5', 'Qt::3DAnimation', extra = ['COMPONENTS', '3DAnimation']),
+ LibraryMapping('application-lib', 'Qt5', 'Qt::AppManApplication', extra = ['COMPONENTS', 'AppManApplication']),
+ LibraryMapping('bluetooth', 'Qt5', 'Qt::Bluetooth', extra = ['COMPONENTS', 'Bluetooth']),
+ LibraryMapping('bootstrap', 'Qt5', 'Qt::Bootstrap', extra = ['COMPONENTS', 'Bootstrap']),
+ # bootstrap-dbus: Not needed in Qt6!
+ LibraryMapping('client', 'Qt5', 'Qt::WaylandClient', extra = ['COMPONENTS', 'WaylandClient']),
+ LibraryMapping('clipboard_support', 'Qt5', 'Qt::ClipboardSupport', extra = ['COMPONENTS', 'ClipboardSupport']),
+ LibraryMapping('common-lib', 'Qt5', 'Qt::AppManCommon', extra = ['COMPONENTS', 'AppManCommon']),
+ LibraryMapping('compositor', 'Qt5', 'Qt::WaylandCompositor', extra = ['COMPONENTS', 'WaylandCompositor']),
+ LibraryMapping('concurrent', 'Qt5', 'Qt::Concurrent', extra = ['COMPONENTS', 'Concurrent']),
+ LibraryMapping('container', 'Qt5', 'Qt::AxContainer', extra = ['COMPONENTS', 'AxContainer']),
+ LibraryMapping('control', 'Qt5', 'Qt::AxServer', extra = ['COMPONENTS', 'AxServer']),
+ LibraryMapping('core_headers', 'Qt5', 'Qt::WebEngineCore', extra = ['COMPONENTS', 'WebEngineCore']),
+ LibraryMapping('core', 'Qt5', 'Qt::Core', extra = ['COMPONENTS', 'Core']),
+ LibraryMapping('coretest', 'Qt5', 'Qt::3DCoreTest', extra = ['COMPONENTS', '3DCoreTest']),
+ LibraryMapping('crypto-lib', 'Qt5', 'Qt::AppManCrypto', extra = ['COMPONENTS', 'AppManCrypto']),
+ LibraryMapping('dbus', 'Qt5', 'Qt::Dbus', extra = ['COMPONENTS', 'DBus']),
+ LibraryMapping('devicediscovery', 'Qt5', 'Qt::DeviceDiscoverySupport', extra = ['COMPONENTS', 'DeviceDiscoverySupport']),
+ LibraryMapping('devicediscovery_support', 'Qt5', 'Qt::DeviceDiscoverySupport', extra = ['COMPONENTS', 'DeviceDiscoverySupport']),
+ LibraryMapping('edid', 'Qt5', 'Qt::EdidSupport', extra = ['COMPONENTS', 'EdidSupport']),
+ LibraryMapping('edid_support', 'Qt5', 'Qt::EdidSupport', extra = ['COMPONENTS', 'EdidSupport']),
+ LibraryMapping('eglconvenience', 'Qt5', 'Qt::EglSupport', extra = ['COMPONENTS', 'EglSupport']),
+ LibraryMapping('eglfsdeviceintegration', 'Qt5', 'Qt::EglFSDeviceIntegration', extra = ['COMPONENTS', 'EglFSDeviceIntegration']),
+ LibraryMapping('eglfs_kms_support', 'Qt5', 'Qt::EglFsKmsSupport', extra = ['COMPONENTS', 'EglFsKmsSupport']),
+ LibraryMapping('egl_support', 'Qt5', 'Qt::EglSupport', extra = ['COMPONENTS', 'EglSupport']),
+ # enginio: Not needed in Qt6!
+ LibraryMapping('eventdispatchers', 'Qt5', 'Qt::EventDispatcherSupport', extra = ['COMPONENTS', 'EventDispatcherSupport']),
+ LibraryMapping('eventdispatcher_support', 'Qt5', 'Qt::EventDispatcherSupport', extra = ['COMPONENTS', 'EventDispatcherSupport']),
+ LibraryMapping('extras', 'Qt5', 'Qt::3DExtras', extra = ['COMPONENTS', '3DExtras']),
+ LibraryMapping('fbconvenience', 'Qt5', 'Qt::FbSupport', extra = ['COMPONENTS', 'FbSupport']),
+ LibraryMapping('fb_support', 'Qt5', 'Qt::FbSupport', extra = ['COMPONENTS', 'FbSupport']),
+ LibraryMapping('fontdatabase_support', 'Qt5', 'Qt::FontDatabaseSupport', extra = ['COMPONENTS', 'FontDatabaseSupport']),
+ LibraryMapping('gamepad', 'Qt5', 'Qt::Gamepad', extra = ['COMPONENTS', 'Gamepad']),
+ LibraryMapping('global', 'Qt5', 'Qt::Core', extra = ['COMPONENTS', 'Core']), # manually added special case
+ LibraryMapping('glx_support', 'Qt5', 'Qt::GlxSupport', extra = ['COMPONENTS', 'GlxSupport']),
+ LibraryMapping('graphics_support', 'Qt5', 'Qt::GraphicsSupport', extra = ['COMPONENTS', 'GraphicsSupport']),
+ LibraryMapping('gsttools', 'Qt5', 'Qt::MultimediaGstTools', extra = ['COMPONENTS', 'MultimediaGstTools']),
+ LibraryMapping('gui', 'Qt5', 'Qt::Gui', extra = ['COMPONENTS', 'Gui']),
+ LibraryMapping('help', 'Qt5', 'Qt::Help', extra = ['COMPONENTS', 'Help']),
+ LibraryMapping('hunspellinputmethod', 'Qt5', 'Qt::HunspellInputMethod', extra = ['COMPONENTS', 'HunspellInputMethod']),
+ LibraryMapping('input', 'Qt5', 'Qt::InputSupport', extra = ['COMPONENTS', 'InputSupport']),
+ LibraryMapping('input_support', 'Qt5', 'Qt::InputSupport', extra = ['COMPONENTS', 'InputSupport']),
+ LibraryMapping('installer-lib', 'Qt5', 'Qt::AppManInstaller', extra = ['COMPONENTS', 'AppManInstaller']),
+ LibraryMapping('kmsconvenience', 'Qt5', 'Qt::KmsSupport', extra = ['COMPONENTS', 'KmsSupport']),
+ LibraryMapping('kms_support', 'Qt5', 'Qt::KmsSupport', extra = ['COMPONENTS', 'KmsSupport']),
+ LibraryMapping('launcher-lib', 'Qt5', 'Qt::AppManLauncher', extra = ['COMPONENTS', 'AppManLauncher']),
+ LibraryMapping('lib', 'Qt5', 'Qt::Designer', extra = ['COMPONENTS', 'Designer']),
+ LibraryMapping('linuxaccessibility_support', 'Qt5', 'Qt::LinuxAccessibilitySupport', extra = ['COMPONENTS', 'LinuxAccessibilitySupport']),
+ LibraryMapping('location', 'Qt5', 'Qt::Location', extra = ['COMPONENTS', 'Location']),
+ LibraryMapping('logic', 'Qt5', 'Qt::3DLogic', extra = ['COMPONENTS', '3DLogic']),
+ LibraryMapping('macextras', 'Qt5', 'Qt::MacExtras', extra = ['COMPONENTS', 'MacExtras']),
+ LibraryMapping('main-lib', 'Qt5', 'Qt::AppManMain', extra = ['COMPONENTS', 'AppManMain']),
+ LibraryMapping('manager-lib', 'Qt5', 'Qt::AppManManager', extra = ['COMPONENTS', 'AppManManager']),
+ LibraryMapping('monitor-lib', 'Qt5', 'Qt::AppManMonitor', extra = ['COMPONENTS', 'AppManMonitor']),
+ LibraryMapping('multimedia', 'Qt5', 'Qt::Multimedia', extra = ['COMPONENTS', 'Multimedia']),
+ LibraryMapping('multimediawidgets', 'Qt5', 'Qt::MultimediaWidgets', extra = ['COMPONENTS', 'MultimediaWidgets']),
+ LibraryMapping('network', 'Qt5', 'Qt::Network', extra = ['COMPONENTS', 'Network']),
+ LibraryMapping('nfc', 'Qt5', 'Qt::Nfc', extra = ['COMPONENTS', 'Nfc']),
+ LibraryMapping('oauth', 'Qt5', 'Qt::NetworkAuth', extra = ['COMPONENTS', 'NetworkAuth']),
+ LibraryMapping('openglextensions', 'Qt5', 'Qt::OpenGLExtensions', extra = ['COMPONENTS', 'OpenGLExtensions']),
+ LibraryMapping('opengl', 'Qt5', 'Qt::OpenGL', extra = ['COMPONENTS', 'OpenGL']),
+ LibraryMapping('package-lib', 'Qt5', 'Qt::AppManPackage', extra = ['COMPONENTS', 'AppManPackage']),
+ LibraryMapping('packetprotocol', 'Qt5', 'Qt::PacketProtocol', extra = ['COMPONENTS', 'PacketProtocol']),
+ LibraryMapping('particles', 'Qt5', 'Qt::QuickParticles', extra = ['COMPONENTS', 'QuickParticles']),
+ LibraryMapping('platformcompositor', 'Qt5', 'Qt::PlatformCompositorSupport', extra = ['COMPONENTS', 'PlatformCompositorSupport']),
+ LibraryMapping('platformcompositor_support', 'Qt5', 'Qt::PlatformCompositorSupport', extra = ['COMPONENTS', 'PlatformCompositorSupport']),
+ LibraryMapping('plugin-interfaces', 'Qt5', 'Qt::AppManPluginInterfaces', extra = ['COMPONENTS', 'AppManPluginInterfaces']),
+ LibraryMapping('positioning', 'Qt5', 'Qt::Positioning', extra = ['COMPONENTS', 'Positioning']),
+ LibraryMapping('positioningquick', 'Qt5', 'Qt::PositioningQuick', extra = ['COMPONENTS', 'PositioningQuick']),
+ LibraryMapping('printsupport', 'Qt5', 'Qt::PrintSupport', extra = ['COMPONENTS', 'PrintSupport']),
+ LibraryMapping('purchasing', 'Qt5', 'Qt::Purchasing', extra = ['COMPONENTS', 'Purchasing']),
+ LibraryMapping('qmldebug', 'Qt5', 'Qt::QmlDebug', extra = ['COMPONENTS', 'QmlDebug']),
+ LibraryMapping('qmldevtools', 'Qt5', 'Qt::QmlDevTools', extra = ['COMPONENTS', 'QmlDevTools']),
+ LibraryMapping('qml', 'Qt5', 'Qt::Qml', extra = ['COMPONENTS', 'Qml']),
+ LibraryMapping('qmltest', 'Qt5', 'Qt::QuickTest', extra = ['COMPONENTS', 'QuickTest']),
+ LibraryMapping('qtmultimediaquicktools', 'Qt5', 'Qt::MultimediaQuick', extra = ['COMPONENTS', 'MultimediaQuick']),
+ LibraryMapping('quick3danimation', 'Qt5', 'Qt::3DQuickAnimation', extra = ['COMPONENTS', '3DQuickAnimation']),
+ LibraryMapping('quick3dextras', 'Qt5', 'Qt::3DQuickExtras', extra = ['COMPONENTS', '3DQuickExtras']),
+ LibraryMapping('quick3dinput', 'Qt5', 'Qt::3DQuickInput', extra = ['COMPONENTS', '3DQuickInput']),
+ LibraryMapping('quick3d', 'Qt5', 'Qt::3DQuick', extra = ['COMPONENTS', '3DQuick']),
+ LibraryMapping('quick3drender', 'Qt5', 'Qt::3DQuickRender', extra = ['COMPONENTS', '3DQuickRender']),
+ LibraryMapping('quick3dscene2d', 'Qt5', 'Qt::3DQuickScene2D', extra = ['COMPONENTS', '3DQuickScene2D']),
+ LibraryMapping('quickcontrols2', 'Qt5', 'Qt::QuickControls2', extra = ['COMPONENTS', 'QuickControls2']),
+ LibraryMapping('quick', 'Qt5', 'Qt::Quick', extra = ['COMPONENTS', 'Quick']),
+ LibraryMapping('quickshapes', 'Qt5', 'Qt::QuickShapes', extra = ['COMPONENTS', 'QuickShapes']),
+ LibraryMapping('quicktemplates2', 'Qt5', 'Qt::QuickTemplates2', extra = ['COMPONENTS', 'QuickTemplates2']),
+ LibraryMapping('quickwidgets', 'Qt5', 'Qt::QuickWidgets', extra = ['COMPONENTS', 'QuickWidgets']),
+ LibraryMapping('render', 'Qt5', 'Qt::3DRender', extra = ['COMPONENTS', '3DRender']),
+ LibraryMapping('script', 'Qt5', 'Qt::Script', extra = ['COMPONENTS', 'Script']),
+ LibraryMapping('scripttools', 'Qt5', 'Qt::ScriptTools', extra = ['COMPONENTS', 'ScriptTools']),
+ LibraryMapping('sensors', 'Qt5', 'Qt::Sensors', extra = ['COMPONENTS', 'Sensors']),
+ LibraryMapping('serialport', 'Qt5', 'Qt::SerialPort', extra = ['COMPONENTS', 'SerialPort']),
+ LibraryMapping('services', 'Qt5', 'Qt::ServiceSupport', extra = ['COMPONENTS', 'ServiceSupport']),
+ LibraryMapping('service_support', 'Qt5', 'Qt::ServiceSupport', extra = ['COMPONENTS', 'ServiceSupport']),
+ LibraryMapping('sql', 'Qt5', 'Qt::Sql', extra = ['COMPONENTS', 'Sql']),
+ LibraryMapping('svg', 'Qt5', 'Qt::Svg', extra = ['COMPONENTS', 'Svg']),
+ LibraryMapping('testlib', 'Qt5', 'Qt::Test', extra = ['COMPONENTS', 'Test']),
+ LibraryMapping('theme_support', 'Qt5', 'Qt::ThemeSupport', extra = ['COMPONENTS', 'ThemeSupport']),
+ LibraryMapping('tts', 'Qt5', 'Qt::TextToSpeech', extra = ['COMPONENTS', 'TextToSpeech']),
+ LibraryMapping('uiplugin', 'Qt5', 'Qt::UiPlugin', extra = ['COMPONENTS', 'UiPlugin']),
+ LibraryMapping('uitools', 'Qt5', 'Qt::UiTools', extra = ['COMPONENTS', 'UiTools']),
+ LibraryMapping('virtualkeyboard', 'Qt5', 'Qt::VirtualKeyboard', extra = ['COMPONENTS', 'VirtualKeyboard']),
+ LibraryMapping('vulkan_support', 'Qt5', 'Qt::VulkanSupport', extra = ['COMPONENTS', 'VulkanSupport']),
+ LibraryMapping('webchannel', 'Qt5', 'Qt::WebChannel', extra = ['COMPONENTS', 'WebChannel']),
+ LibraryMapping('webengine', 'Qt5', 'Qt::WebEngine', extra = ['COMPONENTS', 'WebEngine']),
+ LibraryMapping('webenginewidgets', 'Qt5', 'Qt::WebEngineWidgets', extra = ['COMPONENTS', 'WebEngineWidgets']),
+ LibraryMapping('websockets', 'Qt5', 'Qt::WebSockets', extra = ['COMPONENTS', 'WebSockets']),
+ LibraryMapping('webview', 'Qt5', 'Qt::WebView', extra = ['COMPONENTS', 'WebView']),
+ LibraryMapping('widgets', 'Qt5', 'Qt::Widgets', extra = ['COMPONENTS', 'Widgets']),
+ LibraryMapping('window-lib', 'Qt5', 'Qt::AppManWindow', extra = ['COMPONENTS', 'AppManWindow']),
+ LibraryMapping('windowsuiautomation_support', 'Qt5', 'Qt::WindowsUIAutomationSupport', extra = ['COMPONENTS', 'WindowsUIAutomationSupport']),
+ LibraryMapping('winextras', 'Qt5', 'Qt::WinExtras', extra = ['COMPONENTS', 'WinExtras']),
+ LibraryMapping('x11extras', 'Qt5', 'Qt::X11Extras', extra = ['COMPONENTS', 'X11Extras']),
+ LibraryMapping('xkbcommon_support', 'Qt5', 'Qt::XkbCommonSupport', extra = ['COMPONENTS', 'XkbCommonSupport']),
+ LibraryMapping('xmlpatterns', 'Qt5', 'Qt::XmlPatterns', extra = ['COMPONENTS', 'XmlPatterns']),
+ LibraryMapping('xml', 'Qt5', 'Qt::Xml', extra = ['COMPONENTS', 'Xml']),
+ # qtzlib: No longer supported.
+]
+
+_library_map = [
+ # 3rd party:
+ LibraryMapping('atspi', 'ATSPI2', 'PkgConfig::ATSPI2'),
+ LibraryMapping('corewlan', None, None),
+ LibraryMapping('cups', 'Cups', 'Cups::Cups'),
+ LibraryMapping('dbus', 'DBus1', 'dbus-1'),
+ LibraryMapping('doubleconversion', None, None),
+ LibraryMapping('drm', 'Libdrm', 'Libdrm::Libdrm'),
+ LibraryMapping('egl', 'EGL', 'EGL::EGL'),
+ LibraryMapping('fontconfig', 'Fontconfig', 'Fontconfig::Fontconfig', resultVariable="FONTCONFIG"),
+ LibraryMapping('freetype', 'Freetype', 'Freetype::Freetype', extra=['REQUIRED']),
+ LibraryMapping('gbm', 'gbm', 'gbm::gbm'),
+ LibraryMapping('glib', 'GLIB2', 'GLIB2::GLIB2'),
+ LibraryMapping('gnu_iconv', None, None),
+ LibraryMapping('gtk3', 'GTK3', 'PkgConfig::GTK3'),
+ LibraryMapping('harfbuzz', 'harfbuzz', 'harfbuzz::harfbuzz'),
+ LibraryMapping('host_dbus', None, None),
+ LibraryMapping('icu', 'ICU', 'ICU::i18n ICU::uc ICU::data', extra=['COMPONENTS', 'i18n', 'uc', 'data']),
+ LibraryMapping('journald', 'Libsystemd', 'PkgConfig::Libsystemd'),
+ LibraryMapping('libatomic', 'Atomic', 'Atomic'),
+ LibraryMapping('libdl', None, None),
+ LibraryMapping('libinput', 'Libinput', 'Libinput::Libinput'),
+ LibraryMapping('libjpeg', 'JPEG', 'JPEG::JPEG'),
+ LibraryMapping('libpng', 'PNG', 'PNG::PNG'),
+ LibraryMapping('libproxy', 'Libproxy', 'PkgConfig::Libproxy'),
+ LibraryMapping('librt', 'WrapRt','WrapRt'),
+ LibraryMapping('libudev', 'Libudev', 'PkgConfig::Libudev'),
+ LibraryMapping('lttng-ust', 'LTTngUST', 'LTTng::UST', resultVariable='LTTNGUST'),
+ LibraryMapping('mtdev', 'Mtdev', 'PkgConfig::Mtdev'),
+ LibraryMapping('odbc', 'ODBC', 'ODBC::ODBC'),
+ LibraryMapping('opengl_es2', 'GLESv2', 'GLESv2::GLESv2'),
+ LibraryMapping('opengl', 'OpenGL', 'OpenGL::GL', resultVariable='OpenGL_OpenGL'),
+ LibraryMapping('openssl_headers', 'OpenSSL', 'OpenSSL::SSL_nolink', resultVariable='OPENSSL_INCLUDE_DIR', appendFoundSuffix=False),
+ LibraryMapping('openssl', 'OpenSSL', 'OpenSSL::SSL'),
+ LibraryMapping('pcre2', 'PCRE2', 'PCRE2', extra = ['REQUIRED']),
+ LibraryMapping('posix_iconv', None, None),
+ LibraryMapping('pps', 'PPS', 'PPS::PPS'),
+ LibraryMapping('psql', 'PostgreSQL', 'PostgreSQL::PostgreSQL'),
+ LibraryMapping('slog2', 'Slog2', 'Slog2::Slog2'),
+ LibraryMapping('sqlite2', None, None), # No more sqlite2 support in Qt6!
+ LibraryMapping('sqlite3', 'SQLite3', 'SQLite::SQLite3'),
+ LibraryMapping('sun_iconv', None, None),
+ LibraryMapping('tslib', 'Tslib', 'PkgConfig::Tslib'),
+ LibraryMapping('udev', 'Libudev', 'PkgConfig::Libudev'),
+ LibraryMapping('udev', 'Libudev', 'PkgConfig::Libudev'), # see also libudev!
+ LibraryMapping('vulkan', 'Vulkan', 'Vulkan::Vulkan'),
+ LibraryMapping('wayland_server', 'Wayland', 'Wayland::Server'),
+ LibraryMapping('x11sm', 'X11', '${X11_SM_LIB} ${X11_ICE_LIB}', resultVariable="X11_SM"),
+ LibraryMapping('xcb_glx', 'XCB', 'XCB::GLX', resultVariable='XCB_GLX'),
+ LibraryMapping('xcb_render', 'XCB', 'XCB::RENDER', resultVariable='XCB_RENDER'),
+ LibraryMapping('xcb', 'XCB', 'XCB::XCB', extra = ['1.9']),
+ LibraryMapping('xcb_glx', 'XCB', 'XCB::GLX', extra = ['COMPONENTS', 'GLX'], resultVariable='XCB_GLX'),
+ LibraryMapping('xcb_icccm', 'XCB', 'XCB::ICCCM', extra = ['COMPONENTS', 'ICCCM'], resultVariable='XCB_ICCCM'),
+ LibraryMapping('xcb_image', 'XCB', 'XCB::IMAGE', extra = ['COMPONENTS', 'IMAGE'], resultVariable='XCB_IMAGE'),
+ LibraryMapping('xcb_keysyms', 'XCB', 'XCB::KEYSYMS', extra = ['COMPONENTS', 'KEYSYMS'], resultVariable='XCB_KEYSYMS'),
+ LibraryMapping('xcb_randr', 'XCB', 'XCB::RANDR', extra = ['COMPONENTS', 'RANDR'], resultVariable='XCB_RANDR'),
+ LibraryMapping('xcb_render', 'XCB', 'XCB::RENDER', extra = ['COMPONENTS', 'RENDER'], resultVariable='XCB_RENDER'),
+ LibraryMapping('xcb_renderutil', 'XCB', 'XCB::RENDERUTIL', extra = ['COMPONENTS', 'RENDERUTIL'], resultVariable='XCB_RENDERUTIL'),
+ LibraryMapping('xcb_shape', 'XCB', 'XCB::SHAPE', extra = ['COMPONENTS', 'SHAPE'], resultVariable='XCB_SHAPE'),
+ LibraryMapping('xcb_shm', 'XCB', 'XCB::SHM', extra = ['COMPONENTS', 'SHM'], resultVariable='XCB_SHM'),
+ LibraryMapping('xcb_sync', 'XCB', 'XCB::SYNC', extra = ['COMPONENTS', 'SYNC'], resultVariable='XCB_SYNC'),
+ LibraryMapping('xcb_xfixes', 'XCB', 'XCB::XFIXES', extra = ['COMPONENTS', 'XFIXES'], resultVariable='XCB_XFIXES'),
+ LibraryMapping('xcb_xinerama', 'XCB', 'XCB::XINERAMA', extra = ['COMPONENTS', 'XINERAMA'], resultVariable='XCB_XINERAMA'),
+ LibraryMapping('xcb_xinput', 'XCB', 'XCB::XINPUT', extra = ['COMPONENTS', 'XINPUT'], resultVariable='XCB_XINPUT'),
+ LibraryMapping('xcb_xkb', 'XCB', 'XCB::XKB', extra = ['COMPONENTS', 'XKB'], resultVariable='XCB_XKB'),
+ LibraryMapping('xcb_xlib', 'X11_XCB', 'X11::XCB'),
+ LibraryMapping('xkbcommon_evdev', 'XKB', 'XKB::XKB', extra = ['0.4.1']), # see also xkbcommon
+ LibraryMapping('xkbcommon_x11', 'XKB', 'XKB::XKB', extra = ['0.4.1']), # see also xkbcommon
+ LibraryMapping('xkbcommon', 'XKB', 'XKB::XKB', extra = ['0.4.1']),
+ LibraryMapping('xlib', 'X11', 'X11::XCB'), # FIXME: Is this correct?
+ LibraryMapping('xrender', 'XRender', 'PkgConfig::xrender'),
+ LibraryMapping('zlib', 'ZLIB', 'ZLIB::ZLIB'),
+ LibraryMapping('zstd', 'ZSTD', 'ZSTD::ZSTD'),
+]
-def map_qt_base_library(lib: str) -> str:
- library_map = {
- 'global': 'Qt::Core', # manually added special case
- 'accessibility_support': 'Qt::AccessibilitySupport',
- 'androidextras': 'Qt::AndroidExtras',
- 'animation': 'Qt::3DAnimation',
- 'application-lib': 'Qt::AppManApplication',
- 'bluetooth': 'Qt::Bluetooth',
- 'bootstrap-dbus': 'Qt::BootstrapDBus',
- 'bootstrap': 'Qt::Bootstrap',
- 'client': 'Qt::WaylandClient',
- 'clipboard_support': 'Qt::ClipboardSupport',
- 'common-lib': 'Qt::AppManCommon',
- 'compositor': 'Qt::WaylandCompositor',
- 'concurrent': 'Qt::Concurrent',
- 'container': 'Qt::AxContainer',
- 'control': 'Qt::AxServer',
- 'core_headers': 'Qt::WebEngineCore',
- 'core': 'Qt::Core',
- 'coretest': 'Qt::3DCoreTest',
- 'crypto-lib': 'Qt::AppManCrypto',
- 'dbus': 'Qt::DBus',
- 'devicediscovery': 'Qt::DeviceDiscoverySupport',
- 'devicediscovery_support': 'Qt::DeviceDiscoverySupport',
- 'edid': 'Qt::EdidSupport',
- 'eglconvenience': 'Qt::EglSupport',
- 'eglfsdeviceintegration': 'Qt::EglFSDeviceIntegration',
- 'eglfs_kms_support': 'Qt::EglFsKmsSupport',
- 'egl_support': 'Qt::EglSupport',
- 'enginio_client': 'Enginio',
- 'eventdispatchers': 'Qt::EventDispatcherSupport',
- 'extras': 'Qt::3DExtras',
- 'fb_support': 'Qt::FbSupport',
- 'fbconvenience': 'Qt::FbSupport',
- 'fontdatabase_support': 'Qt::FontDatabaseSupport',
- 'gamepad': 'Qt::Gamepad',
- 'glx_support': 'Qt::GlxSupport',
- 'graphics_support': 'Qt::GraphicsSupport',
- 'gsttools': 'Qt::MultimediaGstTools',
- 'gui': 'Qt::Gui',
- 'help': 'Qt::Help',
- 'hunspellinputmethod': 'Qt::HunspellInputMethod',
- 'input': 'Qt::InputSupport',
- 'input_support': 'Qt::InputSupport',
- 'installer-lib': 'Qt::AppManInstaller',
- 'kmsconvenience': 'Qt::KmsSupport',
- 'kms_support': 'Qt::KmsSupport',
- 'launcher-lib': 'Qt::AppManLauncher',
- 'lib': 'Qt::Designer',
- 'linuxaccessibility_support': 'Qt::LinuxAccessibilitySupport',
- 'location': 'Qt::Location',
- 'logic': 'Qt::3DLogic',
- 'macextras': 'Qt::MacExtras',
- 'main-lib': 'Qt::AppManMain',
- 'manager-lib': 'Qt::AppManManager',
- 'monitor-lib': 'Qt::AppManMonitor',
- 'multimedia': 'Qt::Multimedia',
- 'multimediawidgets': 'Qt::MultimediaWidgets',
- 'network': 'Qt::Network',
- 'nfc': 'Qt::Nfc',
- 'oauth': 'Qt::NetworkAuth',
- 'openglextensions': 'Qt::OpenGLExtensions',
- 'opengl': 'Qt::OpenGL',
- 'package-lib': 'Qt::AppManPackage',
- 'packetprotocol': 'Qt::PacketProtocol',
- 'particles': 'Qt::QuickParticles',
- 'platformcompositor': 'Qt::PlatformCompositorSupport',
- 'platformcompositor_support': 'Qt::PlatformCompositorSupport',
- 'plugin-interfaces': 'Qt::AppManPluginInterfaces',
- 'positioning': 'Qt::Positioning',
- 'positioningquick': 'Qt::PositioningQuick',
- 'printsupport': 'Qt::PrintSupport',
- 'purchasing': 'Qt::Purchasing',
- 'qmldebug': 'Qt::QmlDebug',
- 'qmldevtools': 'Qt::QmlDevTools',
- 'qml': 'Qt::Qml',
- 'qmltest': 'Qt::QuickTest',
- 'qtmultimediaquicktools': 'Qt::MultimediaQuick',
- 'qtzlib': 'Qt::Zlib',
- 'quick3danimation': 'Qt::3DQuickAnimation',
- 'quick3dextras': 'Qt::3DQuickExtras',
- 'quick3dinput': 'Qt::3DQuickInput',
- 'quick3d': 'Qt::3DQuick',
- 'quick3drender': 'Qt::3DQuickRender',
- 'quick3dscene2d': 'Qt::3DQuickScene2D',
- 'quickcontrols2': 'Qt::QuickControls2',
- 'quick': 'Qt::Quick',
- 'quickshapes': 'Qt::QuickShapes',
- 'quicktemplates2': 'Qt::QuickTemplates2',
- 'quickwidgets': 'Qt::QuickWidgets',
- 'render': 'Qt::3DRender',
- 'script': 'Qt::Script',
- 'scripttools': 'Qt::ScriptTools',
- 'sensors': 'Qt::Sensors',
- 'serialport': 'Qt::SerialPort',
- 'services': 'Qt::ServiceSupport',
- 'sql': 'Qt::Sql',
- 'svg': 'Qt::Svg',
- 'testlib': 'Qt::Test',
- 'theme_support': 'Qt::ThemeSupport',
- 'service_support': 'Qt::ServiceSupport',
- 'eventdispatcher_support': 'Qt::EventDispatcherSupport',
- 'edid_support': 'Qt::EdidSupport',
- 'tts': 'Qt::TextToSpeech',
- 'uiplugin': 'Qt::UiPlugin',
- 'uitools': 'Qt::UiTools',
- 'virtualkeyboard': 'Qt::VirtualKeyboard',
- 'vulkan_support': 'Qt::VulkanSupport',
- 'webchannel': 'Qt::WebChannel',
- 'webengine': 'Qt::WebEngine',
- 'webenginewidgets': 'Qt::WebEngineWidgets',
- 'websockets': 'Qt::WebSockets',
- 'webview': 'Qt::WebView',
- 'widgets': 'Qt::Widgets',
- 'window-lib': 'Qt::AppManWindow',
- 'windowsuiautomation_support': 'Qt::WindowsUIAutomationSupport',
- 'winextras': 'Qt::WinExtras',
- 'x11extras': 'Qt::X11Extras',
- 'xcb_qpa_lib': 'Qt::XcbQpa',
- 'xkbcommon_support': 'Qt::XkbCommonSupport',
- 'xmlpatterns': 'Qt::XmlPatterns',
- 'xml': 'Qt::Xml',
- }
- return library_map.get(lib, lib)
+def find_library_mapping(soName: str) -> typing.Optional[LibraryMapping]:
+ for i in _library_map:
+ if i.soName == soName:
+ return i
+ return None
+
+
+def find_qt_library_mapping(soName: str) -> typing.Optional[LibraryMapping]:
+ for i in _qt_library_map:
+ if i.soName == soName:
+ return i
+ return None
+
+
+def featureName(input: str) -> str:
+ return re.sub(r'[^a-zA-Z0-9_]', '_', input)
def map_qt_library(lib: str) -> str:
@@ -164,10 +269,13 @@ def map_qt_library(lib: str) -> str:
if lib.endswith('-private'):
private = True
lib = lib[:-8]
- mapped = map_qt_base_library(lib)
+ mapped = find_qt_library_mapping(lib)
+ qt_name = lib
+ if mapped:
+ qt_name = mapped.targetName
if private:
- mapped += 'Private'
- return mapped
+ qt_name += 'Private'
+ return qt_name
platform_mapping = {
@@ -211,63 +319,14 @@ def substitute_platform(platform: str) -> str:
return platform_mapping.get(platform, platform)
-qmake_library_to_cmake_target_mapping = {
- 'atspi': 'PkgConfig::ATSPI2',
- 'cups': 'Cups::Cups',
- 'drm': 'Libdrm::Libdrm',
- 'doubleconversion': 'double-conversion',
- 'fontconfig': 'Fontconfig::Fontconfig',
- 'freetype': 'Freetype::Freetype',
- 'gbm': 'gbm::gbm',
- 'glib': 'GLIB2::GLIB2',
- 'glx_support': 'Qt::GlxSupport',
- 'glx_supportPrivate': 'Qt::GlxSupportPrivate',
- 'harfbuzz': 'harfbuzz::harfbuzz',
- 'icu': 'ICU::i18n ICU::uc ICU::data',
- 'libatomic': 'Atomic',
- 'libdl': '${CMAKE_DL_LIBS}',
- 'libinput': 'Libinput::Libinput',
- 'libpng' : 'PNG::PNG',
- 'libproxy': 'PkgConfig::Libproxy',
- 'librt': 'WrapRt',
- 'libudev': 'PkgConfig::Libudev',
- 'mtdev': 'PkgConfig::Mtdev',
- 'odbc': 'ODBC::ODBC',
- 'openssl': 'OpenSSL::SSL',
- 'pcre2': 'PCRE2',
- 'psql': 'PostgreSQL::PostgreSQL',
- 'sqlite': 'SQLite::SQLite3',
- 'SQLite3': 'SQLite::SQLite3',
- 'tslib': 'PkgConfig::Tslib',
- 'x11sm': '${X11_SM_LIB} ${X11_ICE_LIB}',
- 'xcb_glx': 'XCB::GLX',
- 'xcb_icccm': 'XCB::ICCCM',
- 'xcb_image': 'XCB::IMAGE',
- 'xcb_keysyms': 'XCB::KEYSYMS',
- 'xcb_randr': 'XCB::RANDR',
- 'xcb_renderutil': 'XCB::RENDERUTIL',
- 'xcb_render': 'XCB::RENDER',
- 'xcb_shape': 'XCB::SHAPE',
- 'xcb_shm': 'XCB::SHM',
- 'xcb_sync': 'XCB::SYNC',
- 'xcb': 'XCB::XCB',
- 'xcb_xfixes': 'XCB::XFIXES',
- 'xcb_xinerama': 'XCB::XINERAMA',
- 'xcb_xinput': 'XCB::XINPUT',
- 'xcb_xkb': 'XCB::XKB',
- 'xcb_xlib': 'X11::XCB',
- 'xkbcommon_evdev': 'XKB::XKB',
- 'xkbcommon_x11': 'XKB::XKB',
- 'xkbcommon': 'XKB::XKB',
- 'xrender': 'XCB::RENDER',
- 'zlib': 'ZLIB::ZLIB',
- 'zstd': 'ZSTD::ZSTD',
-}
-
-
def substitute_libs(lib: str) -> str:
libpostfix = ''
if lib.endswith('/nolink'):
lib = lib[:-7]
libpostfix = '_nolink'
- return qmake_library_to_cmake_target_mapping.get(lib, lib) + libpostfix
+ mapping = find_qt_library_mapping(lib)
+ if not mapping:
+ mapping = find_library_mapping(lib)
+ if not mapping:
+ return lib + libpostfix
+ return mapping.targetName + libpostfix
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 7801c4d103..493517dbc7 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -42,7 +42,7 @@ import typing
from sympy.logic import (simplify_logic, And, Or, Not,)
import pyparsing as pp
-from helper import map_qt_library, map_qt_base_library, featureName, \
+from helper import map_qt_library, featureName, \
substitute_platform, substitute_libs