Add cmake-default script

main
Sean Hickey 2021-09-07 22:19:42 -07:00
parent 2d755b811b
commit 3718ad90e9
2 changed files with 43 additions and 0 deletions

View File

@ -67,7 +67,32 @@ limitations/properties:
* These are only installed for the user that ran the script.
* The thing pointed to by each symlink can change out from under you.
## Alternatives
I may have finally found a more "correct" alternative to this where I
actually used `~/usr/local` as my install prefix. I always found it
annoying that I couldn't change an install prefix after waiting for
the entire `make` command to run. The default prefix is always
`/usr/local` which requires root privileges to install into. However,
there is apparently the [env variable `DESTDIR`][1] which will at
least allow you to add a prefix in front of the default prefix. It
won't "change" it, so you're always stuck with `/usr/local` unless you
actually set the `--prefix` flag before building. But this does let
you do `asdf/usr/local`.
```sh
make DESTDIR=$HOME install
```
```sh
cmake DESTDIR=$HOME --install ./
```
# Copyright
I think this script is too small to reasonably apply copyright
to. It is in the Public Domain.
[1]: https://cmake.org/cmake/help/latest/envvar/DESTDIR.html#envvar:DESTDIR
[2]:

18
cmake-default.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env sh
set -o errexit
mkdir build
cd build
# Source common settings
. $HOME/usr/local/share/config.site
# Configure
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$HOME/usr/local \
$@
# Build
ninja