diff --git a/CMakeLists.txt b/CMakeLists.txt index a7fcb9b399..b911ccfec2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,14 +213,18 @@ if(COMPILE_LUA AND NOT WIN32) foreach(CURRENT_LUAC_PRG luac5.1 luac) find_program(_CHECK_LUAC_PRG ${CURRENT_LUAC_PRG}) if(_CHECK_LUAC_PRG) - set(LUAC_PRG "${_CHECK_LUAC_PRG} -s -o - %s" CACHE STRING "Format for compiling to Lua bytecode") + # Escape "%" for string.format() (in gen_char_blob.lua). #39271 + string(REPLACE "%" "%%" _LUAC_PRG_ESCAPED "${_CHECK_LUAC_PRG}") + set(LUAC_PRG "${_LUAC_PRG_ESCAPED} -s -o - %q" CACHE STRING "Format for compiling to Lua bytecode") break() endif() endforeach() elseif(LUA_PRG MATCHES "luajit") check_lua_module(${LUA_PRG} "jit.bcsave" LUAJIT_HAS_JIT_BCSAVE) if(LUAJIT_HAS_JIT_BCSAVE) - set(LUAC_PRG "${LUA_PRG} -b -s %s -" CACHE STRING "Format for compiling to Lua bytecode") + # Escape "%" for string.format() (in gen_char_blob.lua). #39271 + string(REPLACE "%" "%%" _LUA_PRG_ESCAPED "${LUA_PRG}") + set(LUAC_PRG "${_LUA_PRG_ESCAPED} -b -s %q -" CACHE STRING "Format for compiling to Lua bytecode") endif() endif() endif()