From 56cac19412debce6985177d313df37684ccd3d70 Mon Sep 17 00:00:00 2001 From: Oscar Andreasson Date: Fri, 1 Jan 2016 12:18:06 +0100 Subject: [PATCH] Added CMake build system --- CMakeLists.txt | 27 +++++++++++++++++++++ weatherinfo/CMakeLists.txt | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 weatherinfo/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ff44013 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 2.8) + +project(QmlMirror) + +include(GNUInstallDirs) + +find_package(Qt5Core REQUIRED) +find_package(Qt5Qml REQUIRED) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11") + +set(INSTALLATION_LOCATION ${CMAKE_INSTALL_DATADIR}/QmlMirror) + +install(DIRECTORY . + DESTINATION ${INSTALLATION_LOCATION} + PATTERN build EXCLUDE + PATTERN .git EXCLUDE + PATTERN CMakeLists.txt EXCLUDE + PATTERN weatherinfo EXCLUDE + PATTERN *.pro EXCLUDE + PATTERN *.pro.* EXCLUDE + PATTERN LICENSE EXCLUDE + PATTERN README.md EXCLUDE + ) + +add_subdirectory(weatherinfo) + diff --git a/weatherinfo/CMakeLists.txt b/weatherinfo/CMakeLists.txt new file mode 100644 index 0000000..86af20c --- /dev/null +++ b/weatherinfo/CMakeLists.txt @@ -0,0 +1,48 @@ + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(QT_QML_MODULES_LOCATION lib/qt5/qml) + +macro(add_qml_plugin PLUGIN_ID SOURCE_FILES) + + string(REPLACE "." "/" PLUGIN_PATH "net.frozentux.weatherinfo") + + set(PLUGIN_INSTALLATION_PATH ${QT_QML_MODULES_LOCATION}/${PLUGIN_PATH}) + add_library(${PLUGIN_ID} SHARED ${SOURCE_FILES}) + qt5_use_modules(${PLUGIN_ID} Core Qml Network Positioning Declarative Quick) + + install(TARGETS ${PLUGIN_ID} DESTINATION ${PLUGIN_INSTALLATION_PATH}) + + install(DIRECTORY components DESTINATION ${PLUGIN_INSTALLATION_PATH}) + + # Set the library file name to be the last token of the plugin ID + string(REPLACE "." ";" PLUGIN_LIB_NAME ${PLUGIN_ID}) + list(GET PLUGIN_LIB_NAME -1 PLUGIN_LIB_NAME) + + set(PLUGIN_LOCATION_IN_BUILD ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_PATH}) + + configure_file(qmldir ${PLUGIN_LOCATION_IN_BUILD}/qmldir COPYONLY) + install(FILES ${PLUGIN_LOCATION_IN_BUILD}/qmldir DESTINATION ${PLUGIN_INSTALLATION_PATH}) + + set_target_properties(${PLUGIN_ID} PROPERTIES + OUTPUT_NAME ${PLUGIN_LIB_NAME} + LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_LOCATION_IN_BUILD} + RUNTIME_OUTPUT_DIRECTORY ${PLUGIN_LOCATION_IN_BUILD} + ) + +endmacro() + +set(SOURCE_FILES + appmodel.cpp + appmodel.h + main.cpp + weatherplugin.cpp + weatherplugin.h + images.qrc +) + + +add_qml_plugin(WeatherData "${SOURCE_FILES}") + +