build: build only the compiler and drop the example project

The example duplicated what Demo already covers, and the run mode needs the
runtime include path and Lua link flags at execution time, so they are baked in
at configure time.
This commit is contained in:
BlackAngelTV committed 2026-11-18 08:48:05 +01:00
1 parent 42e95d08b9
commit d32f73006e
8 files changed
+46 -126

No files matched your search

+18 -6
View File
@@ -5,7 +5,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(LUACPP_BUILD_EXAMPLES "Build the example package and program" ON)
option(LUACPP_BUILD_TESTS "Build the conformance test" ON)
# --- Lua 5.4 -----------------------------------------------------------------
@@ -30,21 +29,34 @@ else()
endif()
# --- compiler ----------------------------------------------------------------
# `luacpp run` needs to invoke the C++ compiler and link the Lua VM itself, so
# the include path and link flags are baked into the binary at configure time.
if(LUA54_FOUND)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --cflags lua5.4
OUTPUT_VARIABLE _lua_cflags OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --libs lua5.4
OUTPUT_VARIABLE _lua_libs OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(_lua_cflags "-I${LUA_INCLUDE_DIR}")
string(REPLACE ";" " " _lua_libs "${LUA_LIBRARIES}")
endif()
set(LUACPP_RUNTIME_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(LUACPP_LUA_CFLAGS "${_lua_cflags}")
set(LUACPP_LUA_LIBS "${_lua_libs}")
configure_file(cmake/luacpp-config.hpp.in
"${CMAKE_CURRENT_BINARY_DIR}/generated/luacpp-config.hpp" @ONLY)
add_executable(luacpp
src/main.cpp
src/frontend.cpp
src/codegen.cpp)
target_include_directories(luacpp PRIVATE src)
target_include_directories(luacpp PRIVATE src "${CMAKE_CURRENT_BINARY_DIR}/generated")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(luacpp PRIVATE -Wall -Wextra -Wpedantic)
endif()
include(cmake/lua-package.cmake)
if(LUACPP_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(LUACPP_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)