InstallHelpers.cmake 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #
  2. # install all files matching certain wildcards below ${LMMS_DATA_DIR}/<subdir>
  3. #
  4. # example:
  5. #
  6. # INSTALL_DATA_SUBDIRS("samples" "*.ogg;*.wav;*.flac")
  7. #
  8. # Copyright (c) 2008 Tobias Doerffel
  9. #
  10. # helper-macro
  11. MACRO(LIST_CONTAINS var value)
  12. SET(${var})
  13. FOREACH (value2 ${ARGN})
  14. IF (${value} STREQUAL ${value2})
  15. SET(${var} TRUE)
  16. ENDIF (${value} STREQUAL ${value2})
  17. ENDFOREACH (value2)
  18. ENDMACRO(LIST_CONTAINS)
  19. MACRO(INSTALL_DATA_SUBDIRS _subdir _wildcards)
  20. FOREACH(_wildcard ${_wildcards})
  21. FILE(GLOB_RECURSE files ${_wildcard})
  22. LIST(SORT files)
  23. SET(SUBDIRS)
  24. FOREACH(_item ${files})
  25. GET_FILENAME_COMPONENT(_file "${_item}" PATH)
  26. STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" _file "${_file}")
  27. LIST_CONTAINS(contains _file ${SUBDIRS})
  28. IF(NOT contains)
  29. LIST(APPEND SUBDIRS "${_file}")
  30. ENDIF(NOT contains)
  31. ENDFOREACH(_item ${files})
  32. FOREACH(_item ${SUBDIRS})
  33. FILE(GLOB files "${_item}/${_wildcard}")
  34. LIST(SORT files)
  35. FOREACH(_file ${files})
  36. INSTALL(FILES "${_file}" DESTINATION "${LMMS_DATA_DIR}/${_subdir}/${_item}/")
  37. ENDFOREACH(_file ${files})
  38. ENDFOREACH(_item ${SUBDIRS})
  39. ENDFOREACH(_wildcard ${_wildcards})
  40. ENDMACRO(INSTALL_DATA_SUBDIRS)