1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-15 00:54:46 +00:00
nixpkgs/pkgs/development
Jan Tojnar 75fdc1ced6
cmake.setupHook: define shareDocName
The docdir flag needs to include `PROJECT_NAME` according to [GNU guidelines]. We are passing
`-DCMAKE_INSTALL_DOCDIR=${!outputDoc}/share/doc/${shareDocName}` but `$shareDocName` was unset.

The `multiple-outputs.sh` setup hook actually only defines `shareDocName` as a local variable
so it was not available for cmake setup hook. Making it global would be of limited usability,
since it primarily tries to extract the project name from configure script.
Additionally, it would not be set because the setup hook defines `setOutputFlags=`,
preventing the function defining `shareDocName` from running. And lastly, the function
would not run for single-output derivations.

Previously, we tried [not disabling `setOutputFlags`] and passing the directory flags
only for multi-output derivations that do not disable `setOutputFlags` but that meant having
two different branches of code, making it harder to check correctness. The multi-output
one did in fact not work due to aforementioned undefined `shareDocName`. It also broke
derivations that set `setOutputFlags=` like [`qtModule` function does] (probably
because some Qt modules have configure scripts incompatible with `configureFlags` defined
by `multiple-outputs.sh` setup hook). For that reason, it was [reverted], putting us back to start.

Let’s try to extract the project name from CMake in the cmake setup hook.

CMake has a `-L` flag for dumping variables but `PROJECT_NAME` did not seem to be among them
when I tested, so I had to resort to parsing the `CMakeLists.txt` file.

The extraction function is limited, it does not deal with

* project name on different line from the `project(` command opening
    - that will just not get matched so we will fall back to
      using the derivation name
* variable interpolation
    - we will just fall back to using derivation name when the extracted
      `project_name` contains a dollar character
* multiple [`project`] commands
    - The command sets `PROJECT_NAME` variable anew with each call, so the
      last `project` call before `include(GNUInstallDirs)` command will be used
      when the included module would [cache the `CMAKE_INSTALL_DOCDIR` variable].
      We will just take the first discovered `project` command for simplicity.
      Hopefully, there are not many projects that use multiple `project` calls
      before including `GNUInstallDirs`.

In either case, we will have some subdirectory so the conflicts will be minimized.

[GNU guidelines]: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html#index-docdir
[not disabling `setOutputFlags`]: be1b22538a
[`qtModule` function  does]: https://github.com/NixOS/nixpkgs/pull/12740
[reverted]: https://github.com/NixOS/nixpkgs/pull/92298
[`PROJECT_NAME`]: https://cmake.org/cmake/help/v3.18/variable/PROJECT_NAME.html
[`project`]: https://cmake.org/cmake/help/v3.18/command/project.html
[cache the `CMAKE_INSTALL_DOCDIR` variable]: 92e30d576d/Modules/GNUInstallDirs.cmake (L298-L299)
2020-07-16 04:38:07 +02:00
..
androidndk-pkgs
arduino Merge pull request #92000 from f4814/platformio-udev 2020-07-11 14:10:33 +02:00
beam-modules
bower-modules/generic
chez-modules
compilers nextpnr: fix build on macOS 2020-07-13 15:45:40 +02:00
coq-modules coqPackages.coq-extensible-records: remove at 1.2.0 2020-07-10 11:26:41 +02:00
dhall-modules
dotnet-modules
em-modules/generic
go-modules
go-packages
guile-modules
haskell-modules
idris-modules
interpreters Merge pull request #87738 from cw789/erlang_update 2020-07-14 14:50:53 +02:00
java-modules
libraries Merge pull request #92295 from avnik/wine-update 2020-07-14 16:35:23 -04:00
lisp-modules
lua-modules
misc
mobile
node-packages rust-analyzer: 2020-06-08 -> 2020-07-13 2020-07-14 20:15:55 +08:00
ocaml-modules ocamlPackages.lambdasoup: 0.6.3 → 0.7.1 2020-07-11 15:23:47 +02:00
perl-modules
pharo
pure-modules
python-modules Merge pull request #93137 from rnhmjoj/uncertain 2020-07-15 09:19:58 +02:00
r-modules
ruby-modules defaultGemConfig.mathematical: fix cross compilation 2020-07-10 07:48:12 +02:00
tools cmake.setupHook: define shareDocName 2020-07-16 04:38:07 +02:00
web deno: 1.1.3 -> 1.2.0 2020-07-14 11:25:24 +00:00