2016-03-06 20:42:49 -07:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
set(LUA_TARGET linux)
|
2023-03-02 14:50:43 -07:00
|
|
|
elseif(APPLE)
|
2016-03-06 20:42:49 -07:00
|
|
|
set(LUA_TARGET macosx)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
|
|
|
set(LUA_TARGET freebsd)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "BSD")
|
2023-09-03 15:00:26 -07:00
|
|
|
set(LUA_TARGET bsd)
|
2022-05-17 06:08:24 -07:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "^MINGW")
|
2023-09-03 15:00:26 -07:00
|
|
|
set(LUA_TARGET mingw)
|
2016-03-06 20:42:49 -07:00
|
|
|
else()
|
|
|
|
if(UNIX)
|
|
|
|
set(LUA_TARGET posix)
|
|
|
|
else()
|
|
|
|
set(LUA_TARGET generic)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-09-03 15:00:26 -07:00
|
|
|
set(LUA_CFLAGS "-O2 -g3 -fPIC")
|
2017-01-21 18:21:27 -07:00
|
|
|
set(LUA_LDFLAGS "")
|
|
|
|
|
2023-03-16 11:24:04 -07:00
|
|
|
if(ENABLE_ASAN_UBSAN)
|
2017-01-21 18:21:27 -07:00
|
|
|
set(LUA_CFLAGS "${LUA_CFLAGS} -fsanitize=address")
|
|
|
|
set(LUA_CFLAGS "${LUA_CFLAGS} -fno-omit-frame-pointer")
|
|
|
|
set(LUA_CFLAGS "${LUA_CFLAGS} -fno-optimize-sibling-calls")
|
|
|
|
|
|
|
|
set(LUA_LDFLAGS "${LUA_LDFLAGS} -fsanitize=address")
|
|
|
|
endif()
|
|
|
|
|
2016-03-06 20:42:49 -07:00
|
|
|
set(LUA_CONFIGURE_COMMAND
|
2022-09-11 04:39:49 -07:00
|
|
|
sed -e "/^CC/s@gcc@${CMAKE_C_COMPILER}@"
|
2017-01-21 18:21:27 -07:00
|
|
|
-e "/^CFLAGS/s@-O2@${LUA_CFLAGS}@"
|
|
|
|
-e "/^MYLDFLAGS/s@$@${LUA_LDFLAGS}@"
|
2016-03-06 20:42:49 -07:00
|
|
|
-e "s@-lreadline@@g"
|
|
|
|
-e "s@-lhistory@@g"
|
|
|
|
-e "s@-lncurses@@g"
|
|
|
|
-i ${DEPS_BUILD_DIR}/src/lua/src/Makefile &&
|
|
|
|
sed -e "/#define LUA_USE_READLINE/d"
|
2018-02-01 10:42:42 -07:00
|
|
|
-e "s@\\(#define LUA_ROOT[ ]*\"\\)/usr/local@\\1${DEPS_INSTALL_DIR}@"
|
2016-03-06 20:42:49 -07:00
|
|
|
-i ${DEPS_BUILD_DIR}/src/lua/src/luaconf.h)
|
2017-01-21 18:21:27 -07:00
|
|
|
set(LUA_INSTALL_TOP_ARG "INSTALL_TOP=${DEPS_INSTALL_DIR}")
|
2016-03-06 20:42:49 -07:00
|
|
|
|
2024-03-18 04:23:53 -07:00
|
|
|
get_externalproject_options(lua ${DEPS_IGNORE_SHA})
|
2022-08-29 07:57:46 -07:00
|
|
|
ExternalProject_Add(lua
|
|
|
|
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/lua
|
|
|
|
CONFIGURE_COMMAND "${LUA_CONFIGURE_COMMAND}"
|
|
|
|
BUILD_IN_SOURCE 1
|
|
|
|
BUILD_COMMAND ${MAKE_PRG} ${LUA_INSTALL_TOP_ARG} ${LUA_TARGET}
|
2023-11-20 04:42:54 -07:00
|
|
|
INSTALL_COMMAND ${MAKE_PRG} ${LUA_INSTALL_TOP_ARG} install
|
|
|
|
${EXTERNALPROJECT_OPTIONS})
|