mirror of
https://github.com/neovim/neovim.git
synced 2024-12-26 14:11:15 -07:00
7c83657397
Closes #3689 cmake: Add `desktop-install` and `icon-install` targets. `runtime` target will trigger them. Specification: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys Icons are stored system-wide in /usr/share/applications or user wide at /usr/share/icons/hicolor/scalable/apps and can be overriden in ~/.local/share/icons nvim.desktop file can be installed system wide or in ~/.local/share/applications/ To test without an installer: $ xdg-desktop-menu install --novendor runtime/nvim.desktop $ xdg-icon-resource install --novendor --mode user --size 64 contrib/nvim-icon.png Once it is installed, you can test with gtk-launch if installed or dmenu/rofi (drun mode)
150 lines
4.8 KiB
CMake
150 lines
4.8 KiB
CMake
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)
|
|
set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt)
|
|
set(FUNCS_DATA ${PROJECT_BINARY_DIR}/funcs_data.mpack)
|
|
|
|
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}
|
|
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_SYN_VIM} ${FUNCS_DATA}
|
|
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
|
|
${FUNCS_DATA}
|
|
)
|
|
|
|
if(POLICY CMP0054)
|
|
cmake_policy(SET CMP0054 OLD)
|
|
endif()
|
|
|
|
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)
|
|
if("${PACKNAME}_DOC_FILES")
|
|
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}"
|
|
)
|
|
|
|
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()
|
|
|
|
file(GLOB DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
|
|
|
|
set(BUILDDOCFILES)
|
|
foreach(DF ${DOCFILES})
|
|
get_filename_component(F ${DF} NAME)
|
|
list(APPEND BUILDDOCFILES ${GENERATED_RUNTIME_DIR}/doc/${F})
|
|
endforeach()
|
|
|
|
add_custom_target(helptags
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${PROJECT_SOURCE_DIR}/runtime/doc ${GENERATED_RUNTIME_DIR}/doc
|
|
COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
|
|
-u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
|
|
DEPENDS
|
|
nvim
|
|
WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
|
|
)
|
|
|
|
add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
|
|
DEPENDS
|
|
helptags
|
|
)
|
|
|
|
add_custom_target(doc_html
|
|
COMMAND make html
|
|
DEPENDS
|
|
${GENERATED_HELP_TAGS}
|
|
WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}/doc"
|
|
)
|
|
|
|
add_custom_target(
|
|
runtime ALL
|
|
DEPENDS
|
|
${GENERATED_SYN_VIM}
|
|
${GENERATED_HELP_TAGS}
|
|
${GENERATED_PACKAGE_TAGS}
|
|
)
|
|
|
|
# Optional targets for nvim.desktop file and icon.
|
|
find_program(XDG_MENU_PRG xdg-desktop-menu)
|
|
find_program(XDG_ICON_PRG xdg-icon-resource)
|
|
if(XDG_MENU_PRG)
|
|
add_custom_target(desktop-file
|
|
COMMAND xdg-desktop-menu install --novendor ${PROJECT_SOURCE_DIR}/runtime/nvim.desktop)
|
|
# add_dependencies(runtime desktop-file)
|
|
endif()
|
|
if(XDG_ICON_PRG)
|
|
add_custom_target(desktop-icon
|
|
COMMAND xdg-icon-resource install --novendor --size 128 ${PROJECT_SOURCE_DIR}/runtime/nvim.png)
|
|
# add_dependencies(runtime desktop-icon)
|
|
endif()
|
|
|
|
# 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(
|
|
FILES ${GENERATED_HELP_TAGS} ${BUILDDOCFILES}
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/doc)
|
|
|
|
install_helper(
|
|
FILES ${GENERATED_SYN_VIM}
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/syntax/vim)
|
|
|
|
file(GLOB_RECURSE RUNTIME_PROGRAMS
|
|
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
*.awk *.sh *.bat)
|
|
|
|
foreach(PROG ${RUNTIME_PROGRAMS})
|
|
get_filename_component(BASEDIR ${PROG} PATH)
|
|
install_helper(PROGRAMS ${PROG}
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
|
|
endforeach()
|
|
|
|
file(GLOB_RECURSE RUNTIME_FILES
|
|
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
*.vim *.dict *.py *.rb *.ps *.tutor)
|
|
|
|
foreach(F ${RUNTIME_FILES})
|
|
get_filename_component(BASEDIR ${F} PATH)
|
|
install_helper(FILES ${F}
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
|
|
endforeach()
|