FindLuaJit.cmake 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. find_package(PkgConfig)
  7. if (PKG_CONFIG_FOUND)
  8. pkg_check_modules(PC_LUAJIT QUIET luajit)
  9. endif()
  10. set(LUAJIT_DEFINITIONS ${PC_LUAJIT_CFLAGS_OTHER})
  11. find_path(LUAJIT_INCLUDE_DIR luajit.h
  12. PATHS ${PC_LUAJIT_INCLUDEDIR} ${PC_LUAJIT_INCLUDE_DIRS}
  13. PATH_SUFFIXES luajit-2.0 luajit-2.1)
  14. if(MSVC)
  15. list(APPEND LUAJIT_NAMES lua51)
  16. elseif(MINGW)
  17. list(APPEND LUAJIT_NAMES libluajit libluajit-5.1)
  18. else()
  19. list(APPEND LUAJIT_NAMES luajit-5.1)
  20. endif()
  21. find_library(LUAJIT_LIBRARY NAMES ${LUAJIT_NAMES}
  22. PATHS ${PC_LUAJIT_LIBDIR} ${PC_LUAJIT_LIBRARY_DIRS})
  23. set(LUAJIT_LIBRARIES ${LUAJIT_LIBRARY})
  24. set(LUAJIT_INCLUDE_DIRS ${LUAJIT_INCLUDE_DIR})
  25. include(FindPackageHandleStandardArgs)
  26. # handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE
  27. # if all listed variables are TRUE
  28. find_package_handle_standard_args(LuaJit DEFAULT_MSG
  29. LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)
  30. mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARY)