FindLuaJit.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # - Try to find luajit
  2. # Once done this will define
  3. # LUAJIT_FOUND - System has luajit
  4. # LUAJIT_INCLUDE_DIRS - The luajit include directories
  5. # LUAJIT_LIBRARIES - The libraries needed to use luajit
  6. if(NOT USE_BUNDLED_LUAJIT)
  7. find_package(PkgConfig)
  8. if (PKG_CONFIG_FOUND)
  9. pkg_check_modules(PC_LUAJIT QUIET luajit)
  10. endif()
  11. else()
  12. set(PC_LUAJIT_INCLUDEDIR)
  13. set(PC_LUAJIT_INCLUDE_DIRS)
  14. set(PC_LUAJIT_LIBDIR)
  15. set(PC_LUAJIT_LIBRARY_DIRS)
  16. set(LIMIT_SEARCH NO_DEFAULT_PATH)
  17. endif()
  18. set(LUAJIT_DEFINITIONS ${PC_LUAJIT_CFLAGS_OTHER})
  19. find_path(LUAJIT_INCLUDE_DIR luajit.h
  20. PATHS ${PC_LUAJIT_INCLUDEDIR} ${PC_LUAJIT_INCLUDE_DIRS}
  21. PATH_SUFFIXES luajit-2.0
  22. ${LIMIT_SEARCH})
  23. # If we're asked to use static linkage, add libluajit-5.1.a as a preferred
  24. # library name.
  25. if(LUAJIT_USE_STATIC)
  26. list(APPEND LUAJIT_NAMES
  27. "${CMAKE_STATIC_LIBRARY_PREFIX}luajit-5.1${CMAKE_STATIC_LIBRARY_SUFFIX}")
  28. endif()
  29. if(MSVC)
  30. list(APPEND LUAJIT_NAMES lua51)
  31. elseif(MINGW)
  32. list(APPEND LUAJIT_NAMES libluajit libluajit-5.1)
  33. else()
  34. list(APPEND LUAJIT_NAMES luajit-5.1)
  35. endif()
  36. find_library(LUAJIT_LIBRARY NAMES ${LUAJIT_NAMES}
  37. PATHS ${PC_LUAJIT_LIBDIR} ${PC_LUAJIT_LIBRARY_DIRS}
  38. ${LIMIT_SEARCH})
  39. set(LUAJIT_LIBRARIES ${LUAJIT_LIBRARY})
  40. set(LUAJIT_INCLUDE_DIRS ${LUAJIT_INCLUDE_DIR})
  41. include(FindPackageHandleStandardArgs)
  42. # handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE
  43. # if all listed variables are TRUE
  44. find_package_handle_standard_args(LuaJit DEFAULT_MSG
  45. LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)
  46. mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARY)