Skip to content

Latest commit

 

History

History
87 lines (66 loc) · 2.01 KB

File metadata and controls

87 lines (66 loc) · 2.01 KB

CMake Build Instructions

Modern CMake (3.20+) build system for C++23 Lua implementation.

Quick Start

# Configure
cmake -B build -DCMAKE_BUILD_TYPE=Release

# Build
cmake --build build

# Run tests
cd build && ctest --output-on-failure

# Install (optional)
cmake --install build --prefix /usr/local

Build Options

Option Default Description
CMAKE_BUILD_TYPE - Debug, Release, RelWithDebInfo, MinSizeRel
LUA_BUILD_TESTS ON Enable test mode with ltests.h
LUA_BUILD_SHARED OFF Build shared library
LUA_ENABLE_ASAN OFF Enable AddressSanitizer
LUA_ENABLE_UBSAN OFF Enable UndefinedBehaviorSanitizer
LUA_ENABLE_COVERAGE OFF Enable code coverage reporting (gcov/lcov)
LUA_ENABLE_LTO OFF Enable Link Time Optimization

Examples

Debug with sanitizers:

cmake -B build -DCMAKE_BUILD_TYPE=Debug -DLUA_ENABLE_ASAN=ON -DLUA_ENABLE_UBSAN=ON
cmake --build build

Code coverage:

cmake -B build -DCMAKE_BUILD_TYPE=Debug -DLUA_ENABLE_COVERAGE=ON
cmake --build build
cd testes && ../build/lua all.lua
lcov --capture --directory ../build --output-file coverage.info
genhtml coverage.info --output-directory coverage_html

Release with LTO:

cmake -B build -DCMAKE_BUILD_TYPE=Release -DLUA_ENABLE_LTO=ON
cmake --build build

Production:

cmake -B build -DCMAKE_BUILD_TYPE=Release -DLUA_BUILD_TESTS=OFF -DLUA_BUILD_SHARED=ON
cmake --build build

Targets

  • liblua_static: Static library liblua.a
  • liblua_shared: Shared library liblua.so (if enabled)
  • lua: Lua interpreter executable

Testing

cd build && ctest                # Run all tests
cd build && ctest --output-on-failure  # Verbose

Parallel Builds

cmake --build build --parallel
cmake --build build -- -j$(nproc)

Cleaning

cmake --build build --target clean  # Clean artifacts
rm -rf build                        # Full clean