Skip to content

Repository files navigation

CMake compiler for Mix

Build StatusHex Version

A CMake compiler to help building Ports/NIFs in your Elixir/mix project.

Installation

Add elixir_cmake to your list of dependencies in mix.exs:

defdepsdo[{:elixir_cmake,"~> 0.7.0"}]end

Add :cmake to your compilers in mix.exs:

defprojectdo[# ...compilers: [:cmake]++Mix.compilers(),# ...]end

Basic Usage

CMakeLists.txt

Create your CMakeLists.txt in the root of your project or specify the path to an existing CMakeLists.txt file in your project config.

defprojectdo[# ...cmake_lists: "path/to/CMakeLists.txt",# ...]end

The source files can reside anywhere the CMakeLists.txt file has access to.

You will need to copy the contents to your priv directory by either specifying a compile alias or by directing the binary output to priv/ in your CMakeLists.txt. file.

In this example we specify a project namedEXAMPLE, with source files in src/:

cmake_minimum_required(VERSION3.0)
project(EXAMPLE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY${CMAKE_SOURCE_DIR}/priv)
file(GLOBEXAMPLE_SRCsrc/*.c)
SET (CMAKE_C_FLAGS"-g -O3 -pedantic -Wall -Wextra -Wno-unused-parameter -std=c99")
include_directories(SYSTEM)
add_executable(example${EXAMPLE_SRC})

Run mix compile (or mix compile.cmake for just the CMake build) and you should find a compiled binary in priv/ afterwards.

Configuration Options

TODO

Be sure to read the documentation too.

About

CMake compiler for Mix

Topics

Resources

Stars

9 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages