diff options
author | Marco Martin <notmart@gmail.com> | 2015-12-09 12:14:38 +0100 |
---|---|---|
committer | Marco Martin <notmart@gmail.com> | 2015-12-29 10:33:34 +0100 |
commit | 76377cdf5d0658672bea5cc84f1c7d5657b8aea2 (patch) | |
tree | c92b63f1e3e1b1c99ba66f4927028676f66b97df /kde-modules/KDEPackageAppTemplates.cmake | |
parent | 70f8c5f9efaae8f16874d8cfc551e8ae19558fba (diff) | |
download | extra-cmake-modules-76377cdf5d0658672bea5cc84f1c7d5657b8aea2.tar.gz extra-cmake-modules-76377cdf5d0658672bea5cc84f1c7d5657b8aea2.tar.bz2 |
Make the KAppTemplate CMake module globalv5.18.0-rc1v5.18.0
templates are very useful as teaching tool in order to make
a minimal application that uses a certain framework.
templates in the KAppTemplate repository will always get forgotten
(plus kapptemplate is not really necessary as they work in kdevelop as well)
An ideal situation would be frameworks having templates in their own repos
with templates of barebone apps using the main framework features.
In order to do that, the cmake stuff needed in order to correctly install
a template needs to be ported to a place avaiable to all frameworks
REVIEW:126185
Diffstat (limited to 'kde-modules/KDEPackageAppTemplates.cmake')
-rw-r--r-- | kde-modules/KDEPackageAppTemplates.cmake | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/kde-modules/KDEPackageAppTemplates.cmake b/kde-modules/KDEPackageAppTemplates.cmake new file mode 100644 index 00000000..c0eb8b90 --- /dev/null +++ b/kde-modules/KDEPackageAppTemplates.cmake @@ -0,0 +1,124 @@ +#.rst: +# KDETemplateGenerator +# ------------------- +# +# Packages KApptemplate/KDevelop compatible application templates +# +# This module provides a functionality to package in a tarball and +# install project templates compatible with the format used by +# KApptemplate and KDevelop. Useful for providing minimal examples +# for the usage of the KDE Frameworks. +# +# This module provides the following function: +# +# kde_package_app_templates( TEMPLATES template1 [template2] [...] INSTALL_DIR directory) +# +# INSTALL_DIR is the directory to install the template package to. +# In most cases you will want to use the variable KDE_INSTALL_KTEMPLATESDIR +# from :kde-module:`KDEInstallDirs`. +# +# TEMPLATES lists subdirectories containing template files; +# each ``<template>`` directory will be packaged into a file named +# ``<template>.tar.bz2`` and installed to the appropriate location. +# +# The template is a minimal source tree of an application as if it was +# an application project by itself, with names (file names or text inside) +# the text files replaced by the following placeholders when needed: +# +# ``%{PROJECTDIRNAME}`` +# %{APPNAMELC}-%{VERSION} for KAppTemplate +# ``%{APPNAME}`` +# project name as entered by user ex: MyKApp +# ``%{APPNAMELC}`` +# project name in lower case ex: mykapp +# ``%{APPNAMEUC}`` +# project name in upper case ex: MYKAPP +# +# ``%{CPP_TEMPLATE}`` +# license header for cpp file +# ``%{H_TEMPLATE}`` +# license header for h file +# +# ``%{AUTHOR}`` +# author name ex: George Ignacious +# ``%{EMAIL}`` +# author email ex: foo@bar.org +# ``%{VERSION}`` +# project version ex: 0.1 +# +# ``%{dest}`` +# used in .kdevtemplate +# ``%{src}`` +# used in .kdevtemplate +# +# Multiple templates can be passed at once. +# +# +# Since 5.18 + +#============================================================================= +# Copyright 2015 Marco Martin <mart@kde.org> +# Copyright 2014 Simon Wächter<waechter.simon@gmail.com> +# Copyright 2013 Nico Kruber<nico.kruber@gmail.com> +# Copyright 2012 Jeremy Whiting <jpwhiting@kde.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING-CMAKE-SCRIPTS for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of extra-cmake-modules, substitute the full +# License text for the above reference.) + +include(CMakeParseArguments) + +function(kde_package_app_templates) + set(_oneValueArgs INSTALL_DIR) + set(_multiValueArgs TEMPLATES) + cmake_parse_arguments(ARG "" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN} ) + + if(NOT ARG_TEMPLATES) + message(FATAL_ERROR "No TEMPLATES argument given to kde_package_app_templates") + endif() + + if(NOT ARG_INSTALL_DIR) + message(FATAL_ERROR "No INSTALL_DIR argument given to kde_package_app_templates") + endif() + + foreach(_templateName ${ARG_TEMPLATES}) + + get_filename_component(_tmp_file ${_templateName} ABSOLUTE) + get_filename_component(_baseName ${_tmp_file} NAME_WE) + set(_template ${CMAKE_CURRENT_BINARY_DIR}/${_baseName}.tar.bz2) + + file(GLOB _files "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*") + set(_deps) + foreach(_file ${_files}) + get_filename_component(_fileName ${_file} NAME) + string(COMPARE NOTEQUAL ${_fileName} .kdev_ignore _v1) + string(REGEX MATCH "\\.svn" _v2 ${_fileName}) + if(WIN32) + string(REGEX MATCH "_svn" _v3 ${_fileName}) + else(WIN32) + set(_v3 FALSE) + endif() + if (_v1 AND NOT _v2 AND NOT _v3) + set(_deps ${_deps} ${_file}) + endif () + endforeach() + + add_custom_target(${_baseName} ALL DEPENDS ${_template}) + + add_custom_command(OUTPUT ${_template} + COMMAND ${CMAKE_COMMAND} -E tar "cvfj" ${_template} . + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} + ) + + + install(FILES ${_template} DESTINATION ${ARG_INSTALL_DIR}) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_template}") + + endforeach() +endfunction() |