3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/build-managers
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
..
alibuild alibuild: 1.5.4rc3 -> 1.5.5 2020-03-31 09:29:48 -07:00
apache-ant treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
apache-maven maven: Wrap mvnDebug for convenience 2020-05-15 16:56:58 +02:00
arpa2cm
bam
bazel bazel: 3.3.0 -> 3.3.1 2020-07-01 23:23:33 +02:00
bear treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
bloop treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
bmake bmake: 20200606 -> 20200629 2020-07-03 01:07:55 +00:00
boot treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
buck
cmake cmake.setupHook: define shareDocName 2020-07-16 04:38:07 +02:00
colormake colormake: use fetchFromGitHub 2020-05-29 20:00:56 -04:00
conan conan: 1.25.0 -> 1.27.0 2020-07-01 12:45:39 -07:00
doit treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
drake treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
dub treewide: add quotes to recently-changed urls 2020-03-28 00:05:50 +01:00
gn gn: 20190403 -> 2020-03-09 2020-03-24 14:41:11 +01:00
gnumake gnumake42: bring this version back 2020-07-06 10:55:32 +02:00
gradle gradle: 5.6.4 -> 6.5.1 2020-07-04 14:56:12 -07:00
gup
icmake treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
jam treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
kati treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
leiningen treewide: remove the-kenny from maintainers 2020-05-09 10:28:57 +01:00
mage mage: 1.9.0 -> 1.10.0 2020-07-11 16:06:12 +00:00
meson meson: fix hash after incorrect merge 2020-06-04 17:53:31 +02:00
mill mill: 0.7.3 -> 0.7.4 2020-07-07 10:04:15 -07:00
mk treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
msbuild treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
ninja treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
pants
qbs qbs: 1.15.0 -> 1.16.0 2020-05-10 05:13:15 +00:00
rake treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
rebar treewide: remove the-kenny from maintainers 2020-05-09 10:28:57 +01:00
rebar3 treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
redo treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
redo-apenwarr redo-apenwarr: install bash completion 2020-07-07 04:20:00 -05:00
redo-c redo-c: Initial 0.2 2020-07-10 00:48:57 +02:00
redo-sh treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
remake treewide: Per RFC45, remove all unquoted URLs 2020-04-10 17:54:53 +01:00
samurai samurai: 1.0 -> 1.1 2020-04-01 18:58:42 -07:00
sbt sbt: 1.3.12 -> 1.3.13 2020-06-30 14:57:54 +00:00
sbt-extras sbt-extras: 2019-10-21 -> 2020-06-01 (#89289) 2020-06-01 08:46:15 +00:00
scons scons: Add passthru.py2 for backward compatibility 2020-03-27 10:49:52 -07:00
shards shards: 0.9.0 -> 0.10.0 2020-04-22 17:30:22 +08:00
tup tup: fix setup hook location 2020-06-13 11:03:55 +05:30
waf waf: 2.0.19 -> 2.0.20 2020-04-21 08:40:14 +02:00
wafHook Merge pull request #79593 from thefloweringash/wafhook-phases 2020-03-22 01:59:41 -04:00