FindLuaJIT.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Locate LuaJIT library
  2. # This module defines
  3. # LUAJIT_FOUND, if false, do not try to link to Lua
  4. # LUA_INCLUDE_DIR, where to find lua.h
  5. # LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
  6. #
  7. # This module is similar to FindLua51.cmake except that it finds LuaJit instead.
  8. FIND_PATH(LUA_INCLUDE_DIR luajit.h
  9. HINTS
  10. $ENV{LUA_DIR}
  11. PATH_SUFFIXES include/luajit-2.1 include/luajit-2.0 include/luajit-5_1-2.1 include/luajit-5_1-2.0 include luajit
  12. PATHS
  13. ~/Library/Frameworks
  14. /Library/Frameworks
  15. /sw # Fink
  16. /opt/local # DarwinPorts
  17. /opt/csw # Blastwave
  18. /opt
  19. )
  20. # Test if running on vcpkg toolchain
  21. if(DEFINED VCPKG_TARGET_TRIPLET AND DEFINED VCPKG_APPLOCAL_DEPS)
  22. # On vcpkg luajit is 'lua51' and normal lua is 'lua'
  23. FIND_LIBRARY(LUA_LIBRARY
  24. NAMES lua51
  25. HINTS
  26. $ENV{LUA_DIR}
  27. PATH_SUFFIXES lib
  28. )
  29. else()
  30. FIND_LIBRARY(LUA_LIBRARY
  31. NAMES luajit-5.1
  32. HINTS
  33. $ENV{LUA_DIR}
  34. PATH_SUFFIXES lib64 lib
  35. PATHS
  36. ~/Library/Frameworks
  37. /Library/Frameworks
  38. /sw
  39. /opt/local
  40. /opt/csw
  41. /opt
  42. )
  43. endif()
  44. IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
  45. FILE(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT .+\"")
  46. STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
  47. UNSET(lua_version_str)
  48. ENDIF()
  49. INCLUDE(FindPackageHandleStandardArgs)
  50. # handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
  51. # all listed variables are TRUE
  52. FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
  53. REQUIRED_VARS LUA_LIBRARY LUA_INCLUDE_DIR
  54. VERSION_VAR LUA_VERSION_STRING)
  55. MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)