Skip to content

Instantly share code, notes, and snippets.

@jacmoe
Forked from squeek502/CMakeLists.txt
Created December 23, 2020 21:10
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 jacmoe/71e6bdedb0cfcefee259da9bb1ea1104 to your computer and use it in GitHub Desktop.
Save jacmoe/71e6bdedb0cfcefee259da9bb1ea1104 to your computer and use it in GitHub Desktop.
Lua 5.3.x Windows CMake build script
  • Add CMakeLists.txt and make.bat to a Lua 5.3.x source code download from here: https://www.lua.org/ftp/
  • Execute make.bat
project ( lua C )
cmake_minimum_required ( VERSION 2.8 )
include_directories ( src ${CMAKE_CURRENT_BINARY_DIR} )
set ( SRC_CORE src/lapi.c src/lcode.c src/lctype.c src/ldebug.c src/ldo.c src/ldump.c src/lfunc.c src/lgc.c src/llex.c
src/lmem.c src/lobject.c src/lopcodes.c src/lparser.c src/lstate.c src/lstring.c src/ltable.c
src/ltm.c src/lundump.c src/lvm.c src/lzio.c )
set ( SRC_LIB src/lauxlib.c src/lbaselib.c src/lbitlib.c src/lcorolib.c src/ldblib.c src/liolib.c
src/lmathlib.c src/loslib.c src/lstrlib.c src/ltablib.c src/lutf8lib.c src/loadlib.c src/linit.c )
set ( SRC_LUA src/lua.c )
set ( SRC_LUAC src/luac.c )
add_library ( liblua ${SRC_CORE} ${SRC_LIB} )
set_target_properties ( liblua PROPERTIES OUTPUT_NAME lua )
add_library ( libluadll SHARED ${SRC_CORE} ${SRC_LIB} )
target_compile_definitions ( libluadll PRIVATE _CRT_SECURE_NO_WARNINGS LUA_BUILD_AS_DLL )
set_target_properties ( libluadll PROPERTIES OUTPUT_NAME lua53 )
add_executable ( lua ${SRC_LUA} )
target_link_libraries ( lua libluadll )
add_executable ( luac ${SRC_LUAC} )
target_link_libraries ( luac liblua )
@echo off
set GENERATOR=Visual Studio 12
reg query HKEY_CLASSES_ROOT\VisualStudio.DTE.14.0 >nul 2>nul
IF %errorlevel%==0 set GENERATOR=Visual Studio 14
if not defined platform set platform=x64
if "%platform%" EQU "x64" (set GENERATOR=%GENERATOR% Win64)
IF NOT "x%1" == "x" GOTO :%1
GOTO :build
:build
cmake -H. -Bbuild -G"%GENERATOR%"
cmake --build build --config Release
COPY build\Release\lua.exe .
GOTO :end
:clean
IF EXIST build RMDIR /S /Q build
IF EXIST lua.exe DEL /F /Q lua.exe
GOTO :end
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment