CMakeLists.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. file(GLOB 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. file(GLOB "${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt)
  26. if(${PACKNAME}_DOC_FILES)
  27. file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME})
  28. add_custom_target("${PACKNAME}-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. WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
  36. )
  37. add_dependencies(${PACKNAME}-tags nvim_runtime_deps)
  38. add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
  39. DEPENDS
  40. "${PACKNAME}-tags"
  41. )
  42. set("${PACKNAME}_DOC_NAMES")
  43. foreach(DF "${${PACKNAME}_DOC_FILES}")
  44. get_filename_component(F ${DF} NAME)
  45. list(APPEND "${PACKNAME}_DOC_NAMES" ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/${F})
  46. endforeach()
  47. install_helper(
  48. FILES ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags "${${PACKNAME}_DOC_NAMES}"
  49. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/pack/dist/opt/${PACKNAME}/doc)
  50. list(APPEND GENERATED_PACKAGE_TAGS "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags")
  51. endif()
  52. endforeach()
  53. file(GLOB DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
  54. set(BUILDDOCFILES)
  55. foreach(DF ${DOCFILES})
  56. get_filename_component(F ${DF} NAME)
  57. list(APPEND BUILDDOCFILES ${GENERATED_RUNTIME_DIR}/doc/${F})
  58. endforeach()
  59. add_custom_target(helptags
  60. COMMAND ${CMAKE_COMMAND} -E remove doc/*
  61. COMMAND ${CMAKE_COMMAND} -E copy_directory
  62. ${PROJECT_SOURCE_DIR}/runtime/doc doc
  63. COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
  64. -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
  65. DEPENDS
  66. nvim
  67. WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
  68. )
  69. add_dependencies(helptags nvim_runtime_deps)
  70. add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
  71. DEPENDS
  72. helptags
  73. )
  74. add_custom_target(doc_html
  75. COMMAND make html
  76. DEPENDS
  77. helptags
  78. WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}/doc"
  79. )
  80. add_custom_target(
  81. runtime ALL
  82. DEPENDS
  83. ${GENERATED_SYN_VIM}
  84. ${GENERATED_HELP_TAGS}
  85. ${GENERATED_PACKAGE_TAGS}
  86. )
  87. # CMake is painful here. It will create the destination using the user's
  88. # current umask, and we don't want that. And we don't just want to install
  89. # the target directory, as it will mess with existing permissions. So this
  90. # seems like the best compromise. If we create it, then everyone can see it.
  91. # If it's preexisting, leave it alone.
  92. install_helper(
  93. FILES ${GENERATED_HELP_TAGS} ${BUILDDOCFILES}
  94. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/doc)
  95. install_helper(
  96. FILES ${GENERATED_SYN_VIM}
  97. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/syntax/vim)
  98. if(NOT APPLE)
  99. install_helper(
  100. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.desktop
  101. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
  102. install_helper(
  103. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.png
  104. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pixmaps)
  105. endif()
  106. file(GLOB_RECURSE RUNTIME_PROGRAMS
  107. RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
  108. *.awk *.sh *.bat)
  109. foreach(PROG ${RUNTIME_PROGRAMS})
  110. get_filename_component(BASEDIR ${PROG} PATH)
  111. install_helper(PROGRAMS ${PROG}
  112. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
  113. endforeach()
  114. file(GLOB_RECURSE RUNTIME_FILES
  115. RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
  116. rgb.txt
  117. *.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
  118. foreach(F ${RUNTIME_FILES})
  119. get_filename_component(BASEDIR ${F} PATH)
  120. install_helper(FILES ${F}
  121. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
  122. endforeach()