diff options
author | spiff <spiff@xbmc.org> | 2013-08-19 18:08:29 +0200 |
---|---|---|
committer | spiff <spiff@xbmc.org> | 2013-08-20 20:20:21 +0200 |
commit | b6adadb41271b7720e7139f1a47d5ed2eaa49568 (patch) | |
tree | 8a72eb81861e318631d6d61080bc6aff0041b031 /project/cmake | |
parent | 0efa87e32eee79adc8591bea12da908adeda6319 (diff) |
updated addon helpers
in particular, we now handle buildsystems which output several add-ons
properly. real life case; screensavers.rsxs
Diffstat (limited to 'project/cmake')
-rw-r--r-- | project/cmake/xbmc-addon-helpers.cmake | 80 |
1 files changed, 50 insertions, 30 deletions
diff --git a/project/cmake/xbmc-addon-helpers.cmake b/project/cmake/xbmc-addon-helpers.cmake index 1b25a11c78..d25fe1eb6b 100644 --- a/project/cmake/xbmc-addon-helpers.cmake +++ b/project/cmake/xbmc-addon-helpers.cmake @@ -1,29 +1,17 @@ -# Install an add-on in the appropriate way -macro (install_addon target version) - IF(PACKAGE_ZIP OR PACKAGE_TGZ) - # Pack files together to create an archive - INSTALL(DIRECTORY ${target} DESTINATION ./) - IF(WIN32) - INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/${target}.dll DESTINATION ${target}) - ELSE(WIN32) - INSTALL(TARGETS ${target} DESTINATION ${target}) - ENDIF(WIN32) - IF(PACKAGE_ZIP) - SET(CPACK_GENERATOR "ZIP") - ENDIF(PACKAGE_ZIP) - IF(PACKAGE_TGZ) - SET(CPACK_GENERATOR "TGZ") - ENDIF(PACKAGE_TGZ) - SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) - SET(CPACK_PACKAGE_FILE_NAME ${target}-${version}) - IF(CMAKE_BUILD_TYPE STREQUAL "Release") - SET(CPACK_STRIP_FILES TRUE) - ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release") - INCLUDE(CPack) - ELSE(PACKAGE_ZIP OR PACKAGE_TGZ) - INSTALL(TARGETS ${target} DESTINATION lib/xbmc/addons/${target}) - INSTALL(DIRECTORY ${target} DESTINATION share/xbmc/addons) - ENDIF(PACKAGE_ZIP OR PACKAGE_TGZ) +# Workaround for the fact that cpack's filenames are not customizable. +# Each add-on is added as a separate component to facilitate zip/tgz packaging. +# The filenames are always of the form basename-component, which is +# incompatible with the addonid-version scheme we want. This hack renames +# the files from the file names generated by the 'package' target. +# Sadly we cannot extend the 'package' target, as it is a builtin target, see +# http://public.kitware.com/Bug/view.php?id=8438 +# Thus, we have to add an 'addon-package' target. +add_custom_target(addon-package + COMMAND cmake --build ${CMAKE_BINARY_DIR} --target package) + +macro(add_cpack_workaround target version) + add_custom_command(TARGET addon-package PRE_BUILD + COMMAND cmake -E rename addon-${target}-${version}.zip ${target}-${version}.zip) endmacro() # Grab the version from a given add-on's addon.xml @@ -51,14 +39,46 @@ macro (prepare_addon_environment) ENDIF(WIN32) endmacro() -# Build and link an add-on -macro (build_addon target sources libs version) - ADD_LIBRARY(${target} ${${sources}}) +# Build, link and optionally package an add-on +macro (build_addon target prefix libs) + ADD_LIBRARY(${target} ${${prefix}_SOURCES}) TARGET_LINK_LIBRARIES(${target} ${${libs}}) - SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${${version}} + addon_version(${target} ${prefix}) + SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${${prefix}_VERSION} SOVERSION 13.0 PREFIX "") IF(OS STREQUAL "android") SET_TARGET_PROPERTIES(${target} PROPERTIES PREFIX "lib") ENDIF(OS STREQUAL "android") + + IF(PACKAGE_ZIP OR PACKAGE_TGZ) + IF(PACKAGE_ZIP) + SET(CPACK_GENERATOR "ZIP") + ENDIF(PACKAGE_ZIP) + IF(PACKAGE_TGZ) + SET(CPACK_GENERATOR "TGZ") + ENDIF(PACKAGE_TGZ) + SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) + set(CPACK_PACKAGE_FILE_NAME addon) + IF(CMAKE_BUILD_TYPE STREQUAL "Release") + SET(CPACK_STRIP_FILES TRUE) + ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release") + set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) + set(CPACK_COMPONENTS_IGNORE_GROUPS 1) + list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) + # Pack files together to create an archive + INSTALL(DIRECTORY ${target} DESTINATION ./ COMPONENT ${target}-${${prefix}_VERSION}) + IF(WIN32) + INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/${target}.dll + DESTINATION ${target} + COMPONENT ${target}-${${prefix}_VERSION}) + ELSE(WIN32) + INSTALL(TARGETS ${target} DESTINATION ${target} + COMPONENT ${target}-${${prefix}_VERSION}) + ENDIF(WIN32) + add_cpack_workaround(${target} ${${prefix}_VERSION}) + ELSE(PACKAGE_ZIP OR PACKAGE_TGZ) + INSTALL(TARGETS ${target} DESTINATION lib/xbmc/addons/${target}) + INSTALL(DIRECTORY ${target} DESTINATION share/xbmc/addons) + ENDIF(PACKAGE_ZIP OR PACKAGE_TGZ) endmacro() |