Giter VIP home page Giter VIP logo

lua's Introduction

The Lua Programming Language

The Lua Programming Language with Modern CMake

.github/workflows/clang.yml .github/workflows/gcc.yml .github/workflows/osx.yml MSVC

About

This is a bundle of the Lua Programming Language v5.4.4 that provides a modern CMake script for easy inclusion into projects and installation. For usage instructions, see the next section.

logo

Usage Instructions

There are a couple of ways to integrate this bundle into your project. All of them will use the same linking code, so let's discuss how to include it first.

As a Subdirectory

The easiest way is to clone this repository directly into your source tree (i.e. under ./external/lua for example) and then adding this to your CMakelists.txt file

add_subdirectory(<path-to-lua-dir>)

You can also add this repository as a submodule using git.

Using FetchContent

An alternative use is to have CMake deal with downloading the code via FetchContent. Note that this assumes you have version at least 3.11. To add this, add the following to your CMakelists.txt:

include(FetchContent)

FetchContent_Declare(
    lua
    GIT_REPOSITORY "https://github.com/marovira/lua"
    GIT_TAG "<latest-commit-hash>"
)

FetchContent_MakeAvailable(lua)

Where <latest-commit-hash> can be retrieved from this repository.

Installing

The final option is to directly install the bundle. To do this, you must install it as with any other CMake package (build and run the install target). Once that is done, you must copy ./cmake/Findlua.cmake file into your project's directory (ideally under ./cmake/Findlua.cmake) and then add the following to your CMakelists.txt:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} <your-cmake-dir>)
find_package(lua REQUIRED)

The reason why we need a separate Findlua.cmake file is very simple: CMake does ship with a FindLua.cmake, but that file is written using an older CMake style (so we can't link using target_link_libraries). Moreover, the way in which you must install Lua isn't entirely straight-forward (especially if you don't use a package manager) unless you read through the code and figure out which directories it looks for.

Linking

Once you have added Lua to your build, you can link against it by adding:

target_link_libraries(<your-target> PRIVATE lua::lua)

Once that is done you can include the Lua headers as follows:

#include <lua.h>

You will find an example executable under the ./test directory containing a sample CMake configuration for building with this bundle.

Licenses

Lua is published under the MIT license and can be viewed here. For more information, please see their official website here.

This bundle is published under the BSD-3 license can be viewed here

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.