Need: a generic tool to quickly turn any CMake or configure-based source code tree into an executable without manual step.
You're a programmer and often get source code (github, tar.gz, whatever) to try.
Here we focus on software that, for its build process, uses CMake
or
a configure
script generated by autotools (generally C or C++
programs).
Whenever you get any CMake
or configure
-based source tree from the
net, CMake
or configure
does the heavy lifting, yet some steps remain:
-
manually create up a build directory, (if out-of-source-build is wished, which is always good practice) which implies...
-
...manually choose a name for build and install directories depending on some factors, like the operating system used to compile (any experienced Linux user knows what happens when using binaries made for another distribution or release).
-
manually do a configure step,
-
manually set up an install directory (if installing without root privilege either by choice like I do, or because system-wide install is not even possible and even when it is, needs password prompting)
It makes sense that CMake
and configure
keeps those steps manual
because it is a generic tool, and there's no generic answer to those
steps.
But in your context, you probably have your usual answers to what
CMake
or configure
needs. So, why not write those answers once
and for all?
-
Call the script, it does all the steps above so you don't have to. You just get your software runnable.
-
Profit!
-
No downside, script is just a wrapper to the initial
CMake
orconfigure
call. You can do what you wish of the resulting tree. -
Fully scriptable, you can also provide additional
configure
-time argument toCMake
orconfigure
if needed, in the form of additional arguments to the script.
Build and install tree are named based on OS name and version.
This means that there's never any doubt about which operating system a particular build/install directory is targetting.
-
This averts the scenario of running old build/install trees in newer versions of distributions, which too often results in:
-
missing library at run time (because distribution upgraded to a newer binary-incompatible library, as binary linking is less flexible than compilation-time configuration),
-
and/or crashes due to subtle library breakage.
-
-
This allows to easily find and purge versions for old OSes.
find /mystorage -iname "*.OSID_myoldOS.*tree" -print0 | xargs -0 rm -rf
Also, OS-marks are compatible with multi-architecture scripts. You can for example compute OS_ID in another script and refer e.g. to:
/path/to/some-tool.OSID_${OS_ID}.installtree/bin/awesometool
and expect it to do the right thing.
If you change OS, just re-run the script on your new OS and bam it works!
So is most free software. Even more when people share their .emacs
configuration, etc.
But you can fork this repo and adapt the script to your local context!
The scripts are self-contained and self-explanatory, see cmake_project_bootstrap.sh and configure_project_bootstrap.sh.