This fixes a variety of issues related to building the documentation
with CMake. In particular it cleans up the dependency management and
fixes some issues where the documentation build was using generated
files from the source directory.
fish's cmake install routines were attempting to create system
directories that already existed, an operation for which the permissions
to do so may not be available (e.g. /usr/local/share/pkgconfig)
This commit first checks if a directory exists before creating it.
Homebrew and other systems set the path for the extra completion,
function and configuration directories outside the writeable prefix.
Mirror the autotools build in trying to create these directories, but
not causing the whole install to fail if this operation in unsuccessful.
The custom command for fish.pc had a dependency on FBVF, but it appears
that the relative path to FBVF was incorrect and with CMake 3.10.1 under
FreeBSD this was consistently causing the build to fail if
../build_tools/git_version_gen.sh hadn't (coincidentally, I think?)
already run.
Explicitly set the dependency path for FBVF to the binary directory.
The custom command for fish.pc had a dependency on FBVF, but there was
no cmake rule for the generation of the FBVF file. With CMake 3.10.1
under FreeBSD, this was consistently causing the build to fail if
../build_tools/git_version_gen.sh hadn't (coincidentally, I think?)
already run.
The non-ncurses version of term.h requires that curses.h be first
included. Only very recent versions of CMake include a LANGUAGE
option to CHECK_INCLUDE_FILES, so we aren't using it and specifying
CXX here..
CheckFunctionExists checks for C linkage only, and recommends the use of
CheckSymbolExists in the documentation. This improves the detection of
C++ features, as opposed to C features.
`-v` is a non-standard GNU-only extension to `awk`, its usage in the
generation of the fish.pc script breaks on non-GNU platforms (such as
FreeBSD and presumably macOS).
Using `sed` with only standard posix commands instead.
This untangles the CMake versioning issues (I hope) as discussed in #4626.
Note most of the advice found on the Internet about how to inject git
versions into CMake is just wrong.
The behavior we want is to unconditionally run the script
build_tools/git_version_gen.sh at build time (i.e. when you invoke ninja or
make, and not when you invoke cmake, which is build system generation time).
This script is careful to only update the FISH-BUILD-VERSION-FILE if the
contents have changed, to avoid spurious rebuilding dependencies of
FISH-BUILD-VERSION-FILE. Assuming the git version hasn't changed, the script
will run, but not update FISH-BUILD-VERSION-FILE, and therefore
fish_version.o will not have to be rebuilt.
This might normally rebuild more than is necessary even if the timestamp is
not updated, because ninja computes the dependency chain ahead of time. But
Ninja also supports the 'restat' option for just this case, and CMake is rad
and exposes this via BYPRODUCTS. So mark FISH-BUILD-VERSION-FILE as a
byproduct and make the script always update a dummy file
(fish-build-version-witness.txt). Note this is the use case for which
BYPRODUCTS is designed.
We also have fish_version.cpp #include "FISH-BUILD-VERSION-FILE", and do a
semi-silly thing and make FISH-BUILD-VERSION-FILE valid C++ (so there's just
one version file). This means we have to filter out the quotes in other
cases..
This reverts commit 25839b8c36.
This was an attempt to simplify the version generation, but it
computed the version at build sytem generation time rather than
at build time, requiring another run of CMake to update it.
Correctly generate FISH_BUILD_VERSION for use in fish_version.h/cpp and
fish.pc to allow `fish --version` and `echo $version` to work again.
Not needing the same convoluted measures used by Makefile builds to
prevent the regeneration of the fish version file when it hasn't
changed.
Purposely created a new `cmake_git_version_gen.sh` file so that the old
`git_version_gen.sh` remains compatible with the existing Makefile build
script. Same reason why `fish.pc.in` was not modified to use a lowercase
variable name to match the CMAKE variable of the same name.
Closes#4626
If `doxygen` isn't installed, the man files aren't built and that's
quite ok. The cmake `install` target was presuming the man files would
always be present and the install stage was failing if they weren't
built.