fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

David AdamCMake: stop installing embedded files0fafff2c8

master
5.4 KiB170 linesraw
1set(CMAKE_INSTALL_MESSAGE NEVER)
2
3set(prefix ${CMAKE_INSTALL_PREFIX})
4set(bindir ${CMAKE_INSTALL_BINDIR})
5set(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
6set(mandir ${CMAKE_INSTALL_MANDIR})
7
8set(datadir ${CMAKE_INSTALL_FULL_DATADIR})
9file(RELATIVE_PATH rel_datadir ${CMAKE_INSTALL_PREFIX} ${datadir})
10
11set(docdir ${CMAKE_INSTALL_DOCDIR})
12
13set(rel_completionsdir "fish/vendor_completions.d")
14set(rel_functionsdir "fish/vendor_functions.d")
15set(rel_confdir "fish/vendor_conf.d")
16
17set(
18    extra_completionsdir "${datadir}/${rel_completionsdir}"
19    CACHE STRING "Path for extra completions"
20)
21
22set(
23    extra_functionsdir "${datadir}/${rel_functionsdir}"
24    CACHE STRING "Path for extra functions"
25)
26
27set(
28    extra_confdir "${datadir}/${rel_confdir}"
29    CACHE STRING "Path for extra configuration"
30)
31
32
33# These are the man pages that go in system manpath; all manpages go in the fish-specific manpath.
34set(MANUALS
35    ${SPHINX_OUTPUT_DIR}/man/man1/fish.1
36    ${SPHINX_OUTPUT_DIR}/man/man1/fish_indent.1
37    ${SPHINX_OUTPUT_DIR}/man/man1/fish_key_reader.1
38    ${SPHINX_OUTPUT_DIR}/man/man1/fish-doc.1
39    ${SPHINX_OUTPUT_DIR}/man/man1/fish-tutorial.1
40    ${SPHINX_OUTPUT_DIR}/man/man1/fish-language.1
41    ${SPHINX_OUTPUT_DIR}/man/man1/fish-interactive.1
42    ${SPHINX_OUTPUT_DIR}/man/man1/fish-terminal-compatibility.1
43    ${SPHINX_OUTPUT_DIR}/man/man1/fish-completions.1
44    ${SPHINX_OUTPUT_DIR}/man/man1/fish-prompt-tutorial.1
45    ${SPHINX_OUTPUT_DIR}/man/man1/fish-for-bash-users.1
46    ${SPHINX_OUTPUT_DIR}/man/man1/fish-faq.1
47)
48
49# Determine which man page we don't want to install.
50# On OS X, don't install a man page for open, since we defeat fish's open
51# function on OS X.
52# On other operating systems, don't install a realpath man page, as they almost all have a realpath
53# command, while macOS does not.
54if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
55    set(CONDEMNED_PAGE "open.1")
56else()
57    set(CONDEMNED_PAGE "realpath.1")
58endif()
59
60# Define a function to help us create directories.
61function(FISH_CREATE_DIRS)
62    foreach(dir ${ARGV})
63        install(DIRECTORY DESTINATION ${dir})
64    endforeach(dir)
65endfunction(FISH_CREATE_DIRS)
66
67function(FISH_TRY_CREATE_DIRS)
68    foreach(dir ${ARGV})
69        if(NOT IS_ABSOLUTE ${dir})
70            set(abs_dir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${dir}")
71        else()
72            set(abs_dir "\$ENV{DESTDIR}${dir}")
73        endif()
74        install(SCRIPT CODE "
75            EXECUTE_PROCESS(COMMAND mkdir -p ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
76            execute_process(COMMAND chmod 755 ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
77        ")
78    endforeach()
79endfunction(FISH_TRY_CREATE_DIRS)
80
81install(
82    PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fish
83    PERMISSIONS
84        OWNER_READ
85        OWNER_WRITE
86        OWNER_EXECUTE
87        GROUP_READ
88        GROUP_EXECUTE
89        WORLD_READ
90        WORLD_EXECUTE
91    DESTINATION ${bindir}
92)
93
94if(NOT IS_ABSOLUTE ${bindir})
95    set(abs_bindir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${bindir}")
96else()
97    set(abs_bindir "\$ENV{DESTDIR}${bindir}")
98endif()
99install(CODE "file(CREATE_LINK ${abs_bindir}/fish ${abs_bindir}/fish_indent)")
100install(CODE "file(CREATE_LINK ${abs_bindir}/fish ${abs_bindir}/fish_key_reader)")
101
102fish_create_dirs(${sysconfdir}/fish/conf.d ${sysconfdir}/fish/completions
103    ${sysconfdir}/fish/functions)
104install(FILES etc/config.fish DESTINATION ${sysconfdir}/fish/)
105
106fish_create_dirs(
107    ${rel_datadir}/fish
108    ${rel_datadir}/fish/man/man1
109)
110
111# This file is embedded in the executable by rust-embed and never read from the filesystem
112configure_file(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
113
114# Create only the vendor directories inside the prefix (#5029 / #6508)
115fish_create_dirs(
116    ${rel_datadir}/fish/vendor_completions.d
117    ${rel_datadir}/fish/vendor_functions.d
118    ${rel_datadir}/fish/vendor_conf.d
119)
120
121fish_try_create_dirs(${rel_datadir}/pkgconfig)
122configure_file(fish.pc.in fish.pc.noversion @ONLY)
123
124add_custom_command(
125    OUTPUT fish.pc
126    COMMAND sed '/Version/d' fish.pc.noversion > fish.pc
127    COMMAND printf "Version: " >> fish.pc
128    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh >> fish.pc
129    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
130    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion
131)
132
133add_custom_target(build_fish_pc ALL DEPENDS fish.pc)
134
135install(
136    FILES ${CMAKE_CURRENT_BINARY_DIR}/fish.pc
137    DESTINATION ${rel_datadir}/pkgconfig
138)
139
140# CONDEMNED_PAGE is managed by the conditional above
141# Building the man pages is optional: if sphinx isn't installed, they're not built
142install(
143    DIRECTORY ${SPHINX_OUTPUT_DIR}/man/man1/
144    DESTINATION ${rel_datadir}/fish/man/man1
145    FILES_MATCHING
146    PATTERN "*.1"
147    PATTERN ${CONDEMNED_PAGE} EXCLUDE
148)
149
150# Building the man pages is optional: if Sphinx isn't installed, they're not built
151install(FILES ${MANUALS} DESTINATION ${mandir}/man1/ OPTIONAL)
152install(
153    DIRECTORY ${SPHINX_OUTPUT_DIR}/html/ # Trailing slash is important!
154    DESTINATION ${docdir} OPTIONAL
155)
156install(FILES CHANGELOG.rst DESTINATION ${docdir})
157
158# Group install targets into a InstallTargets folder
159set_property(
160    TARGET build_fish_pc
161    PROPERTY FOLDER cmake/InstallTargets
162)
163
164# Make a target build_root that installs into the buildroot directory, for testing.
165set(BUILDROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/buildroot)
166add_custom_target(
167    build_root
168    COMMAND DESTDIR=${BUILDROOT_DIR} ${CMAKE_COMMAND}
169        --build ${CMAKE_CURRENT_BINARY_DIR} --target install
170)