Merge pull request #93166 from jtojnar/cmake-docdir

This commit is contained in:
Jan Tojnar 2020-07-18 06:51:29 +02:00 committed by GitHub
commit 7dff6d6681
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View file

@ -34,8 +34,6 @@ stdenv.mkDerivation rec {
"-DUSE_KWALLET=OFF"
];
# Doc has high risk of collisions
postInstall = "rm -r $out/share/doc";
# darktable changed its rpath handling in commit
# 83c70b876af6484506901e6b381304ae0d073d3c and as a result the

View file

@ -57,9 +57,6 @@ in stdenv.mkDerivation {
++ lib.optionals enableQt [ qt5.wrapQtAppsHook ]
;
# Doc has high risk of collisions
postInstall = "rm -r $out/share/doc";
buildInputs = [
openssl
curl

View file

@ -68,6 +68,24 @@ cmakeConfigurePhase() {
# nix/store directory.
cmakeFlags="-DCMAKE_INSTALL_NAME_DIR=${!outputLib}/lib $cmakeFlags"
# The docdir flag needs to include PROJECT_NAME as per GNU guidelines,
# try to extract it from CMakeLists.txt.
if [[ -z "$shareDocName" ]]; then
local cmakeLists="${cmakeDir}/CMakeLists.txt"
if [[ -f "$cmakeLists" ]]; then
local shareDocName="$(grep --only-matching --perl-regexp --ignore-case '\bproject\s*\(\s*"?\K([^[:space:]")]+)' < "$cmakeLists" | head -n1)"
fi
# The argument sometimes contains garbage or variable interpolation.
# When that is the case, lets fall back to the derivation name.
if [[ -z "$shareDocName" ]] || echo "$shareDocName" | grep -q '[^a-zA-Z0-9_-+]'; then
if [[ -n "${pname-}" ]]; then
shareDocName="$pname"
else
shareDocName="$(echo "$name" | sed 's/-[^a-zA-Z].*//')"
fi
fi
fi
# This ensures correct paths with multiple output derivations
# It requires the project to use variables from GNUInstallDirs module
# https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html