CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. set(SYN_VIM_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genvimvim.lua)
  2. set(GENERATED_RUNTIME_DIR ${PROJECT_BINARY_DIR}/runtime)
  3. set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim)
  4. set(GENERATED_HELP_TAGS ${GENERATED_RUNTIME_DIR}/doc/tags)
  5. set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt)
  6. set(FUNCS_DATA ${PROJECT_BINARY_DIR}/funcs_data.mpack)
  7. file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR})
  8. file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax)
  9. file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax/vim)
  10. add_custom_command(OUTPUT ${GENERATED_SYN_VIM}
  11. COMMAND ${LUA_PRG} ${SYN_VIM_GENERATOR}
  12. ${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_SYN_VIM} ${FUNCS_DATA}
  13. DEPENDS
  14. ${SYN_VIM_GENERATOR}
  15. ${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua
  16. ${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua
  17. ${PROJECT_SOURCE_DIR}/src/nvim/options.lua
  18. ${PROJECT_SOURCE_DIR}/src/nvim/eval.c
  19. ${FUNCS_DATA}
  20. )
  21. glob_wrapper(PACKAGES ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*)
  22. set(GENERATED_PACKAGE_TAGS)
  23. foreach(PACKAGE ${PACKAGES})
  24. get_filename_component(PACKNAME ${PACKAGE} NAME)
  25. glob_wrapper("${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt)
  26. if(${PACKNAME}_DOC_FILES)
  27. file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME})
  28. add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
  29. COMMAND ${CMAKE_COMMAND} -E copy_directory
  30. ${PACKAGE} ${GENERATED_PACKAGE_DIR}/${PACKNAME}
  31. COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
  32. -u NONE -i NONE -e --headless -c "helptags doc" -c quit
  33. DEPENDS
  34. nvim
  35. nvim_runtime_deps
  36. WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
  37. )
  38. set("${PACKNAME}_DOC_NAMES")
  39. foreach(DF "${${PACKNAME}_DOC_FILES}")
  40. get_filename_component(F ${DF} NAME)
  41. list(APPEND "${PACKNAME}_DOC_NAMES" ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/${F})
  42. endforeach()
  43. install_helper(
  44. FILES ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags "${${PACKNAME}_DOC_NAMES}"
  45. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/pack/dist/opt/${PACKNAME}/doc)
  46. list(APPEND GENERATED_PACKAGE_TAGS "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags")
  47. endif()
  48. endforeach()
  49. glob_wrapper(DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
  50. set(BUILDDOCFILES)
  51. foreach(DF ${DOCFILES})
  52. get_filename_component(F ${DF} NAME)
  53. list(APPEND BUILDDOCFILES ${GENERATED_RUNTIME_DIR}/doc/${F})
  54. endforeach()
  55. add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
  56. COMMAND ${CMAKE_COMMAND} -E remove doc/*
  57. COMMAND ${CMAKE_COMMAND} -E copy_directory
  58. ${PROJECT_SOURCE_DIR}/runtime/doc doc
  59. COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
  60. -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
  61. DEPENDS
  62. nvim
  63. nvim_runtime_deps
  64. WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
  65. )
  66. add_custom_target(doc_html
  67. COMMAND make html
  68. DEPENDS
  69. ${GENERATED_HELP_TAGS}
  70. WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}/doc"
  71. )
  72. add_custom_target(
  73. runtime ALL
  74. DEPENDS
  75. ${GENERATED_SYN_VIM}
  76. ${GENERATED_HELP_TAGS}
  77. ${GENERATED_PACKAGE_TAGS}
  78. )
  79. # CMake is painful here. It will create the destination using the user's
  80. # current umask, and we don't want that. And we don't just want to install
  81. # the target directory, as it will mess with existing permissions. So this
  82. # seems like the best compromise. If we create it, then everyone can see it.
  83. # If it's preexisting, leave it alone.
  84. install_helper(
  85. FILES ${GENERATED_HELP_TAGS} ${BUILDDOCFILES}
  86. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/doc)
  87. install_helper(
  88. FILES ${GENERATED_SYN_VIM}
  89. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/syntax/vim)
  90. if(NOT APPLE)
  91. install_helper(
  92. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.desktop
  93. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
  94. install_helper(
  95. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.png
  96. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
  97. endif()
  98. globrecurse_wrapper(RUNTIME_PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR} *.awk *.sh *.bat)
  99. foreach(PROG ${RUNTIME_PROGRAMS})
  100. get_filename_component(BASEDIR ${PROG} PATH)
  101. install_helper(PROGRAMS ${PROG}
  102. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
  103. endforeach()
  104. globrecurse_wrapper(RUNTIME_FILES ${CMAKE_CURRENT_SOURCE_DIR}
  105. *.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
  106. foreach(F ${RUNTIME_FILES})
  107. get_filename_component(BASEDIR ${F} PATH)
  108. install_helper(FILES ${F}
  109. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
  110. endforeach()