# Copyright © 2013 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . project(lomiri-content-hub-plugin) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick ) set(CMAKE_AUTOMOC TRUE) set(QT_IMPORTS_DIR "${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/qml") set(CONTENT_HUB_IMPORTS_DIR "${QT_IMPORTS_DIR}/Lomiri/Content") set(PLUGIN lomiri-content-hub-plugin) add_definitions(-DQT_NO_KEYWORDS) if (ENABLE_UBUNTU_COMPAT) add_definitions(-DENABLE_UBUNTU_COMPAT) endif () include_directories( ${CMAKE_SOURCE_DIR} ${LOMIRI_API_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS} ${LOMIRI_LAUNCH_INCLUDE_DIRS} ) set(PLUGIN_HDRS contenthandler.h contenthub.h contenthubplugin.h contenticonprovider.h contentitem.h contentpeer.h contentpeermodel.h contentscope.h contentstore.h contenttransfer.h contenttype.h qmlimportexporthandler.h ) set(PLUGIN_SRC contenthandler.cpp contenthub.cpp contenthubplugin.cpp contenticonprovider.cpp contentitem.cpp contentpeer.cpp contentpeermodel.cpp contentscope.cpp contentstore.cpp contenttransfer.cpp contenttype.cpp qmlimportexporthandler.cpp ../../../src/com/lomiri/content/debug.cpp ) add_library(${PLUGIN} MODULE ${PLUGIN_SRC} ${PLUGIN_HDRS}) target_link_libraries(${PLUGIN} Qt::Core Qt::Qml Qt::Quick Qt::DBus) target_link_libraries( ${PLUGIN} lomiri-content-hub${QT_SUFFIX} ${LOMIRI_API_LIBRARIES} ${GLIB_LIBRARIES} ${LOMIRI_LAUNCH_LDFLAGS} ) install(TARGETS ${PLUGIN} DESTINATION ${CONTENT_HUB_IMPORTS_DIR}) file(GLOB QML_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} qml${QT_VERSION_MAJOR}/*.qml qml${QT_VERSION_MAJOR}/qmldir) install(FILES ${QML_FILES} DESTINATION ${CONTENT_HUB_IMPORTS_DIR}) # copy qml files and assets over to build dir to be able to import them uninstalled foreach(src_file ${QML_FILES}) get_filename_component(out_file ${src_file} NAME) list(APPEND QML_OUT_FILES ${out_file}) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${out_file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src_file} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${src_file} ${CMAKE_CURRENT_BINARY_DIR}/${out_file}) endforeach() add_custom_target(copy_files_to_build_dir DEPENDS ${QML_OUT_FILES}) add_dependencies(${PLUGIN} copy_files_to_build_dir) if(NOT CMAKE_CROSSCOMPILING) set(CHECK_DEFAULT_PATH "") if (EXISTS "/etc/debian_version") set(CHECK_DEFAULT_PATH "NO_DEFAULT_PATH") endif() find_program(QML_PLUGIN_DUMP qmlplugindump REQUIRED PATHS /usr/lib/qt${QT_VERSION_MAJOR}/bin ${CHECK_DEFAULT_PATH} ) if (ENABLE_QT6) set(LOMIRI_CONTENT_VERSION 2.0) else() set(LOMIRI_CONTENT_VERSION 1.1) endif() add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes COMMAND ${QML_PLUGIN_DUMP} -noinstantiate -notrelocatable Lomiri.Content ${LOMIRI_CONTENT_VERSION} ../../ > ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes DEPENDS ${PLUGIN} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) add_custom_target(Content_generated_files ALL SOURCES ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes DESTINATION ${CONTENT_HUB_IMPORTS_DIR}) endif()