cmake_minimum_required(VERSION 3.16) project(untitled LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core QmlDomPrivate) file(WRITE ${CMAKE_BINARY_DIR}/main.cpp "#include #include int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QQmlJS::Dom::DomItem items; return app.exec(); } ") add_executable(untitled ${CMAKE_BINARY_DIR}/main.cpp ) target_link_libraries(untitled Qt6::QmlDomPrivate)