CMakeLists.txt 4.65 KB
Newer Older
1 2 3 4
set(SYN_VIM_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genvimvim.lua)
set(GENERATED_RUNTIME_DIR ${PROJECT_BINARY_DIR}/runtime)
set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim)
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 8 9 10 11 12 13

file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR})
file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax)
file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax/vim)

add_custom_command(OUTPUT ${GENERATED_SYN_VIM}
  COMMAND ${LUA_PRG} ${SYN_VIM_GENERATOR}
14
          ${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_SYN_VIM} ${FUNCS_DATA}
15 16 17 18 19 20
  DEPENDS
    ${SYN_VIM_GENERATOR}
    ${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua
    ${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua
    ${PROJECT_SOURCE_DIR}/src/nvim/options.lua
    ${PROJECT_SOURCE_DIR}/src/nvim/eval.c
21
    ${FUNCS_DATA}
22 23
)

24 25 26 27 28 29
file(GLOB PACKAGES ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*)

set(GENERATED_PACKAGE_TAGS)
foreach(PACKAGE ${PACKAGES})
  get_filename_component(PACKNAME ${PACKAGE} NAME)
  file(GLOB "${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt)
30
  if(${PACKNAME}_DOC_FILES)
31 32 33 34 35 36 37 38 39 40
    file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME})
    add_custom_target("${PACKNAME}-tags"
      COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${PACKAGE} ${GENERATED_PACKAGE_DIR}/${PACKNAME}
      COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
        -u NONE -i NONE -e --headless -c "helptags doc" -c quit
      DEPENDS
        nvim
      WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
    )
41
    add_dependencies(${PACKNAME}-tags nvim_runtime_deps)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

    add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
      DEPENDS
        "${PACKNAME}-tags"
      )

    set("${PACKNAME}_DOC_NAMES")
    foreach(DF "${${PACKNAME}_DOC_FILES}")
      get_filename_component(F ${DF} NAME)
      list(APPEND "${PACKNAME}_DOC_NAMES" ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/${F})
    endforeach()

    install_helper(
      FILES ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags "${${PACKNAME}_DOC_NAMES}"
      DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/pack/dist/opt/${PACKNAME}/doc)

    list(APPEND GENERATED_PACKAGE_TAGS "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags")
  endif()
endforeach()

62 63
file(GLOB DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)

64 65 66 67 68 69
set(BUILDDOCFILES)
foreach(DF ${DOCFILES})
  get_filename_component(F ${DF} NAME)
  list(APPEND BUILDDOCFILES ${GENERATED_RUNTIME_DIR}/doc/${F})
endforeach()

70
add_custom_target(helptags
Justin M. Keyes's avatar
Justin M. Keyes committed
71
  COMMAND ${CMAKE_COMMAND} -E remove doc/*
72
  COMMAND ${CMAKE_COMMAND} -E copy_directory
Justin M. Keyes's avatar
Justin M. Keyes committed
73
    ${PROJECT_SOURCE_DIR}/runtime/doc doc
74
  COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
75
    -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
76 77
  DEPENDS
    nvim
78
  WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
79
)
80
add_dependencies(helptags nvim_runtime_deps)
81

82 83 84 85 86
add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
  DEPENDS
    helptags
)

87 88 89
add_custom_target(doc_html
  COMMAND make html
  DEPENDS
Justin M. Keyes's avatar
Justin M. Keyes committed
90
    helptags
91 92 93
  WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}/doc"
)

94 95 96 97 98
add_custom_target(
  runtime ALL
  DEPENDS
    ${GENERATED_SYN_VIM}
    ${GENERATED_HELP_TAGS}
99
    ${GENERATED_PACKAGE_TAGS}
100 101 102 103 104 105 106 107 108
)

# CMake is painful here.  It will create the destination using the user's
# current umask, and we don't want that.  And we don't just want to install
# the target directory, as it will mess with existing permissions.  So this
# seems like the best compromise.  If we create it, then everyone can see it.
# If it's preexisting, leave it alone.

install_helper(
109 110
  FILES ${GENERATED_HELP_TAGS} ${BUILDDOCFILES}
  DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/doc)
111

112 113 114 115
install_helper(
  FILES ${GENERATED_SYN_VIM}
  DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/syntax/vim)

116 117 118 119 120 121 122 123 124 125
if(NOT APPLE)
  install_helper(
    FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.desktop
    DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)

  install_helper(
    FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.png
    DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pixmaps)
endif()

126 127
file(GLOB_RECURSE RUNTIME_PROGRAMS
  RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
128
  *.awk *.sh *.bat)
129 130 131 132

foreach(PROG ${RUNTIME_PROGRAMS})
  get_filename_component(BASEDIR ${PROG} PATH)
  install_helper(PROGRAMS ${PROG}
133 134 135 136 137
                 DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
endforeach()

file(GLOB_RECURSE RUNTIME_FILES
  RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
138
  rgb.txt
139
  *.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
140 141 142 143 144

foreach(F ${RUNTIME_FILES})
  get_filename_component(BASEDIR ${F} PATH)
  install_helper(FILES ${F}
                 DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
145
endforeach()