diff options
author | Marco Martin <notmart@gmail.com> | 2015-11-27 14:36:53 +0100 |
---|---|---|
committer | Marco Martin <notmart@gmail.com> | 2015-11-30 14:46:38 +0100 |
commit | 1e8e0da3eb475bb8b78baa54cb0c34b913c2dc5d (patch) | |
tree | 3a2b8003ae5408cb4dbb060927f22210ead929cb | |
parent | c941061aa989bba945e296aad47df22f9c8ddd5f (diff) | |
download | extra-cmake-modules-1e8e0da3eb475bb8b78baa54cb0c34b913c2dc5d.tar.gz extra-cmake-modules-1e8e0da3eb475bb8b78baa54cb0c34b913c2dc5d.tar.bz2 |
Make the KAppTemplate CMake module global
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
-rw-r--r-- | kde-modules/KDETemplateMacro.cmake | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/kde-modules/KDETemplateMacro.cmake b/kde-modules/KDETemplateMacro.cmake new file mode 100644 index 00000000..796c3f1e --- /dev/null +++ b/kde-modules/KDETemplateMacro.cmake @@ -0,0 +1,49 @@ +macro(kdetemplate_add_app_templates _templateNames) + foreach(_templateName ${ARGV}) + + get_filename_component(_tmp_file ${_templateName} ABSOLUTE) + get_filename_component(_baseName ${_tmp_file} NAME_WE) + if(WIN32) + set(_template ${CMAKE_CURRENT_BINARY_DIR}/${_baseName}.zip) + else(WIN32) + set(_template ${CMAKE_CURRENT_BINARY_DIR}/${_baseName}.tar.bz2) + endif() + + + 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}) + + if(WIN32) + add_custom_command(OUTPUT ${_template} + COMMAND 7za ARGS a -r -tzip ${_template} ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/* + DEPENDS ${_deps} + ) + else(WIN32) + add_custom_command(OUTPUT ${_template} + COMMAND tar ARGS -c -C ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName} + --exclude .kdev_ignore --exclude .svn + -j -f ${_template} . + DEPENDS ${_deps} + ) + endif() + + install(FILES ${_template} DESTINATION ${DATA_INSTALL_DIR}/kdevappwizard/templates) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_template}") + + endforeach() +endmacro() |