mapbox / mason

Cross platform package manager for C/C++ apps
BSD 2-Clause "Simplified" License
255 stars 69 forks source link

Mason CMake #339

Open kkaefer opened 7 years ago

kkaefer commented 7 years ago

Following https://github.com/mapbox/mason/issues/187, my long term goal is to split Mason in two pieces: A small-ish client that downloads/installs/uses packages, and a system that builds packages.

We're using the CMake script in gl-native with much success so far; except for a special-case to support old packages, it does not have a dependency on the scripts folder (cf. https://github.com/mapbox/mason/issues/186). Since that is only required for old packages, we don't need it anymore, now that we have newer versions of all packages.

I believe there's value in only having one canonical client rather than several concurrent implementations. Therefore, I'd like to evolve the CMake client and make it the canonical way of using CMake. In gl-native, our build system doesn't require the shell-script based version anymore, but some other supporting scripts still require it, and we use it to install dependencies on CI.

The road forward I am imagining looks like this:

This leaves out one use case: Installing cross compilers. Right now, we have dedicated support for Android toolchain flags built into Mason. Instead of having it there, I'd like to make this more generic, along the lines of toolchain.cmake/sh (see GCC package). This requires somewhat standardizing the format (/cc @springmeyer @tmpsantos) so that we can switch between compilers more easily.

Another thing to consider when removing the scripts dependency is that we have to manually mark packages as HEADER_ONLY when installing. mason.cmake does this by supporting a syntax like this: mason_use(geometry VERSION 0.9.0 HEADER_ONLY). It might be a good idea to support the same syntax instead of porting over mason.sh syntax: cmake/mason.cmake install geometry VERSION 0.9.0 HEADER_ONLY

kkaefer commented 7 years ago

See https://github.com/mapbox/mapbox-gl-native/blob/remove-mason/cmake/mason.cmake for an altered version of mason.cmake that does this.

Unfortunately, Linux systems can't pass arguments in the shebang, so we'll have to resort to a helper script that just forwards the args and adds -P

springmeyer commented 7 years ago

👍 It feels right to me to be able to use mason packages without the mason bash installation client when appropriate. Thanks for pushing this forward.

I believe there's value in only having one canonical client rather than several concurrent implementations.

The bash client will remain of value however to projects that don't use cmake, right?

mapsam commented 6 years ago

I'm just starting to learn cmake, so pardon if this comment doesn't make a ton of sense!

I'd love to be able to automatically install a common mason.cmake file, like this one - could this live as a template in mason and be added to a project with a (future) Mason client? Something like:

mason init --cmake

Which adds a cmake/mason.cmake file to the project folder.

springmeyer commented 6 years ago

I like how you are thinking here @mapsam. Before I answer specifically I'll sketch out a basic vision for how I think "mason clients" should work.

Certainly, once mason.cmake is moved from https://github.com/mapbox/mason/blob/master/mason.cmake to a separate repo is would be easy, for ease of use, to add a command to the nodejs or bash that would init the cmake file. I think your idea of mason init --cmake is great.

Currently users of mason.cmake all copy/vendorize. So I think it would be a non-breaking change to move https://github.com/mapbox/mason/blob/master/mason.cmake to https://github.com/mapbox/mason-cmake or the like. @kkaefer @mapsam - thoughts?