cmake: Add man and info outputs

By default, the cmake derivation contains the documentation in .rst
format. This format is not well suited for interactive use. Therefore,
we add both man and info outputs and convert the documentation to
these formats using Sphinx.

These formats are enabled by default only in cmake versions for
interactive use (ncurses, Qt), because using Sphinx in the basic
version leads to circular dependency (infinite recursion). Namely,
Sphinx has imagemagick in its checkInputs and imagemagick has several
transitive dependencies, which have cmake in nativeBuildInputs.
This commit is contained in:
Michal Sojka 2021-05-27 22:53:40 +02:00
parent d9e4512443
commit 498b5e578a

View file

@ -8,6 +8,7 @@
, useOpenSSL ? !isBootstrap, openssl
, useNcurses ? false, ncurses
, withQt5 ? false, qtbase
, buildDocs ? (!isBootstrap && (useNcurses || withQt5)), sphinx, texinfo
}:
stdenv.mkDerivation (rec {
@ -35,14 +36,16 @@ stdenv.mkDerivation (rec {
] ++ lib.optional stdenv.isCygwin ./3.2.2-cygwin.patch;
outputs = [ "out" ];
outputs = [ "out" ]
++ lib.optionals buildDocs [ "man" "info" ];
setOutputFlags = false;
setupHook = ./setup-hook.sh;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ setupHook pkg-config ];
nativeBuildInputs = [ setupHook pkg-config ]
++ lib.optionals buildDocs [ texinfo ];
buildInputs = []
++ lib.optionals useSharedLibraries [ bzip2 curlMinimal expat libarchive xz zlib libuv rhash ]
@ -68,6 +71,11 @@ stdenv.mkDerivation (rec {
"--docdir=share/doc/${pname}${version}"
] ++ (if useSharedLibraries then [ "--no-system-jsoncpp" "--system-libs" ] else [ "--no-system-libs" ]) # FIXME: cleanup
++ lib.optional withQt5 "--qt-gui"
++ lib.optionals buildDocs [
"--sphinx-build=${sphinx}/bin/sphinx-build"
"--sphinx-man"
"--sphinx-info"
]
# Workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20568
++ lib.optionals stdenv.hostPlatform.is32bit [
"CFLAGS=-D_FILE_OFFSET_BITS=64"