CMakeLists.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. set(GENERATED_RUNTIME_DIR ${PROJECT_BINARY_DIR}/runtime)
  2. set(GENERATED_HELP_TAGS ${GENERATED_RUNTIME_DIR}/doc/tags)
  3. set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt)
  4. set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim)
  5. set(SYN_VIM_GENERATOR ${PROJECT_SOURCE_DIR}/src/nvim/generators/gen_vimvim.lua)
  6. file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax/vim)
  7. get_directory_property(LUA_GEN DIRECTORY ${PROJECT_SOURCE_DIR}/src/nvim DEFINITION LUA_GEN)
  8. get_directory_property(LUA_GEN_DEPS DIRECTORY ${PROJECT_SOURCE_DIR}/src/nvim DEFINITION LUA_GEN_DEPS)
  9. add_custom_command(OUTPUT ${GENERATED_SYN_VIM}
  10. COMMAND ${LUA_GEN} ${SYN_VIM_GENERATOR} ${GENERATED_SYN_VIM} ${FUNCS_DATA}
  11. DEPENDS
  12. ${LUA_GEN_DEPS}
  13. ${SYN_VIM_GENERATOR}
  14. ${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua
  15. ${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua
  16. ${PROJECT_SOURCE_DIR}/src/nvim/options.lua
  17. ${PROJECT_SOURCE_DIR}/src/nvim/eval.c
  18. ${FUNCS_DATA}
  19. )
  20. file(GLOB PACKAGES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*)
  21. set(GENERATED_PACKAGE_TAGS)
  22. foreach(PACKAGE ${PACKAGES})
  23. get_filename_component(PACKNAME ${PACKAGE} NAME)
  24. file(GLOB "${PACKNAME}_DOC_FILES" CONFIGURE_DEPENDS ${PACKAGE}/doc/*.txt)
  25. if(${PACKNAME}_DOC_FILES)
  26. file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME})
  27. add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
  28. COMMAND ${CMAKE_COMMAND} -E copy_directory
  29. ${PACKAGE} ${GENERATED_PACKAGE_DIR}/${PACKNAME}
  30. COMMAND $<TARGET_FILE:nvim_bin>
  31. -u NONE -i NONE -e --headless -c "helptags doc" -c quit
  32. DEPENDS
  33. nvim_bin
  34. nvim_runtime_deps
  35. WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
  36. )
  37. set("${PACKNAME}_DOC_NAMES")
  38. foreach(DF "${${PACKNAME}_DOC_FILES}")
  39. get_filename_component(F ${DF} NAME)
  40. list(APPEND "${PACKNAME}_DOC_NAMES" ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/${F})
  41. endforeach()
  42. install_helper(
  43. FILES ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags "${${PACKNAME}_DOC_NAMES}"
  44. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/pack/dist/opt/${PACKNAME}/doc)
  45. list(APPEND GENERATED_PACKAGE_TAGS "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags")
  46. endif()
  47. endforeach()
  48. set(BUILDDOCFILES)
  49. foreach(DF ${DOCFILES})
  50. get_filename_component(F ${DF} NAME)
  51. list(APPEND BUILDDOCFILES ${GENERATED_RUNTIME_DIR}/doc/${F})
  52. endforeach()
  53. add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
  54. COMMAND ${CMAKE_COMMAND} -E remove_directory doc
  55. COMMAND ${CMAKE_COMMAND} -E copy_directory
  56. ${PROJECT_SOURCE_DIR}/runtime/doc doc
  57. COMMAND $<TARGET_FILE:nvim_bin>
  58. -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
  59. DEPENDS
  60. nvim_bin
  61. nvim_runtime_deps
  62. WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
  63. )
  64. add_custom_target(
  65. nvim_runtime
  66. DEPENDS
  67. ${GENERATED_SYN_VIM}
  68. ${GENERATED_HELP_TAGS}
  69. ${GENERATED_PACKAGE_TAGS}
  70. )
  71. # CMake is painful here. It will create the destination using the user's
  72. # current umask, and we don't want that. And we don't just want to install
  73. # the target directory, as it will mess with existing permissions. So this
  74. # seems like the best compromise. If we create it, then everyone can see it.
  75. # If it's preexisting, leave it alone.
  76. install_helper(
  77. FILES ${GENERATED_HELP_TAGS} ${BUILDDOCFILES}
  78. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/doc)
  79. install_helper(
  80. FILES ${GENERATED_SYN_VIM}
  81. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/syntax/vim)
  82. if(NOT APPLE)
  83. install_helper(
  84. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.desktop
  85. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
  86. endif()
  87. install_helper(
  88. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.png
  89. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
  90. file(GLOB RUNTIME_ROOT_FILES CONFIGURE_DEPENDS *.vim *.lua *.ico)
  91. install_helper(FILES ${RUNTIME_ROOT_FILES}
  92. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/)
  93. file(GLOB RUNTIME_DIRS CONFIGURE_DEPENDS */)
  94. foreach(D ${RUNTIME_DIRS})
  95. if(IS_DIRECTORY ${D})
  96. install_helper(DIRECTORY ${D}
  97. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/)
  98. endif()
  99. endforeach()
  100. # only foo.sh script in runtime/
  101. install_helper(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/less.sh DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/scripts/)