Modern CMake (3.20+) build system for C++23 Lua implementation.
# 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| 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 |
Debug with sanitizers:
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DLUA_ENABLE_ASAN=ON -DLUA_ENABLE_UBSAN=ON
cmake --build buildCode 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_htmlRelease with LTO:
cmake -B build -DCMAKE_BUILD_TYPE=Release -DLUA_ENABLE_LTO=ON
cmake --build buildProduction:
cmake -B build -DCMAKE_BUILD_TYPE=Release -DLUA_BUILD_TESTS=OFF -DLUA_BUILD_SHARED=ON
cmake --build build- liblua_static: Static library
liblua.a - liblua_shared: Shared library
liblua.so(if enabled) - lua: Lua interpreter executable
cd build && ctest # Run all tests
cd build && ctest --output-on-failure # Verbosecmake --build build --parallel
cmake --build build -- -j$(nproc)cmake --build build --target clean # Clean artifacts
rm -rf build # Full clean