Commit Graph

68 Commits

Author SHA1 Message Date
Brad King 5071c93a78 GNUInstallDirs: Fix regression on -DCMAKE_INSTALL_<dir>=<default>
In commit 42dfcbf1a5 (GNUInstallDirs: Refactor LIBDIR default
calculation, 2025-03-27, v4.1.0-rc1~384^2~2) we introduced the
`_GNUInstallDirs_LIBDIR_get_default` helper and exercised code from
commit 9789f7d05e (GNUInstallDirs: Add internal helper to compute
specific defaults, 2025-03-28, v4.1.0-rc1~384^2~3) for the first time.
Fix the latter's code to update the `CMAKE_INSTALL_<dir>` cache entry
without triggering conversion of a relative path to an absolute path.

Fixes: #27027
2025-07-02 09:14:56 -04:00
Peter Kokot 535734ee16 GNUInstallDirs: Update documentation
- Added intro code block showing how to include this module.
- Reworded module introduction.
- Used "command" instead of "function".
- Reworded command arguments and descriptions.
- Added the "See Also" section.
2025-05-30 02:35:45 +02:00
Cristian Le cc6dbd194c GNUInstallDirs: Cache CMAKE_INSTALL_* with leading usr/ for install prefix /
As a consequence, `GNUInstallDirs_get_absolute_install_dir` does not
alter the `var` argument (the relative path argument).

Closes: #26834
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-29 13:49:42 -04:00
Cristian Le a7fcb1320c GNUInstallDirs: Make GNUInstallDirs_get_absolute_install_dir a function
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-29 18:05:50 +02:00
Cristian Le 03e796f9ab GNUInstallDirs: Move the common handler for SYSCONFDIR and LOCALSTATEDIR
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-29 18:05:50 +02:00
Cristian Le 4ed399ccfb GNUInstallDirs: Change special path defaults to absolute
Add policy `CMP0192` for compatibility.

Closes: #25852
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-09 11:31:43 -04:00
Cristian Le 7566a477f7 GNUInstallDirs: Factor out helper for special absolute path logic
Factor out part of `GNUInstallDirs_get_absolute_install_dir`
into a dedicated `_GNUInstallDirs_special_absolute` helper.

Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-07 14:20:43 -04:00
Cristian Le 42dfcbf1a5 GNUInstallDirs: Refactor LIBDIR default calculation
Implement via the `_GNUInstallDirs_<dir>_get_default` helper.

Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 12:17:39 -04:00
Cristian Le 9789f7d05e GNUInstallDirs: Add internal helper to compute specific defaults
Create an internal `_GNUInstallDirs_<dir>_get_default` helper and
generalize the logic used to update the `CMAKE_INSTALL_LIBDIR` default.

Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 12:16:43 -04:00
Cristian Le 83f44bbf53 GNUInstallDirs: Factor out helper to compute system type
Factor a `_GNUInstallDirs_get_system_type_for_install` helper
out of the `CMAKE_INSTALL_LIBDIR` logic.

Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 11:59:24 -04:00
Cristian Le 0c9b6aa9e4 GNUInstallDirs: De-duplicate description of defaults
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 11:48:02 -04:00
Cristian Le 18e1341950 GNUInstallDirs: Move defaults from arguments to variables
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 11:46:50 -04:00
Cristian Le 9f41a67fce GNUInstallDirs: Reduce duplication of CMAKE_INSTALL_ prefix
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 11:43:51 -04:00
Cristian Le 5cc1fdad4f GNUInstallDirs: Re-order definitions
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 11:43:27 -04:00
Cristian Le b5f93020c6 GNUInstallDirs: Simplify INFODIR and MANDIR init on BSD platforms
These were using `_GNUInstallDirs_cache_path_fallback` but do not fall
back to `DATAROOTDIR/{info,man}` on BSD platforms.  Convert them to
`_GNUInstallDirs_cache_path`.

Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 11:41:43 -04:00
Cristian Le 98f8e55b99 GNUInstallDirs: Convert macros into functions
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-04 11:35:06 -04:00
Roger Leigh 99c8abed55 kFreeBSD: Remove support for obsolete platform
kFreeBSD is no longer maintained or supported and was never an
officially-supported release architecture for Debian.

Closes: #26742
2025-03-05 11:57:49 -05:00
Kitware Robot 1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Nikita Nemkin 9890cfc4ec Help: More syntax highlighting for literal blocks
Covers almost all blocks containing actual code, except:

* Parsed-literal blocks can't be highlighted, including many command
  summaries and substitution-heavy docs like find_... commands.
  This is a Sphinx limitation.

* Code with errors, like CMP0049, DEPLOYMENT_ADDITIONAL_FILES,
  DEPLOYMENT_REMOTE_DIRECTORY, @PACKAGE_INIT@ substitution in the
  tutorial, bracket arguments/comments in cmake-language.7 and
  cmake-developer.7.

* FindQt4 module, which needs reformatting.
2025-01-29 16:48:53 -05:00
Brad King 90d814f024 CMP0054: Remove support for OLD behavior 2025-01-20 09:46:55 -05:00
Robert Maynard af293ff7c3 Help: Explicitly discourage absolute install destinations
Document some of the problems caused by absolute install destinations.
Encourage use of relative paths.
2024-02-16 09:53:55 -05:00
Brad King 8de3983b4c GNUInstallDirs: Do not treat /opt/homebrew as under /opt
Fixes: #23579
2022-06-02 10:04:35 -04:00
Brad King 624ec3692f GNUInstallDirs: Revert "Apply Debian multiarch LIBDIR to more prefixes"
Revert commit dd9584b352 (GNUInstallDirs: Apply Debian multiarch LIBDIR
to more prefixes, 2021-11-19, v3.23.0-rc1~323^2).  There are separate
problems with activating multiarch `LIBDIR` for each prefix it added:

* Prefix `/` is often used to stage an installation with `DESTDIR`
  for inclusion in a tarball package or similar.

* Prefix `/usr/local` is the default `CMAKE_INSTALL_PREFIX`, causing
  the multiarch `LIBDIR` to be cached after the first configuration,
  even if the prefix changes later.

Revert the change for now, except for the documentation update.
Further discussion will be needed to select a way to enable
multiarch `LIBDIR` for `/` and `/usr/local`.

Fixes: #23365
Issue: #19698
2022-03-30 11:51:01 -04:00
Brad King dbf0c8c233 Merge topic 'GNUInstallDirs-freebsd-mandir'
c07bba2730 GNUInstallDirs: Update CMAKE_INSTALL_MANDIR for FreeBSD

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6722
2021-12-01 09:42:13 -05:00
Brad King 6f05012126 Merge topic 'GNUInstallDirs-conda-fix'
7896991af0 GNUInstallDirs: Prefer system lib64 over conda lib when ambiguous

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6773
2021-12-01 09:34:33 -05:00
Dmitry Marakasov c07bba2730 GNUInstallDirs: Update CMAKE_INSTALL_MANDIR for FreeBSD
FreeBSD has switched from PREFIX/man ro PREFIX/share/man
see https://cgit.freebsd.org/ports/tree/CHANGES entry 20200115.

Fixes: #22883
2021-11-30 12:16:37 -05:00
Robert Maynard 7896991af0 GNUInstallDirs: Prefer system lib64 over conda lib when ambiguous
Update logic added by commit ecaca8c129 (GNUInstallDirs now aware of
conda lib directory requirements, 2021-09-08, v3.22.0-rc1~142^2).
When it is ambiguous if we are doing a conda install or a system
install prefer using the system library directory.

Fixes: #22962
2021-11-30 10:51:33 -05:00
Mathieu Malaterre dd9584b352 GNUInstallDirs: Apply Debian multiarch LIBDIR to more prefixes
On typical Debian amd64 system (bullseye), multiarch is setup as:

```
% cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
```

Where:

```
% apt-cache policy libc6:amd64
libc6:
  Installed: 2.31-13+deb11u2
  Candidate: 2.31-13+deb11u2
  Version table:
 *** 2.31-13+deb11u2 500
        500 http://deb.debian.org/debian bullseye/main amd64 Packages
        100 /var/lib/dpkg/status
```

Update GNUInstallDirs to support all three cases `/`, `/usr/` and
`/usr/local/`.

Fixes: #19698
2021-11-19 09:40:06 -05:00
Brad King b7c91c74eb Merge topic 'revert-debian-libexec'
6658e260d4 GNUInstallDirs: Fix misinterpretation of Debian Policy on LIBEXECDIR

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6607
2021-10-08 09:45:12 -04:00
Timo Röhling 6658e260d4 GNUInstallDirs: Fix misinterpretation of Debian Policy on LIBEXECDIR
Revert commit 798c1c3192 (GNUInstallDirs: Comply with Debian Policy on
LIBEXECDIR, 2020-10-08, v3.19.0-rc1~11^2).

The Debian Policy builds upon FHS 3.0 and permits installing to
`/usr/libexec`. While Policy does grant an additional exception for
applications to use a single subdirectory of `/usr/lib/<triplet>`, this
is not meant to replace `/usr/libexec` as valid target.

Fixes: #22731
2021-10-07 14:29:18 -04:00
Robert Maynard ecaca8c129 GNUInstallDirs now aware of conda lib directory requirements
No matter the OS when installing for conda the library components
need to be placed into the `lib` directory.

To better meet these requirements GNUInstallDirs now checks to see
if it is being asked to install into a conda install location,
and if so use the 'lib' directory instead of the system directory
name.
2021-09-13 08:42:40 -04:00
Brad King 78eff650fa Merge topic 'GNUInstallDirs-variable-named-0'
49a5dbcaff GNUInstallDirs: avoid unwanted variable dereference

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6474
2021-08-25 09:12:23 -04:00
Ben Boeckel 49a5dbcaff GNUInstallDirs: avoid unwanted variable dereference
In some situations, it seems that the variable `0` is defined. In the
case found, it was set to `1`. This makes the detection of the missing
third argument bogus and unnecessarily triggers a warning.

This oversight was introduced in 229b5ee994 (GNUInstallDirs: Add dir
argument to GNUInstallDirs_get_absolute_install_dir, 2020-10-31) prior
to CMake 3.20's release cycle.
2021-08-22 12:42:48 -04:00
Natanael Copa 37b24e0bed GNUInstallDirs: don't use lib64 on Alpine Linux
Fixes: #22318
2021-06-18 11:16:18 -04:00
Josef Angstenberger dad5b9d845 Modules: Fix typos and spelling in comments 2021-05-07 17:00:15 +02:00
Brad King 06171fd7aa GNUInstallDirs: Clarify that CMAKE_INSTALL_<dir> may be absolute
Fixes: #21991
2021-03-29 09:45:27 -04:00
Nikita Nemkin 8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Roger Leigh 229b5ee994 GNUInstallDirs: Add dir argument to GNUInstallDirs_get_absolute_install_dir
Fixes: #21152
2020-11-04 15:10:21 -05:00
Dennis Klein 798c1c3192 GNUInstallDirs: Comply with Debian Policy on LIBEXECDIR
If CMAKE_INSTALL_PREFIX is /usr, CMAKE_INSTALL_LIBEXECDIR shall return
the same value as CMAKE_INSTALL_LIBDIR on Debian.

While the FHS allows /usr/libexec for internal binaries
(https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#usrlibexec) the
Debian Policy Manual states an exception here (section 9.1.1 bullet point 4):
https://www.debian.org/doc/debian-policy/ch-opersys#file-system-structure.

Fixes: #21287
2020-10-08 11:10:41 -04:00
Vitaly Lipatov c18ed7236d GNUInstallDirs: Warn when CMAKE_SYSTEM_NAME is not set
If a project writes `include(GNUInstallDirs)` before `project()` then
`CMAKE_SYSTEM_NAME` may not be set and an incorrect `LIBDIR` may be
computed.  Warn about this case.
2020-01-30 09:14:47 -05:00
Antonio Rojas 18365587c8 GNUInstallDirs: Keep 'lib' as default LIBDIR on Arch Linux based systems
Fixes: #15373
2019-08-26 11:14:13 -04:00
Tobias C. Berner f835f189ae GNUInstallDirs: Update FreeBSD "info" destination to share/info
FreeBSD ports commit r484628 (Install texinfo files (GNU info) into
${PREFIX}/share/info, 2018-11-10) changed the "info" destination
from "info" to "share/info".  The commit included a patch to their
distribution of CMake to fix the `GNUInstallDirs` module too.
Apply a similar logic change to our upstream version of the module.

We already made a similar change for GNU/kFreeBSD in commit
v3.13.0-rc2~8^2 (GNUInstallDirs: Don't use BSD info and man paths on
GNU/kFreeBSD, 2018-10-21).

Fixes: #18585
2018-11-13 13:35:50 -05:00
Brad King 4c0d97dd98 GNUInstallDirs: Split "info" and "man" default logic
The conditions may soon differ.
2018-11-13 13:35:35 -05:00
Brad King afd928f85a Merge topic 'rst-block-comments'
75f73dde0f Utilities/Scripts: Remove temporary block-style comment conversion script
df4ed1e9ff Help: Convert remaining modules to block-style comments
7115aa6c22 Utilities/Scripts: Add temporary block-style comment conversion script

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2510
2018-10-23 10:24:09 -04:00
James Clarke b2d7ab8bd1 GNUInstallDirs: Don't use BSD info and man paths on GNU/kFreeBSD 2018-10-22 12:58:54 -04:00
Kitware Robot df4ed1e9ff Help: Convert remaining modules to block-style comments 2018-10-22 11:09:34 -04:00
Brad King 24e2bc4219 GNUInstallDirs: Update link to 64-bit ABI documents
Suggested-by: Chris Coutinho <chrisbcoutinho@gmail.com>
Fixes: #17503
2017-11-27 10:01:35 -05:00
Christian Pfeiffer a8be8b1b54 GNUInstallDirs: Enable CMP0054
Fixes: #17381
2017-10-23 09:02:54 -04:00
Felix Geyer 40814a7ce9 GNUInstallDirs: Add RUNSTATEDIR variable 2017-04-20 17:25:46 +02:00
Roger Leigh 53b5d6345d GNUInstallDirs: Set UNINITALIZED cache properties to type PATH
Also convert the path to a cmake path
2016-12-12 22:23:26 +00:00