Commit 276367e5 authored by Volker Krause's avatar Volker Krause

Use the Qt Quick compiler rather than qmllint, if available

parent 2a151086
......@@ -20,11 +20,11 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX ITINERARY VERSION_HEADER itinerary_ver
# build-time dependencies
find_package(Qt5 REQUIRED COMPONENTS Test Quick)
find_package(Qt5 OPTIONAL_COMPONENTS QuickCompiler)
find_package(KF5 REQUIRED COMPONENTS I18n)
find_package(KF5Contacts CONFIG REQUIRED)
find_package(KPimPkPass CONFIG REQUIRED)
find_package(KPimItinerary CONFIG REQUIRED)
find_package(QmlLint)
set_package_properties(QmlLint PROPERTIES URL "https://qt.io" PURPOSE "Validate QML code.")
find_package(SharedMimeInfo 1.0 REQUIRED)
find_package(ZLIB REQUIRED)
......
# Copyright (C) 2016-2018 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# All rights reserved.
#
# Author: Volker Krause <volker.krause@kdab.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
find_program(QMLLINT_EXECUTABLE qmllint)
if (QMLLINT_EXECUTABLE AND NOT Qt5Core_VERSION VERSION_LESS 5.4)
if(NOT QMLLINT_IS_WORKING)
# Try to fix common problems on Debian-based distros -- they provide /usr/bin/qmllint, which is a symlink to
# /usr/lib/x86_64-linux-gnu/qt4/bin/qmllint (or the Qt5 version of it). The actual executable is part of different
# package, so might not even be installed => double-check whether qmllint is working by executing it
execute_process(COMMAND ${QMLLINT_EXECUTABLE} --version RESULT_VARIABLE _qmllint_result OUTPUT_QUIET ERROR_QUIET)
if (_qmllint_result EQUAL 0)
set(QMLLINT_IS_WORKING TRUE CACHE BOOL "Whether the found qmllint executable is actually usable" FORCE)
endif()
endif()
if(QMLLINT_IS_WORKING)
set(QmlLint_FOUND TRUE)
endif()
endif()
# validate a list of qml files
function(qml_lint)
if (NOT QMLLINT_EXECUTABLE OR NOT QmlLint_FOUND)
return()
endif()
foreach(_file ${ARGN})
get_filename_component(_file_abs ${_file} ABSOLUTE)
string(REPLACE "/" "__" _target_name ${_file})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target_name}.qmllint
COMMAND ${QMLLINT_EXECUTABLE} ${_file_abs}
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${_target_name}.qmllint
MAIN_DEPENDENCY ${_file_abs}
)
add_custom_target(${_target_name}_qmllint ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_target_name}.qmllint)
endforeach()
endfunction()
......@@ -18,6 +18,12 @@ target_link_libraries(itinerary PUBLIC
Qt5::Network
)
if (Qt5QuickCompiler_FOUND)
qtquick_compiler_add_resources(qml_srcs qml.qrc)
else ()
set(qml_srcs qml.qrc)
endif()
add_executable(itinerary-app
main.cpp
applicationcontroller.cpp
......@@ -25,7 +31,7 @@ add_executable(itinerary-app
localizer.cpp
pkpassimageprovider.cpp
settings.cpp
qml.qrc
${qml_srcs}
)
target_include_directories(itinerary-app PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(itinerary-app PRIVATE
......@@ -86,34 +92,6 @@ else ()
set_target_properties(itinerary-app PROPERTIES OUTPUT_NAME "itinerary")
endif()
qml_lint(
main.qml
BoardingPass.qml
BusDelegate.qml
BusPage.qml
CountryInfoDelegate.qml
DetailsPage.qml
FlightDelegate.qml
FlightPage.qml
HotelDelegate.qml
HotelPage.qml
ImportDialog.qml
PkPassPage.qml
PlaceDelegate.qml
RestaurantDelegate.qml
RestaurantPage.qml
SettingsPage.qml
TicketTokenDelegate.qml
TimelineDelegate.qml
TimelinePage.qml
TouristAttractionDelegate.qml
TrainDelegate.qml
TrainPage.qml
WeatherForecastDelegate.qml
+android/ImportDialog.qml
)
install(TARGETS itinerary-app ${INSTALL_TARGETS_DEFAULT_ARGS})
if (NOT ANDROID)
install(PROGRAMS org.kde.itinerary.desktop DESTINATION ${KDE_INSTALL_APPDIR})
......
......@@ -162,7 +162,7 @@ int main(int argc, char **argv)
engine.rootContext()->setContextProperty(QStringLiteral("_timelineModel"), &timelineModel);
engine.rootContext()->setContextProperty(QStringLiteral("_appController"), &appController);
engine.rootContext()->setContextProperty(QStringLiteral("_settings"), &settings);
engine.load(QStringLiteral(":/main.qml"));
engine.load(QStringLiteral("qrc:/main.qml"));
for (const auto &file : parser.positionalArguments()) {
appController.importLocalFile(QUrl::fromLocalFile(file));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment