Skip to content

Instantly share code, notes, and snippets.

@DarkKowalski
Last active September 14, 2023 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarkKowalski/ca2f53e3a0f91c6f2cab7557945f4d91 to your computer and use it in GitHub Desktop.
Save DarkKowalski/ca2f53e3a0f91c6f2cab7557945f4d91 to your computer and use it in GitHub Desktop.
Compile Lua on Windows
# cmake -B build -DCMAKE_INSTALL_PREFIX=out
# cmake --build build --config RelWithDebInfo
# cmake --install build --config RelWithDebInfo
cmake_minimum_required(VERSION 3.24)
project(lua VERSION 5.4.6 LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(LUA_LIBRARY_SOURCE_FILES
lapi.c
lauxlib.c
lbaselib.c
lcode.c
lcorolib.c
lctype.c
ldblib.c
ldebug.c
ldo.c
ldump.c
lfunc.c
lgc.c
linit.c
liolib.c
llex.c
lmathlib.c
lmem.c
loadlib.c
lobject.c
lopcodes.c
loslib.c
lparser.c
lstate.c
lstring.c
lstrlib.c
ltable.c
ltablib.c
ltests.c
ltm.c
lundump.c
lutf8lib.c
lvm.c
lzio.c
)
set(LUA_PUBLIC_HEADER_FILES
lua.h
luaconf.h
lualib.h
lauxlib.h
)
add_library(lua54 SHARED ${LUA_LIBRARY_SOURCE_FILES})
set_target_properties(lua54 PROPERTIES
PUBLIC_HEADER "${LUA_PUBLIC_HEADER_FILES}"
)
if(MSVC)
target_compile_options(lua54 PRIVATE /GL)
target_link_options(lua54 PRIVATE /LTCG)
endif()
if(WIN32)
target_compile_definitions(lua54 PRIVATE LUA_BUILD_AS_DLL)
add_executable(lua lua.c)
target_link_libraries(lua lua54)
endif()
install(TARGETS lua54)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment