Coder Social home page Coder Social logo

lua-cmake's Introduction

Easily embed lua into applications managed with CMake

Due to its simplicity and portability, Lua became a popular choice for extending applications through a scripting language. The interpreter is available on most platforms, however, depending on globally installed packages is not always reliable (outdated versions, static vs. dynamic library etc.). As compile times of the interpreter are neglible, embedding it as a git submodule can be preferrable. To simplify the Lua integration into cmake-managed projects, this repository offers two simple facilities.

  • The CMakeLists.txt contains instructions for building the interpreter as a library. It is intended to be used via cmake's add_subdirectory command, and sets up the lua::lib target that can be linked against. Public headers are taken care of and are propagated as a usage requirement.
  • A git clone of the upstream sources is configured as a submodule, such that recursive initialization of this repository pulls them in.

The Lua version pulled in is the current v5.4.1. The library is built as C (not C++, which is possible), with default upstream compiler flags. Whether a shared or static library is built depends on cmake's BUILD_SHARED_LIBS flag. No install target is configured and no standalone executable is built, given the intended use case.

Here's how to use it:

cd path/to/your/project

git submodule add https://github.com/lubgr/lua-cmake external/lua

# Necessary to automatically pull the upstream Lua sources:
git submodule update --init --recursive external/lua

In the CMakeLists.txt of your application, add

add_subdirectory(external/lua)

target_link_libraries(yourTarget PRIVATE lua::lib)

That's it. Further integration with a library to facilitate the bindings (e.g. sol2) is straightfoward.

lua-cmake's People

Contributors

lubgr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lua-cmake's Issues

Git command doesn't work

I have tried using powershell, git bash, and cmd with your command, all of which under administrator/elevated privileges, and all of which were properly cd'd to the correct directory (which clearly has no bearing on this type of error anyways), and each and every time the bash/terminal returns to me this error.

"fatal: not a git repository (or any of the parent directories): .git"

The command I was using was the one listed on projects main page

git submodule add https://github.com/lubgr/lua-cmake external/lua

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.