From 1352f42854cb7fd060717902566fbe2590c19b34 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 26 Apr 2012 16:17:12 +0000 Subject: [PATCH] - added support for checking if LuaJit library is installed and use that instead of normal Lua for increased lua performance (Currently only implemented in gcc builds) --- mk/cmake/Modules/FindLUAJIT.cmake | 36 +++++++++++++++++++++++++++++++ mk/linux/setupBuildDeps.sh | 6 +++--- source/shared_lib/CMakeLists.txt | 23 +++++++++++++++----- 3 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 mk/cmake/Modules/FindLUAJIT.cmake diff --git a/mk/cmake/Modules/FindLUAJIT.cmake b/mk/cmake/Modules/FindLUAJIT.cmake new file mode 100644 index 000000000..a4342ee65 --- /dev/null +++ b/mk/cmake/Modules/FindLUAJIT.cmake @@ -0,0 +1,36 @@ +# Find the LuaJIT includes and library +# +# LUAJIT_INCLUDE_DIR - where to find lua.h +# LUAJIT_LIBRARIES - List of fully qualified libraries to link against +# LUAJIT_FOUND - Set to TRUE if found + +# Copyright (c) 2012, Mark Vejvoda, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +OPTION(WANT_STATIC_LIBS "builds as many static libs as possible" OFF) +IF(WANT_STATIC_LIBS) + OPTION(LUAJIT_FIND_STATIC "Set to ON to link your project with static library (instead of DLL)." ON) +ENDIF() + +find_path(LUAJIT_INCLUDE_DIR luajit.h + NAMES luajit.h + PATH_SUFFIXES luajit-2.0) + +if (LUAJIT_FIND_STATIC) + find_library(LUAJIT_LIBRARIES luajit.a + NAMES libluajit-5.1.a) +else (LUATJIT_FIND_STATIC) + find_library(LUAJIT_LIBRARIES luajit + NAMES luajit-5.1) +endif (LUAJIT_FIND_STATIC) + +mark_as_advanced(LUAJIT_INCLUDE_DIR) +mark_as_advanced(LUAJIT_LIBRARIES) + +# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LUAJIT DEFAULT_MSG LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR) + diff --git a/mk/linux/setupBuildDeps.sh b/mk/linux/setupBuildDeps.sh index 15b22520b..d4a27b62b 100755 --- a/mk/linux/setupBuildDeps.sh +++ b/mk/linux/setupBuildDeps.sh @@ -28,12 +28,12 @@ elif [ -f /etc/fedora-release ]; then sudo yum install SDL-devel xerces-c-devel mesa-libGL-devel mesa-libGLU-devel libvorbis-devel wxBase wxGTK-devel lua-devel libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libX11-devel libxml2-dev libircclient-dev glew-devel ftgl-devel elif [ "$OSTYPE" = "i686" ] && [ "$version" = "Ubuntu" ]; then echo "=====> Using build deps for old Ubuntu 8.04..." - sudo apt-get install libsdl1.2-dev libxerces28-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev + sudo apt-get install libsdl1.2-dev libxerces28-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libxml2-dev libircclient-dev libglew-dev libluajit-5.1-dev elif [ "$OSTYPE" = "x86_64" ]; then echo "=====> Using build deps for debian based 64 bit linux..." - sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev cmake-curses-gui libgtk2.0-dev libxml2-dev libircclient-dev libftgl-dev libminiupnpc-dev libglew-dev librtmp-dev + sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev cmake-curses-gui libgtk2.0-dev libxml2-dev libircclient-dev libftgl-dev libminiupnpc-dev libglew-dev librtmp-dev libluajit-5.1-dev else echo "=====> Using build deps for debian based 32 bit Linux..." - sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev cmake-curses-gui libgtk2.0-dev libxml2-dev libircclient-dev libftgl-dev libminiupnpc-dev libglew-dev librtmp-dev + sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev cmake-curses-gui libgtk2.0-dev libxml2-dev libircclient-dev libftgl-dev libminiupnpc-dev libglew-dev librtmp-dev libluajit-5.1-dev fi diff --git a/source/shared_lib/CMakeLists.txt b/source/shared_lib/CMakeLists.txt index a4ebf532d..f551160a4 100644 --- a/source/shared_lib/CMakeLists.txt +++ b/source/shared_lib/CMakeLists.txt @@ -109,11 +109,24 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST # SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${VORBIS_FILE_LIBRARY}) # ENDIF() - FIND_PACKAGE(LUA REQUIRED) - INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) - IF(UNIX) - SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${LUA_LIBRARIES}) - ENDIF() + + FIND_PACKAGE(LUAJIT) + IF(LUAJIT_FOUND) + MESSAGE(STATUS "**NOTE: LUAJIT found and will grealy improve Lua performance.") + + INCLUDE_DIRECTORIES(${LUAJIT_INCLUDE_DIR}) + IF(UNIX) + SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${LUAJIT_LIBRARIES}) + ENDIF() + ELSE() + MESSAGE(STATUS "**WARNING: LUAJIT NOT found and will grealy affect Lua performance.") + + FIND_PACKAGE(LUA REQUIRED) + INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) + IF(UNIX) + SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${LUA_LIBRARIES}) + ENDIF() + ENDIF() OPTION(WANT_STATIC_LIBS "builds as many static libs as possible" OFF)