Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 41
Example: C module
drahosp edited this page Feb 19, 2013
·
4 revisions
Writing CMake scripts for installing C modules without dependenies is very straightforward. The following steps are required:
- Define project name - This is usually equal to the name of the module.
- Copy the cmake macro folder directory from our Tools
- Create the module using a macro
- Write commands for installing module and other files
For example here is the CMake script for building the LPeg module:
# Define projects name# The C tells CMAKE to check for C compilersproject ( lpeg C )
# Define minimun version of CMAKE for compatibilitycmake_minimum_required ( VERSION2.8 )
# Include dist.cmake - defines LuaDist related macros and install paths# Also include Lua related macrosinclude ( cmake/dist.cmake )
include ( lua )
# Create and install a Lua module:# first parameter is module's name (the name that can be required in Lua)# second and following parameters are the source files (here only one file)# last parameter is a .def file for exporting symbols from dll produced by MS compilersinstall_lua_module ( lpeglpeg.clpeg.def)
install_lua_module ( rere.lua )
# Schedules a test, this is optionaladd_lua_test ( test.lua )
# Install test ( NOTE: This does not execute testing, just installs)install_test ( test.lua )
# Install documentationinstall_doc ( re.htmllpeg.htmllpeg-128.gif )If a module is build from multiple files, e.g. md5 module, the following form can be used:
# Multiple files in subdirectory with linkinstall_lua_module ( other.lib.coresrc/core.csrc/util.cLINK${SOME_LIB}${SOME_OTHER_LIB} )Additionally file paths can be stored as a list in a variable and passed into the macro. You can find out more abut CMake by reading the full documentation.