[Interest] qmake to cmake - error: redefinition of 'unit' const QQmlPrivate::CachedQmlUnit unit

Nuno Santos nuno.santos at imaginando.pt
Wed Dec 14 20:11:10 CET 2022


Hi,

I’m trying to start porting my .pro/.pri files to cmake and I’m stumbling on the following error:

error: redefinition of ‘unit' const QQmlPrivate::CachedQmlUnit unit

The file shared_qmlcache_loader.cpp has a the following content:

namespace QmlCacheGeneratedCode {
namespace _shared_resources_qml_Browser_qml { 
    extern const unsigned char qmlData[];
    extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[];
    const QQmlPrivate::CachedQmlUnit unit = {
        reinterpret_cast<const QV4::CompiledData::Unit*>(&qmlData), &aotBuiltFunctions[0], nullptr
    };
}
namespace _shared_resources_qml_BrowserBank_qml { 
    extern const unsigned char qmlData[];
    extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[];
    const QQmlPrivate::CachedQmlUnit unit = {
        reinterpret_cast<const QV4::CompiledData::Unit*>(&qmlData), &aotBuiltFunctions[0], nullptr
    };
}

unit is always being used as a variable for each qml component.

In my CMakeLists.txt I have the following include:

include(qml.cmake)

list(APPEND QML_FILES
    resources/qml/Browser.qml
    resources/qml/BrowserBank.qml
    resources/qml/BrowserButton.qml
    …


qt_add_qml_module(shared
    URI shared
    VERSION 1.0
    QML_FILES ${QML_FILES}
    SOURCES ${SOURCE_FILES}
)

Not specifying qml source, it compiles correctly.






More information about the Interest mailing list