Merge pull request #93166 from jtojnar/cmake-docdir
This commit is contained in:
@@ -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, let’s 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
|
||||
|
||||
Reference in New Issue
Block a user