diff options
Diffstat (limited to 'nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh')
-rwxr-xr-x | nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh index 87bbefa6bbf..0bb695615fc 100755 --- a/nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh +++ b/nixpkgs/pkgs/development/tools/build-managers/cmake/setup-hook.sh @@ -48,7 +48,7 @@ cmakeConfigurePhase() { # on macOS we want to prefer Unix-style headers to Frameworks # because we usually do not package the framework - cmakeFlags="-DCMAKE_FIND_FRAMEWORK=last $cmakeFlags" + cmakeFlags="-DCMAKE_FIND_FRAMEWORK=LAST $cmakeFlags" # on macOS i686 was only relevant for 10.5 or earlier. cmakeFlags="-DCMAKE_OSX_ARCHITECTURES=x86_64 $cmakeFlags" @@ -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 |