elixir_cmake v0.8.0 mix compile.cmake View Source

Builds native source using CMake Runs cmake in the current project (followed by make) .

This task runs cmake in the current project; any output coming from cmake is printed in real-time on stdout.

Configuration

This compiler can be configured through the return value of the project/0 function in mix.exs; for example:

def project() do
  [
    # ...
    compilers: [:cmake] ++ Mix.compilers,
    # ...
  ]
end

The following options are available:

  • :cmake_env - (map of binary to binary) it's a map of extra environment variables to be passed to cmake. You can also pass a function in here in case make_env needs access to things that are not available during project setup; the function should return a map of binary to binary. Many default environment variables are set, see section below

Default environment variables

There are also several default environment variables set:

Compilation artifacts and working with priv directories

Generally speaking, compilation artifacts are written to the priv directory, as that the only directory, besides ebin, which are available to Erlang/OTP applications. However, note that Mix projects supports the :build_embedded configuration, which controls if assets in the _build directory are symlinked (when false, the default) or copied (true). In order to support both options for :build_embedded, it is important to follow the given guidelines:

  • The "priv" directory must not exist in the source code
  • The Makefile should copy any artifact to $MIX_APP_PATH/priv or, even better, to $MIX_APP_PATH/priv/$MIX_TARGET
  • If there are static assets, the Makefile should copy them over from a directory at the project root (not named "priv")

Link to this section Summary

Functions

Removes compiled artifacts

Runs this task

Link to this section Functions

Removes compiled artifacts.

Runs this task.