BuildLua.cmake 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  2. set(LUA_TARGET linux)
  3. elseif(APPLE)
  4. set(LUA_TARGET macosx)
  5. elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
  6. set(LUA_TARGET freebsd)
  7. elseif(CMAKE_SYSTEM_NAME MATCHES "BSD")
  8. set(LUA_TARGET bsd)
  9. elseif(CMAKE_SYSTEM_NAME MATCHES "^MINGW")
  10. set(LUA_TARGET mingw)
  11. else()
  12. if(UNIX)
  13. set(LUA_TARGET posix)
  14. else()
  15. set(LUA_TARGET generic)
  16. endif()
  17. endif()
  18. set(LUA_CFLAGS "-O2 -g3 -fPIC")
  19. set(LUA_LDFLAGS "")
  20. if(ENABLE_ASAN_UBSAN)
  21. set(LUA_CFLAGS "${LUA_CFLAGS} -fsanitize=address")
  22. set(LUA_CFLAGS "${LUA_CFLAGS} -fno-omit-frame-pointer")
  23. set(LUA_CFLAGS "${LUA_CFLAGS} -fno-optimize-sibling-calls")
  24. set(LUA_LDFLAGS "${LUA_LDFLAGS} -fsanitize=address")
  25. endif()
  26. set(LUA_CONFIGURE_COMMAND
  27. sed -e "/^CC/s@gcc@${CMAKE_C_COMPILER}@"
  28. -e "/^CFLAGS/s@-O2@${LUA_CFLAGS}@"
  29. -e "/^MYLDFLAGS/s@$@${LUA_LDFLAGS}@"
  30. -e "s@-lreadline@@g"
  31. -e "s@-lhistory@@g"
  32. -e "s@-lncurses@@g"
  33. -i ${DEPS_BUILD_DIR}/src/lua/src/Makefile &&
  34. sed -e "/#define LUA_USE_READLINE/d"
  35. -e "s@\\(#define LUA_ROOT[ ]*\"\\)/usr/local@\\1${DEPS_INSTALL_DIR}@"
  36. -i ${DEPS_BUILD_DIR}/src/lua/src/luaconf.h)
  37. set(LUA_INSTALL_TOP_ARG "INSTALL_TOP=${DEPS_INSTALL_DIR}")
  38. get_externalproject_options(lua ${DEPS_IGNORE_SHA})
  39. ExternalProject_Add(lua
  40. DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/lua
  41. CONFIGURE_COMMAND "${LUA_CONFIGURE_COMMAND}"
  42. BUILD_IN_SOURCE 1
  43. BUILD_COMMAND ${MAKE_PRG} ${LUA_INSTALL_TOP_ARG} ${LUA_TARGET}
  44. INSTALL_COMMAND ${MAKE_PRG} ${LUA_INSTALL_TOP_ARG} install
  45. ${EXTERNALPROJECT_OPTIONS})