Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Example: Lua module

drahosp edited this page Mar 19, 2011 · 5 revisions

Building pure Lua modules

The CMake script for installing pure modules is easy.

All you have to do is:

  • define project name - usually the name of the module.
  • include dist.cmake - this file provides macros relevant to LuaDist and will set up all variables that contain instalation paths.
  • write commands for installing module's files.

Here is an commented example fo the Abelhas module:

# Define projects name
# The NONE tells CMake to not check for compilers as they are not needed
project ( abelhas NONE )

# Define minimun version of CMake for compatibility
cmake_minimum_required ( VERSION 2.6 )

# Include dist.cmake - defines some macros and install paths
include ( dist.cmake )

# All is set up, so install:
# First argument is the require name. Second argument is the source of the module.
install_lua_module ( pso pso.lua )
# or: install_lua_module ( pso.submodule src/pso_submodule.lua )
# LuaDist will take care of the installation and renaming automatically

# Install files README COPYING to data directory
install_data ( README COPYING )

# Install all files from examples directory
install_example ( examples/ )

# Install the content of the doc directory
install_doc ( doc/ )

That's all. Alternatively you can use CMake INSTALL command and install using INSTALL_* variables, but the included macro simplifies things considerably.

If you want to install a lua based application simply call:

install_lua_executable ( app_name src/app.lua )

LuaDist will automatically generate a binary executable for your application.